This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // SPDX-License-Identifier: MIT | |
| pragma solidity ^0.8.22; | |
| import "forge-std/Script.sol"; | |
| import {console} from "forge-std/console.sol"; | |
| import {IRouter} from "@balancer-v3-monorepo/interfaces/vault/IRouter.sol"; | |
| import {IERC20} from "@openzeppelin/contracts/interfaces/IERC20.sol"; | |
| import {IPermit2} from "@permit2/interfaces/IPermit2.sol"; | |
| // forge script --chain mainnet script/SwapSingleToEth.s.sol:SwapSingleToEth --rpc-url http://localhost:8545 -vvvv |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // pnpm test ./test/entities/swaps/v3/swap.integration.test.ts | |
| import { config } from 'dotenv'; | |
| config(); | |
| import { | |
| Address, | |
| createTestClient, | |
| http, | |
| publicActions, | |
| walletActions, | |
| TestActions, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * | |
| * Run with: | |
| * pnpm example ./examples/swaps/zeKrakenExample.ts | |
| */ | |
| import { Address } from 'viem'; | |
| import { | |
| BalancerApi, | |
| API_ENDPOINT, | |
| ChainId, |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // pnpm example ./examples/balanceTracking-28-04-25.ts | |
| // Checks events for pool: https://balancer.fi/pools/base/v3/0xaf5b7999f491c42c05b5a2ca80f1d200d617cc8c | |
| import { Address, createPublicClient, http, parseAbiItem, Log } from 'viem'; | |
| import { base } from 'viem/chains'; | |
| import fs from 'fs'; | |
| import path from 'path'; | |
| // Define event signatures | |
| const swapEvent = parseAbiItem( | |
| 'event Swap(address indexed pool, address indexed tokenIn, address indexed tokenOut, uint256 amountIn, uint256 amountOut, uint256 swapFeePercentage, uint256 swapFeeAmount)', |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // pnpm example ./examples/balanceTracking.ts | |
| import { Address, createPublicClient, http, parseAbiItem, Log } from 'viem'; | |
| import { base } from 'viem/chains'; | |
| import fs from 'fs'; | |
| import path from 'path'; | |
| // Define event signatures | |
| const swapEvent = parseAbiItem( | |
| 'event Swap(address indexed pool, address indexed tokenIn, address indexed tokenOut, uint256 amountIn, uint256 amountOut, uint256 swapFeePercentage, uint256 swapFeeAmount)', | |
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| /** | |
| * Example showing how to find a swap for a pair using SOR directly | |
| * - Path only uses swaps: use queryBatchSwap on Vault to see result | |
| * - Path use join/exit: Use SDK functions to build calls to submit tx via Relayer | |
| */ | |
| import dotenv from 'dotenv'; | |
| import { BigNumber, parseFixed } from '@ethersproject/bignumber'; | |
| import { Wallet } from '@ethersproject/wallet'; | |
| import { AddressZero } from '@ethersproject/constants'; | |
| import { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Example using Etherscan API to analyse contract gas usage over time period. | |
| // And .env file with ETHERSCAN API key. Free key from: https://etherscan.io/myapikey. | |
| require('dotenv').config(); | |
| const moment = require('moment'); | |
| const axios = require('axios').default; | |
| const Decimal = require('decimal.js'); | |
| export const BONE = new Decimal(10).pow(18); | |
| // Returns all transactions for block range |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // Example showing how to get tx info from tx hash using ethers.js | |
| // Add .env file with INFURA key. Free key from: https://infura.io/ | |
| require('dotenv').config(); | |
| import { JsonRpcProvider } from '@ethersproject/providers'; | |
| import { Interface } from '@ethersproject/abi'; | |
| async function getTransactionDetails(){ | |
| let txHash = `0x4b55c0b756dbfbcd997e94b98698241299d16d5297cd17aa463d280d215a1f52`; // Example tx hash from Etherscan |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // npm add @ethersproject/abi | |
| import { Interface } from '@ethersproject/abi'; | |
| function transactionParsing(){ | |
| console.log(`transactionParsing`); | |
| const proxyArtifact = require('./abi/ExchangeProxy.json'); // See below | |
| const iface = new Interface(proxyArtifact.abi); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require('dotenv').config(); | |
| var moment = require('moment'); | |
| const axios = require('axios').default; | |
| const Decimal = require('decimal.js'); | |
| export const BONE = new Decimal(10).pow(18); | |
| // Returns all transactions for block range | |
| export async function fetchTransactions(startBlock, endBlock) { | |
| const proxyAddr = `0x6317C5e82A06E1d8bf200d21F4510Ac2c038AC81`; |
NewerOlder