diff --git a/eth/abis/KashiPairMediumRiskV1.json b/eth/abis/KashiPairMediumRiskV1.json new file mode 100644 index 0000000..d457fb4 --- /dev/null +++ b/eth/abis/KashiPairMediumRiskV1.json @@ -0,0 +1,775 @@ +[ + { + "inputs": [ + { + "internalType": "contract IBentoBoxV1", + "name": "bentoBox_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "accruedAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feeFraction", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint64", + "name": "rate", + "type": "uint64" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "utilization", + "type": "uint256" + } + ], + "name": "LogAccrue", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "share", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fraction", + "type": "uint256" + } + ], + "name": "LogAddAsset", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "share", + "type": "uint256" + } + ], + "name": "LogAddCollateral", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feeAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "part", + "type": "uint256" + } + ], + "name": "LogBorrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "LogExchangeRate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "newFeeTo", + "type": "address" + } + ], + "name": "LogFeeTo", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "share", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fraction", + "type": "uint256" + } + ], + "name": "LogRemoveAsset", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "share", + "type": "uint256" + } + ], + "name": "LogRemoveCollateral", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "part", + "type": "uint256" + } + ], + "name": "LogRepay", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "feeTo", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feesEarnedFraction", + "type": "uint256" + } + ], + "name": "LogWithdrawFees", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "_from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "_to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "_value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "accrue", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "accrueInfo", + "outputs": [ + { + "internalType": "uint64", + "name": "interestPerSecond", + "type": "uint64" + }, + { "internalType": "uint64", "name": "lastAccrued", "type": "uint64" }, + { + "internalType": "uint128", + "name": "feesEarnedFraction", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "bool", "name": "skim", "type": "bool" }, + { "internalType": "uint256", "name": "share", "type": "uint256" } + ], + "name": "addAsset", + "outputs": [ + { "internalType": "uint256", "name": "fraction", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "bool", "name": "skim", "type": "bool" }, + { "internalType": "uint256", "name": "share", "type": "uint256" } + ], + "name": "addCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "", "type": "address" }, + { "internalType": "address", "name": "", "type": "address" } + ], + "name": "allowance", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "approve", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "asset", + "outputs": [ + { "internalType": "contract IERC20", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "bentoBox", + "outputs": [ + { "internalType": "contract IBentoBoxV1", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "borrow", + "outputs": [ + { "internalType": "uint256", "name": "part", "type": "uint256" }, + { "internalType": "uint256", "name": "share", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "claimOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collateral", + "outputs": [ + { "internalType": "contract IERC20", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint8[]", "name": "actions", "type": "uint8[]" }, + { "internalType": "uint256[]", "name": "values", "type": "uint256[]" }, + { "internalType": "bytes[]", "name": "datas", "type": "bytes[]" } + ], + "name": "cook", + "outputs": [ + { "internalType": "uint256", "name": "value1", "type": "uint256" }, + { "internalType": "uint256", "name": "value2", "type": "uint256" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [{ "internalType": "uint8", "name": "", "type": "uint8" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "exchangeRate", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeTo", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "bytes", "name": "data", "type": "bytes" }], + "name": "init", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address[]", "name": "users", "type": "address[]" }, + { + "internalType": "uint256[]", + "name": "maxBorrowParts", + "type": "uint256[]" + }, + { "internalType": "address", "name": "to", "type": "address" }, + { + "internalType": "contract ISwapper", + "name": "swapper", + "type": "address" + }, + { "internalType": "bool", "name": "open", "type": "bool" } + ], + "name": "liquidate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "masterContract", + "outputs": [ + { + "internalType": "contract KashiPairMediumRiskV1", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "nonces", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { "internalType": "contract IOracle", "name": "", "type": "address" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracleData", + "outputs": [{ "internalType": "bytes", "name": "", "type": "bytes" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner_", "type": "address" }, + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "fraction", "type": "uint256" } + ], + "name": "removeAsset", + "outputs": [ + { "internalType": "uint256", "name": "share", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "share", "type": "uint256" } + ], + "name": "removeCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "bool", "name": "skim", "type": "bool" }, + { "internalType": "uint256", "name": "part", "type": "uint256" } + ], + "name": "repay", + "outputs": [ + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "newFeeTo", "type": "address" } + ], + "name": "setFeeTo", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ISwapper", + "name": "swapper", + "type": "address" + }, + { "internalType": "bool", "name": "enable", "type": "bool" } + ], + "name": "setSwapper", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "contract ISwapper", "name": "", "type": "address" } + ], + "name": "swappers", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalAsset", + "outputs": [ + { "internalType": "uint128", "name": "elastic", "type": "uint128" }, + { "internalType": "uint128", "name": "base", "type": "uint128" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalBorrow", + "outputs": [ + { "internalType": "uint128", "name": "elastic", "type": "uint128" }, + { "internalType": "uint128", "name": "base", "type": "uint128" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalCollateralShare", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transfer", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "amount", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "newOwner", "type": "address" }, + { "internalType": "bool", "name": "direct", "type": "bool" }, + { "internalType": "bool", "name": "renounce", "type": "bool" } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "updateExchangeRate", + "outputs": [ + { "internalType": "bool", "name": "updated", "type": "bool" }, + { "internalType": "uint256", "name": "rate", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "userBorrowPart", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [{ "internalType": "address", "name": "", "type": "address" }], + "name": "userCollateralShare", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "withdrawFees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/eth/abis/SushiswapV2Router.json b/eth/abis/SushiswapV2Router.json new file mode 100644 index 0000000..efc7f31 --- /dev/null +++ b/eth/abis/SushiswapV2Router.json @@ -0,0 +1,398 @@ +[ + { + "inputs": [ + { "internalType": "address", "name": "_factory", "type": "address" }, + { "internalType": "address", "name": "_WETH", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "WETH", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenA", "type": "address" }, + { "internalType": "address", "name": "tokenB", "type": "address" }, + { + "internalType": "uint256", + "name": "amountADesired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountBDesired", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, + { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "addLiquidity", + "outputs": [ + { "internalType": "uint256", "name": "amountA", "type": "uint256" }, + { "internalType": "uint256", "name": "amountB", "type": "uint256" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { + "internalType": "uint256", + "name": "amountTokenDesired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "addLiquidityETH", + "outputs": [ + { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, + { "internalType": "uint256", "name": "amountETH", "type": "uint256" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveIn", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveOut", "type": "uint256" } + ], + "name": "getAmountIn", + "outputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveIn", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveOut", "type": "uint256" } + ], + "name": "getAmountOut", + "outputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" } + ], + "name": "getAmountsIn", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" } + ], + "name": "getAmountsOut", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountA", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveA", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveB", "type": "uint256" } + ], + "name": "quote", + "outputs": [ + { "internalType": "uint256", "name": "amountB", "type": "uint256" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenA", "type": "address" }, + { "internalType": "address", "name": "tokenB", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, + { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "removeLiquidity", + "outputs": [ + { "internalType": "uint256", "name": "amountA", "type": "uint256" }, + { "internalType": "uint256", "name": "amountB", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "removeLiquidityETH", + "outputs": [ + { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, + { "internalType": "uint256", "name": "amountETH", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "removeLiquidityETHSupportingFeeOnTransferTokens", + "outputs": [ + { "internalType": "uint256", "name": "amountETH", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "bool", "name": "approveMax", "type": "bool" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "removeLiquidityETHWithPermit", + "outputs": [ + { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, + { "internalType": "uint256", "name": "amountETH", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "bool", "name": "approveMax", "type": "bool" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "removeLiquidityETHWithPermitSupportingFeeOnTransferTokens", + "outputs": [ + { "internalType": "uint256", "name": "amountETH", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenA", "type": "address" }, + { "internalType": "address", "name": "tokenB", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, + { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "bool", "name": "approveMax", "type": "bool" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "removeLiquidityWithPermit", + "outputs": [ + { "internalType": "uint256", "name": "amountA", "type": "uint256" }, + { "internalType": "uint256", "name": "amountB", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapETHForExactTokens", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactETHForTokens", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactETHForTokensSupportingFeeOnTransferTokens", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactTokensForETH", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactTokensForETHSupportingFeeOnTransferTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactTokensForTokens", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactTokensForTokensSupportingFeeOnTransferTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "uint256", "name": "amountInMax", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapTokensForExactETH", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "uint256", "name": "amountInMax", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapTokensForExactTokens", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { "stateMutability": "payable", "type": "receive" } +] diff --git a/eth/abis/UniswapV2SwapRouter.json b/eth/abis/UniswapV2SwapRouter.json new file mode 100644 index 0000000..efc7f31 --- /dev/null +++ b/eth/abis/UniswapV2SwapRouter.json @@ -0,0 +1,398 @@ +[ + { + "inputs": [ + { "internalType": "address", "name": "_factory", "type": "address" }, + { "internalType": "address", "name": "_WETH", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "WETH", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenA", "type": "address" }, + { "internalType": "address", "name": "tokenB", "type": "address" }, + { + "internalType": "uint256", + "name": "amountADesired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountBDesired", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, + { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "addLiquidity", + "outputs": [ + { "internalType": "uint256", "name": "amountA", "type": "uint256" }, + { "internalType": "uint256", "name": "amountB", "type": "uint256" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { + "internalType": "uint256", + "name": "amountTokenDesired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "addLiquidityETH", + "outputs": [ + { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, + { "internalType": "uint256", "name": "amountETH", "type": "uint256" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveIn", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveOut", "type": "uint256" } + ], + "name": "getAmountIn", + "outputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveIn", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveOut", "type": "uint256" } + ], + "name": "getAmountOut", + "outputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" } + ], + "name": "getAmountsIn", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" } + ], + "name": "getAmountsOut", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountA", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveA", "type": "uint256" }, + { "internalType": "uint256", "name": "reserveB", "type": "uint256" } + ], + "name": "quote", + "outputs": [ + { "internalType": "uint256", "name": "amountB", "type": "uint256" } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenA", "type": "address" }, + { "internalType": "address", "name": "tokenB", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, + { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "removeLiquidity", + "outputs": [ + { "internalType": "uint256", "name": "amountA", "type": "uint256" }, + { "internalType": "uint256", "name": "amountB", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "removeLiquidityETH", + "outputs": [ + { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, + { "internalType": "uint256", "name": "amountETH", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "removeLiquidityETHSupportingFeeOnTransferTokens", + "outputs": [ + { "internalType": "uint256", "name": "amountETH", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "bool", "name": "approveMax", "type": "bool" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "removeLiquidityETHWithPermit", + "outputs": [ + { "internalType": "uint256", "name": "amountToken", "type": "uint256" }, + { "internalType": "uint256", "name": "amountETH", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountTokenMin", + "type": "uint256" + }, + { "internalType": "uint256", "name": "amountETHMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "bool", "name": "approveMax", "type": "bool" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "removeLiquidityETHWithPermitSupportingFeeOnTransferTokens", + "outputs": [ + { "internalType": "uint256", "name": "amountETH", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "tokenA", "type": "address" }, + { "internalType": "address", "name": "tokenB", "type": "address" }, + { "internalType": "uint256", "name": "liquidity", "type": "uint256" }, + { "internalType": "uint256", "name": "amountAMin", "type": "uint256" }, + { "internalType": "uint256", "name": "amountBMin", "type": "uint256" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "bool", "name": "approveMax", "type": "bool" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "removeLiquidityWithPermit", + "outputs": [ + { "internalType": "uint256", "name": "amountA", "type": "uint256" }, + { "internalType": "uint256", "name": "amountB", "type": "uint256" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapETHForExactTokens", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactETHForTokens", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactETHForTokensSupportingFeeOnTransferTokens", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactTokensForETH", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactTokensForETHSupportingFeeOnTransferTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactTokensForTokens", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOutMin", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapExactTokensForTokensSupportingFeeOnTransferTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "uint256", "name": "amountInMax", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapTokensForExactETH", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { "internalType": "uint256", "name": "amountInMax", "type": "uint256" }, + { "internalType": "address[]", "name": "path", "type": "address[]" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "name": "swapTokensForExactTokens", + "outputs": [ + { "internalType": "uint256[]", "name": "amounts", "type": "uint256[]" } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { "stateMutability": "payable", "type": "receive" } +] diff --git a/eth/abis/UniswapV3NonfungiblePositionManager.json b/eth/abis/UniswapV3NonfungiblePositionManager.json new file mode 100644 index 0000000..720db54 --- /dev/null +++ b/eth/abis/UniswapV3NonfungiblePositionManager.json @@ -0,0 +1,686 @@ +[ + { + "inputs": [ + { "internalType": "address", "name": "_factory", "type": "address" }, + { "internalType": "address", "name": "_WETH9", "type": "address" }, + { + "internalType": "address", + "name": "_tokenDescriptor_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "approved", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "operator", + "type": "address" + }, + { + "indexed": false, + "internalType": "bool", + "name": "approved", + "type": "bool" + } + ], + "name": "ApprovalForAll", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "Collect", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "DecreaseLiquidity", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "IncreaseLiquidity", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint256", + "name": "tokenId", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "PERMIT_TYPEHASH", + "outputs": [{ "internalType": "bytes32", "name": "", "type": "bytes32" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "WETH9", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "tokenId", "type": "uint256" } + ], + "name": "approve", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" } + ], + "name": "balanceOf", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "baseURI", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "tokenId", "type": "uint256" } + ], + "name": "burn", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "uint256", "name": "tokenId", "type": "uint256" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { + "internalType": "uint128", + "name": "amount0Max", + "type": "uint128" + }, + { "internalType": "uint128", "name": "amount1Max", "type": "uint128" } + ], + "internalType": "struct INonfungiblePositionManager.CollectParams", + "name": "params", + "type": "tuple" + } + ], + "name": "collect", + "outputs": [ + { "internalType": "uint256", "name": "amount0", "type": "uint256" }, + { "internalType": "uint256", "name": "amount1", "type": "uint256" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token0", "type": "address" }, + { "internalType": "address", "name": "token1", "type": "address" }, + { "internalType": "uint24", "name": "fee", "type": "uint24" }, + { "internalType": "uint160", "name": "sqrtPriceX96", "type": "uint160" } + ], + "name": "createAndInitializePoolIfNecessary", + "outputs": [ + { "internalType": "address", "name": "pool", "type": "address" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "uint256", "name": "tokenId", "type": "uint256" }, + { "internalType": "uint128", "name": "liquidity", "type": "uint128" }, + { + "internalType": "uint256", + "name": "amount0Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Min", + "type": "uint256" + }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "internalType": "struct INonfungiblePositionManager.DecreaseLiquidityParams", + "name": "params", + "type": "tuple" + } + ], + "name": "decreaseLiquidity", + "outputs": [ + { "internalType": "uint256", "name": "amount0", "type": "uint256" }, + { "internalType": "uint256", "name": "amount1", "type": "uint256" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "tokenId", "type": "uint256" } + ], + "name": "getApproved", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "uint256", "name": "tokenId", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amount0Desired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Desired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount0Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Min", + "type": "uint256" + }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "internalType": "struct INonfungiblePositionManager.IncreaseLiquidityParams", + "name": "params", + "type": "tuple" + } + ], + "name": "increaseLiquidity", + "outputs": [ + { "internalType": "uint128", "name": "liquidity", "type": "uint128" }, + { "internalType": "uint256", "name": "amount0", "type": "uint256" }, + { "internalType": "uint256", "name": "amount1", "type": "uint256" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "address", "name": "operator", "type": "address" } + ], + "name": "isApprovedForAll", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "address", "name": "token0", "type": "address" }, + { "internalType": "address", "name": "token1", "type": "address" }, + { "internalType": "uint24", "name": "fee", "type": "uint24" }, + { "internalType": "int24", "name": "tickLower", "type": "int24" }, + { "internalType": "int24", "name": "tickUpper", "type": "int24" }, + { + "internalType": "uint256", + "name": "amount0Desired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Desired", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount0Min", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1Min", + "type": "uint256" + }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" } + ], + "internalType": "struct INonfungiblePositionManager.MintParams", + "name": "params", + "type": "tuple" + } + ], + "name": "mint", + "outputs": [ + { "internalType": "uint256", "name": "tokenId", "type": "uint256" }, + { "internalType": "uint128", "name": "liquidity", "type": "uint128" }, + { "internalType": "uint256", "name": "amount0", "type": "uint256" }, + { "internalType": "uint256", "name": "amount1", "type": "uint256" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes[]", "name": "data", "type": "bytes[]" } + ], + "name": "multicall", + "outputs": [ + { "internalType": "bytes[]", "name": "results", "type": "bytes[]" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "tokenId", "type": "uint256" } + ], + "name": "ownerOf", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "spender", "type": "address" }, + { "internalType": "uint256", "name": "tokenId", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "permit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "tokenId", "type": "uint256" } + ], + "name": "positions", + "outputs": [ + { "internalType": "uint96", "name": "nonce", "type": "uint96" }, + { "internalType": "address", "name": "operator", "type": "address" }, + { "internalType": "address", "name": "token0", "type": "address" }, + { "internalType": "address", "name": "token1", "type": "address" }, + { "internalType": "uint24", "name": "fee", "type": "uint24" }, + { "internalType": "int24", "name": "tickLower", "type": "int24" }, + { "internalType": "int24", "name": "tickUpper", "type": "int24" }, + { "internalType": "uint128", "name": "liquidity", "type": "uint128" }, + { + "internalType": "uint256", + "name": "feeGrowthInside0LastX128", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeGrowthInside1LastX128", + "type": "uint256" + }, + { "internalType": "uint128", "name": "tokensOwed0", "type": "uint128" }, + { "internalType": "uint128", "name": "tokensOwed1", "type": "uint128" } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "refundETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "tokenId", "type": "uint256" } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "tokenId", "type": "uint256" }, + { "internalType": "bytes", "name": "_data", "type": "bytes" } + ], + "name": "safeTransferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "selfPermit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "nonce", "type": "uint256" }, + { "internalType": "uint256", "name": "expiry", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "selfPermitAllowed", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "nonce", "type": "uint256" }, + { "internalType": "uint256", "name": "expiry", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "selfPermitAllowedIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "selfPermitIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "operator", "type": "address" }, + { "internalType": "bool", "name": "approved", "type": "bool" } + ], + "name": "setApprovalForAll", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes4", "name": "interfaceId", "type": "bytes4" } + ], + "name": "supportsInterface", + "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "amountMinimum", "type": "uint256" }, + { "internalType": "address", "name": "recipient", "type": "address" } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "index", "type": "uint256" } + ], + "name": "tokenByIndex", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "owner", "type": "address" }, + { "internalType": "uint256", "name": "index", "type": "uint256" } + ], + "name": "tokenOfOwnerByIndex", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "tokenId", "type": "uint256" } + ], + "name": "tokenURI", + "outputs": [{ "internalType": "string", "name": "", "type": "string" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "from", "type": "address" }, + { "internalType": "address", "name": "to", "type": "address" }, + { "internalType": "uint256", "name": "tokenId", "type": "uint256" } + ], + "name": "transferFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amount0Owed", "type": "uint256" }, + { "internalType": "uint256", "name": "amount1Owed", "type": "uint256" }, + { "internalType": "bytes", "name": "data", "type": "bytes" } + ], + "name": "uniswapV3MintCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountMinimum", "type": "uint256" }, + { "internalType": "address", "name": "recipient", "type": "address" } + ], + "name": "unwrapWETH9", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { "stateMutability": "payable", "type": "receive" } +] diff --git a/eth/abis/UniswapV3SwapRouter.json b/eth/abis/UniswapV3SwapRouter.json new file mode 100644 index 0000000..330736e --- /dev/null +++ b/eth/abis/UniswapV3SwapRouter.json @@ -0,0 +1,273 @@ +[ + { + "inputs": [ + { "internalType": "address", "name": "_factory", "type": "address" }, + { "internalType": "address", "name": "_WETH9", "type": "address" } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "WETH9", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "bytes", "name": "path", "type": "bytes" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountOutMinimum", + "type": "uint256" + } + ], + "internalType": "struct ISwapRouter.ExactInputParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactInput", + "outputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "address", "name": "tokenIn", "type": "address" }, + { "internalType": "address", "name": "tokenOut", "type": "address" }, + { "internalType": "uint24", "name": "fee", "type": "uint24" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint256", "name": "amountIn", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountOutMinimum", + "type": "uint256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "internalType": "struct ISwapRouter.ExactInputSingleParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactInputSingle", + "outputs": [ + { "internalType": "uint256", "name": "amountOut", "type": "uint256" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "bytes", "name": "path", "type": "bytes" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountInMaximum", + "type": "uint256" + } + ], + "internalType": "struct ISwapRouter.ExactOutputParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactOutput", + "outputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { "internalType": "address", "name": "tokenIn", "type": "address" }, + { "internalType": "address", "name": "tokenOut", "type": "address" }, + { "internalType": "uint24", "name": "fee", "type": "uint24" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint256", "name": "amountOut", "type": "uint256" }, + { + "internalType": "uint256", + "name": "amountInMaximum", + "type": "uint256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + } + ], + "internalType": "struct ISwapRouter.ExactOutputSingleParams", + "name": "params", + "type": "tuple" + } + ], + "name": "exactOutputSingle", + "outputs": [ + { "internalType": "uint256", "name": "amountIn", "type": "uint256" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [{ "internalType": "address", "name": "", "type": "address" }], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { "internalType": "bytes[]", "name": "data", "type": "bytes[]" } + ], + "name": "multicall", + "outputs": [ + { "internalType": "bytes[]", "name": "results", "type": "bytes[]" } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [], + "name": "refundETH", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "selfPermit", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "nonce", "type": "uint256" }, + { "internalType": "uint256", "name": "expiry", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "selfPermitAllowed", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "nonce", "type": "uint256" }, + { "internalType": "uint256", "name": "expiry", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "selfPermitAllowedIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "value", "type": "uint256" }, + { "internalType": "uint256", "name": "deadline", "type": "uint256" }, + { "internalType": "uint8", "name": "v", "type": "uint8" }, + { "internalType": "bytes32", "name": "r", "type": "bytes32" }, + { "internalType": "bytes32", "name": "s", "type": "bytes32" } + ], + "name": "selfPermitIfNecessary", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "amountMinimum", "type": "uint256" }, + { "internalType": "address", "name": "recipient", "type": "address" } + ], + "name": "sweepToken", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "address", "name": "token", "type": "address" }, + { "internalType": "uint256", "name": "amountMinimum", "type": "uint256" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "feeBips", "type": "uint256" }, + { "internalType": "address", "name": "feeRecipient", "type": "address" } + ], + "name": "sweepTokenWithFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "int256", "name": "amount0Delta", "type": "int256" }, + { "internalType": "int256", "name": "amount1Delta", "type": "int256" }, + { "internalType": "bytes", "name": "_data", "type": "bytes" } + ], + "name": "uniswapV3SwapCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountMinimum", "type": "uint256" }, + { "internalType": "address", "name": "recipient", "type": "address" } + ], + "name": "unwrapWETH9", + "outputs": [], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { "internalType": "uint256", "name": "amountMinimum", "type": "uint256" }, + { "internalType": "address", "name": "recipient", "type": "address" }, + { "internalType": "uint256", "name": "feeBips", "type": "uint256" }, + { "internalType": "address", "name": "feeRecipient", "type": "address" } + ], + "name": "unwrapWETH9WithFee", + "outputs": [], + "stateMutability": "payable", + "type": "function" + } +] diff --git a/eth/abis/index.ts b/eth/abis/index.ts index 39d0588..f53187f 100644 --- a/eth/abis/index.ts +++ b/eth/abis/index.ts @@ -22,7 +22,11 @@ import WrappedToken from './WrappedToken.json'; import WrappedTokenController from './WrappedTokenController.json'; import WrappedTokenFactory from './WrappedTokenFactory.json'; import WrappedTokenMembers from './WrappedTokenMembers.json'; - +import UniswapV2SwapRouter from './UniswapV2SwapRouter.json'; +import UniswapV3SwapRouter from './UniswapV3SwapRouter.json'; +import UniswapV3NonfungiblePositionManager from './UniswapV3NonfungiblePositionManager.json'; +import SushiswapV2Router from './SushiswapV2Router.json'; +import KashiPairMediumRiskV1 from './KashiPairMediumRiskV1.json'; export default { Compound, CompoundComptroller, @@ -43,6 +47,11 @@ export default { StandardERC20, WalletFactory, WalletSimple, + UniswapV2SwapRouter, + UniswapV3SwapRouter, + UniswapV3NonfungiblePositionManager, + SushiswapV2Router, + KashiPairMediumRiskV1, WrappedToken, WrappedTokenController, WrappedTokenFactory, diff --git a/eth/config/instances.json b/eth/config/instances.json index 55b8eb9..b833a47 100644 --- a/eth/config/instances.json +++ b/eth/config/instances.json @@ -8,8 +8,10 @@ "ZRX": "0xe41d2489571d322189246dafa5ebde1f4699f498", "KNC": "0xdd974d5c2e2928dea5f71b9825b8b646686bd200", "USDC": "0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48", - "DAI": "0x6b175474e89094c44da98b954eedeac495271d0f", - "SAI": "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359" + "DAI": "0x6B175474E89094C44Da98b954EedeAC495271d0F", + "SAI": "0x89d24a6b4ccb1b6faa2625fe562bdd9a23260359", + "UNI": "0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984", + "USDT": "0xdac17f958d2ee523a2206206994597c13d831ec7" }, "WrappedToken": { "WBTC": "0x2260fac5e5542a773aa44fbcfedf7c193bc2c599" @@ -76,5 +78,21 @@ "ForwarderFactory": { }, "WalletFactory": { + }, + "UniswapV2SwapRouter": { + "default": "0x7a250d5630b4cf539739df2c5dacb4c659f2488d" + }, + "UniswapV3SwapRouter": { + "default": "0xe592427a0aece92de3edee1f18e0157c05861564" + }, + "UniswapV3NonfungiblePositionManager":{ + "default": "0xC36442b4a4522E871399CD717aBDD847Ab11FE88" + }, + "SushiswapV2Router":{ + "default": "0xd9e1cE17f2641f24aE83637ab66a2cca9C378B9F" + }, + "KashiPairMediumRiskV1":{ + "default": "0x2cBA6Ab6574646Badc84F0544d05059e57a5dc42" + } } diff --git a/eth/examples/Sushiswap/createLiquidityPool.ts b/eth/examples/Sushiswap/createLiquidityPool.ts new file mode 100644 index 0000000..118b0e5 --- /dev/null +++ b/eth/examples/Sushiswap/createLiquidityPool.ts @@ -0,0 +1,93 @@ +import { getContractsFactory } from '../../../src/index'; +import { BitGo } from 'bitgo'; + +async function sendBitGoTx() { + const tokenA = 'DAI'; + const tokenB = 'UNI'; + const walletAddress = 'wallet addresses'; + const amountADesired = 100e18; // amount of DAI desired + const amountBDesired = 250e14; // amount of UNI desired + const amountAMin = 995e17; //minimum amout of DAI + const amountBMin = 254e14; // minimum amout of UNI + const deadline = 'deadline'; + + const bitGo = new BitGo({ env: 'test', accessToken: + 'accesstoken' }); + const baseCoin = bitGo.coin('teth'); + const bitGoWallet = await baseCoin + .wallets() + .get({ id: 'walletId' }); + + + const liquidityPoolContract = getContractsFactory('eth') +.getContract('SushiswapV2Router') +.instance(); + + const tokenAContract = getContractsFactory('eth') + .getContract('StandardERC20') + .instance(tokenA); + + let { data, amount } = tokenAContract.methods().approve.call({ + _spender: liquidityPoolContract.address, + _value: amountADesired.toString(10), + }); + + let transaction = await bitGoWallet.send({ + data: data, amount: amount, address: tokenAContract.address, + walletPassphrase: 'walletPassphrase', + }); + + // we need to approve the amount of DAI for the liquidityPool contract to control + console.log( + `To approve ${amountADesired} ${tokenA} to DAI token contract, send:`, + ); + console.log(`Data: ${data}`); + console.log(`Amount: ${amount}`); + + const tokenBContract = getContractsFactory('eth') + .getContract('StandardERC20') + .instance(tokenB); + + ({ data, amount } = tokenBContract.methods().approve.call({ + _spender: liquidityPoolContract.address, + _value: amountBDesired.toString(10), + })); + + transaction = await bitGoWallet.send({ + data: data, amount: amount, address: tokenBContract.address, + walletPassphrase: 'walletPassphrase', + }); + + //we need to approve the amount of UNI for the liquidityPool contract to control + console.log( + `To approve ${amountBDesired} ${tokenB} to UNI token contract, send:`, + ); + console.log(`Data: ${data}`); + console.log(`Amount: ${amount}`); + + ({ data, amount } = liquidityPoolContract.methods().addLiquidity.call({ + tokenA: tokenAContract.address, + tokenB: tokenBContract.address, + amountADesired: amountADesired.toString(10), + amountBDesired: amountBDesired.toString(10), + amountAMin: amountAMin.toString(10), + amountBMin: amountBMin.toString(10), + to: walletAddress, + deadline: deadline, + })); + + transaction = await bitGoWallet.send({ + data: data, amount: amount, address: liquidityPoolContract.address, + walletPassphrase: 'walletPassphrase', + }); + + console.log(transaction); + + // Once the above txs are confirmed, we can create swap liquidity pool + console.log(`To create liquidity pool with pair of ${tokenA} ${tokenB}, send: `); + console.log(`${tokenA} amount: ${amountADesired} and ${tokenB} amount: ${amountBDesired} `); + console.log(`to: ${liquidityPoolContract.address}`); +} + + +sendBitGoTx(); diff --git a/eth/examples/Sushiswap/kashiBorrow.ts b/eth/examples/Sushiswap/kashiBorrow.ts new file mode 100644 index 0000000..86e8123 --- /dev/null +++ b/eth/examples/Sushiswap/kashiBorrow.ts @@ -0,0 +1,155 @@ +import { getContractsFactory } from '../../../src/index'; +import { BitGo } from 'bitgo'; +import * as utils from '../utils'; +import ethers from 'ethers'; +import * as ethUtil from 'ethereumjs-util'; +// Example to borrow DAI with WETH as Collateral in Kashi + +async function sendBitGoTx() { + const bitGo = new BitGo({ env: 'test', accessToken: 'accesstoken' }); + const baseCoin = bitGo.coin('teth'); + const bitGoWallet = await baseCoin.wallets().get({ id: 'walletId' }); + /* + * 24 ACTION_BENTO_SETAPPROVAL ParamNames user, _masterContract, approved, v, r, s. ABI encoding address, address, bool, uint8, bytes32, bytes32 + * for information in v, r, s visit https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md + * example dataForAction24 ='0x + * 0000000000000000000000006c31cdbf161bad81f9eceb107d757cb85f2dbcab (wallet Address) + * 0000000000000000000000002cba6ab6574646badc84f0544d05059e57a5dc42 (KashiPairMediumRiskV1 contract Address) + * 0000000000000000000000000000000000000000000000000000000000000001 (approved) + * 000000000000000000000000000000000000000000000000000000000000001c (v) + * 45dcc6b8a59747de4424b7f11e5cfadd0399579d24ec91d433c8fda4d8b26246 (r) + * 0d135ac427b217fe96dfbd86f97fe904f68dbb87538feec734f07af9ab9fd9c3' (s) + * 5 ACTION_BORROW ParamNames amount, to. ABI encoding int256, address. + * example dataForAction5 ='0x + * 0000000000000000000000000000000000000000000000028c418afbbb5c0000 (amount) + * 0000000000000000000000006c31cdbf161bad81f9eceb107d757cb85f2dbcab' (to) + * 20 ACTION_BENTO_DEPOSIT ParamNames token, to, amount, share. ABI encoding IERC20, address, int256, int256 + * example dataForAction20 ='0x + * 0000000000000000000000000000000000000000000000000000000000000000 (IERC20) + * 0000000000000000000000006c31cdbf161bad81f9eceb107d757cb85f2dbcab (wallet Address) + * 00000000000000000000000000000000000000000000000000470de4df820000 (amount) + * 0000000000000000000000000000000000000000000000000000000000000000 (share) + * 10 ACTION_ADD_COLLATERAL ParamNames share, to, skim. ABI encoding int256, address, bool + * example dataForAction10 ='0x + * fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe (share) + * 0000000000000000000000006c31cdbf161bad81f9eceb107d757cb85f2dbcab (wallet Address) + * 0000000000000000000000000000000000000000000000000000000000000000 (skim) + */ + + + const sampleWalletAddress = '0x6c31cdbf161bad81f9eceb107d757cb85f2dbcab'; + const masterContract = '0x2cba6ab6574646badc84f0544d05059e57a5dc42'; + const approved = true; + const nonce = 'nonce'; + const kashiApprovalHash = utils.getKashiApprovalHash( + sampleWalletAddress, + masterContract, + approved, + nonce, + ); + + const bentoBoxV1ContractAddress = + '0xF5BCE5077908a1b7370B9ae04AdC565EBd643966'; + const kashiBorrowContractAddress = + '0x2cba6ab6574646badc84f0544d05059e57a5dc42'; + const chainId = 1; + const domainSeperatorHash = utils.getKashiDomainSeperatorHash( + chainId, + bentoBoxV1ContractAddress, + ); + const digest = utils.getMasterContractApprovalHash( + domainSeperatorHash, + kashiApprovalHash, + ); + + const privateKeyHex = 'privateKeyHex'; + const privkey = Buffer.from(privateKeyHex.replace(/^0x/i, ''), 'hex'); + const signature = ethUtil.ecsign(digest, privkey); + + let dataForAction24 = utils.stripHexPrefix( + ethers.utils.hexZeroPad(sampleWalletAddress, 32), + ); + dataForAction24 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(kashiBorrowContractAddress, 32), + ); + dataForAction24 += utils.stripHexPrefix(ethers.utils.hexZeroPad('0x1', 32)); + dataForAction24 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(ethers.utils.hexlify(signature.v), 32), + ); + dataForAction24 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(signature.r.toString('hex'), 32), + ); + dataForAction24 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(signature.s.toString('hex'), 32), + ); + + const amountToBorrow = 50e18; + let dataForAction5 = utils.stripHexPrefix( + ethers.utils.hexZeroPad( + ethUtil.addHexPrefix(amountToBorrow.toString(16)), + 32, + ), + ); + dataForAction5 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(sampleWalletAddress, 32), + ); + + const amountToDeposit = 1e18; + let dataForAction20 = utils.stripHexPrefix(ethers.utils.hexZeroPad('0x', 32)); + dataForAction20 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(sampleWalletAddress, 32), + ); + dataForAction20 += utils.stripHexPrefix( + ethers.utils.hexZeroPad( + ethUtil.addHexPrefix(amountToDeposit.toString(16)), + 32, + ), + ); + const share = 0; + dataForAction20 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(ethUtil.addHexPrefix(share.toString(16)), 32), + ); + + let dataForAction10 = utils.stripHexPrefix( + ethers.utils.hexZeroPad( + ethUtil.addHexPrefix(utils.MAX_VALUE_SHARE.toString(16)), + 32, + ), + ); + dataForAction10 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(sampleWalletAddress, 32), + ); + const skim = 0; + dataForAction10 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(skim.toString(16), 32), + ); + + const actions = ['24', '5', '20', '10']; + const values = ['0', '0', amountToDeposit, '0']; + const datas = [ + ethUtil.addHexPrefix(dataForAction24), + ethUtil.addHexPrefix(dataForAction5), + ethUtil.addHexPrefix(dataForAction20), + ethUtil.addHexPrefix(dataForAction10), + ]; + const borrowContract = getContractsFactory('eth') + .getContract('KashiPairMediumRiskV1') + .instance(); + + const { data, amount } = borrowContract.methods().cook.call({ + actions, + values, + datas, + }); + + const transaction = await bitGoWallet.send({ + data: data, + amount: amount, + address: borrowContract.address, + walletPassphrase: 'walletPassphrase', + }); + + console.log(transaction); +} + +sendBitGoTx(); diff --git a/eth/examples/Sushiswap/kashiLend.ts b/eth/examples/Sushiswap/kashiLend.ts new file mode 100644 index 0000000..c629a77 --- /dev/null +++ b/eth/examples/Sushiswap/kashiLend.ts @@ -0,0 +1,140 @@ +import { getContractsFactory } from '../../../src/index'; +import { BitGo } from 'bitgo'; +import * as utils from '../utils'; +import ethers from 'ethers'; +import * as ethUtil from 'ethereumjs-util'; +// Example to lend USDT in Kashi + +async function sendBitGoTx() { + const bitGo = new BitGo({ env: 'test', accessToken: 'accesstoken' }); + const baseCoin = bitGo.coin('teth'); + const bitGoWallet = await baseCoin.wallets().get({ id: 'walletId' }); + + /* + * 24 ACTION_BENTO_SETAPPROVAL ParamNames user, _masterContract, approved, v, r, s. ABI encoding address, address, bool, uint8, bytes32, bytes32 + * for information in v, r, s visit https://github.com/ethereum/EIPs/blob/master/EIPS/eip-155.md + * userAddress= walletAddress + * _masterContract=KashiPairMediumRiskV1 contract Address + * example dataForAction24 ='0x + * 0000000000000000000000006c31cdbf161bad81f9eceb107d757cb85f2dbcab (wallet Address) + * 0000000000000000000000002cba6ab6574646badc84f0544d05059e57a5dc42 (KashiPairMediumRiskV1 contract Address) + * 0000000000000000000000000000000000000000000000000000000000000001 (approved) + * 000000000000000000000000000000000000000000000000000000000000001c (v) + * 45dcc6b8a59747de4424b7f11e5cfadd0399579d24ec91d433c8fda4d8b26246 (r) + * 0d135ac427b217fe96dfbd86f97fe904f68dbb87538feec734f07af9ab9fd9c3' (s) + * + * 20 ACTION_BENTO_DEPOSIT ParamNames token, to, amount, share. ABI encoding IERC20, address, int256, int256 + * example dataForAction20='0x + * 000000000000000000000000dac17f958d2ee523a2206206994597c13d831ec7 (USDT contract Address) + * 0000000000000000000000006c31cdbf161bad81f9eceb107d757cb85f2dbcab (wallet Address) + * 00000000000000000000000000000000000000000000000000000000017b31ee (amount) + * 0000000000000000000000000000000000000000000000000000000000000000' (share) + * 1 ACTION_ADD_ASSET ParamNames share, to, skim. ABI encoding int256, address, bool + * example dataForAction1='0x + * fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffe (share) + * 0000000000000000000000006c31cdbf161bad81f9eceb107d757cb85f2dbcab (wallet Address) + * 0000000000000000000000000000000000000000000000000000000000000000' (skim) + */ + const actions = ['24', '20', '1']; + const values = ['0', '0', '0']; + const sampleWalletAddress = '0x6c31cdbf161bad81f9eceb107d757cb85f2dbcab'; + const masterContract = '0x2cba6ab6574646badc84f0544d05059e57a5dc42'; + const approved = true; + const nonce = 'nonce'; + const kashiApprovalHash = utils.getKashiApprovalHash( + sampleWalletAddress, + masterContract, + approved, + nonce, + ); + + const bentoBoxV1ContractAddress = + '0xF5BCE5077908a1b7370B9ae04AdC565EBd643966'; + const kashiBorrowContractAddress = + '0x2cba6ab6574646badc84f0544d05059e57a5dc42'; + const chainId = 1; + const domainSeperatorHash = utils.getKashiDomainSeperatorHash( + chainId, + bentoBoxV1ContractAddress, + ); + const digest = utils.getMasterContractApprovalHash( + domainSeperatorHash, + kashiApprovalHash, + ); + + const privateKeyHex = 'privateKeyHex'; + const privkey = Buffer.from(privateKeyHex.replace(/^0x/i, ''), 'hex'); + const signature = ethUtil.ecsign(digest, privkey); + + let dataForAction24 = utils.stripHexPrefix( + ethers.utils.hexZeroPad(sampleWalletAddress, 32), + ); + dataForAction24 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(kashiBorrowContractAddress, 32), + ); + dataForAction24 += utils.stripHexPrefix(ethers.utils.hexZeroPad('0x1', 32)); + dataForAction24 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(ethers.utils.hexlify(signature.v), 32), + ); + dataForAction24 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(signature.r.toString('hex'), 32), + ); + dataForAction24 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(signature.s.toString('hex'), 32), + ); + + const amountToDeposit = 1e18; + let dataForAction20 = utils.stripHexPrefix(ethers.utils.hexZeroPad('0x', 32)); + dataForAction20 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(sampleWalletAddress, 32), + ); + dataForAction20 += utils.stripHexPrefix( + ethers.utils.hexZeroPad( + ethUtil.addHexPrefix(amountToDeposit.toString(16)), + 32, + ), + ); + const share = 0; + dataForAction20 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(ethUtil.addHexPrefix(share.toString(16)), 32), + ); + + let dataForAction1 = utils.stripHexPrefix( + ethers.utils.hexZeroPad( + ethUtil.addHexPrefix(utils.MAX_VALUE_SHARE.toString(16)), + 32, + ), + ); + dataForAction1 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(sampleWalletAddress, 32), + ); + const skim = 0; + dataForAction1 += utils.stripHexPrefix( + ethers.utils.hexZeroPad(skim.toString(16), 32), + ); + + const datas = [ethUtil.addHexPrefix(dataForAction24), ethUtil.addHexPrefix(dataForAction20), ethUtil.addHexPrefix(dataForAction1)]; + const lendContract = getContractsFactory('eth') + .getContract('KashiPairMediumRiskV1') + .instance(); + + + const { data, amount } = lendContract.methods().cook.call({ + actions, + values, + datas, + }); + + const transaction = await bitGoWallet.send({ + data: data, + amount: amount, + address: lendContract.address, + walletPassphrase: 'walletPassphrase', + }); + + console.log(transaction); + + +} + +sendBitGoTx(); diff --git a/eth/examples/Sushiswap/removeLiquidityPool.ts b/eth/examples/Sushiswap/removeLiquidityPool.ts new file mode 100644 index 0000000..abd05c7 --- /dev/null +++ b/eth/examples/Sushiswap/removeLiquidityPool.ts @@ -0,0 +1,66 @@ +import { getContractsFactory } from '../../../src/index'; +import { BitGo } from 'bitgo'; +import * as utils from '../utils'; +import * as ethUtil from 'ethereumjs-util'; +async function sendBitGoTx() { + const tokenAContractAddress = '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984'; //UNI + const tokenBContractAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F'; //DAI + + const walletAddress = '0x61E64B5224f88944222c4Aa7CCE1809c17106De5'; + const liquidity = 220e9; + const amountAMin = 20e15; + const amountBMin = 99e18; + const deadline = 'deadline'; + + const bitGo = new BitGo({ env: 'test', accessToken: 'accesstoken' }); + const baseCoin = bitGo.coin('teth'); + const bitGoWallet = await baseCoin.wallets().get({ id: 'walletId' }); + const liquidityPoolContract = getContractsFactory('eth') + .getContract('SushiswapV2Router') + .instance(); + + const chainId = 1; + const sushiSwapV2FactoryContractAddress = '0xC0AEe478e3658e2610c5F7A4A2E1777cE9e4f2Ac'; + const sampleWalletAddress = '0x6c31cdbf161bad81f9eceb107d757cb85f2dbcab'; + const spender = liquidityPoolContract.address; + const value = liquidity.toString(10); + const nonce = 'nonce'; + const name = 'SushiSwap LP Token'; + const permitApprovalHash = utils.getUniSushiSwapV2ApprovalHash(sampleWalletAddress, spender, value, nonce, deadline); + const domainSeperatorHash = utils.getUniSushiSwapV2PairDomainSeperatorHash(name, chainId, sushiSwapV2FactoryContractAddress); + const digest = utils.getMasterContractApprovalHash(domainSeperatorHash, permitApprovalHash); + const privateKeyHex = 'privateKeyHex'; + const privkey = Buffer.from(privateKeyHex.replace(/^0x/i, ''), 'hex'); + const signature = ethUtil.ecsign(digest, privkey); + + const v = signature.v; + const r = ethUtil.addHexPrefix(signature.r.toString('hex')); + const s = ethUtil.addHexPrefix(signature.s.toString('hex')); + + + const { data, amount } = liquidityPoolContract + .methods() + .removeLiquidityWithPermit.call({ + tokenA: tokenAContractAddress, + tokenB: tokenBContractAddress, + liquidity: liquidity.toString(10), + amountAMin: amountAMin.toString(10), + amountBMin: amountBMin.toString(10), + to: walletAddress, + deadline: deadline, + v: v, + r: r, + s: s, + }); + + const transaction = await bitGoWallet.send({ + data: data, + amount: amount, + address: liquidityPoolContract.address, + walletPassphrase: 'walletPassphrase', + }); + + console.log(transaction); +} + +sendBitGoTx(); diff --git a/eth/examples/Sushiswap/swap.ts b/eth/examples/Sushiswap/swap.ts new file mode 100644 index 0000000..bc48ab0 --- /dev/null +++ b/eth/examples/Sushiswap/swap.ts @@ -0,0 +1,42 @@ +import { getContractsFactory } from '../../../src/index'; +import { BitGo } from 'bitgo'; + + +// Example to swap from 0.01 ETH to DAI + +async function sendBitGoTx() { + const DAIContractAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F'; + const wrappedEtherContractAddress = '0xd0A1E359811322d97991E03f863a0C30C2cF029C'; + const toAddress = 'wallet address'; + const amountOutMin = 50e17; + const deadline = 'deadline'; + const swapRouter = getContractsFactory('eth').getContract('SushiswapV2Router').instance(); + const path = [wrappedEtherContractAddress, DAIContractAddress]; + + const txInput = swapRouter.methods().swapExactETHForTokens. +call({ amountOutMin: amountOutMin.toString(10), path: path, to: toAddress, deadline: deadline }); + + txInput.amount = 1e16; + console.log(`To swap ETH to DAI with SushiswapV2Router contract, send:`); + console.log(`Data: ${txInput.data}`); + console.log(`Amount: ${txInput.amount}`); + console.log(`To: ${swapRouter.address}`); + + + const bitGo = new BitGo({ env: 'test', accessToken: +'accesstoken' }); + const baseCoin = bitGo.coin('teth'); + const bitGoWallet = await baseCoin + .wallets() + .get({ id: 'walletId' }); + + + const transaction = await bitGoWallet.send({ + data: txInput.data, amount: txInput.amount, address: swapRouter.address, + walletPassphrase: 'walletPassphrase', + }); + + console.log(transaction); +} + +sendBitGoTx(); diff --git a/eth/examples/Uniswap/createLiquidityPoolV2.ts b/eth/examples/Uniswap/createLiquidityPoolV2.ts new file mode 100644 index 0000000..994861b --- /dev/null +++ b/eth/examples/Uniswap/createLiquidityPoolV2.ts @@ -0,0 +1,66 @@ +import { getContractsFactory } from '../../../src/index'; +import { BitGo } from 'bitgo'; + +//create DAI/ETH Liquidity Pool +async function sendBitGoTx() { + const token = 'DAI'; + const walletAddress = 'wallet address'; + const amountTokenDesired = 54e18; + const amountTokenMin = 53e18; + const amountETHMin = 995e13; + const deadline = 'deadline'; + + const bitGo = new BitGo({ env: 'test', accessToken: + 'accesstoken' }); + const baseCoin = bitGo.coin('teth'); + const bitGoWallet = await baseCoin + .wallets() + .get({ id: 'walletId' }); + + + const liquidityPoolContract = getContractsFactory('eth') + .getContract('UniswapV2SwapRouter') + .instance(); + + // we need to approve the amount of DAI for the liquidityPool contract to control + const tokenContract = getContractsFactory('eth') + .getContract('StandardERC20') + .instance(token); + + let { data, amount } = tokenContract.methods().approve.call({ + _spender: liquidityPoolContract.address, + _value: amountTokenDesired.toString(10), + }); + + let transaction = await bitGoWallet.send({ + data: data, amount: amount, address: tokenContract.address, + walletPassphrase: 'walletPassphrase', + }); + + console.log( + `To approve ${amountTokenDesired} ${token} to DAI token contract, send:`, + ); + console.log(`Data: ${data}`); + console.log(`Amount: ${amount}`); + + + ({ data, amount } = liquidityPoolContract.methods().addLiquidityETH.call({ + token: tokenContract.address, + amountTokenDesired: amountTokenDesired.toString(10), + amountTokenMin: amountTokenMin.toString(10), + amountETHMin: amountETHMin.toString(10), + to: walletAddress, + deadline, + })); + + transaction = await bitGoWallet.send({ + data: data, amount: amount, address: liquidityPoolContract.address, + walletPassphrase: 'walletPassphrase', + }); + + console.log(transaction); + +} + + +sendBitGoTx(); diff --git a/eth/examples/Uniswap/createLiquidityPoolV3.ts b/eth/examples/Uniswap/createLiquidityPoolV3.ts new file mode 100644 index 0000000..0ddadc3 --- /dev/null +++ b/eth/examples/Uniswap/createLiquidityPoolV3.ts @@ -0,0 +1,106 @@ +import { getContractsFactory } from '../../../src/index'; +import { BitGo } from 'bitgo'; + +async function sendBitGoTx() { + const token0 = 'UNI'; + const token1 = 'DAI'; + const token0ContractAddress = '0x1f9840a85d5aF5bf1D1762F925BDADdC4201F984'; + const token1ContractAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F'; + const walletAddress = '0x6f32a7e465d50f61df96dfffc5bfb6d4059c7cd6'; + const fee = '3000'; + const tickLower = '-887220'; + const tickUpper = '887220'; + const amount0Desired = 148e14; + const amount1Desired = 499e17; + const amount0Min = 147e14; + const amount1Min = 498e17; + const deadline = 'deadline'; + + const bitGo = new BitGo({ env: 'test', accessToken: 'accesstoken' }); + const baseCoin = bitGo.coin('teth'); + const bitGoWallet = await baseCoin.wallets().get({ id: 'walletId' }); + + const liquidityPoolContract = getContractsFactory('eth') + .getContract('UniswapV3NonfungiblePositionManager') + .instance(); + + const token0Contract = getContractsFactory('eth') + .getContract('StandardERC20') + .instance(token0); + + let { data, amount } = token0Contract.methods().approve.call({ + _spender: liquidityPoolContract.address, + _value: amount0Desired.toString(10), + }); + + // we need to approve the amount of UNI for the liquidityPool contract to control + console.log( + `To approve ${amount0Desired} ${token0} to UNI token contract, send:`, + ); + console.log(`Data: ${data}`); + console.log(`Amount: ${amount}`); + + let transaction = await bitGoWallet.send({ + data: data, + amount: amount, + address: token0Contract.address, + walletPassphrase: 'walletPassphrase', + }); + + const token1Contract = getContractsFactory('eth') + .getContract('StandardERC20') + .instance(token1); + + ({ data, amount } = token1Contract.methods().approve.call({ + _spender: liquidityPoolContract.address, + _value: amount1Desired.toString(10), + })); + + //we need to approve the amount of DAI for the liquidityPool contract to control + console.log( + `To approve ${amount1Desired} ${token1} to DAI token contract, send:`, + ); + console.log(`Data: ${data}`); + console.log(`Amount: ${amount}`); + + transaction = await bitGoWallet.send({ + data: data, + amount: amount, + address: token1Contract.address, + walletPassphrase: 'walletPassphrase', + }); + + ({ data, amount } = liquidityPoolContract.methods().mint.call({ + token0: token0ContractAddress, + token1: token1ContractAddress, + fee: fee, + tickLower: tickLower, + tickUpper: tickUpper, + amount0Desired: amount0Desired.toString(10), + amount1Desired: amount1Desired.toString(10), + amount0Min: amount0Min.toString(10), + amount1Min: amount1Min.toString(10), + recipient: walletAddress, + deadline: deadline, + })); + + // Once the above txs are confirmed, we can create swap liquidity pool + console.log( + `To create liquidity pool with pair of ${token0} ${token1}, send: `, + ); + console.log( + `${token0} amount: ${amount0Desired} and ${token1} amount: ${amount1Desired} `, + ); + console.log(`to: ${liquidityPoolContract.address}`); + + transaction = await bitGoWallet.send({ + data: data, + amount: amount, + address: liquidityPoolContract.address, + walletPassphrase: 'walletPassphrase', + }); + + console.log(transaction); +} + +sendBitGoTx(); diff --git a/eth/examples/Uniswap/removeLiquidityPoolV2.ts b/eth/examples/Uniswap/removeLiquidityPoolV2.ts new file mode 100644 index 0000000..f06cc08 --- /dev/null +++ b/eth/examples/Uniswap/removeLiquidityPoolV2.ts @@ -0,0 +1,64 @@ +import { getContractsFactory } from '../../../src/index'; +import { BitGo } from 'bitgo'; +import * as utils from '../utils'; +import * as ethUtil from 'ethereumjs-util'; +//remove DAI/ETH Liquidity Pool +async function sendBitGoTx() { + const liquidity = 10e18; + const tokenContractAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F'; //DAI + const walletAddress = '0x61E64B5224f88944222c4Aa7CCE1809c17106De5'; + const amountTokenMin = 99e18; + const amountETHMin = 9e15; + const deadline = 'deadline'; + + + const bitGo = new BitGo({ env: 'test', accessToken: 'accesstoken' }); + const baseCoin = bitGo.coin('teth'); + const bitGoWallet = await baseCoin.wallets().get({ id: 'walletId' }); + + const liquidityPoolContract = getContractsFactory('eth') + .getContract('UniswapV2SwapRouter') + .instance(); + const chainId = 1; + const uniSwapV2FactoryContractAddress = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f'; + const sampleWalletAddress = '0x6c31cdbf161bad81f9eceb107d757cb85f2dbcab'; + const spender = liquidityPoolContract.address; + const value = liquidity.toString(10); + const nonce = 'nonce'; + const name = 'Uniswap V2'; + const permitApprovalHash = utils.getUniSushiSwapV2ApprovalHash(sampleWalletAddress, spender, value, nonce, deadline); + const domainSeperatorHash = utils.getUniSushiSwapV2PairDomainSeperatorHash(name, chainId, uniSwapV2FactoryContractAddress); + const digest = utils.getMasterContractApprovalHash(domainSeperatorHash, permitApprovalHash); + const privateKeyHex = 'privateKeyHex'; + const privkey = Buffer.from(privateKeyHex.replace(/^0x/i, ''), 'hex'); + const signature = ethUtil.ecsign(digest, privkey); + + const v = signature.v; + const r = ethUtil.addHexPrefix(signature.r.toString('hex')); + const s = ethUtil.addHexPrefix(signature.s.toString('hex')); + + const { data, amount } = liquidityPoolContract + .methods() + .addLiquidityETH.call({ + token: tokenContractAddress, + liquidity: liquidity.toString(10), + amountTokenMin: amountTokenMin.toString(10), + amountETHMin: amountETHMin.toString(10), + to: walletAddress, + deadline, + v: v, + r: r, + s: s, + }); + + const transaction = await bitGoWallet.send({ + data: data, + amount: amount, + address: liquidityPoolContract.address, + walletPassphrase: 'walletPassphrase', + }); + + console.log(transaction); +} + +sendBitGoTx(); diff --git a/eth/examples/Uniswap/removeLiquidityPoolV3.ts b/eth/examples/Uniswap/removeLiquidityPoolV3.ts new file mode 100644 index 0000000..94830f1 --- /dev/null +++ b/eth/examples/Uniswap/removeLiquidityPoolV3.ts @@ -0,0 +1,74 @@ +import { getContractsFactory } from '../../../src/index'; +import { BitGo } from 'bitgo'; + +//remove DAI/ETH Liquidity Pool +async function sendBitGoTx() { + + const DAIContractAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F'; + const tokenId = 'tokenId'; // you can get the id calling balanceOf and tokenOfOwnerByIndex + const liquidity = 18e17; + const amount0Min = 80e15; //eth + const amount1Min = 40e18; //dai + const deadline = 'deadline'; + const bitGo = new BitGo({ env: 'test', accessToken: 'accesstoken' }); + const baseCoin = bitGo.coin('teth'); + const bitGoWallet = await baseCoin.wallets().get({ id: 'walletId' }); + + const liquidityPoolContract = getContractsFactory('eth') + .getContract('UniswapV3NonfungiblePositionManager') + .instance(); + + const data1 = liquidityPoolContract + .methods() + .decreaseLiquidity.call({ + tokenId, + liquidity: liquidity.toString(10), + amount0Min: amount0Min.toString(10), + amount1Min: amount1Min.toString(10), + deadline, + }); + + const recipient = 'walletAddress'; + const amountMax = '340282366920938463463374607431768211455'; + + const data2 = liquidityPoolContract + .methods() + .collect.call({ + tokenId, + recipient, + amount0Max: amountMax, + amount1Max: amountMax, + }); + + const data3 = liquidityPoolContract + .methods() + .unwrapWETH9.call({ + amountMinimum: amount1Min.toString(10), + recipient, + }); + + const data4 = liquidityPoolContract + .methods() + .sweepToken.call({ + token: DAIContractAddress, + amountMinimum: amount0Min.toString(10), + recipient, + }); + const dataBytes = [data1.data, data2.data, data3.data, data4.data]; + + const { data, amount } = liquidityPoolContract + .methods() + .multicall.call({ data: dataBytes }); + + + const transaction = await bitGoWallet.send({ + data: data, + amount: amount, + address: liquidityPoolContract.address, + walletPassphrase: 'walletPassphrase', + }); + + console.log(transaction); +} + +sendBitGoTx(); diff --git a/eth/examples/Uniswap/swapV2.ts b/eth/examples/Uniswap/swapV2.ts new file mode 100644 index 0000000..20037dd --- /dev/null +++ b/eth/examples/Uniswap/swapV2.ts @@ -0,0 +1,42 @@ +import { getContractsFactory } from '../../../src/index'; +import { BitGo } from 'bitgo'; + + +// Example to swap from 0.01 ETH to DAI + +async function sendBitGoTx() { + const DAIContractAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F'; + const amountOutMin = 50e17; + const wrappedEtherContractAddress = '0xd0A1E359811322d97991E03f863a0C30C2cF029C'; + const toAddress = 'walletAddress'; + const swapRouter = getContractsFactory('eth').getContract('UniswapV2SwapRouter').instance(); + const path = [wrappedEtherContractAddress, DAIContractAddress]; + const deadline = 'deadline'; + const ethAmount = 1e16; + + const txInput = swapRouter.methods().swapExactETHForTokens. +call({ amountOutMin: amountOutMin.toString(10), path: path, to: toAddress, deadline: deadline }); + txInput.amount = ethAmount.toString(10); + console.log(`To swap ETH to DAI with UniwapV2Router contract, send:`); + console.log(`Data: ${txInput.data}`); + console.log(`Amount: ${txInput.amount}`); + console.log(`To: ${swapRouter.address}`); + + + const bitGo = new BitGo({ env: 'test', accessToken: +'accesstoken' }); + const baseCoin = bitGo.coin('teth'); + const bitGoWallet = await baseCoin + .wallets() + .get({ id: 'walletId' }); + + + const transaction = await bitGoWallet.send({ + data: txInput.data, amount: txInput.amount, address: swapRouter.address, + walletPassphrase: 'walletPassphrase', + }); + + console.log(transaction); +} + +sendBitGoTx(); diff --git a/eth/examples/Uniswap/swapV3.ts b/eth/examples/Uniswap/swapV3.ts new file mode 100644 index 0000000..104b8b9 --- /dev/null +++ b/eth/examples/Uniswap/swapV3.ts @@ -0,0 +1,45 @@ +import { getContractsFactory } from '../../../src/index'; +import { BitGo } from 'bitgo'; + +// Example to swap from 0.01 ETH to DAI + +async function sendBitGoTx() { + const bitGo = new BitGo({ env: 'test', accessToken: 'accesstoken' }); + const baseCoin = bitGo.coin('teth'); + const bitGoWallet = await baseCoin.wallets().get({ id: 'walletId' }); + + const DAIContractAddress = '0x6B175474E89094C44Da98b954EedeAC495271d0F'; + const amountOutMinimum = 50e17; + const amountIn = 1e16; + const wrappedEtherContractAddress = '0xd0A1E359811322d97991E03f863a0C30C2cF029C'; + const walletAddress = '0x6f32a7e465d50f61df96dfffc5bfb6d4059c7cd6'; + const fee = '3000'; + const sqrtPriceLimitX96 = '0'; + const deadline = 'deadline'; + + const swapRouter = getContractsFactory('eth') + .getContract('UniswapV3SwapRouter') + .instance(); + const txInput = swapRouter.methods().exactInputSingle.call({ + tokenIn: wrappedEtherContractAddress, + tokenOut: DAIContractAddress, + fee: fee, + recipient: walletAddress, + deadline: deadline, + amountIn: amountIn.toString(10), + amountOutMinimum: amountOutMinimum, + sqrtPriceLimitX96: sqrtPriceLimitX96, + }); + + txInput.amount = amountIn.toString(10); + const transaction = await bitGoWallet.send({ + data: txInput.data, + amount: txInput.amount, + address: swapRouter.address, + walletPassphrase: 'walletPassphrase', + }); + + console.log(transaction); +} + +sendBitGoTx(); diff --git a/eth/examples/utils.ts b/eth/examples/utils.ts new file mode 100644 index 0000000..acba0ab --- /dev/null +++ b/eth/examples/utils.ts @@ -0,0 +1,109 @@ +import * as abi from 'ethereumjs-abi'; +import ethers from 'ethers'; + + +const APPROVAL_SIGNATURE_HASH = +ethers.utils.keccak256(ethers.utils.toUtf8Bytes('SetMasterContractApproval(string warning,address user,address masterContract,bool approved,uint256 nonce)')); +const WARNING_MESSAGE_HASH = +ethers.utils.keccak256(ethers.utils.toUtf8Bytes('Give FULL access to funds in (and approved to) BentoBox?')); +const EIP191_PREFIX_FOR_EIP712_STRUCTURED_DATA = '\x19\x01'; +const DOMAIN_SEPARATOR_SIGNATURE_HASH = ethers.utils.keccak256(ethers.utils.toUtf8Bytes('EIP712Domain(string name,uint256 chainId,address verifyingContract)')); +const SUSHISWAPV2PAIR_DOMAIN_SEPERATOR_HASH = ethers.utils.keccak256(ethers.utils.toUtf8Bytes('EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)')); +const BENTOBOX_HASH = ethers.utils.keccak256(ethers.utils.toUtf8Bytes('BentoBox V1')); +const SUSHISWAP_PERMIT_TYPEHASH = 0x6e71edae12b1b97f4d1f60370fef10105fa2faae0126114a169c64845d6126c9; +export const MAX_VALUE_SHARE = 115792089237316195423570985008687907853269984665640564039457584007913129639934; +export function getKashiApprovalHash( + user, + master, + approved, + nonce, +) { + return ethers.utils.keccak256(ethers.utils.defaultAbiCoder.encode( + ['bytes32', 'bytes32', 'address', 'address', 'bool', 'uint256'], + [ + APPROVAL_SIGNATURE_HASH, + WARNING_MESSAGE_HASH, + user, + master, + approved, + nonce, + ], + )); +} + +export function getKashiDomainSeperatorHash( + chainId, + address, +) { + return ethers.utils.keccak256(ethers.utils.defaultAbiCoder.encode( + ['string', 'string', 'string', 'uint256', 'address'], + [ + DOMAIN_SEPARATOR_SIGNATURE_HASH, + BENTOBOX_HASH, + chainId, + address, + ], + )); +} + +export function getUniSushiSwapV2PairDomainSeperatorHash( + name, + chainId, + address, +) { + return ethers.utils.keccak256(ethers.utils.defaultAbiCoder.encode( + ['bytes32', 'bytes32', 'bytes32', 'uint', 'address'], + [ + SUSHISWAPV2PAIR_DOMAIN_SEPERATOR_HASH, + ethers.utils.keccak256(ethers.utils.toUtf8Bytes(name)), + ethers.utils.keccak256(ethers.utils.toUtf8Bytes('1')), + chainId, + address, + ], + )); +} + + +export function getUniSushiSwapV2ApprovalHash( + owner, + spender, + value, + nonce, + deadline, +) { + return ethers.utils.keccak256(ethers.utils.defaultAbiCoder.encode( + ['bytes32', 'address', 'address', 'uint', 'uint', 'uint'], + [ + SUSHISWAP_PERMIT_TYPEHASH, + owner, + spender, + value, + nonce, + deadline, + ], + )); +} + +export function getMasterContractApprovalHash ( + domainSeperatorHash, + kashiApprovalHash, +) { + return abi.soliditySHA3( + ['string', 'bytes32', 'bytes32'], + [ + EIP191_PREFIX_FOR_EIP712_STRUCTURED_DATA, + domainSeperatorHash, + kashiApprovalHash, + + ], + ); +} + +export const stripHexPrefix = (str: string): string => { + if (typeof str !== 'string') { + throw new Error(`[stripHexPrefix] input must be type 'string', received ${typeof str}`); + } + + return ethers.utils.isHexString(str) ? str.slice(2) : str; +}; + diff --git a/src/base/methods/methods.ts b/src/base/methods/methods.ts index 4b24090..0f9bdf0 100644 --- a/src/base/methods/methods.ts +++ b/src/base/methods/methods.ts @@ -2,6 +2,7 @@ export type MethodsClass = new(...args: any[]) => TMethod; export interface Parameter { + components: any; name: string type: string; } diff --git a/src/eth/methods/methods.ts b/src/eth/methods/methods.ts index 6de8c26..1a55904 100644 --- a/src/eth/methods/methods.ts +++ b/src/eth/methods/methods.ts @@ -2,7 +2,7 @@ import * as abi from 'ethereumjs-abi'; import { ensure } from '../../util/ensure'; import * as ethUtil from 'ethereumjs-util'; import { Method, MethodDefinition, Parameter } from '../../base/methods/methods'; - +import * as ethers from 'ethers'; export interface EthMethodDefinition extends MethodDefinition { constant: boolean; payable: boolean; @@ -38,14 +38,36 @@ export class EthMethod implements Method { call(params: { [key: string]: any }): any { const types: string[] = []; const values: string[] = []; - this.inputs.forEach((input: Parameter) => { - ensure(params[input.name] !== undefined, `Missing required parameter: ${input.name}`); - values.push(params[input.name]); - types.push(input.type); + let data = ''; + this.inputs.forEach((input) => { + if (Array.isArray(input.components)) { + let tuple = 'tuple('; + input.components.forEach(component => { + ensure(params[component.name] !== undefined, `Missing required parameter: ${component.name}`); + tuple += component.type + ','; + values.push(params[component.name]); + }); + tuple = tuple.slice(0, -1); + tuple += ')'; + + types.push(tuple); + const abiElement = 'function ' + this.name + '(' + tuple + ')'; + const iface = new ethers.utils.Interface([abiElement]); + const methodId = iface.functions[this.name].sighash; + data = methodId + ethers.utils.defaultAbiCoder.encode(types, [values]).slice(2); + + } else { + ensure(params[input.name] !== undefined, `Missing required parameter: ${input.name}`); + values.push(params[input.name]); + types.push(input.type); + data = ethUtil.addHexPrefix(this.id + abi.rawEncode(types, values).toString('hex')); + + } + }); return { - data: ethUtil.addHexPrefix(this.id + abi.rawEncode(types, values).toString('hex')), + data, amount: '0', }; } diff --git a/test/testutil.ts b/test/testutil.ts index c196fab..d4c1dec 100644 --- a/test/testutil.ts +++ b/test/testutil.ts @@ -64,6 +64,18 @@ const generateTrxHexString = (length: number): () => string => { }; }; +const generateEthAddress = () => { + return () => { + return '0x61E64B5224f88944222c4Aa7CCE1809c17106De5'; + }; +}; + +const generateIntArrray = (arr:string[]) => { + return () => { + return arr; + }; +}; + const solidityTypes: { [key: string]: any } = { eth: { uint: generateNumber(2e8), @@ -75,7 +87,7 @@ const solidityTypes: { [key: string]: any } = { uint256: generateNumber(2e16), int256: generateSignedInteger(2e8), bool: generateFromOptions([true, false]), - address: generateHexString(40), + address: generateEthAddress(), bytes: generateHexString(32), bytes1: generateHexString(2), bytes2: generateHexString(4), @@ -86,6 +98,12 @@ const solidityTypes: { [key: string]: any } = { bytes32: generateHexString(64), string: generateFromOptions(['asdfadsf', 'hello world', 'test']), ['address[]']: generateHexStringArray(40, 1), + ['uint8[]']: generateIntArrray([generateNumber(2e2)(), generateNumber(2e2)()]), + ['uint256[]']: generateIntArrray([generateNumber(2e16)(), generateNumber(2e8)()]), + ['bytes[]']: generateHexStringArray(40, 1), + uint24: generateNumber(2e4), + uint160: generateNumber(2e8), + int24: generateNumber(2e4), }, trx: { uint: generateNumber(2e8), @@ -120,16 +138,25 @@ export function testFuzzedContractMethods (chainName:string, contract: Contract< const name = methodDefinition.name; for (let i = 0; i < FUZZING_REPETITIONS; i++) { - const args: { [key: string]: any } = {}; + let args: { [key: string]: any } = {}; params.forEach((param: Parameter) => { - args[param.name] = getSolidityParameter(chainName, param.type); + if (param.type === 'tuple') { + const obj :{[key: string]: any} = {}; + param.components.forEach((key:{name: string, type: string}) => { + obj[key.name] = getSolidityParameter(chainName, key.type); + }); + args = obj; + } else { + args[param.name] = getSolidityParameter(chainName, param.type); + } + }); const contractInstance = contract.instance(args.instanceName || 'default'); if (args.address) { contractInstance.address = args.address; } - + callback(contractInstance.methods()[name].call(args)); } });