diff --git a/abi/cow-swap-settlement.json b/abi/cow-swap-settlement.json new file mode 100644 index 00000000..683bda5e --- /dev/null +++ b/abi/cow-swap-settlement.json @@ -0,0 +1,581 @@ +[ + { + "inputs": [ + { + "internalType": "contract GPv2Authentication", + "name": "authenticator_", + "type": "address" + }, + { + "internalType": "contract IVault", + "name": "vault_", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + } + ], + "name": "Interaction", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "orderUid", + "type": "bytes" + } + ], + "name": "OrderInvalidated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "orderUid", + "type": "bytes" + }, + { + "indexed": false, + "internalType": "bool", + "name": "signed", + "type": "bool" + } + ], + "name": "PreSignature", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "solver", + "type": "address" + } + ], + "name": "Settlement", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract IERC20", + "name": "sellToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract IERC20", + "name": "buyToken", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "sellAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "buyAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "feeAmount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "orderUid", + "type": "bytes" + } + ], + "name": "Trade", + "type": "event" + }, + { + "inputs": [], + "name": "authenticator", + "outputs": [ + { + "internalType": "contract GPv2Authentication", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "domainSeparator", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "filledAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "orderUids", + "type": "bytes[]" + } + ], + "name": "freeFilledAmountStorage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "orderUids", + "type": "bytes[]" + } + ], + "name": "freePreSignatureStorage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "offset", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "length", + "type": "uint256" + } + ], + "name": "getStorageAt", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "orderUid", + "type": "bytes" + } + ], + "name": "invalidateOrder", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "preSignature", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "orderUid", + "type": "bytes" + }, + { + "internalType": "bool", + "name": "signed", + "type": "bool" + } + ], + "name": "setPreSignature", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "clearingPrices", + "type": "uint256[]" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "sellTokenIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "buyTokenIndex", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "sellAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "buyAmount", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "validTo", + "type": "uint32" + }, + { + "internalType": "bytes32", + "name": "appData", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "feeAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "flags", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "executedAmount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct GPv2Trade.Data[]", + "name": "trades", + "type": "tuple[]" + }, + { + "components": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "callData", + "type": "bytes" + } + ], + "internalType": "struct GPv2Interaction.Data[][3]", + "name": "interactions", + "type": "tuple[][3]" + } + ], + "name": "settle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "targetContract", + "type": "address" + }, + { + "internalType": "bytes", + "name": "calldataPayload", + "type": "bytes" + } + ], + "name": "simulateDelegatecall", + "outputs": [ + { + "internalType": "bytes", + "name": "response", + "type": "bytes" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "targetContract", + "type": "address" + }, + { + "internalType": "bytes", + "name": "calldataPayload", + "type": "bytes" + } + ], + "name": "simulateDelegatecallInternal", + "outputs": [ + { + "internalType": "bytes", + "name": "response", + "type": "bytes" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "assetInIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "assetOutIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "internalType": "struct IVault.BatchSwapStep[]", + "name": "swaps", + "type": "tuple[]" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "sellTokenIndex", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "buyTokenIndex", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "sellAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "buyAmount", + "type": "uint256" + }, + { + "internalType": "uint32", + "name": "validTo", + "type": "uint32" + }, + { + "internalType": "bytes32", + "name": "appData", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "feeAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "flags", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "executedAmount", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + } + ], + "internalType": "struct GPv2Trade.Data", + "name": "trade", + "type": "tuple" + } + ], + "name": "swap", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "vault", + "outputs": [ + { + "internalType": "contract IVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "vaultRelayer", + "outputs": [ + { + "internalType": "contract GPv2VaultRelayer", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] \ No newline at end of file diff --git a/abi/one-inch-aggregation-router.json b/abi/one-inch-aggregation-router.json new file mode 100644 index 00000000..080dfd11 --- /dev/null +++ b/abi/one-inch-aggregation-router.json @@ -0,0 +1,2188 @@ +[ + { + "inputs": [ + { + "internalType": "contract IWETH", + "name": "weth", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "AccessDenied", + "type": "error" + }, + { + "inputs": [], + "name": "AdvanceNonceFailed", + "type": "error" + }, + { + "inputs": [], + "name": "AlreadyFilled", + "type": "error" + }, + { + "inputs": [], + "name": "ArbitraryStaticCallFailed", + "type": "error" + }, + { + "inputs": [], + "name": "BadPool", + "type": "error" + }, + { + "inputs": [], + "name": "BadSignature", + "type": "error" + }, + { + "inputs": [], + "name": "ETHTransferFailed", + "type": "error" + }, + { + "inputs": [], + "name": "ETHTransferFailed", + "type": "error" + }, + { + "inputs": [], + "name": "EmptyPools", + "type": "error" + }, + { + "inputs": [], + "name": "EthDepositRejected", + "type": "error" + }, + { + "inputs": [], + "name": "GetAmountCallFailed", + "type": "error" + }, + { + "inputs": [], + "name": "IncorrectDataLength", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientBalance", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidMsgValue", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidMsgValue", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidatedOrder", + "type": "error" + }, + { + "inputs": [], + "name": "MakingAmountExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "MakingAmountTooLow", + "type": "error" + }, + { + "inputs": [], + "name": "OnlyOneAmountShouldBeZero", + "type": "error" + }, + { + "inputs": [], + "name": "OrderExpired", + "type": "error" + }, + { + "inputs": [], + "name": "PermitLengthTooLow", + "type": "error" + }, + { + "inputs": [], + "name": "PredicateIsNotTrue", + "type": "error" + }, + { + "inputs": [], + "name": "PrivateOrder", + "type": "error" + }, + { + "inputs": [], + "name": "RFQBadSignature", + "type": "error" + }, + { + "inputs": [], + "name": "RFQPrivateOrder", + "type": "error" + }, + { + "inputs": [], + "name": "RFQSwapWithZeroAmount", + "type": "error" + }, + { + "inputs": [], + "name": "RFQZeroTargetIsForbidden", + "type": "error" + }, + { + "inputs": [], + "name": "ReentrancyDetected", + "type": "error" + }, + { + "inputs": [], + "name": "RemainingAmountIsZero", + "type": "error" + }, + { + "inputs": [], + "name": "ReservesCallFailed", + "type": "error" + }, + { + "inputs": [], + "name": "ReturnAmountIsNotEnough", + "type": "error" + }, + { + "inputs": [], + "name": "SafePermitBadLength", + "type": "error" + }, + { + "inputs": [], + "name": "SafeTransferFailed", + "type": "error" + }, + { + "inputs": [], + "name": "SafeTransferFromFailed", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "success", + "type": "bool" + }, + { + "internalType": "bytes", + "name": "res", + "type": "bytes" + } + ], + "name": "SimulationResults", + "type": "error" + }, + { + "inputs": [], + "name": "SwapAmountTooLarge", + "type": "error" + }, + { + "inputs": [], + "name": "SwapWithZeroAmount", + "type": "error" + }, + { + "inputs": [], + "name": "TakingAmountExceeded", + "type": "error" + }, + { + "inputs": [], + "name": "TakingAmountIncreased", + "type": "error" + }, + { + "inputs": [], + "name": "TakingAmountTooHigh", + "type": "error" + }, + { + "inputs": [], + "name": "TransferFromMakerToTakerFailed", + "type": "error" + }, + { + "inputs": [], + "name": "TransferFromTakerToMakerFailed", + "type": "error" + }, + { + "inputs": [], + "name": "UnknownOrder", + "type": "error" + }, + { + "inputs": [], + "name": "WrongAmount", + "type": "error" + }, + { + "inputs": [], + "name": "WrongGetter", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroAddress", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroMinReturn", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroReturnAmount", + "type": "error" + }, + { + "inputs": [], + "name": "ZeroTargetIsForbidden", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newNonce", + "type": "uint256" + } + ], + "name": "NonceIncreased", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "orderHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "remainingRaw", + "type": "uint256" + } + ], + "name": "OrderCanceled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "orderHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "remaining", + "type": "uint256" + } + ], + "name": "OrderFilled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "orderHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + } + ], + "name": "OrderFilledRFQ", + "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" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "amount", + "type": "uint8" + } + ], + "name": "advanceNonce", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "offsets", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "and", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "arbitraryStaticCall", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "salt", + "type": "uint256" + }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "allowedSender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "offsets", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "interactions", + "type": "bytes" + } + ], + "internalType": "struct OrderLib.Order", + "name": "order", + "type": "tuple" + } + ], + "name": "cancelOrder", + "outputs": [ + { + "internalType": "uint256", + "name": "orderRemaining", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "orderHash", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "orderInfo", + "type": "uint256" + } + ], + "name": "cancelOrderRFQ", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "orderInfo", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "additionalMask", + "type": "uint256" + } + ], + "name": "cancelOrderRFQ", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "salt", + "type": "uint256" + }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "allowedSender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "offsets", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "interactions", + "type": "bytes" + } + ], + "internalType": "struct OrderLib.Order", + "name": "order", + "type": "tuple" + } + ], + "name": "checkPredicate", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IClipperExchangeInterface", + "name": "clipperExchange", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "srcToken", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "dstToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "inputAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "outputAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "goodUntil", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "vs", + "type": "bytes32" + } + ], + "name": "clipperSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "returnAmount", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IClipperExchangeInterface", + "name": "clipperExchange", + "type": "address" + }, + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "srcToken", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "dstToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "inputAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "outputAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "goodUntil", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "vs", + "type": "bytes32" + } + ], + "name": "clipperSwapTo", + "outputs": [ + { + "internalType": "uint256", + "name": "returnAmount", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IClipperExchangeInterface", + "name": "clipperExchange", + "type": "address" + }, + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "srcToken", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "dstToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "inputAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "outputAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "goodUntil", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "vs", + "type": "bytes32" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + } + ], + "name": "clipperSwapToWithPermit", + "outputs": [ + { + "internalType": "uint256", + "name": "returnAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "destroy", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "eq", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "salt", + "type": "uint256" + }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "allowedSender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "offsets", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "interactions", + "type": "bytes" + } + ], + "internalType": "struct OrderLib.Order", + "name": "order", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "interaction", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "skipPermitAndThresholdAmount", + "type": "uint256" + } + ], + "name": "fillOrder", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "internalType": "address", + "name": "allowedSender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takingAmount", + "type": "uint256" + } + ], + "internalType": "struct OrderRFQLib.OrderRFQ", + "name": "order", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "flagsAndAmount", + "type": "uint256" + } + ], + "name": "fillOrderRFQ", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "internalType": "address", + "name": "allowedSender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takingAmount", + "type": "uint256" + } + ], + "internalType": "struct OrderRFQLib.OrderRFQ", + "name": "order", + "type": "tuple" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "vs", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "flagsAndAmount", + "type": "uint256" + } + ], + "name": "fillOrderRFQCompact", + "outputs": [ + { + "internalType": "uint256", + "name": "filledMakingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "filledTakingAmount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "orderHash", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "internalType": "address", + "name": "allowedSender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takingAmount", + "type": "uint256" + } + ], + "internalType": "struct OrderRFQLib.OrderRFQ", + "name": "order", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "flagsAndAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "fillOrderRFQTo", + "outputs": [ + { + "internalType": "uint256", + "name": "filledMakingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "filledTakingAmount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "orderHash", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "info", + "type": "uint256" + }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "internalType": "address", + "name": "allowedSender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takingAmount", + "type": "uint256" + } + ], + "internalType": "struct OrderRFQLib.OrderRFQ", + "name": "order", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "flagsAndAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + } + ], + "name": "fillOrderRFQToWithPermit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "salt", + "type": "uint256" + }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "allowedSender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "offsets", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "interactions", + "type": "bytes" + } + ], + "internalType": "struct OrderLib.Order", + "name": "order_", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "interaction", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "skipPermitAndThresholdAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "target", + "type": "address" + } + ], + "name": "fillOrderTo", + "outputs": [ + { + "internalType": "uint256", + "name": "actualMakingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "actualTakingAmount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "orderHash", + "type": "bytes32" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "salt", + "type": "uint256" + }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "allowedSender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "offsets", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "interactions", + "type": "bytes" + } + ], + "internalType": "struct OrderLib.Order", + "name": "order", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "signature", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "interaction", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "skipPermitAndThresholdAmount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + } + ], + "name": "fillOrderToWithPermit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "gt", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "uint256", + "name": "salt", + "type": "uint256" + }, + { + "internalType": "address", + "name": "makerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "takerAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "address", + "name": "allowedSender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "makingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "takingAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "offsets", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "interactions", + "type": "bytes" + } + ], + "internalType": "struct OrderLib.Order", + "name": "order", + "type": "tuple" + } + ], + "name": "hashOrder", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "increaseNonce", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "maker", + "type": "address" + }, + { + "internalType": "uint256", + "name": "slot", + "type": "uint256" + } + ], + "name": "invalidatorForOrderRFQ", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "lt", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "nonce", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "makerAddress", + "type": "address" + }, + { + "internalType": "uint256", + "name": "makerNonce", + "type": "uint256" + } + ], + "name": "nonceEquals", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "offsets", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "or", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "orderHash", + "type": "bytes32" + } + ], + "name": "remaining", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "orderHash", + "type": "bytes32" + } + ], + "name": "remainingRaw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32[]", + "name": "orderHashes", + "type": "bytes32[]" + } + ], + "name": "remainingsRaw", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "rescueFunds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "target", + "type": "address" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "simulate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IAggregationExecutor", + "name": "executor", + "type": "address" + }, + { + "components": [ + { + "internalType": "contract IERC20", + "name": "srcToken", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "dstToken", + "type": "address" + }, + { + "internalType": "address payable", + "name": "srcReceiver", + "type": "address" + }, + { + "internalType": "address payable", + "name": "dstReceiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minReturnAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "flags", + "type": "uint256" + } + ], + "internalType": "struct GenericRouter.SwapDescription", + "name": "desc", + "type": "tuple" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "swap", + "outputs": [ + { + "internalType": "uint256", + "name": "returnAmount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "spentAmount", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "time", + "type": "uint256" + } + ], + "name": "timestampBelow", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "timeNonceAccount", + "type": "uint256" + } + ], + "name": "timestampBelowAndNonceEquals", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minReturn", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "pools", + "type": "uint256[]" + } + ], + "name": "uniswapV3Swap", + "outputs": [ + { + "internalType": "uint256", + "name": "returnAmount", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int256", + "name": "amount0Delta", + "type": "int256" + }, + { + "internalType": "int256", + "name": "amount1Delta", + "type": "int256" + }, + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "name": "uniswapV3SwapCallback", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minReturn", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "pools", + "type": "uint256[]" + } + ], + "name": "uniswapV3SwapTo", + "outputs": [ + { + "internalType": "uint256", + "name": "returnAmount", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "srcToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minReturn", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "pools", + "type": "uint256[]" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + } + ], + "name": "uniswapV3SwapToWithPermit", + "outputs": [ + { + "internalType": "uint256", + "name": "returnAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "srcToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minReturn", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "pools", + "type": "uint256[]" + } + ], + "name": "unoswap", + "outputs": [ + { + "internalType": "uint256", + "name": "returnAmount", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "srcToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minReturn", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "pools", + "type": "uint256[]" + } + ], + "name": "unoswapTo", + "outputs": [ + { + "internalType": "uint256", + "name": "returnAmount", + "type": "uint256" + } + ], + "stateMutability": "payable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address payable", + "name": "recipient", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "srcToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minReturn", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "pools", + "type": "uint256[]" + }, + { + "internalType": "bytes", + "name": "permit", + "type": "bytes" + } + ], + "name": "unoswapToWithPermit", + "outputs": [ + { + "internalType": "uint256", + "name": "returnAmount", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "stateMutability": "payable", + "type": "receive" + } +] \ No newline at end of file diff --git a/abi/uniswap-v3.json b/abi/uniswap-v3.json new file mode 100644 index 00000000..49cc338e --- /dev/null +++ b/abi/uniswap-v3.json @@ -0,0 +1,988 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount0", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount1", + "type": "uint128" + } + ], + "name": "Collect", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount0", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount1", + "type": "uint128" + } + ], + "name": "CollectProtocol", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "paid0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "paid1", + "type": "uint256" + } + ], + "name": "Flash", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "observationCardinalityNextOld", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "observationCardinalityNextNew", + "type": "uint16" + } + ], + "name": "IncreaseObservationCardinalityNext", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + }, + { + "indexed": false, + "internalType": "int24", + "name": "tick", + "type": "int24" + } + ], + "name": "Initialize", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "feeProtocol0Old", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "feeProtocol1Old", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "feeProtocol0New", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "feeProtocol1New", + "type": "uint8" + } + ], + "name": "SetFeeProtocol", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "amount0", + "type": "int256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "amount1", + "type": "int256" + }, + { + "indexed": false, + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "int24", + "name": "tick", + "type": "int24" + } + ], + "name": "Swap", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint128", + "name": "amount0Requested", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "amount1Requested", + "type": "uint128" + } + ], + "name": "collect", + "outputs": [ + { + "internalType": "uint128", + "name": "amount0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "amount1", + "type": "uint128" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint128", + "name": "amount0Requested", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "amount1Requested", + "type": "uint128" + } + ], + "name": "collectProtocol", + "outputs": [ + { + "internalType": "uint128", + "name": "amount0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "amount1", + "type": "uint128" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "fee", + "outputs": [ + { + "internalType": "uint24", + "name": "", + "type": "uint24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeGrowthGlobal0X128", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeGrowthGlobal1X128", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "flash", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "observationCardinalityNext", + "type": "uint16" + } + ], + "name": "increaseObservationCardinalityNext", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "liquidity", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLiquidityPerTick", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "observations", + "outputs": [ + { + "internalType": "uint32", + "name": "blockTimestamp", + "type": "uint32" + }, + { + "internalType": "int56", + "name": "tickCumulative", + "type": "int56" + }, + { + "internalType": "uint160", + "name": "secondsPerLiquidityCumulativeX128", + "type": "uint160" + }, + { + "internalType": "bool", + "name": "initialized", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32[]", + "name": "secondsAgos", + "type": "uint32[]" + } + ], + "name": "observe", + "outputs": [ + { + "internalType": "int56[]", + "name": "tickCumulatives", + "type": "int56[]" + }, + { + "internalType": "uint160[]", + "name": "secondsPerLiquidityCumulativeX128s", + "type": "uint160[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "positions", + "outputs": [ + { + "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": "protocolFees", + "outputs": [ + { + "internalType": "uint128", + "name": "token0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "token1", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "feeProtocol0", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "feeProtocol1", + "type": "uint8" + } + ], + "name": "setFeeProtocol", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "slot0", + "outputs": [ + { + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + }, + { + "internalType": "int24", + "name": "tick", + "type": "int24" + }, + { + "internalType": "uint16", + "name": "observationIndex", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "observationCardinality", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "observationCardinalityNext", + "type": "uint16" + }, + { + "internalType": "uint8", + "name": "feeProtocol", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "unlocked", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + } + ], + "name": "snapshotCumulativesInside", + "outputs": [ + { + "internalType": "int56", + "name": "tickCumulativeInside", + "type": "int56" + }, + { + "internalType": "uint160", + "name": "secondsPerLiquidityInsideX128", + "type": "uint160" + }, + { + "internalType": "uint32", + "name": "secondsInside", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "bool", + "name": "zeroForOne", + "type": "bool" + }, + { + "internalType": "int256", + "name": "amountSpecified", + "type": "int256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "swap", + "outputs": [ + { + "internalType": "int256", + "name": "amount0", + "type": "int256" + }, + { + "internalType": "int256", + "name": "amount1", + "type": "int256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int16", + "name": "", + "type": "int16" + } + ], + "name": "tickBitmap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tickSpacing", + "outputs": [ + { + "internalType": "int24", + "name": "", + "type": "int24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "", + "type": "int24" + } + ], + "name": "ticks", + "outputs": [ + { + "internalType": "uint128", + "name": "liquidityGross", + "type": "uint128" + }, + { + "internalType": "int128", + "name": "liquidityNet", + "type": "int128" + }, + { + "internalType": "uint256", + "name": "feeGrowthOutside0X128", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeGrowthOutside1X128", + "type": "uint256" + }, + { + "internalType": "int56", + "name": "tickCumulativeOutside", + "type": "int56" + }, + { + "internalType": "uint160", + "name": "secondsPerLiquidityOutsideX128", + "type": "uint160" + }, + { + "internalType": "uint32", + "name": "secondsOutside", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "initialized", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token0", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token1", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/db/migrations/1721432059587-Data.js b/db/migrations/1721690414027-Data.js similarity index 99% rename from db/migrations/1721432059587-Data.js rename to db/migrations/1721690414027-Data.js index e5cda09c..210ee9fb 100644 --- a/db/migrations/1721432059587-Data.js +++ b/db/migrations/1721690414027-Data.js @@ -1,5 +1,5 @@ -module.exports = class Data1721432059587 { - name = 'Data1721432059587' +module.exports = class Data1721690414027 { + name = 'Data1721690414027' async up(db) { await db.query(`CREATE TABLE "es_token" ("id" character varying NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "circulating" numeric NOT NULL, "staked" numeric NOT NULL, "total" numeric NOT NULL, CONSTRAINT "PK_69bef9eb94d9a5d42d726d1e661" PRIMARY KEY ("id"))`) @@ -285,7 +285,7 @@ module.exports = class Data1721432059587 { await db.query(`CREATE INDEX "IDX_091cfbe0d977006e05144bd1fe" ON "o_token_vault" ("timestamp") `) await db.query(`CREATE INDEX "IDX_fa92b36d011441a02d9a231860" ON "o_token_vault" ("block_number") `) await db.query(`CREATE INDEX "IDX_3a2bfb2808c1d7cbb0a568910c" ON "o_token_vault" ("address") `) - await db.query(`CREATE TABLE "o_token_activity" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "otoken" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "call_data_last4_bytes" text NOT NULL, "address" text, "sighash" text, "action" text, "exchange" text, "interface" text, "from_symbol" text, "to_symbol" text, "amount" numeric, CONSTRAINT "PK_a6e9207d04e252b4de591283276" PRIMARY KEY ("id"))`) + await db.query(`CREATE TABLE "o_token_activity" ("id" character varying NOT NULL, "chain_id" integer NOT NULL, "otoken" text NOT NULL, "timestamp" TIMESTAMP WITH TIME ZONE NOT NULL, "block_number" integer NOT NULL, "tx_hash" text NOT NULL, "type" character varying(12), "data" jsonb, CONSTRAINT "PK_a6e9207d04e252b4de591283276" PRIMARY KEY ("id"))`) await db.query(`CREATE INDEX "IDX_9c617918c3dc521bed5220a185" ON "o_token_activity" ("chain_id") `) await db.query(`CREATE INDEX "IDX_62bfeb1dee3bcefffdbd10172a" ON "o_token_activity" ("otoken") `) await db.query(`CREATE INDEX "IDX_57bb1f7d2fd6fe063b9cd434b2" ON "o_token_activity" ("timestamp") `) diff --git a/package-lock.json b/package-lock.json index 92cb3116..5f1373c4 100644 --- a/package-lock.json +++ b/package-lock.json @@ -28,7 +28,7 @@ "viem": "^1.10.13" }, "devDependencies": { - "@subsquid/evm-typegen": "^4.2.0", + "@subsquid/evm-typegen": "^4.3.0", "@subsquid/typeorm-codegen": "^2.0.1", "@trivago/prettier-plugin-sort-imports": "^4.2.0", "@types/js-yaml": "^4.0.8", @@ -1232,9 +1232,9 @@ } }, "node_modules/@subsquid/evm-typegen": { - "version": "4.2.0", - "resolved": "https://registry.npmjs.org/@subsquid/evm-typegen/-/evm-typegen-4.2.0.tgz", - "integrity": "sha512-JlRx+plPBknJSb7GjEVdVIUeddIaH39ELxUXyENKLeeWSVhkFeSjlmuFPJuldsY2hx+xoPZnECyqIKiSyjrFWw==", + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/@subsquid/evm-typegen/-/evm-typegen-4.3.0.tgz", + "integrity": "sha512-a/9MyePxlKmWpcsAopcZXBeNv+W0Mf39j7USOeHyE9QYJ7avF6baMsOQFvzbOwlk8s6w/uEURMxAMvnKgCWo5Q==", "dev": true, "dependencies": { "@subsquid/evm-abi": "^0.3.0", diff --git a/package.json b/package.json index 4ecba760..b4c05db5 100644 --- a/package.json +++ b/package.json @@ -40,7 +40,7 @@ "viem": "^1.10.13" }, "devDependencies": { - "@subsquid/evm-typegen": "^4.2.0", + "@subsquid/evm-typegen": "^4.3.0", "@subsquid/typeorm-codegen": "^2.0.1", "@trivago/prettier-plugin-sort-imports": "^4.2.0", "@types/js-yaml": "^4.0.8", diff --git a/schema.graphql b/schema.graphql index 18d611c0..bca63088 100644 --- a/schema.graphql +++ b/schema.graphql @@ -967,18 +967,49 @@ type OTokenActivity @entity { timestamp: DateTime! @index blockNumber: Int! @index txHash: String! @index - callDataLast4Bytes: String! - address: String - sighash: String - - action: String - exchange: String - interface: String - - fromSymbol: String - toSymbol: String - amount: BigInt -} + type: OTokenActivityType + data: JSON +} + + +enum OTokenActivityType { + Approval + Bridge + ClaimRewards + DelegateVote + ExtendStake + Migrate + Stake + Transfer + Swap + Wrap + Unwrap + Mint + Redeem + Zap + Unstake + Vote +} + +#type OTokenActivity @entity { +# id: ID! +# chainId: Int! @index +# otoken: String! @index +# timestamp: DateTime! @index +# blockNumber: Int! @index +# txHash: String! @index +# callDataLast4Bytes: String! +# address: String +# sighash: String +# +# action: String +# exchange: String +# interface: String +# +# fromSymbol: String +# toSymbol: String +# amount: BigInt +#} """ The Vault entity tracks the OUSD vault balance over time. """ diff --git a/schema/otoken.graphql b/schema/otoken.graphql index 16202b71..6ad10ae6 100644 --- a/schema/otoken.graphql +++ b/schema/otoken.graphql @@ -105,15 +105,46 @@ type OTokenActivity @entity { timestamp: DateTime! @index blockNumber: Int! @index txHash: String! @index - callDataLast4Bytes: String! - address: String - sighash: String + type: OTokenActivityType + data: JSON +} - action: String - exchange: String - interface: String - fromSymbol: String - toSymbol: String - amount: BigInt +enum OTokenActivityType { + Approval + Bridge + ClaimRewards + DelegateVote + ExtendStake + Migrate + Stake + Transfer + Swap + Wrap + Unwrap + Mint + Redeem + Zap + Unstake + Vote } + +#type OTokenActivity @entity { +# id: ID! +# chainId: Int! @index +# otoken: String! @index +# timestamp: DateTime! @index +# blockNumber: Int! @index +# txHash: String! @index +# callDataLast4Bytes: String! +# address: String +# sighash: String +# +# action: String +# exchange: String +# interface: String +# +# fromSymbol: String +# toSymbol: String +# amount: BigInt +#} diff --git a/scripts/parse-tx-activity.ts b/scripts/parse-tx-activity.ts deleted file mode 100644 index 3078b142..00000000 --- a/scripts/parse-tx-activity.ts +++ /dev/null @@ -1,25 +0,0 @@ -/** - * This script takes a transaction hash and parses the activity. Useful for - * debugging the activity parser without having to run Squid. - */ -import { createPublicClient, http } from 'viem' -import { mainnet } from 'viem/chains' - -import { type Transaction, activityFromTx } from '../src/utils/activityFromTx' - -const client = createPublicClient({ - chain: mainnet, - transport: http(process.env.RPC_ENDPOINT), -}) - -async function go(hash: `0x${string}`) { - const transaction = await client.getTransaction({ hash }) - const receipt = await client.getTransactionReceipt({ hash }) - const activity = await activityFromTx( - transaction as Transaction, - receipt.logs, - ) - console.log(activity) -} - -go('0xd3705c324d3e59545a21eb9773108cbb266631251484ace5016b59c25719a02a') diff --git a/src/abi/balancer-meta-pool-strategy.ts b/src/abi/balancer-meta-pool-strategy.ts index 03889da6..42dd9c58 100644 --- a/src/abi/balancer-meta-pool-strategy.ts +++ b/src/abi/balancer-meta-pool-strategy.ts @@ -21,12 +21,12 @@ export const functions = { auraRewardPoolAddress: viewFun("0x3132a21d", "auraRewardPoolAddress()", {}, p.address), balancerPoolId: viewFun("0xdbbb64b9", "balancerPoolId()", {}, p.bytes32), balancerVault: viewFun("0x158274a5", "balancerVault()", {}, p.address), - "checkBalance(address)": viewFun("0x5f515226", "checkBalance(address)", {"_asset": p.address}, p.uint256), - "checkBalance()": viewFun("0xc71daccb", "checkBalance()", {}, p.uint256), + 'checkBalance(address)': viewFun("0x5f515226", "checkBalance(address)", {"_asset": p.address}, p.uint256), + 'checkBalance()': viewFun("0xc71daccb", "checkBalance()", {}, p.uint256), claimGovernance: fun("0x5d36b190", "claimGovernance()", {}, ), collectRewardTokens: fun("0x5a063f63", "collectRewardTokens()", {}, ), - "deposit(address,uint256)": fun("0x47e7ef24", "deposit(address,uint256)", {"_0": p.address, "_1": p.uint256}, ), - "deposit(address[],uint256[])": fun("0xefc908a1", "deposit(address[],uint256[])", {"_0": p.array(p.address), "_1": p.array(p.uint256)}, ), + 'deposit(address,uint256)': fun("0x47e7ef24", "deposit(address,uint256)", {"_0": p.address, "_1": p.uint256}, ), + 'deposit(address[],uint256[])': fun("0xefc908a1", "deposit(address[],uint256[])", {"_0": p.array(p.address), "_1": p.array(p.uint256)}, ), depositAll: fun("0xde5f6268", "depositAll()", {}, ), frxETH: viewFun("0x565d3e6e", "frxETH()", {}, p.address), getRewardTokenAddresses: viewFun("0xf6ca71b0", "getRewardTokenAddresses()", {}, p.array(p.address)), @@ -52,8 +52,8 @@ export const functions = { transferGovernance: fun("0xd38bfff4", "transferGovernance(address)", {"_newGovernor": p.address}, ), transferToken: fun("0x1072cbea", "transferToken(address,uint256)", {"_asset": p.address, "_amount": p.uint256}, ), vaultAddress: viewFun("0x430bf08a", "vaultAddress()", {}, p.address), - "withdraw(address,address,uint256)": fun("0xd9caed12", "withdraw(address,address,uint256)", {"_recipient": p.address, "_strategyAsset": p.address, "_strategyAmount": p.uint256}, ), - "withdraw(address,address[],uint256[])": fun("0xedbd7668", "withdraw(address,address[],uint256[])", {"_recipient": p.address, "_strategyAssets": p.array(p.address), "_strategyAmounts": p.array(p.uint256)}, ), + 'withdraw(address,address,uint256)': fun("0xd9caed12", "withdraw(address,address,uint256)", {"_recipient": p.address, "_strategyAsset": p.address, "_strategyAmount": p.uint256}, ), + 'withdraw(address,address[],uint256[])': fun("0xedbd7668", "withdraw(address,address[],uint256[])", {"_recipient": p.address, "_strategyAssets": p.array(p.address), "_strategyAmounts": p.array(p.uint256)}, ), withdrawAll: fun("0x853828b6", "withdrawAll()", {}, ), wstETH: viewFun("0x4aa07e64", "wstETH()", {}, p.address), } @@ -76,12 +76,12 @@ export class Contract extends ContractBase { return this.eth_call(functions.balancerVault, {}) } - "checkBalance(address)"(_asset: CheckBalanceParams_0["_asset"]) { - return this.eth_call(functions["checkBalance(address)"], {_asset}) + 'checkBalance(address)'(_asset: CheckBalanceParams_0["_asset"]) { + return this.eth_call(functions['checkBalance(address)'], {_asset}) } - "checkBalance()"() { - return this.eth_call(functions["checkBalance()"], {}) + 'checkBalance()'() { + return this.eth_call(functions['checkBalance()'], {}) } frxETH() { @@ -171,11 +171,11 @@ export type BalancerPoolIdReturn = FunctionReturn export type BalancerVaultReturn = FunctionReturn -export type CheckBalanceParams_0 = FunctionArguments -export type CheckBalanceReturn_0 = FunctionReturn +export type CheckBalanceParams_0 = FunctionArguments +export type CheckBalanceReturn_0 = FunctionReturn -export type CheckBalanceParams_1 = FunctionArguments -export type CheckBalanceReturn_1 = FunctionReturn +export type CheckBalanceParams_1 = FunctionArguments +export type CheckBalanceReturn_1 = FunctionReturn export type ClaimGovernanceParams = FunctionArguments export type ClaimGovernanceReturn = FunctionReturn @@ -183,11 +183,11 @@ export type ClaimGovernanceReturn = FunctionReturn export type CollectRewardTokensReturn = FunctionReturn -export type DepositParams_0 = FunctionArguments -export type DepositReturn_0 = FunctionReturn +export type DepositParams_0 = FunctionArguments +export type DepositReturn_0 = FunctionReturn -export type DepositParams_1 = FunctionArguments -export type DepositReturn_1 = FunctionReturn +export type DepositParams_1 = FunctionArguments +export type DepositReturn_1 = FunctionReturn export type DepositAllParams = FunctionArguments export type DepositAllReturn = FunctionReturn @@ -264,11 +264,11 @@ export type TransferTokenReturn = FunctionReturn export type VaultAddressParams = FunctionArguments export type VaultAddressReturn = FunctionReturn -export type WithdrawParams_0 = FunctionArguments -export type WithdrawReturn_0 = FunctionReturn +export type WithdrawParams_0 = FunctionArguments +export type WithdrawReturn_0 = FunctionReturn -export type WithdrawParams_1 = FunctionArguments -export type WithdrawReturn_1 = FunctionReturn +export type WithdrawParams_1 = FunctionArguments +export type WithdrawReturn_1 = FunctionReturn export type WithdrawAllParams = FunctionArguments export type WithdrawAllReturn = FunctionReturn diff --git a/src/abi/balancer-meta-stable-pool.ts b/src/abi/balancer-meta-stable-pool.ts index e54a9478..5d3a1e70 100644 --- a/src/abi/balancer-meta-stable-pool.ts +++ b/src/abi/balancer-meta-stable-pool.ts @@ -47,8 +47,8 @@ export const functions = { nonces: viewFun("0x7ecebe00", "nonces(address)", {"owner": p.address}, p.uint256), onExitPool: fun("0x74f3b009", "onExitPool(bytes32,address,address,uint256[],uint256,uint256,bytes)", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"amountsOut": p.array(p.uint256), "dueProtocolFeeAmounts": p.array(p.uint256)}), onJoinPool: fun("0xd5c096c4", "onJoinPool(bytes32,address,address,uint256[],uint256,uint256,bytes)", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"amountsIn": p.array(p.uint256), "dueProtocolFeeAmounts": p.array(p.uint256)}), - "onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256[],uint256,uint256)": fun("0x01ec954a", "onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256[],uint256,uint256)", {"request": p.struct({"kind": p.uint8, "tokenIn": p.address, "tokenOut": p.address, "amount": p.uint256, "poolId": p.bytes32, "lastChangeBlock": p.uint256, "from": p.address, "to": p.address, "userData": p.bytes}), "balances": p.array(p.uint256), "indexIn": p.uint256, "indexOut": p.uint256}, p.uint256), - "onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256,uint256)": fun("0x9d2c110c", "onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256,uint256)", {"request": p.struct({"kind": p.uint8, "tokenIn": p.address, "tokenOut": p.address, "amount": p.uint256, "poolId": p.bytes32, "lastChangeBlock": p.uint256, "from": p.address, "to": p.address, "userData": p.bytes}), "balanceTokenIn": p.uint256, "balanceTokenOut": p.uint256}, p.uint256), + 'onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256[],uint256,uint256)': fun("0x01ec954a", "onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256[],uint256,uint256)", {"request": p.struct({"kind": p.uint8, "tokenIn": p.address, "tokenOut": p.address, "amount": p.uint256, "poolId": p.bytes32, "lastChangeBlock": p.uint256, "from": p.address, "to": p.address, "userData": p.bytes}), "balances": p.array(p.uint256), "indexIn": p.uint256, "indexOut": p.uint256}, p.uint256), + 'onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256,uint256)': fun("0x9d2c110c", "onSwap((uint8,address,address,uint256,bytes32,uint256,address,address,bytes),uint256,uint256)", {"request": p.struct({"kind": p.uint8, "tokenIn": p.address, "tokenOut": p.address, "amount": p.uint256, "poolId": p.bytes32, "lastChangeBlock": p.uint256, "from": p.address, "to": p.address, "userData": p.bytes}), "balanceTokenIn": p.uint256, "balanceTokenOut": p.uint256}, p.uint256), permit: fun("0xd505accf", "permit(address,address,uint256,uint256,uint8,bytes32,bytes32)", {"owner": p.address, "spender": p.address, "value": p.uint256, "deadline": p.uint256, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, ), queryExit: fun("0x6028bfd4", "queryExit(bytes32,address,address,uint256[],uint256,uint256,bytes)", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"bptIn": p.uint256, "amountsOut": p.array(p.uint256)}), queryJoin: fun("0x87ec6817", "queryJoin(bytes32,address,address,uint256[],uint256,uint256,bytes)", {"poolId": p.bytes32, "sender": p.address, "recipient": p.address, "balances": p.array(p.uint256), "lastChangeBlock": p.uint256, "protocolSwapFeePercentage": p.uint256, "userData": p.bytes}, {"bptOut": p.uint256, "amountsIn": p.array(p.uint256)}), @@ -288,11 +288,11 @@ export type OnExitPoolReturn = FunctionReturn export type OnJoinPoolParams = FunctionArguments export type OnJoinPoolReturn = FunctionReturn -export type OnSwapParams_0 = FunctionArguments -export type OnSwapReturn_0 = FunctionReturn +export type OnSwapParams_0 = FunctionArguments +export type OnSwapReturn_0 = FunctionReturn -export type OnSwapParams_1 = FunctionArguments -export type OnSwapReturn_1 = FunctionReturn +export type OnSwapParams_1 = FunctionArguments +export type OnSwapReturn_1 = FunctionReturn export type PermitParams = FunctionArguments export type PermitReturn = FunctionReturn diff --git a/src/abi/base-reward-pool-4626.ts b/src/abi/base-reward-pool-4626.ts index 80182fc0..c28563d8 100644 --- a/src/abi/base-reward-pool-4626.ts +++ b/src/abi/base-reward-pool-4626.ts @@ -29,8 +29,8 @@ export const functions = { earned: viewFun("0x008cc262", "earned(address)", {"account": p.address}, p.uint256), extraRewards: viewFun("0x40c35446", "extraRewards(uint256)", {"_0": p.uint256}, p.address), extraRewardsLength: viewFun("0xd55a23f4", "extraRewardsLength()", {}, p.uint256), - "getReward()": fun("0x3d18b912", "getReward()", {}, p.bool), - "getReward(address,bool)": fun("0x7050ccd9", "getReward(address,bool)", {"_account": p.address, "_claimExtras": p.bool}, p.bool), + 'getReward()': fun("0x3d18b912", "getReward()", {}, p.bool), + 'getReward(address,bool)': fun("0x7050ccd9", "getReward(address,bool)", {"_account": p.address, "_claimExtras": p.bool}, p.bool), historicalRewards: viewFun("0x262d3d6d", "historicalRewards()", {}, p.uint256), lastTimeRewardApplicable: viewFun("0x80faa57d", "lastTimeRewardApplicable()", {}, p.uint256), lastUpdateTime: viewFun("0xc8f33c91", "lastUpdateTime()", {}, p.uint256), @@ -68,8 +68,8 @@ export const functions = { transfer: fun("0xa9059cbb", "transfer(address,uint256)", {"_0": p.address, "_1": p.uint256}, p.bool), transferFrom: fun("0x23b872dd", "transferFrom(address,address,uint256)", {"_0": p.address, "_1": p.address, "_2": p.uint256}, p.bool), userRewardPerTokenPaid: viewFun("0x8b876347", "userRewardPerTokenPaid(address)", {"_0": p.address}, p.uint256), - "withdraw(uint256,bool)": fun("0x38d07436", "withdraw(uint256,bool)", {"amount": p.uint256, "claim": p.bool}, p.bool), - "withdraw(uint256,address,address)": fun("0xb460af94", "withdraw(uint256,address,address)", {"assets": p.uint256, "receiver": p.address, "owner": p.address}, p.uint256), + 'withdraw(uint256,bool)': fun("0x38d07436", "withdraw(uint256,bool)", {"amount": p.uint256, "claim": p.bool}, p.bool), + 'withdraw(uint256,address,address)': fun("0xb460af94", "withdraw(uint256,address,address)", {"assets": p.uint256, "receiver": p.address, "owner": p.address}, p.uint256), withdrawAll: fun("0x1c1c6fe5", "withdrawAll(bool)", {"claim": p.bool}, ), withdrawAllAndUnwrap: fun("0x49f039a2", "withdrawAllAndUnwrap(bool)", {"claim": p.bool}, ), withdrawAndUnwrap: fun("0xc32e7202", "withdrawAndUnwrap(uint256,bool)", {"amount": p.uint256, "claim": p.bool}, p.bool), @@ -290,11 +290,11 @@ export type ExtraRewardsReturn = FunctionReturn export type ExtraRewardsLengthParams = FunctionArguments export type ExtraRewardsLengthReturn = FunctionReturn -export type GetRewardParams_0 = FunctionArguments -export type GetRewardReturn_0 = FunctionReturn +export type GetRewardParams_0 = FunctionArguments +export type GetRewardReturn_0 = FunctionReturn -export type GetRewardParams_1 = FunctionArguments -export type GetRewardReturn_1 = FunctionReturn +export type GetRewardParams_1 = FunctionArguments +export type GetRewardReturn_1 = FunctionReturn export type HistoricalRewardsParams = FunctionArguments export type HistoricalRewardsReturn = FunctionReturn @@ -407,11 +407,11 @@ export type TransferFromReturn = FunctionReturn export type UserRewardPerTokenPaidParams = FunctionArguments export type UserRewardPerTokenPaidReturn = FunctionReturn -export type WithdrawParams_0 = FunctionArguments -export type WithdrawReturn_0 = FunctionReturn +export type WithdrawParams_0 = FunctionArguments +export type WithdrawReturn_0 = FunctionReturn -export type WithdrawParams_1 = FunctionArguments -export type WithdrawReturn_1 = FunctionReturn +export type WithdrawParams_1 = FunctionArguments +export type WithdrawReturn_1 = FunctionReturn export type WithdrawAllParams = FunctionArguments export type WithdrawAllReturn = FunctionReturn diff --git a/src/abi/base-reward-pool.ts b/src/abi/base-reward-pool.ts index e994170e..197b8f38 100644 --- a/src/abi/base-reward-pool.ts +++ b/src/abi/base-reward-pool.ts @@ -19,8 +19,8 @@ export const functions = { earned: viewFun("0x008cc262", "earned(address)", {"account": p.address}, p.uint256), extraRewards: viewFun("0x40c35446", "extraRewards(uint256)", {"_0": p.uint256}, p.address), extraRewardsLength: viewFun("0xd55a23f4", "extraRewardsLength()", {}, p.uint256), - "getReward()": fun("0x3d18b912", "getReward()", {}, p.bool), - "getReward(address,bool)": fun("0x7050ccd9", "getReward(address,bool)", {"_account": p.address, "_claimExtras": p.bool}, p.bool), + 'getReward()': fun("0x3d18b912", "getReward()", {}, p.bool), + 'getReward(address,bool)': fun("0x7050ccd9", "getReward(address,bool)", {"_account": p.address, "_claimExtras": p.bool}, p.bool), historicalRewards: viewFun("0x262d3d6d", "historicalRewards()", {}, p.uint256), lastTimeRewardApplicable: viewFun("0x80faa57d", "lastTimeRewardApplicable()", {}, p.uint256), lastUpdateTime: viewFun("0xc8f33c91", "lastUpdateTime()", {}, p.uint256), @@ -177,11 +177,11 @@ export type ExtraRewardsReturn = FunctionReturn export type ExtraRewardsLengthParams = FunctionArguments export type ExtraRewardsLengthReturn = FunctionReturn -export type GetRewardParams_0 = FunctionArguments -export type GetRewardReturn_0 = FunctionReturn +export type GetRewardParams_0 = FunctionArguments +export type GetRewardReturn_0 = FunctionReturn -export type GetRewardParams_1 = FunctionArguments -export type GetRewardReturn_1 = FunctionReturn +export type GetRewardParams_1 = FunctionArguments +export type GetRewardReturn_1 = FunctionReturn export type HistoricalRewardsParams = FunctionArguments export type HistoricalRewardsReturn = FunctionReturn diff --git a/src/abi/ccip-evm2evmofframp.ts b/src/abi/ccip-evm2evmofframp.ts index fba28539..800635ce 100644 --- a/src/abi/ccip-evm2evmofframp.ts +++ b/src/abi/ccip-evm2evmofframp.ts @@ -4,8 +4,8 @@ import type { EventParams as EParams, FunctionArguments, FunctionReturn } from ' export const events = { AdminSet: event("0x8fe72c3e0020beb3234e76ae6676fa576fbfcae600af1c4fea44784cf0db329c", "AdminSet(address)", {"newAdmin": p.address}), - "ConfigSet((address,uint64,uint64,address,address,address),(uint32,address,address,uint16,uint32,uint32))": event("0xe668e1a4644c1a030b909bbfd837f5cfa914994ed5e0bb2e9c34a5c37753128a", "ConfigSet((address,uint64,uint64,address,address,address),(uint32,address,address,uint16,uint32,uint32))", {"staticConfig": p.struct({"commitStore": p.address, "chainSelector": p.uint64, "sourceChainSelector": p.uint64, "onRamp": p.address, "prevOffRamp": p.address, "armProxy": p.address}), "dynamicConfig": p.struct({"permissionLessExecutionThresholdSeconds": p.uint32, "router": p.address, "priceRegistry": p.address, "maxNumberOfTokensPerMsg": p.uint16, "maxDataBytes": p.uint32, "maxPoolReleaseOrMintGas": p.uint32})}), - "ConfigSet(uint32,bytes32,uint64,address[],address[],uint8,bytes,uint64,bytes)": event("0x1591690b8638f5fb2dbec82ac741805ac5da8b45dc5263f4875b0496fdce4e05", "ConfigSet(uint32,bytes32,uint64,address[],address[],uint8,bytes,uint64,bytes)", {"previousConfigBlockNumber": p.uint32, "configDigest": p.bytes32, "configCount": p.uint64, "signers": p.array(p.address), "transmitters": p.array(p.address), "f": p.uint8, "onchainConfig": p.bytes, "offchainConfigVersion": p.uint64, "offchainConfig": p.bytes}), + 'ConfigSet((address,uint64,uint64,address,address,address),(uint32,address,address,uint16,uint32,uint32))': event("0xe668e1a4644c1a030b909bbfd837f5cfa914994ed5e0bb2e9c34a5c37753128a", "ConfigSet((address,uint64,uint64,address,address,address),(uint32,address,address,uint16,uint32,uint32))", {"staticConfig": p.struct({"commitStore": p.address, "chainSelector": p.uint64, "sourceChainSelector": p.uint64, "onRamp": p.address, "prevOffRamp": p.address, "armProxy": p.address}), "dynamicConfig": p.struct({"permissionLessExecutionThresholdSeconds": p.uint32, "router": p.address, "priceRegistry": p.address, "maxNumberOfTokensPerMsg": p.uint16, "maxDataBytes": p.uint32, "maxPoolReleaseOrMintGas": p.uint32})}), + 'ConfigSet(uint32,bytes32,uint64,address[],address[],uint8,bytes,uint64,bytes)': event("0x1591690b8638f5fb2dbec82ac741805ac5da8b45dc5263f4875b0496fdce4e05", "ConfigSet(uint32,bytes32,uint64,address[],address[],uint8,bytes,uint64,bytes)", {"previousConfigBlockNumber": p.uint32, "configDigest": p.bytes32, "configCount": p.uint64, "signers": p.array(p.address), "transmitters": p.array(p.address), "f": p.uint8, "onchainConfig": p.bytes, "offchainConfigVersion": p.uint64, "offchainConfig": p.bytes}), ExecutionStateChanged: event("0xd4f851956a5d67c3997d1c9205045fef79bae2947fdee7e9e2641abc7391ef65", "ExecutionStateChanged(uint64,bytes32,uint8,bytes)", {"sequenceNumber": indexed(p.uint64), "messageId": indexed(p.bytes32), "state": p.uint8, "returnData": p.bytes}), OwnershipTransferRequested: event("0xed8889f560326eb138920d842192f0eb3dd22b4f139c87a2c57538e05bae1278", "OwnershipTransferRequested(address,address)", {"from": indexed(p.address), "to": indexed(p.address)}), OwnershipTransferred: event("0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "OwnershipTransferred(address,address)", {"from": indexed(p.address), "to": indexed(p.address)}), @@ -114,8 +114,8 @@ export class Contract extends ContractBase { /// Event types export type AdminSetEventArgs = EParams -export type ConfigSetEventArgs_0 = EParams -export type ConfigSetEventArgs_1 = EParams +export type ConfigSetEventArgs_0 = EParams +export type ConfigSetEventArgs_1 = EParams export type ExecutionStateChangedEventArgs = EParams export type OwnershipTransferRequestedEventArgs = EParams export type OwnershipTransferredEventArgs = EParams diff --git a/src/abi/cow-swap-settlement.ts b/src/abi/cow-swap-settlement.ts new file mode 100644 index 00000000..aa271f78 --- /dev/null +++ b/src/abi/cow-swap-settlement.ts @@ -0,0 +1,114 @@ +import * as p from '@subsquid/evm-codec' +import { event, fun, viewFun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' + +export const events = { + Interaction: event("0xed99827efb37016f2275f98c4bcf71c7551c75d59e9b450f79fa32e60be672c2", "Interaction(address,uint256,bytes4)", {"target": indexed(p.address), "value": p.uint256, "selector": p.bytes4}), + OrderInvalidated: event("0x875b6cb035bbd4ac6500fabc6d1e4ca5bdc58a3e2b424ccb5c24cdbebeb009a9", "OrderInvalidated(address,bytes)", {"owner": indexed(p.address), "orderUid": p.bytes}), + PreSignature: event("0x01bf7c8b0ca55deecbea89d7e58295b7ffbf685fd0d96801034ba8c6ffe1c68d", "PreSignature(address,bytes,bool)", {"owner": indexed(p.address), "orderUid": p.bytes, "signed": p.bool}), + Settlement: event("0x40338ce1a7c49204f0099533b1e9a7ee0a3d261f84974ab7af36105b8c4e9db4", "Settlement(address)", {"solver": indexed(p.address)}), + Trade: event("0xa07a543ab8a018198e99ca0184c93fe9050a79400a0a723441f84de1d972cc17", "Trade(address,address,address,uint256,uint256,uint256,bytes)", {"owner": indexed(p.address), "sellToken": p.address, "buyToken": p.address, "sellAmount": p.uint256, "buyAmount": p.uint256, "feeAmount": p.uint256, "orderUid": p.bytes}), +} + +export const functions = { + authenticator: viewFun("0x2335c76b", "authenticator()", {}, p.address), + domainSeparator: viewFun("0xf698da25", "domainSeparator()", {}, p.bytes32), + filledAmount: viewFun("0x2479fb6e", "filledAmount(bytes)", {"_0": p.bytes}, p.uint256), + freeFilledAmountStorage: fun("0xed9f35ce", "freeFilledAmountStorage(bytes[])", {"orderUids": p.array(p.bytes)}, ), + freePreSignatureStorage: fun("0xa2a7d51b", "freePreSignatureStorage(bytes[])", {"orderUids": p.array(p.bytes)}, ), + getStorageAt: viewFun("0x5624b25b", "getStorageAt(uint256,uint256)", {"offset": p.uint256, "length": p.uint256}, p.bytes), + invalidateOrder: fun("0x15337bc0", "invalidateOrder(bytes)", {"orderUid": p.bytes}, ), + preSignature: viewFun("0xd08d33d1", "preSignature(bytes)", {"_0": p.bytes}, p.uint256), + setPreSignature: fun("0xec6cb13f", "setPreSignature(bytes,bool)", {"orderUid": p.bytes, "signed": p.bool}, ), + settle: fun("0x13d79a0b", "settle(address[],uint256[],(uint256,uint256,address,uint256,uint256,uint32,bytes32,uint256,uint256,uint256,bytes)[],(address,uint256,bytes)[][3])", {"tokens": p.array(p.address), "clearingPrices": p.array(p.uint256), "trades": p.array(p.struct({"sellTokenIndex": p.uint256, "buyTokenIndex": p.uint256, "receiver": p.address, "sellAmount": p.uint256, "buyAmount": p.uint256, "validTo": p.uint32, "appData": p.bytes32, "feeAmount": p.uint256, "flags": p.uint256, "executedAmount": p.uint256, "signature": p.bytes})), "interactions": p.fixedSizeArray(p.array(p.struct({"target": p.address, "value": p.uint256, "callData": p.bytes})), 3)}, ), + simulateDelegatecall: fun("0xf84436bd", "simulateDelegatecall(address,bytes)", {"targetContract": p.address, "calldataPayload": p.bytes}, p.bytes), + simulateDelegatecallInternal: fun("0x43218e19", "simulateDelegatecallInternal(address,bytes)", {"targetContract": p.address, "calldataPayload": p.bytes}, p.bytes), + swap: fun("0x845a101f", "swap((bytes32,uint256,uint256,uint256,bytes)[],address[],(uint256,uint256,address,uint256,uint256,uint32,bytes32,uint256,uint256,uint256,bytes))", {"swaps": p.array(p.struct({"poolId": p.bytes32, "assetInIndex": p.uint256, "assetOutIndex": p.uint256, "amount": p.uint256, "userData": p.bytes})), "tokens": p.array(p.address), "trade": p.struct({"sellTokenIndex": p.uint256, "buyTokenIndex": p.uint256, "receiver": p.address, "sellAmount": p.uint256, "buyAmount": p.uint256, "validTo": p.uint32, "appData": p.bytes32, "feeAmount": p.uint256, "flags": p.uint256, "executedAmount": p.uint256, "signature": p.bytes})}, ), + vault: viewFun("0xfbfa77cf", "vault()", {}, p.address), + vaultRelayer: viewFun("0x9b552cc2", "vaultRelayer()", {}, p.address), +} + +export class Contract extends ContractBase { + + authenticator() { + return this.eth_call(functions.authenticator, {}) + } + + domainSeparator() { + return this.eth_call(functions.domainSeparator, {}) + } + + filledAmount(_0: FilledAmountParams["_0"]) { + return this.eth_call(functions.filledAmount, {_0}) + } + + getStorageAt(offset: GetStorageAtParams["offset"], length: GetStorageAtParams["length"]) { + return this.eth_call(functions.getStorageAt, {offset, length}) + } + + preSignature(_0: PreSignatureParams["_0"]) { + return this.eth_call(functions.preSignature, {_0}) + } + + vault() { + return this.eth_call(functions.vault, {}) + } + + vaultRelayer() { + return this.eth_call(functions.vaultRelayer, {}) + } +} + +/// Event types +export type InteractionEventArgs = EParams +export type OrderInvalidatedEventArgs = EParams +export type PreSignatureEventArgs = EParams +export type SettlementEventArgs = EParams +export type TradeEventArgs = EParams + +/// Function types +export type AuthenticatorParams = FunctionArguments +export type AuthenticatorReturn = FunctionReturn + +export type DomainSeparatorParams = FunctionArguments +export type DomainSeparatorReturn = FunctionReturn + +export type FilledAmountParams = FunctionArguments +export type FilledAmountReturn = FunctionReturn + +export type FreeFilledAmountStorageParams = FunctionArguments +export type FreeFilledAmountStorageReturn = FunctionReturn + +export type FreePreSignatureStorageParams = FunctionArguments +export type FreePreSignatureStorageReturn = FunctionReturn + +export type GetStorageAtParams = FunctionArguments +export type GetStorageAtReturn = FunctionReturn + +export type InvalidateOrderParams = FunctionArguments +export type InvalidateOrderReturn = FunctionReturn + +export type PreSignatureParams = FunctionArguments +export type PreSignatureReturn = FunctionReturn + +export type SetPreSignatureParams = FunctionArguments +export type SetPreSignatureReturn = FunctionReturn + +export type SettleParams = FunctionArguments +export type SettleReturn = FunctionReturn + +export type SimulateDelegatecallParams = FunctionArguments +export type SimulateDelegatecallReturn = FunctionReturn + +export type SimulateDelegatecallInternalParams = FunctionArguments +export type SimulateDelegatecallInternalReturn = FunctionReturn + +export type SwapParams = FunctionArguments +export type SwapReturn = FunctionReturn + +export type VaultParams = FunctionArguments +export type VaultReturn = FunctionReturn + +export type VaultRelayerParams = FunctionArguments +export type VaultRelayerReturn = FunctionReturn + diff --git a/src/abi/curve-lp-token.ts b/src/abi/curve-lp-token.ts index 8a2a5ea4..bd3fa6e3 100644 --- a/src/abi/curve-lp-token.ts +++ b/src/abi/curve-lp-token.ts @@ -33,18 +33,18 @@ export const functions = { price_oracle: viewFun("0x86fc88d3", "price_oracle()", {}, p.uint256), get_virtual_price: viewFun("0xbb7b8b80", "get_virtual_price()", {}, p.uint256), calc_token_amount: viewFun("0xed8e84f3", "calc_token_amount(uint256[2],bool)", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_is_deposit": p.bool}, p.uint256), - "add_liquidity(uint256[2],uint256)": fun("0x0b4c7e4d", "add_liquidity(uint256[2],uint256)", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_min_mint_amount": p.uint256}, p.uint256), - "add_liquidity(uint256[2],uint256,address)": fun("0x0c3e4b54", "add_liquidity(uint256[2],uint256,address)", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_min_mint_amount": p.uint256, "_receiver": p.address}, p.uint256), + 'add_liquidity(uint256[2],uint256)': fun("0x0b4c7e4d", "add_liquidity(uint256[2],uint256)", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_min_mint_amount": p.uint256}, p.uint256), + 'add_liquidity(uint256[2],uint256,address)': fun("0x0c3e4b54", "add_liquidity(uint256[2],uint256,address)", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_min_mint_amount": p.uint256, "_receiver": p.address}, p.uint256), get_dy: viewFun("0x5e0d443f", "get_dy(int128,int128,uint256)", {"i": p.int128, "j": p.int128, "dx": p.uint256}, p.uint256), - "exchange(int128,int128,uint256,uint256)": fun("0x3df02124", "exchange(int128,int128,uint256,uint256)", {"i": p.int128, "j": p.int128, "_dx": p.uint256, "_min_dy": p.uint256}, p.uint256), - "exchange(int128,int128,uint256,uint256,address)": fun("0xddc1f59d", "exchange(int128,int128,uint256,uint256,address)", {"i": p.int128, "j": p.int128, "_dx": p.uint256, "_min_dy": p.uint256, "_receiver": p.address}, p.uint256), - "remove_liquidity(uint256,uint256[2])": fun("0x5b36389c", "remove_liquidity(uint256,uint256[2])", {"_burn_amount": p.uint256, "_min_amounts": p.fixedSizeArray(p.uint256, 2)}, p.fixedSizeArray(p.uint256, 2)), - "remove_liquidity(uint256,uint256[2],address)": fun("0x3eb1719f", "remove_liquidity(uint256,uint256[2],address)", {"_burn_amount": p.uint256, "_min_amounts": p.fixedSizeArray(p.uint256, 2), "_receiver": p.address}, p.fixedSizeArray(p.uint256, 2)), - "remove_liquidity_imbalance(uint256[2],uint256)": fun("0xe3103273", "remove_liquidity_imbalance(uint256[2],uint256)", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_max_burn_amount": p.uint256}, p.uint256), - "remove_liquidity_imbalance(uint256[2],uint256,address)": fun("0x52d2cfdd", "remove_liquidity_imbalance(uint256[2],uint256,address)", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_max_burn_amount": p.uint256, "_receiver": p.address}, p.uint256), + 'exchange(int128,int128,uint256,uint256)': fun("0x3df02124", "exchange(int128,int128,uint256,uint256)", {"i": p.int128, "j": p.int128, "_dx": p.uint256, "_min_dy": p.uint256}, p.uint256), + 'exchange(int128,int128,uint256,uint256,address)': fun("0xddc1f59d", "exchange(int128,int128,uint256,uint256,address)", {"i": p.int128, "j": p.int128, "_dx": p.uint256, "_min_dy": p.uint256, "_receiver": p.address}, p.uint256), + 'remove_liquidity(uint256,uint256[2])': fun("0x5b36389c", "remove_liquidity(uint256,uint256[2])", {"_burn_amount": p.uint256, "_min_amounts": p.fixedSizeArray(p.uint256, 2)}, p.fixedSizeArray(p.uint256, 2)), + 'remove_liquidity(uint256,uint256[2],address)': fun("0x3eb1719f", "remove_liquidity(uint256,uint256[2],address)", {"_burn_amount": p.uint256, "_min_amounts": p.fixedSizeArray(p.uint256, 2), "_receiver": p.address}, p.fixedSizeArray(p.uint256, 2)), + 'remove_liquidity_imbalance(uint256[2],uint256)': fun("0xe3103273", "remove_liquidity_imbalance(uint256[2],uint256)", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_max_burn_amount": p.uint256}, p.uint256), + 'remove_liquidity_imbalance(uint256[2],uint256,address)': fun("0x52d2cfdd", "remove_liquidity_imbalance(uint256[2],uint256,address)", {"_amounts": p.fixedSizeArray(p.uint256, 2), "_max_burn_amount": p.uint256, "_receiver": p.address}, p.uint256), calc_withdraw_one_coin: viewFun("0xcc2b27d7", "calc_withdraw_one_coin(uint256,int128)", {"_burn_amount": p.uint256, "i": p.int128}, p.uint256), - "remove_liquidity_one_coin(uint256,int128,uint256)": fun("0x1a4d01d2", "remove_liquidity_one_coin(uint256,int128,uint256)", {"_burn_amount": p.uint256, "i": p.int128, "_min_received": p.uint256}, p.uint256), - "remove_liquidity_one_coin(uint256,int128,uint256,address)": fun("0x081579a5", "remove_liquidity_one_coin(uint256,int128,uint256,address)", {"_burn_amount": p.uint256, "i": p.int128, "_min_received": p.uint256, "_receiver": p.address}, p.uint256), + 'remove_liquidity_one_coin(uint256,int128,uint256)': fun("0x1a4d01d2", "remove_liquidity_one_coin(uint256,int128,uint256)", {"_burn_amount": p.uint256, "i": p.int128, "_min_received": p.uint256}, p.uint256), + 'remove_liquidity_one_coin(uint256,int128,uint256,address)': fun("0x081579a5", "remove_liquidity_one_coin(uint256,int128,uint256,address)", {"_burn_amount": p.uint256, "i": p.int128, "_min_received": p.uint256, "_receiver": p.address}, p.uint256), ramp_A: fun("0x3c157e64", "ramp_A(uint256,uint256)", {"_future_A": p.uint256, "_future_time": p.uint256}, ), stop_ramp_A: fun("0x551a6588", "stop_ramp_A()", {}, ), admin_balances: viewFun("0xe2e7d264", "admin_balances(uint256)", {"i": p.uint256}, p.uint256), @@ -270,41 +270,41 @@ export type Get_virtual_priceReturn = FunctionReturn export type Calc_token_amountReturn = FunctionReturn -export type Add_liquidityParams_0 = FunctionArguments -export type Add_liquidityReturn_0 = FunctionReturn +export type Add_liquidityParams_0 = FunctionArguments +export type Add_liquidityReturn_0 = FunctionReturn -export type Add_liquidityParams_1 = FunctionArguments -export type Add_liquidityReturn_1 = FunctionReturn +export type Add_liquidityParams_1 = FunctionArguments +export type Add_liquidityReturn_1 = FunctionReturn export type Get_dyParams = FunctionArguments export type Get_dyReturn = FunctionReturn -export type ExchangeParams_0 = FunctionArguments -export type ExchangeReturn_0 = FunctionReturn +export type ExchangeParams_0 = FunctionArguments +export type ExchangeReturn_0 = FunctionReturn -export type ExchangeParams_1 = FunctionArguments -export type ExchangeReturn_1 = FunctionReturn +export type ExchangeParams_1 = FunctionArguments +export type ExchangeReturn_1 = FunctionReturn -export type Remove_liquidityParams_0 = FunctionArguments -export type Remove_liquidityReturn_0 = FunctionReturn +export type Remove_liquidityParams_0 = FunctionArguments +export type Remove_liquidityReturn_0 = FunctionReturn -export type Remove_liquidityParams_1 = FunctionArguments -export type Remove_liquidityReturn_1 = FunctionReturn +export type Remove_liquidityParams_1 = FunctionArguments +export type Remove_liquidityReturn_1 = FunctionReturn -export type Remove_liquidity_imbalanceParams_0 = FunctionArguments -export type Remove_liquidity_imbalanceReturn_0 = FunctionReturn +export type Remove_liquidity_imbalanceParams_0 = FunctionArguments +export type Remove_liquidity_imbalanceReturn_0 = FunctionReturn -export type Remove_liquidity_imbalanceParams_1 = FunctionArguments -export type Remove_liquidity_imbalanceReturn_1 = FunctionReturn +export type Remove_liquidity_imbalanceParams_1 = FunctionArguments +export type Remove_liquidity_imbalanceReturn_1 = FunctionReturn export type Calc_withdraw_one_coinParams = FunctionArguments export type Calc_withdraw_one_coinReturn = FunctionReturn -export type Remove_liquidity_one_coinParams_0 = FunctionArguments -export type Remove_liquidity_one_coinReturn_0 = FunctionReturn +export type Remove_liquidity_one_coinParams_0 = FunctionArguments +export type Remove_liquidity_one_coinReturn_0 = FunctionReturn -export type Remove_liquidity_one_coinParams_1 = FunctionArguments -export type Remove_liquidity_one_coinReturn_1 = FunctionReturn +export type Remove_liquidity_one_coinParams_1 = FunctionArguments +export type Remove_liquidity_one_coinReturn_1 = FunctionReturn export type Ramp_AParams = FunctionArguments export type Ramp_AReturn = FunctionReturn diff --git a/src/abi/curve-registry-exchange.ts b/src/abi/curve-registry-exchange.ts index eedaf0ac..6afd6a60 100644 --- a/src/abi/curve-registry-exchange.ts +++ b/src/abi/curve-registry-exchange.ts @@ -8,20 +8,20 @@ export const events = { } export const functions = { - "exchange_with_best_rate(address,address,uint256,uint256)": fun("0x10e5e303", "exchange_with_best_rate(address,address,uint256,uint256)", {"_from": p.address, "_to": p.address, "_amount": p.uint256, "_expected": p.uint256}, p.uint256), - "exchange_with_best_rate(address,address,uint256,uint256,address)": fun("0x9f69a6a6", "exchange_with_best_rate(address,address,uint256,uint256,address)", {"_from": p.address, "_to": p.address, "_amount": p.uint256, "_expected": p.uint256, "_receiver": p.address}, p.uint256), - "exchange(address,address,address,uint256,uint256)": fun("0x4798ce5b", "exchange(address,address,address,uint256,uint256)", {"_pool": p.address, "_from": p.address, "_to": p.address, "_amount": p.uint256, "_expected": p.uint256}, p.uint256), - "exchange(address,address,address,uint256,uint256,address)": fun("0x1a4c1ca3", "exchange(address,address,address,uint256,uint256,address)", {"_pool": p.address, "_from": p.address, "_to": p.address, "_amount": p.uint256, "_expected": p.uint256, "_receiver": p.address}, p.uint256), - "exchange_multiple(address[9],uint256[3][4],uint256,uint256)": fun("0x353ca424", "exchange_multiple(address[9],uint256[3][4],uint256,uint256)", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256, "_expected": p.uint256}, p.uint256), - "exchange_multiple(address[9],uint256[3][4],uint256,uint256,address[4])": fun("0x9db4f7aa", "exchange_multiple(address[9],uint256[3][4],uint256,uint256,address[4])", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256, "_expected": p.uint256, "_pools": p.fixedSizeArray(p.address, 4)}, p.uint256), - "exchange_multiple(address[9],uint256[3][4],uint256,uint256,address[4],address)": fun("0x0651cb35", "exchange_multiple(address[9],uint256[3][4],uint256,uint256,address[4],address)", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256, "_expected": p.uint256, "_pools": p.fixedSizeArray(p.address, 4), "_receiver": p.address}, p.uint256), - "get_best_rate(address,address,uint256)": viewFun("0x4e21df75", "get_best_rate(address,address,uint256)", {"_from": p.address, "_to": p.address, "_amount": p.uint256}, {"_0": p.address, "_1": p.uint256}), - "get_best_rate(address,address,uint256,address[8])": viewFun("0x488de9af", "get_best_rate(address,address,uint256,address[8])", {"_from": p.address, "_to": p.address, "_amount": p.uint256, "_exclude_pools": p.fixedSizeArray(p.address, 8)}, {"_0": p.address, "_1": p.uint256}), + 'exchange_with_best_rate(address,address,uint256,uint256)': fun("0x10e5e303", "exchange_with_best_rate(address,address,uint256,uint256)", {"_from": p.address, "_to": p.address, "_amount": p.uint256, "_expected": p.uint256}, p.uint256), + 'exchange_with_best_rate(address,address,uint256,uint256,address)': fun("0x9f69a6a6", "exchange_with_best_rate(address,address,uint256,uint256,address)", {"_from": p.address, "_to": p.address, "_amount": p.uint256, "_expected": p.uint256, "_receiver": p.address}, p.uint256), + 'exchange(address,address,address,uint256,uint256)': fun("0x4798ce5b", "exchange(address,address,address,uint256,uint256)", {"_pool": p.address, "_from": p.address, "_to": p.address, "_amount": p.uint256, "_expected": p.uint256}, p.uint256), + 'exchange(address,address,address,uint256,uint256,address)': fun("0x1a4c1ca3", "exchange(address,address,address,uint256,uint256,address)", {"_pool": p.address, "_from": p.address, "_to": p.address, "_amount": p.uint256, "_expected": p.uint256, "_receiver": p.address}, p.uint256), + 'exchange_multiple(address[9],uint256[3][4],uint256,uint256)': fun("0x353ca424", "exchange_multiple(address[9],uint256[3][4],uint256,uint256)", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256, "_expected": p.uint256}, p.uint256), + 'exchange_multiple(address[9],uint256[3][4],uint256,uint256,address[4])': fun("0x9db4f7aa", "exchange_multiple(address[9],uint256[3][4],uint256,uint256,address[4])", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256, "_expected": p.uint256, "_pools": p.fixedSizeArray(p.address, 4)}, p.uint256), + 'exchange_multiple(address[9],uint256[3][4],uint256,uint256,address[4],address)': fun("0x0651cb35", "exchange_multiple(address[9],uint256[3][4],uint256,uint256,address[4],address)", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256, "_expected": p.uint256, "_pools": p.fixedSizeArray(p.address, 4), "_receiver": p.address}, p.uint256), + 'get_best_rate(address,address,uint256)': viewFun("0x4e21df75", "get_best_rate(address,address,uint256)", {"_from": p.address, "_to": p.address, "_amount": p.uint256}, {"_0": p.address, "_1": p.uint256}), + 'get_best_rate(address,address,uint256,address[8])': viewFun("0x488de9af", "get_best_rate(address,address,uint256,address[8])", {"_from": p.address, "_to": p.address, "_amount": p.uint256, "_exclude_pools": p.fixedSizeArray(p.address, 8)}, {"_0": p.address, "_1": p.uint256}), get_exchange_amount: viewFun("0x3973e834", "get_exchange_amount(address,address,address,uint256)", {"_pool": p.address, "_from": p.address, "_to": p.address, "_amount": p.uint256}, p.uint256), get_input_amount: viewFun("0x7fa5a654", "get_input_amount(address,address,address,uint256)", {"_pool": p.address, "_from": p.address, "_to": p.address, "_amount": p.uint256}, p.uint256), get_exchange_amounts: viewFun("0x4be9ae42", "get_exchange_amounts(address,address,address,uint256[100])", {"_pool": p.address, "_from": p.address, "_to": p.address, "_amounts": p.fixedSizeArray(p.uint256, 100)}, p.fixedSizeArray(p.uint256, 100)), - "get_exchange_multiple_amount(address[9],uint256[3][4],uint256)": viewFun("0x7b3d22cf", "get_exchange_multiple_amount(address[9],uint256[3][4],uint256)", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256}, p.uint256), - "get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])": viewFun("0xe6eabf23", "get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256, "_pools": p.fixedSizeArray(p.address, 4)}, p.uint256), + 'get_exchange_multiple_amount(address[9],uint256[3][4],uint256)': viewFun("0x7b3d22cf", "get_exchange_multiple_amount(address[9],uint256[3][4],uint256)", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256}, p.uint256), + 'get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])': viewFun("0xe6eabf23", "get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])", {"_route": p.fixedSizeArray(p.address, 9), "_swap_params": p.fixedSizeArray(p.fixedSizeArray(p.uint256, 3), 4), "_amount": p.uint256, "_pools": p.fixedSizeArray(p.address, 4)}, p.uint256), get_calculator: viewFun("0x5d7dc825", "get_calculator(address)", {"_pool": p.address}, p.address), update_registry_address: fun("0x4bbc5b1f", "update_registry_address()", {}, p.bool), set_calculator: fun("0x188c7ee5", "set_calculator(address,address)", {"_pool": p.address, "_calculator": p.address}, p.bool), @@ -37,12 +37,12 @@ export const functions = { export class Contract extends ContractBase { - "get_best_rate(address,address,uint256)"(_from: Get_best_rateParams_0["_from"], _to: Get_best_rateParams_0["_to"], _amount: Get_best_rateParams_0["_amount"]) { - return this.eth_call(functions["get_best_rate(address,address,uint256)"], {_from, _to, _amount}) + 'get_best_rate(address,address,uint256)'(_from: Get_best_rateParams_0["_from"], _to: Get_best_rateParams_0["_to"], _amount: Get_best_rateParams_0["_amount"]) { + return this.eth_call(functions['get_best_rate(address,address,uint256)'], {_from, _to, _amount}) } - "get_best_rate(address,address,uint256,address[8])"(_from: Get_best_rateParams_1["_from"], _to: Get_best_rateParams_1["_to"], _amount: Get_best_rateParams_1["_amount"], _exclude_pools: Get_best_rateParams_1["_exclude_pools"]) { - return this.eth_call(functions["get_best_rate(address,address,uint256,address[8])"], {_from, _to, _amount, _exclude_pools}) + 'get_best_rate(address,address,uint256,address[8])'(_from: Get_best_rateParams_1["_from"], _to: Get_best_rateParams_1["_to"], _amount: Get_best_rateParams_1["_amount"], _exclude_pools: Get_best_rateParams_1["_exclude_pools"]) { + return this.eth_call(functions['get_best_rate(address,address,uint256,address[8])'], {_from, _to, _amount, _exclude_pools}) } get_exchange_amount(_pool: Get_exchange_amountParams["_pool"], _from: Get_exchange_amountParams["_from"], _to: Get_exchange_amountParams["_to"], _amount: Get_exchange_amountParams["_amount"]) { @@ -57,12 +57,12 @@ export class Contract extends ContractBase { return this.eth_call(functions.get_exchange_amounts, {_pool, _from, _to, _amounts}) } - "get_exchange_multiple_amount(address[9],uint256[3][4],uint256)"(_route: Get_exchange_multiple_amountParams_0["_route"], _swap_params: Get_exchange_multiple_amountParams_0["_swap_params"], _amount: Get_exchange_multiple_amountParams_0["_amount"]) { - return this.eth_call(functions["get_exchange_multiple_amount(address[9],uint256[3][4],uint256)"], {_route, _swap_params, _amount}) + 'get_exchange_multiple_amount(address[9],uint256[3][4],uint256)'(_route: Get_exchange_multiple_amountParams_0["_route"], _swap_params: Get_exchange_multiple_amountParams_0["_swap_params"], _amount: Get_exchange_multiple_amountParams_0["_amount"]) { + return this.eth_call(functions['get_exchange_multiple_amount(address[9],uint256[3][4],uint256)'], {_route, _swap_params, _amount}) } - "get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])"(_route: Get_exchange_multiple_amountParams_1["_route"], _swap_params: Get_exchange_multiple_amountParams_1["_swap_params"], _amount: Get_exchange_multiple_amountParams_1["_amount"], _pools: Get_exchange_multiple_amountParams_1["_pools"]) { - return this.eth_call(functions["get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])"], {_route, _swap_params, _amount, _pools}) + 'get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])'(_route: Get_exchange_multiple_amountParams_1["_route"], _swap_params: Get_exchange_multiple_amountParams_1["_swap_params"], _amount: Get_exchange_multiple_amountParams_1["_amount"], _pools: Get_exchange_multiple_amountParams_1["_pools"]) { + return this.eth_call(functions['get_exchange_multiple_amount(address[9],uint256[3][4],uint256,address[4])'], {_route, _swap_params, _amount, _pools}) } get_calculator(_pool: Get_calculatorParams["_pool"]) { @@ -95,32 +95,32 @@ export type TokenExchangeEventArgs = EParams export type ExchangeMultipleEventArgs = EParams /// Function types -export type Exchange_with_best_rateParams_0 = FunctionArguments -export type Exchange_with_best_rateReturn_0 = FunctionReturn +export type Exchange_with_best_rateParams_0 = FunctionArguments +export type Exchange_with_best_rateReturn_0 = FunctionReturn -export type Exchange_with_best_rateParams_1 = FunctionArguments -export type Exchange_with_best_rateReturn_1 = FunctionReturn +export type Exchange_with_best_rateParams_1 = FunctionArguments +export type Exchange_with_best_rateReturn_1 = FunctionReturn -export type ExchangeParams_0 = FunctionArguments -export type ExchangeReturn_0 = FunctionReturn +export type ExchangeParams_0 = FunctionArguments +export type ExchangeReturn_0 = FunctionReturn -export type ExchangeParams_1 = FunctionArguments -export type ExchangeReturn_1 = FunctionReturn +export type ExchangeParams_1 = FunctionArguments +export type ExchangeReturn_1 = FunctionReturn -export type Exchange_multipleParams_0 = FunctionArguments -export type Exchange_multipleReturn_0 = FunctionReturn +export type Exchange_multipleParams_0 = FunctionArguments +export type Exchange_multipleReturn_0 = FunctionReturn -export type Exchange_multipleParams_1 = FunctionArguments -export type Exchange_multipleReturn_1 = FunctionReturn +export type Exchange_multipleParams_1 = FunctionArguments +export type Exchange_multipleReturn_1 = FunctionReturn -export type Exchange_multipleParams_2 = FunctionArguments -export type Exchange_multipleReturn_2 = FunctionReturn +export type Exchange_multipleParams_2 = FunctionArguments +export type Exchange_multipleReturn_2 = FunctionReturn -export type Get_best_rateParams_0 = FunctionArguments -export type Get_best_rateReturn_0 = FunctionReturn +export type Get_best_rateParams_0 = FunctionArguments +export type Get_best_rateReturn_0 = FunctionReturn -export type Get_best_rateParams_1 = FunctionArguments -export type Get_best_rateReturn_1 = FunctionReturn +export type Get_best_rateParams_1 = FunctionArguments +export type Get_best_rateReturn_1 = FunctionReturn export type Get_exchange_amountParams = FunctionArguments export type Get_exchange_amountReturn = FunctionReturn @@ -131,11 +131,11 @@ export type Get_input_amountReturn = FunctionReturn export type Get_exchange_amountsReturn = FunctionReturn -export type Get_exchange_multiple_amountParams_0 = FunctionArguments -export type Get_exchange_multiple_amountReturn_0 = FunctionReturn +export type Get_exchange_multiple_amountParams_0 = FunctionArguments +export type Get_exchange_multiple_amountReturn_0 = FunctionReturn -export type Get_exchange_multiple_amountParams_1 = FunctionArguments -export type Get_exchange_multiple_amountReturn_1 = FunctionReturn +export type Get_exchange_multiple_amountParams_1 = FunctionArguments +export type Get_exchange_multiple_amountReturn_1 = FunctionReturn export type Get_calculatorParams = FunctionArguments export type Get_calculatorReturn = FunctionReturn diff --git a/src/abi/governance.ts b/src/abi/governance.ts index 0ca54b18..73011e92 100644 --- a/src/abi/governance.ts +++ b/src/abi/governance.ts @@ -28,8 +28,8 @@ export const functions = { castVoteWithReason: fun("0x7b3c71d3", "castVoteWithReason(uint256,uint8,string)", {"proposalId": p.uint256, "support": p.uint8, "reason": p.string}, p.uint256), castVoteWithReasonAndParams: fun("0x5f398a14", "castVoteWithReasonAndParams(uint256,uint8,string,bytes)", {"proposalId": p.uint256, "support": p.uint8, "reason": p.string, "params": p.bytes}, p.uint256), castVoteWithReasonAndParamsBySig: fun("0x03420181", "castVoteWithReasonAndParamsBySig(uint256,uint8,string,bytes,uint8,bytes32,bytes32)", {"proposalId": p.uint256, "support": p.uint8, "reason": p.string, "params": p.bytes, "v": p.uint8, "r": p.bytes32, "s": p.bytes32}, p.uint256), - "execute(address[],uint256[],bytes[],bytes32)": fun("0x2656227d", "execute(address[],uint256[],bytes[],bytes32)", {"targets": p.array(p.address), "values": p.array(p.uint256), "calldatas": p.array(p.bytes), "descriptionHash": p.bytes32}, p.uint256), - "execute(uint256)": fun("0xfe0d94c1", "execute(uint256)", {"proposalId": p.uint256}, ), + 'execute(address[],uint256[],bytes[],bytes32)': fun("0x2656227d", "execute(address[],uint256[],bytes[],bytes32)", {"targets": p.array(p.address), "values": p.array(p.uint256), "calldatas": p.array(p.bytes), "descriptionHash": p.bytes32}, p.uint256), + 'execute(uint256)': fun("0xfe0d94c1", "execute(uint256)", {"proposalId": p.uint256}, ), getActions: viewFun("0x328dd982", "getActions(uint256)", {"proposalId": p.uint256}, {"targets": p.array(p.address), "values": p.array(p.uint256), "signatures": p.array(p.string), "calldatas": p.array(p.bytes)}), getReceipt: viewFun("0xe23a9a52", "getReceipt(uint256,address)", {"proposalId": p.uint256, "voter": p.address}, p.struct({"hasVoted": p.bool, "support": p.uint8, "votes": p.uint256})), getVotes: viewFun("0xeb9019d4", "getVotes(address,uint256)", {"account": p.address, "blockNumber": p.uint256}, p.uint256), @@ -46,10 +46,10 @@ export const functions = { proposalSnapshot: viewFun("0x2d63f693", "proposalSnapshot(uint256)", {"proposalId": p.uint256}, p.uint256), proposalThreshold: viewFun("0xb58131b0", "proposalThreshold()", {}, p.uint256), proposals: viewFun("0x013cf08b", "proposals(uint256)", {"proposalId": p.uint256}, {"id": p.uint256, "proposer": p.address, "eta": p.uint256, "startBlock": p.uint256, "endBlock": p.uint256, "forVotes": p.uint256, "againstVotes": p.uint256, "abstainVotes": p.uint256, "canceled": p.bool, "executed": p.bool}), - "propose(address[],uint256[],bytes[],string)": fun("0x7d5e81e2", "propose(address[],uint256[],bytes[],string)", {"targets": p.array(p.address), "values": p.array(p.uint256), "calldatas": p.array(p.bytes), "description": p.string}, p.uint256), - "propose(address[],uint256[],string[],bytes[],string)": fun("0xda95691a", "propose(address[],uint256[],string[],bytes[],string)", {"targets": p.array(p.address), "values": p.array(p.uint256), "signatures": p.array(p.string), "calldatas": p.array(p.bytes), "description": p.string}, p.uint256), - "queue(address[],uint256[],bytes[],bytes32)": fun("0x160cbed7", "queue(address[],uint256[],bytes[],bytes32)", {"targets": p.array(p.address), "values": p.array(p.uint256), "calldatas": p.array(p.bytes), "descriptionHash": p.bytes32}, p.uint256), - "queue(uint256)": fun("0xddf0b009", "queue(uint256)", {"proposalId": p.uint256}, ), + 'propose(address[],uint256[],bytes[],string)': fun("0x7d5e81e2", "propose(address[],uint256[],bytes[],string)", {"targets": p.array(p.address), "values": p.array(p.uint256), "calldatas": p.array(p.bytes), "description": p.string}, p.uint256), + 'propose(address[],uint256[],string[],bytes[],string)': fun("0xda95691a", "propose(address[],uint256[],string[],bytes[],string)", {"targets": p.array(p.address), "values": p.array(p.uint256), "signatures": p.array(p.string), "calldatas": p.array(p.bytes), "description": p.string}, p.uint256), + 'queue(address[],uint256[],bytes[],bytes32)': fun("0x160cbed7", "queue(address[],uint256[],bytes[],bytes32)", {"targets": p.array(p.address), "values": p.array(p.uint256), "calldatas": p.array(p.bytes), "descriptionHash": p.bytes32}, p.uint256), + 'queue(uint256)': fun("0xddf0b009", "queue(uint256)", {"proposalId": p.uint256}, ), quorum: viewFun("0xf8ce560a", "quorum(uint256)", {"blockNumber": p.uint256}, p.uint256), quorumDenominator: viewFun("0x97c3d334", "quorumDenominator()", {}, p.uint256), quorumNumerator: viewFun("0xa7713a70", "quorumNumerator()", {}, p.uint256), @@ -224,11 +224,11 @@ export type CastVoteWithReasonAndParamsReturn = FunctionReturn export type CastVoteWithReasonAndParamsBySigReturn = FunctionReturn -export type ExecuteParams_0 = FunctionArguments -export type ExecuteReturn_0 = FunctionReturn +export type ExecuteParams_0 = FunctionArguments +export type ExecuteReturn_0 = FunctionReturn -export type ExecuteParams_1 = FunctionArguments -export type ExecuteReturn_1 = FunctionReturn +export type ExecuteParams_1 = FunctionArguments +export type ExecuteReturn_1 = FunctionReturn export type GetActionsParams = FunctionArguments export type GetActionsReturn = FunctionReturn @@ -278,17 +278,17 @@ export type ProposalThresholdReturn = FunctionReturn export type ProposalsReturn = FunctionReturn -export type ProposeParams_0 = FunctionArguments -export type ProposeReturn_0 = FunctionReturn +export type ProposeParams_0 = FunctionArguments +export type ProposeReturn_0 = FunctionReturn -export type ProposeParams_1 = FunctionArguments -export type ProposeReturn_1 = FunctionReturn +export type ProposeParams_1 = FunctionArguments +export type ProposeReturn_1 = FunctionReturn -export type QueueParams_0 = FunctionArguments -export type QueueReturn_0 = FunctionReturn +export type QueueParams_0 = FunctionArguments +export type QueueReturn_0 = FunctionReturn -export type QueueParams_1 = FunctionArguments -export type QueueReturn_1 = FunctionReturn +export type QueueParams_1 = FunctionArguments +export type QueueReturn_1 = FunctionReturn export type QuorumParams = FunctionArguments export type QuorumReturn = FunctionReturn diff --git a/src/abi/legacy-staking.ts b/src/abi/legacy-staking.ts index 71557785..f828db98 100644 --- a/src/abi/legacy-staking.ts +++ b/src/abi/legacy-staking.ts @@ -9,12 +9,12 @@ export const events = { NewRates: event("0xa804368c7f1a6216d92d17d9753b923dfc3da14ae33d231e8d79e39202e249c3", "NewRates(address,uint256[])", {"user": indexed(p.address), "rates": p.array(p.uint256)}), Paused: event("0xe8699cf681560fd07de85543bd994263f4557bdc5179dd702f256d15fd083e1d", "Paused(address,bool)", {"user": indexed(p.address), "yes": p.bool}), PendingGovernorshipTransfer: event("0xa39cc5eb22d0f34d8beaefee8a3f17cc229c1a1d1ef87a5ad47313487b1c4f0d", "PendingGovernorshipTransfer(address,address)", {"previousGovernor": indexed(p.address), "newGovernor": indexed(p.address)}), - "Staked(address,uint256,uint256,uint256)": event("0xb4caaf29adda3eefee3ad552a8e85058589bf834c7466cae4ee58787f70589ed", "Staked(address,uint256,uint256,uint256)", {"user": indexed(p.address), "amount": p.uint256, "duration": p.uint256, "rate": p.uint256}), + 'Staked(address indexed,uint256,uint256,uint256)': event("0xb4caaf29adda3eefee3ad552a8e85058589bf834c7466cae4ee58787f70589ed", "Staked(address,uint256,uint256,uint256)", {"user": indexed(p.address), "amount": p.uint256, "duration": p.uint256, "rate": p.uint256}), StakesTransfered: event("0xd0ceb9c39a11711e51ee4b32b97b05d660d6229ecd8be94ce934fa9e77910263", "StakesTransfered(address,address,uint256)", {"fromUser": indexed(p.address), "toUser": p.address, "numStakes": p.uint256}), - "Withdrawn(address,uint256,uint256)": event("0x92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6", "Withdrawn(address,uint256,uint256)", {"user": indexed(p.address), "amount": p.uint256, "stakedAmount": p.uint256}), + 'Withdrawn(address indexed,uint256,uint256)': event("0x92ccf450a286a957af52509bc1c9939d1a6a481783e142e41e2499f0bb66ebc6", "Withdrawn(address,uint256,uint256)", {"user": indexed(p.address), "amount": p.uint256, "stakedAmount": p.uint256}), Upgraded: event("0xbc7cd75a20ee27fd9adebab32041f755214dbc6bffa90cc0225b39da2e5c2d3b", "Upgraded(address)", {"implementation": indexed(p.address)}), - "Staked(address,uint256)": event("0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d", "Staked(address,uint256)", {"user": indexed(p.address), "amount": p.uint256}), - "Withdrawn(address,uint256)": event("0x7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5", "Withdrawn(address,uint256)", {"user": indexed(p.address), "amount": p.uint256}), + 'Staked(address indexed,uint256)': event("0x9e71bc8eea02a63969f509818f2dafb9254532904319f9dbda79b67bd34a5f3d", "Staked(address,uint256)", {"user": indexed(p.address), "amount": p.uint256}), + 'Withdrawn(address indexed,uint256)': event("0x7084f5476618d8e60b11ef0d7d3f06914655adb8793e28ff7f018d4c76d505d5", "Withdrawn(address,uint256)", {"user": indexed(p.address), "amount": p.uint256}), } export class Contract extends ContractBase { @@ -27,9 +27,9 @@ export type NewDurationsEventArgs = EParams export type NewRatesEventArgs = EParams export type PausedEventArgs = EParams export type PendingGovernorshipTransferEventArgs = EParams -export type StakedEventArgs_0 = EParams +export type StakedEventArgs_0 = EParams export type StakesTransferedEventArgs = EParams -export type WithdrawnEventArgs_0 = EParams +export type WithdrawnEventArgs_0 = EParams export type UpgradedEventArgs = EParams -export type StakedEventArgs_1 = EParams -export type WithdrawnEventArgs_1 = EParams +export type StakedEventArgs_1 = EParams +export type WithdrawnEventArgs_1 = EParams diff --git a/src/abi/multicall.ts b/src/abi/multicall.ts index 81081e56..6d91b51d 100644 --- a/src/abi/multicall.ts +++ b/src/abi/multicall.ts @@ -1,7 +1,7 @@ import * as p from '@subsquid/evm-codec' import {fun, ContractBase, type AbiFunction, type FunctionReturn, type FunctionArguments} from '@subsquid/evm-abi' -const aggregate = fun('0x252dba42', "aggregate((address,bytes)[]", { +const aggregate = fun('0x252dba42', "aggregate((address,bytes)[])", { calls: p.array(p.struct({ target: p.address, callData: p.bytes diff --git a/src/abi/one-inch-aggregation-router.ts b/src/abi/one-inch-aggregation-router.ts new file mode 100644 index 00000000..871ec9d8 --- /dev/null +++ b/src/abi/one-inch-aggregation-router.ts @@ -0,0 +1,274 @@ +import * as p from '@subsquid/evm-codec' +import { event, fun, viewFun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' + +export const events = { + NonceIncreased: event("0xfc69110dd11eb791755e4abd6b7d281bae236de95736d38a23782814be5e10db", "NonceIncreased(address,uint256)", {"maker": indexed(p.address), "newNonce": p.uint256}), + OrderCanceled: event("0xcbfa7d191838ece7ba4783ca3a30afd316619b7f368094b57ee7ffde9a923db1", "OrderCanceled(address,bytes32,uint256)", {"maker": indexed(p.address), "orderHash": p.bytes32, "remainingRaw": p.uint256}), + OrderFilled: event("0xb9ed0243fdf00f0545c63a0af8850c090d86bb46682baec4bf3c496814fe4f02", "OrderFilled(address,bytes32,uint256)", {"maker": indexed(p.address), "orderHash": p.bytes32, "remaining": p.uint256}), + OrderFilledRFQ: event("0xc3b639f02b125bfa160e50739b8c44eb2d1b6908e2b6d5925c6d770f2ca78127", "OrderFilledRFQ(bytes32,uint256)", {"orderHash": p.bytes32, "makingAmount": p.uint256}), + OwnershipTransferred: event("0x8be0079c531659141344cd1fd0a4f28419497f9722a3daafe3b4186f6b6457e0", "OwnershipTransferred(address,address)", {"previousOwner": indexed(p.address), "newOwner": indexed(p.address)}), +} + +export const functions = { + advanceNonce: fun("0x72c244a8", "advanceNonce(uint8)", {"amount": p.uint8}, ), + and: viewFun("0xbfa75143", "and(uint256,bytes)", {"offsets": p.uint256, "data": p.bytes}, p.bool), + arbitraryStaticCall: viewFun("0xbf15fcd8", "arbitraryStaticCall(address,bytes)", {"target": p.address, "data": p.bytes}, p.uint256), + cancelOrder: fun("0x2d9a56f6", "cancelOrder((uint256,address,address,address,address,address,uint256,uint256,uint256,bytes))", {"order": p.struct({"salt": p.uint256, "makerAsset": p.address, "takerAsset": p.address, "maker": p.address, "receiver": p.address, "allowedSender": p.address, "makingAmount": p.uint256, "takingAmount": p.uint256, "offsets": p.uint256, "interactions": p.bytes})}, {"orderRemaining": p.uint256, "orderHash": p.bytes32}), + 'cancelOrderRFQ(uint256)': fun("0x825caba1", "cancelOrderRFQ(uint256)", {"orderInfo": p.uint256}, ), + 'cancelOrderRFQ(uint256,uint256)': fun("0xbddccd35", "cancelOrderRFQ(uint256,uint256)", {"orderInfo": p.uint256, "additionalMask": p.uint256}, ), + checkPredicate: viewFun("0x6c838250", "checkPredicate((uint256,address,address,address,address,address,uint256,uint256,uint256,bytes))", {"order": p.struct({"salt": p.uint256, "makerAsset": p.address, "takerAsset": p.address, "maker": p.address, "receiver": p.address, "allowedSender": p.address, "makingAmount": p.uint256, "takingAmount": p.uint256, "offsets": p.uint256, "interactions": p.bytes})}, p.bool), + clipperSwap: fun("0x84bd6d29", "clipperSwap(address,address,address,uint256,uint256,uint256,bytes32,bytes32)", {"clipperExchange": p.address, "srcToken": p.address, "dstToken": p.address, "inputAmount": p.uint256, "outputAmount": p.uint256, "goodUntil": p.uint256, "r": p.bytes32, "vs": p.bytes32}, p.uint256), + clipperSwapTo: fun("0x093d4fa5", "clipperSwapTo(address,address,address,address,uint256,uint256,uint256,bytes32,bytes32)", {"clipperExchange": p.address, "recipient": p.address, "srcToken": p.address, "dstToken": p.address, "inputAmount": p.uint256, "outputAmount": p.uint256, "goodUntil": p.uint256, "r": p.bytes32, "vs": p.bytes32}, p.uint256), + clipperSwapToWithPermit: fun("0xc805a666", "clipperSwapToWithPermit(address,address,address,address,uint256,uint256,uint256,bytes32,bytes32,bytes)", {"clipperExchange": p.address, "recipient": p.address, "srcToken": p.address, "dstToken": p.address, "inputAmount": p.uint256, "outputAmount": p.uint256, "goodUntil": p.uint256, "r": p.bytes32, "vs": p.bytes32, "permit": p.bytes}, p.uint256), + destroy: fun("0x83197ef0", "destroy()", {}, ), + eq: viewFun("0x6fe7b0ba", "eq(uint256,bytes)", {"value": p.uint256, "data": p.bytes}, p.bool), + fillOrder: fun("0x62e238bb", "fillOrder((uint256,address,address,address,address,address,uint256,uint256,uint256,bytes),bytes,bytes,uint256,uint256,uint256)", {"order": p.struct({"salt": p.uint256, "makerAsset": p.address, "takerAsset": p.address, "maker": p.address, "receiver": p.address, "allowedSender": p.address, "makingAmount": p.uint256, "takingAmount": p.uint256, "offsets": p.uint256, "interactions": p.bytes}), "signature": p.bytes, "interaction": p.bytes, "makingAmount": p.uint256, "takingAmount": p.uint256, "skipPermitAndThresholdAmount": p.uint256}, {"_0": p.uint256, "_1": p.uint256, "_2": p.bytes32}), + fillOrderRFQ: fun("0x3eca9c0a", "fillOrderRFQ((uint256,address,address,address,address,uint256,uint256),bytes,uint256)", {"order": p.struct({"info": p.uint256, "makerAsset": p.address, "takerAsset": p.address, "maker": p.address, "allowedSender": p.address, "makingAmount": p.uint256, "takingAmount": p.uint256}), "signature": p.bytes, "flagsAndAmount": p.uint256}, {"_0": p.uint256, "_1": p.uint256, "_2": p.bytes32}), + fillOrderRFQCompact: fun("0x9570eeee", "fillOrderRFQCompact((uint256,address,address,address,address,uint256,uint256),bytes32,bytes32,uint256)", {"order": p.struct({"info": p.uint256, "makerAsset": p.address, "takerAsset": p.address, "maker": p.address, "allowedSender": p.address, "makingAmount": p.uint256, "takingAmount": p.uint256}), "r": p.bytes32, "vs": p.bytes32, "flagsAndAmount": p.uint256}, {"filledMakingAmount": p.uint256, "filledTakingAmount": p.uint256, "orderHash": p.bytes32}), + fillOrderRFQTo: fun("0x5a099843", "fillOrderRFQTo((uint256,address,address,address,address,uint256,uint256),bytes,uint256,address)", {"order": p.struct({"info": p.uint256, "makerAsset": p.address, "takerAsset": p.address, "maker": p.address, "allowedSender": p.address, "makingAmount": p.uint256, "takingAmount": p.uint256}), "signature": p.bytes, "flagsAndAmount": p.uint256, "target": p.address}, {"filledMakingAmount": p.uint256, "filledTakingAmount": p.uint256, "orderHash": p.bytes32}), + fillOrderRFQToWithPermit: fun("0x70ccbd31", "fillOrderRFQToWithPermit((uint256,address,address,address,address,uint256,uint256),bytes,uint256,address,bytes)", {"order": p.struct({"info": p.uint256, "makerAsset": p.address, "takerAsset": p.address, "maker": p.address, "allowedSender": p.address, "makingAmount": p.uint256, "takingAmount": p.uint256}), "signature": p.bytes, "flagsAndAmount": p.uint256, "target": p.address, "permit": p.bytes}, {"_0": p.uint256, "_1": p.uint256, "_2": p.bytes32}), + fillOrderTo: fun("0xe5d7bde6", "fillOrderTo((uint256,address,address,address,address,address,uint256,uint256,uint256,bytes),bytes,bytes,uint256,uint256,uint256,address)", {"order_": p.struct({"salt": p.uint256, "makerAsset": p.address, "takerAsset": p.address, "maker": p.address, "receiver": p.address, "allowedSender": p.address, "makingAmount": p.uint256, "takingAmount": p.uint256, "offsets": p.uint256, "interactions": p.bytes}), "signature": p.bytes, "interaction": p.bytes, "makingAmount": p.uint256, "takingAmount": p.uint256, "skipPermitAndThresholdAmount": p.uint256, "target": p.address}, {"actualMakingAmount": p.uint256, "actualTakingAmount": p.uint256, "orderHash": p.bytes32}), + fillOrderToWithPermit: fun("0xd365c695", "fillOrderToWithPermit((uint256,address,address,address,address,address,uint256,uint256,uint256,bytes),bytes,bytes,uint256,uint256,uint256,address,bytes)", {"order": p.struct({"salt": p.uint256, "makerAsset": p.address, "takerAsset": p.address, "maker": p.address, "receiver": p.address, "allowedSender": p.address, "makingAmount": p.uint256, "takingAmount": p.uint256, "offsets": p.uint256, "interactions": p.bytes}), "signature": p.bytes, "interaction": p.bytes, "makingAmount": p.uint256, "takingAmount": p.uint256, "skipPermitAndThresholdAmount": p.uint256, "target": p.address, "permit": p.bytes}, {"_0": p.uint256, "_1": p.uint256, "_2": p.bytes32}), + gt: viewFun("0x4f38e2b8", "gt(uint256,bytes)", {"value": p.uint256, "data": p.bytes}, p.bool), + hashOrder: viewFun("0x37e7316f", "hashOrder((uint256,address,address,address,address,address,uint256,uint256,uint256,bytes))", {"order": p.struct({"salt": p.uint256, "makerAsset": p.address, "takerAsset": p.address, "maker": p.address, "receiver": p.address, "allowedSender": p.address, "makingAmount": p.uint256, "takingAmount": p.uint256, "offsets": p.uint256, "interactions": p.bytes})}, p.bytes32), + increaseNonce: fun("0xc53a0292", "increaseNonce()", {}, ), + invalidatorForOrderRFQ: viewFun("0x56f16124", "invalidatorForOrderRFQ(address,uint256)", {"maker": p.address, "slot": p.uint256}, p.uint256), + lt: viewFun("0xca4ece22", "lt(uint256,bytes)", {"value": p.uint256, "data": p.bytes}, p.bool), + nonce: viewFun("0x70ae92d2", "nonce(address)", {"_0": p.address}, p.uint256), + nonceEquals: viewFun("0xcf6fc6e3", "nonceEquals(address,uint256)", {"makerAddress": p.address, "makerNonce": p.uint256}, p.bool), + or: viewFun("0x74261145", "or(uint256,bytes)", {"offsets": p.uint256, "data": p.bytes}, p.bool), + owner: viewFun("0x8da5cb5b", "owner()", {}, p.address), + remaining: viewFun("0xbc1ed74c", "remaining(bytes32)", {"orderHash": p.bytes32}, p.uint256), + remainingRaw: viewFun("0x7e54f092", "remainingRaw(bytes32)", {"orderHash": p.bytes32}, p.uint256), + remainingsRaw: viewFun("0x942461bb", "remainingsRaw(bytes32[])", {"orderHashes": p.array(p.bytes32)}, p.array(p.uint256)), + renounceOwnership: fun("0x715018a6", "renounceOwnership()", {}, ), + rescueFunds: fun("0x78e3214f", "rescueFunds(address,uint256)", {"token": p.address, "amount": p.uint256}, ), + simulate: fun("0xbd61951d", "simulate(address,bytes)", {"target": p.address, "data": p.bytes}, ), + swap: fun("0x12aa3caf", "swap(address,(address,address,address,address,uint256,uint256,uint256),bytes,bytes)", {"executor": p.address, "desc": p.struct({"srcToken": p.address, "dstToken": p.address, "srcReceiver": p.address, "dstReceiver": p.address, "amount": p.uint256, "minReturnAmount": p.uint256, "flags": p.uint256}), "permit": p.bytes, "data": p.bytes}, {"returnAmount": p.uint256, "spentAmount": p.uint256}), + timestampBelow: viewFun("0x63592c2b", "timestampBelow(uint256)", {"time": p.uint256}, p.bool), + timestampBelowAndNonceEquals: viewFun("0x2cc2878d", "timestampBelowAndNonceEquals(uint256)", {"timeNonceAccount": p.uint256}, p.bool), + transferOwnership: fun("0xf2fde38b", "transferOwnership(address)", {"newOwner": p.address}, ), + uniswapV3Swap: fun("0xe449022e", "uniswapV3Swap(uint256,uint256,uint256[])", {"amount": p.uint256, "minReturn": p.uint256, "pools": p.array(p.uint256)}, p.uint256), + uniswapV3SwapCallback: fun("0xfa461e33", "uniswapV3SwapCallback(int256,int256,bytes)", {"amount0Delta": p.int256, "amount1Delta": p.int256, "_2": p.bytes}, ), + uniswapV3SwapTo: fun("0xbc80f1a8", "uniswapV3SwapTo(address,uint256,uint256,uint256[])", {"recipient": p.address, "amount": p.uint256, "minReturn": p.uint256, "pools": p.array(p.uint256)}, p.uint256), + uniswapV3SwapToWithPermit: fun("0x2521b930", "uniswapV3SwapToWithPermit(address,address,uint256,uint256,uint256[],bytes)", {"recipient": p.address, "srcToken": p.address, "amount": p.uint256, "minReturn": p.uint256, "pools": p.array(p.uint256), "permit": p.bytes}, p.uint256), + unoswap: fun("0x0502b1c5", "unoswap(address,uint256,uint256,uint256[])", {"srcToken": p.address, "amount": p.uint256, "minReturn": p.uint256, "pools": p.array(p.uint256)}, p.uint256), + unoswapTo: fun("0xf78dc253", "unoswapTo(address,address,uint256,uint256,uint256[])", {"recipient": p.address, "srcToken": p.address, "amount": p.uint256, "minReturn": p.uint256, "pools": p.array(p.uint256)}, p.uint256), + unoswapToWithPermit: fun("0x3c15fd91", "unoswapToWithPermit(address,address,uint256,uint256,uint256[],bytes)", {"recipient": p.address, "srcToken": p.address, "amount": p.uint256, "minReturn": p.uint256, "pools": p.array(p.uint256), "permit": p.bytes}, p.uint256), +} + +export class Contract extends ContractBase { + + and(offsets: AndParams["offsets"], data: AndParams["data"]) { + return this.eth_call(functions.and, {offsets, data}) + } + + arbitraryStaticCall(target: ArbitraryStaticCallParams["target"], data: ArbitraryStaticCallParams["data"]) { + return this.eth_call(functions.arbitraryStaticCall, {target, data}) + } + + checkPredicate(order: CheckPredicateParams["order"]) { + return this.eth_call(functions.checkPredicate, {order}) + } + + eq(value: EqParams["value"], data: EqParams["data"]) { + return this.eth_call(functions.eq, {value, data}) + } + + gt(value: GtParams["value"], data: GtParams["data"]) { + return this.eth_call(functions.gt, {value, data}) + } + + hashOrder(order: HashOrderParams["order"]) { + return this.eth_call(functions.hashOrder, {order}) + } + + invalidatorForOrderRFQ(maker: InvalidatorForOrderRFQParams["maker"], slot: InvalidatorForOrderRFQParams["slot"]) { + return this.eth_call(functions.invalidatorForOrderRFQ, {maker, slot}) + } + + lt(value: LtParams["value"], data: LtParams["data"]) { + return this.eth_call(functions.lt, {value, data}) + } + + nonce(_0: NonceParams["_0"]) { + return this.eth_call(functions.nonce, {_0}) + } + + nonceEquals(makerAddress: NonceEqualsParams["makerAddress"], makerNonce: NonceEqualsParams["makerNonce"]) { + return this.eth_call(functions.nonceEquals, {makerAddress, makerNonce}) + } + + or(offsets: OrParams["offsets"], data: OrParams["data"]) { + return this.eth_call(functions.or, {offsets, data}) + } + + owner() { + return this.eth_call(functions.owner, {}) + } + + remaining(orderHash: RemainingParams["orderHash"]) { + return this.eth_call(functions.remaining, {orderHash}) + } + + remainingRaw(orderHash: RemainingRawParams["orderHash"]) { + return this.eth_call(functions.remainingRaw, {orderHash}) + } + + remainingsRaw(orderHashes: RemainingsRawParams["orderHashes"]) { + return this.eth_call(functions.remainingsRaw, {orderHashes}) + } + + timestampBelow(time: TimestampBelowParams["time"]) { + return this.eth_call(functions.timestampBelow, {time}) + } + + timestampBelowAndNonceEquals(timeNonceAccount: TimestampBelowAndNonceEqualsParams["timeNonceAccount"]) { + return this.eth_call(functions.timestampBelowAndNonceEquals, {timeNonceAccount}) + } +} + +/// Event types +export type NonceIncreasedEventArgs = EParams +export type OrderCanceledEventArgs = EParams +export type OrderFilledEventArgs = EParams +export type OrderFilledRFQEventArgs = EParams +export type OwnershipTransferredEventArgs = EParams + +/// Function types +export type AdvanceNonceParams = FunctionArguments +export type AdvanceNonceReturn = FunctionReturn + +export type AndParams = FunctionArguments +export type AndReturn = FunctionReturn + +export type ArbitraryStaticCallParams = FunctionArguments +export type ArbitraryStaticCallReturn = FunctionReturn + +export type CancelOrderParams = FunctionArguments +export type CancelOrderReturn = FunctionReturn + +export type CancelOrderRFQParams_0 = FunctionArguments +export type CancelOrderRFQReturn_0 = FunctionReturn + +export type CancelOrderRFQParams_1 = FunctionArguments +export type CancelOrderRFQReturn_1 = FunctionReturn + +export type CheckPredicateParams = FunctionArguments +export type CheckPredicateReturn = FunctionReturn + +export type ClipperSwapParams = FunctionArguments +export type ClipperSwapReturn = FunctionReturn + +export type ClipperSwapToParams = FunctionArguments +export type ClipperSwapToReturn = FunctionReturn + +export type ClipperSwapToWithPermitParams = FunctionArguments +export type ClipperSwapToWithPermitReturn = FunctionReturn + +export type DestroyParams = FunctionArguments +export type DestroyReturn = FunctionReturn + +export type EqParams = FunctionArguments +export type EqReturn = FunctionReturn + +export type FillOrderParams = FunctionArguments +export type FillOrderReturn = FunctionReturn + +export type FillOrderRFQParams = FunctionArguments +export type FillOrderRFQReturn = FunctionReturn + +export type FillOrderRFQCompactParams = FunctionArguments +export type FillOrderRFQCompactReturn = FunctionReturn + +export type FillOrderRFQToParams = FunctionArguments +export type FillOrderRFQToReturn = FunctionReturn + +export type FillOrderRFQToWithPermitParams = FunctionArguments +export type FillOrderRFQToWithPermitReturn = FunctionReturn + +export type FillOrderToParams = FunctionArguments +export type FillOrderToReturn = FunctionReturn + +export type FillOrderToWithPermitParams = FunctionArguments +export type FillOrderToWithPermitReturn = FunctionReturn + +export type GtParams = FunctionArguments +export type GtReturn = FunctionReturn + +export type HashOrderParams = FunctionArguments +export type HashOrderReturn = FunctionReturn + +export type IncreaseNonceParams = FunctionArguments +export type IncreaseNonceReturn = FunctionReturn + +export type InvalidatorForOrderRFQParams = FunctionArguments +export type InvalidatorForOrderRFQReturn = FunctionReturn + +export type LtParams = FunctionArguments +export type LtReturn = FunctionReturn + +export type NonceParams = FunctionArguments +export type NonceReturn = FunctionReturn + +export type NonceEqualsParams = FunctionArguments +export type NonceEqualsReturn = FunctionReturn + +export type OrParams = FunctionArguments +export type OrReturn = FunctionReturn + +export type OwnerParams = FunctionArguments +export type OwnerReturn = FunctionReturn + +export type RemainingParams = FunctionArguments +export type RemainingReturn = FunctionReturn + +export type RemainingRawParams = FunctionArguments +export type RemainingRawReturn = FunctionReturn + +export type RemainingsRawParams = FunctionArguments +export type RemainingsRawReturn = FunctionReturn + +export type RenounceOwnershipParams = FunctionArguments +export type RenounceOwnershipReturn = FunctionReturn + +export type RescueFundsParams = FunctionArguments +export type RescueFundsReturn = FunctionReturn + +export type SimulateParams = FunctionArguments +export type SimulateReturn = FunctionReturn + +export type SwapParams = FunctionArguments +export type SwapReturn = FunctionReturn + +export type TimestampBelowParams = FunctionArguments +export type TimestampBelowReturn = FunctionReturn + +export type TimestampBelowAndNonceEqualsParams = FunctionArguments +export type TimestampBelowAndNonceEqualsReturn = FunctionReturn + +export type TransferOwnershipParams = FunctionArguments +export type TransferOwnershipReturn = FunctionReturn + +export type UniswapV3SwapParams = FunctionArguments +export type UniswapV3SwapReturn = FunctionReturn + +export type UniswapV3SwapCallbackParams = FunctionArguments +export type UniswapV3SwapCallbackReturn = FunctionReturn + +export type UniswapV3SwapToParams = FunctionArguments +export type UniswapV3SwapToReturn = FunctionReturn + +export type UniswapV3SwapToWithPermitParams = FunctionArguments +export type UniswapV3SwapToWithPermitReturn = FunctionReturn + +export type UnoswapParams = FunctionArguments +export type UnoswapReturn = FunctionReturn + +export type UnoswapToParams = FunctionArguments +export type UnoswapToReturn = FunctionReturn + +export type UnoswapToWithPermitParams = FunctionArguments +export type UnoswapToWithPermitReturn = FunctionReturn + diff --git a/src/abi/uniswap-v3.ts b/src/abi/uniswap-v3.ts new file mode 100644 index 00000000..a2dae7ea --- /dev/null +++ b/src/abi/uniswap-v3.ts @@ -0,0 +1,206 @@ +import * as p from '@subsquid/evm-codec' +import { event, fun, viewFun, indexed, ContractBase } from '@subsquid/evm-abi' +import type { EventParams as EParams, FunctionArguments, FunctionReturn } from '@subsquid/evm-abi' + +export const events = { + Burn: event("0x0c396cd989a39f4459b5fa1aed6a9a8dcdbc45908acfd67e028cd568da98982c", "Burn(address,int24,int24,uint128,uint256,uint256)", {"owner": indexed(p.address), "tickLower": indexed(p.int24), "tickUpper": indexed(p.int24), "amount": p.uint128, "amount0": p.uint256, "amount1": p.uint256}), + Collect: event("0x70935338e69775456a85ddef226c395fb668b63fa0115f5f20610b388e6ca9c0", "Collect(address,address,int24,int24,uint128,uint128)", {"owner": indexed(p.address), "recipient": p.address, "tickLower": indexed(p.int24), "tickUpper": indexed(p.int24), "amount0": p.uint128, "amount1": p.uint128}), + CollectProtocol: event("0x596b573906218d3411850b26a6b437d6c4522fdb43d2d2386263f86d50b8b151", "CollectProtocol(address,address,uint128,uint128)", {"sender": indexed(p.address), "recipient": indexed(p.address), "amount0": p.uint128, "amount1": p.uint128}), + Flash: event("0xbdbdb71d7860376ba52b25a5028beea23581364a40522f6bcfb86bb1f2dca633", "Flash(address,address,uint256,uint256,uint256,uint256)", {"sender": indexed(p.address), "recipient": indexed(p.address), "amount0": p.uint256, "amount1": p.uint256, "paid0": p.uint256, "paid1": p.uint256}), + IncreaseObservationCardinalityNext: event("0xac49e518f90a358f652e4400164f05a5d8f7e35e7747279bc3a93dbf584e125a", "IncreaseObservationCardinalityNext(uint16,uint16)", {"observationCardinalityNextOld": p.uint16, "observationCardinalityNextNew": p.uint16}), + Initialize: event("0x98636036cb66a9c19a37435efc1e90142190214e8abeb821bdba3f2990dd4c95", "Initialize(uint160,int24)", {"sqrtPriceX96": p.uint160, "tick": p.int24}), + Mint: event("0x7a53080ba414158be7ec69b987b5fb7d07dee101fe85488f0853ae16239d0bde", "Mint(address,address,int24,int24,uint128,uint256,uint256)", {"sender": p.address, "owner": indexed(p.address), "tickLower": indexed(p.int24), "tickUpper": indexed(p.int24), "amount": p.uint128, "amount0": p.uint256, "amount1": p.uint256}), + SetFeeProtocol: event("0x973d8d92bb299f4af6ce49b52a8adb85ae46b9f214c4c4fc06ac77401237b133", "SetFeeProtocol(uint8,uint8,uint8,uint8)", {"feeProtocol0Old": p.uint8, "feeProtocol1Old": p.uint8, "feeProtocol0New": p.uint8, "feeProtocol1New": p.uint8}), + Swap: event("0xc42079f94a6350d7e6235f29174924f928cc2ac818eb64fed8004e115fbcca67", "Swap(address,address,int256,int256,uint160,uint128,int24)", {"sender": indexed(p.address), "recipient": indexed(p.address), "amount0": p.int256, "amount1": p.int256, "sqrtPriceX96": p.uint160, "liquidity": p.uint128, "tick": p.int24}), +} + +export const functions = { + burn: fun("0xa34123a7", "burn(int24,int24,uint128)", {"tickLower": p.int24, "tickUpper": p.int24, "amount": p.uint128}, {"amount0": p.uint256, "amount1": p.uint256}), + collect: fun("0x4f1eb3d8", "collect(address,int24,int24,uint128,uint128)", {"recipient": p.address, "tickLower": p.int24, "tickUpper": p.int24, "amount0Requested": p.uint128, "amount1Requested": p.uint128}, {"amount0": p.uint128, "amount1": p.uint128}), + collectProtocol: fun("0x85b66729", "collectProtocol(address,uint128,uint128)", {"recipient": p.address, "amount0Requested": p.uint128, "amount1Requested": p.uint128}, {"amount0": p.uint128, "amount1": p.uint128}), + factory: viewFun("0xc45a0155", "factory()", {}, p.address), + fee: viewFun("0xddca3f43", "fee()", {}, p.uint24), + feeGrowthGlobal0X128: viewFun("0xf3058399", "feeGrowthGlobal0X128()", {}, p.uint256), + feeGrowthGlobal1X128: viewFun("0x46141319", "feeGrowthGlobal1X128()", {}, p.uint256), + flash: fun("0x490e6cbc", "flash(address,uint256,uint256,bytes)", {"recipient": p.address, "amount0": p.uint256, "amount1": p.uint256, "data": p.bytes}, ), + increaseObservationCardinalityNext: fun("0x32148f67", "increaseObservationCardinalityNext(uint16)", {"observationCardinalityNext": p.uint16}, ), + initialize: fun("0xf637731d", "initialize(uint160)", {"sqrtPriceX96": p.uint160}, ), + liquidity: viewFun("0x1a686502", "liquidity()", {}, p.uint128), + maxLiquidityPerTick: viewFun("0x70cf754a", "maxLiquidityPerTick()", {}, p.uint128), + mint: fun("0x3c8a7d8d", "mint(address,int24,int24,uint128,bytes)", {"recipient": p.address, "tickLower": p.int24, "tickUpper": p.int24, "amount": p.uint128, "data": p.bytes}, {"amount0": p.uint256, "amount1": p.uint256}), + observations: viewFun("0x252c09d7", "observations(uint256)", {"_0": p.uint256}, {"blockTimestamp": p.uint32, "tickCumulative": p.int56, "secondsPerLiquidityCumulativeX128": p.uint160, "initialized": p.bool}), + observe: viewFun("0x883bdbfd", "observe(uint32[])", {"secondsAgos": p.array(p.uint32)}, {"tickCumulatives": p.array(p.int56), "secondsPerLiquidityCumulativeX128s": p.array(p.uint160)}), + positions: viewFun("0x514ea4bf", "positions(bytes32)", {"_0": p.bytes32}, {"liquidity": p.uint128, "feeGrowthInside0LastX128": p.uint256, "feeGrowthInside1LastX128": p.uint256, "tokensOwed0": p.uint128, "tokensOwed1": p.uint128}), + protocolFees: viewFun("0x1ad8b03b", "protocolFees()", {}, {"token0": p.uint128, "token1": p.uint128}), + setFeeProtocol: fun("0x8206a4d1", "setFeeProtocol(uint8,uint8)", {"feeProtocol0": p.uint8, "feeProtocol1": p.uint8}, ), + slot0: viewFun("0x3850c7bd", "slot0()", {}, {"sqrtPriceX96": p.uint160, "tick": p.int24, "observationIndex": p.uint16, "observationCardinality": p.uint16, "observationCardinalityNext": p.uint16, "feeProtocol": p.uint8, "unlocked": p.bool}), + snapshotCumulativesInside: viewFun("0xa38807f2", "snapshotCumulativesInside(int24,int24)", {"tickLower": p.int24, "tickUpper": p.int24}, {"tickCumulativeInside": p.int56, "secondsPerLiquidityInsideX128": p.uint160, "secondsInside": p.uint32}), + swap: fun("0x128acb08", "swap(address,bool,int256,uint160,bytes)", {"recipient": p.address, "zeroForOne": p.bool, "amountSpecified": p.int256, "sqrtPriceLimitX96": p.uint160, "data": p.bytes}, {"amount0": p.int256, "amount1": p.int256}), + tickBitmap: viewFun("0x5339c296", "tickBitmap(int16)", {"_0": p.int16}, p.uint256), + tickSpacing: viewFun("0xd0c93a7c", "tickSpacing()", {}, p.int24), + ticks: viewFun("0xf30dba93", "ticks(int24)", {"_0": p.int24}, {"liquidityGross": p.uint128, "liquidityNet": p.int128, "feeGrowthOutside0X128": p.uint256, "feeGrowthOutside1X128": p.uint256, "tickCumulativeOutside": p.int56, "secondsPerLiquidityOutsideX128": p.uint160, "secondsOutside": p.uint32, "initialized": p.bool}), + token0: viewFun("0x0dfe1681", "token0()", {}, p.address), + token1: viewFun("0xd21220a7", "token1()", {}, p.address), +} + +export class Contract extends ContractBase { + + factory() { + return this.eth_call(functions.factory, {}) + } + + fee() { + return this.eth_call(functions.fee, {}) + } + + feeGrowthGlobal0X128() { + return this.eth_call(functions.feeGrowthGlobal0X128, {}) + } + + feeGrowthGlobal1X128() { + return this.eth_call(functions.feeGrowthGlobal1X128, {}) + } + + liquidity() { + return this.eth_call(functions.liquidity, {}) + } + + maxLiquidityPerTick() { + return this.eth_call(functions.maxLiquidityPerTick, {}) + } + + observations(_0: ObservationsParams["_0"]) { + return this.eth_call(functions.observations, {_0}) + } + + observe(secondsAgos: ObserveParams["secondsAgos"]) { + return this.eth_call(functions.observe, {secondsAgos}) + } + + positions(_0: PositionsParams["_0"]) { + return this.eth_call(functions.positions, {_0}) + } + + protocolFees() { + return this.eth_call(functions.protocolFees, {}) + } + + slot0() { + return this.eth_call(functions.slot0, {}) + } + + snapshotCumulativesInside(tickLower: SnapshotCumulativesInsideParams["tickLower"], tickUpper: SnapshotCumulativesInsideParams["tickUpper"]) { + return this.eth_call(functions.snapshotCumulativesInside, {tickLower, tickUpper}) + } + + tickBitmap(_0: TickBitmapParams["_0"]) { + return this.eth_call(functions.tickBitmap, {_0}) + } + + tickSpacing() { + return this.eth_call(functions.tickSpacing, {}) + } + + ticks(_0: TicksParams["_0"]) { + return this.eth_call(functions.ticks, {_0}) + } + + token0() { + return this.eth_call(functions.token0, {}) + } + + token1() { + return this.eth_call(functions.token1, {}) + } +} + +/// Event types +export type BurnEventArgs = EParams +export type CollectEventArgs = EParams +export type CollectProtocolEventArgs = EParams +export type FlashEventArgs = EParams +export type IncreaseObservationCardinalityNextEventArgs = EParams +export type InitializeEventArgs = EParams +export type MintEventArgs = EParams +export type SetFeeProtocolEventArgs = EParams +export type SwapEventArgs = EParams + +/// Function types +export type BurnParams = FunctionArguments +export type BurnReturn = FunctionReturn + +export type CollectParams = FunctionArguments +export type CollectReturn = FunctionReturn + +export type CollectProtocolParams = FunctionArguments +export type CollectProtocolReturn = FunctionReturn + +export type FactoryParams = FunctionArguments +export type FactoryReturn = FunctionReturn + +export type FeeParams = FunctionArguments +export type FeeReturn = FunctionReturn + +export type FeeGrowthGlobal0X128Params = FunctionArguments +export type FeeGrowthGlobal0X128Return = FunctionReturn + +export type FeeGrowthGlobal1X128Params = FunctionArguments +export type FeeGrowthGlobal1X128Return = FunctionReturn + +export type FlashParams = FunctionArguments +export type FlashReturn = FunctionReturn + +export type IncreaseObservationCardinalityNextParams = FunctionArguments +export type IncreaseObservationCardinalityNextReturn = FunctionReturn + +export type InitializeParams = FunctionArguments +export type InitializeReturn = FunctionReturn + +export type LiquidityParams = FunctionArguments +export type LiquidityReturn = FunctionReturn + +export type MaxLiquidityPerTickParams = FunctionArguments +export type MaxLiquidityPerTickReturn = FunctionReturn + +export type MintParams = FunctionArguments +export type MintReturn = FunctionReturn + +export type ObservationsParams = FunctionArguments +export type ObservationsReturn = FunctionReturn + +export type ObserveParams = FunctionArguments +export type ObserveReturn = FunctionReturn + +export type PositionsParams = FunctionArguments +export type PositionsReturn = FunctionReturn + +export type ProtocolFeesParams = FunctionArguments +export type ProtocolFeesReturn = FunctionReturn + +export type SetFeeProtocolParams = FunctionArguments +export type SetFeeProtocolReturn = FunctionReturn + +export type Slot0Params = FunctionArguments +export type Slot0Return = FunctionReturn + +export type SnapshotCumulativesInsideParams = FunctionArguments +export type SnapshotCumulativesInsideReturn = FunctionReturn + +export type SwapParams = FunctionArguments +export type SwapReturn = FunctionReturn + +export type TickBitmapParams = FunctionArguments +export type TickBitmapReturn = FunctionReturn + +export type TickSpacingParams = FunctionArguments +export type TickSpacingReturn = FunctionReturn + +export type TicksParams = FunctionArguments +export type TicksReturn = FunctionReturn + +export type Token0Params = FunctionArguments +export type Token0Return = FunctionReturn + +export type Token1Params = FunctionArguments +export type Token1Return = FunctionReturn + diff --git a/src/abi/veogv.ts b/src/abi/veogv.ts index d8cd5fb2..a293de16 100644 --- a/src/abi/veogv.ts +++ b/src/abi/veogv.ts @@ -42,8 +42,8 @@ export const functions = { previewRewards: viewFun("0xf166e920", "previewRewards(address)", {"user": p.address}, p.uint256), rewardDebtPerShare: viewFun("0x4423bf57", "rewardDebtPerShare(address)", {"_0": p.address}, p.uint256), rewardsSource: viewFun("0xf7240d2f", "rewardsSource()", {}, p.address), - "stake(uint256,uint256,address)": fun("0x7628a37d", "stake(uint256,uint256,address)", {"amount": p.uint256, "duration": p.uint256, "to": p.address}, ), - "stake(uint256,uint256)": fun("0x7b0472f0", "stake(uint256,uint256)", {"amount": p.uint256, "duration": p.uint256}, ), + 'stake(uint256,uint256,address)': fun("0x7628a37d", "stake(uint256,uint256,address)", {"amount": p.uint256, "duration": p.uint256, "to": p.address}, ), + 'stake(uint256,uint256)': fun("0x7b0472f0", "stake(uint256,uint256)", {"amount": p.uint256, "duration": p.uint256}, ), symbol: viewFun("0x95d89b41", "symbol()", {}, p.string), totalSupply: viewFun("0x18160ddd", "totalSupply()", {}, p.uint256), transfer: fun("0xa9059cbb", "transfer(address,uint256)", {"_0": p.address, "_1": p.uint256}, p.bool), @@ -243,11 +243,11 @@ export type RewardDebtPerShareReturn = FunctionReturn export type RewardsSourceReturn = FunctionReturn -export type StakeParams_0 = FunctionArguments -export type StakeReturn_0 = FunctionReturn +export type StakeParams_0 = FunctionArguments +export type StakeReturn_0 = FunctionReturn -export type StakeParams_1 = FunctionArguments -export type StakeReturn_1 = FunctionReturn +export type StakeParams_1 = FunctionArguments +export type StakeReturn_1 = FunctionReturn export type SymbolParams = FunctionArguments export type SymbolReturn = FunctionReturn diff --git a/src/main-oeth.ts b/src/main-oeth.ts index 5aebb80d..6b8fcb3d 100644 --- a/src/main-oeth.ts +++ b/src/main-oeth.ts @@ -31,11 +31,7 @@ export const processor = { strategies, exchangeRates, ], - postProcessors: [ - exchangeRatesPostProcessor, - dailyStats, - processStatus('oeth'), - ], + postProcessors: [exchangeRatesPostProcessor, dailyStats, processStatus('oeth')], validators: [validateOeth], } export default processor diff --git a/src/mainnet/processors/legacy-staking.ts b/src/mainnet/processors/legacy-staking.ts index 28510117..0613a099 100644 --- a/src/mainnet/processors/legacy-staking.ts +++ b/src/mainnet/processors/legacy-staking.ts @@ -14,10 +14,10 @@ export const setup = (processor: EvmBatchProcessor) => { processor.addLog({ address: [LEGACY_OGN_STAKING], topic0: [ - legacyStakingAbi.events['Staked(address,uint256)'], - legacyStakingAbi.events['Staked(address,uint256,uint256,uint256)'], - legacyStakingAbi.events['Withdrawn(address,uint256)'], - legacyStakingAbi.events['Withdrawn(address,uint256,uint256)'], + legacyStakingAbi.events['Staked(address indexed,uint256)'], + legacyStakingAbi.events['Staked(address indexed,uint256,uint256,uint256)'], + legacyStakingAbi.events['Withdrawn(address indexed,uint256)'], + legacyStakingAbi.events['Withdrawn(address indexed,uint256,uint256)'], legacyStakingAbi.events.StakesTransfered, ].map((ev) => ev.topic), range: { from }, @@ -37,23 +37,24 @@ export const process = async (ctx: Context) => { continue } - if (firstTopic === legacyStakingAbi.events['Staked(address,uint256)'].topic) { - let { user, amount } = legacyStakingAbi.events['Staked(address,uint256)'].decode(log) + if (firstTopic === legacyStakingAbi.events['Staked(address indexed,uint256)'].topic) { + let { user, amount } = legacyStakingAbi.events['Staked(address indexed,uint256)'].decode(log) const staker = await _getStaker(ctx, user, result) staker.inputAmount += amount staker.balance += amount - } else if (firstTopic === legacyStakingAbi.events['Staked(address,uint256,uint256,uint256)'].topic) { - let { user, amount } = legacyStakingAbi.events['Staked(address,uint256,uint256,uint256)'].decode(log) + } else if (firstTopic === legacyStakingAbi.events['Staked(address indexed,uint256,uint256,uint256)'].topic) { + let { user, amount } = legacyStakingAbi.events['Staked(address indexed,uint256,uint256,uint256)'].decode(log) const staker = await _getStaker(ctx, user, result) staker.inputAmount += amount staker.balance += amount - } else if (firstTopic === legacyStakingAbi.events['Withdrawn(address,uint256)'].topic) { - let { user, amount } = legacyStakingAbi.events['Withdrawn(address,uint256)'].decode(log) + } else if (firstTopic === legacyStakingAbi.events['Withdrawn(address indexed,uint256)'].topic) { + let { user, amount } = legacyStakingAbi.events['Withdrawn(address indexed,uint256)'].decode(log) const staker = await _getStaker(ctx, user, result) staker.outputAmount += amount staker.balance -= amount - } else if (firstTopic === legacyStakingAbi.events['Withdrawn(address,uint256,uint256)'].topic) { - let { user, amount, stakedAmount } = legacyStakingAbi.events['Withdrawn(address,uint256,uint256)'].decode(log) + } else if (firstTopic === legacyStakingAbi.events['Withdrawn(address indexed,uint256,uint256)'].topic) { + let { user, amount, stakedAmount } = + legacyStakingAbi.events['Withdrawn(address indexed,uint256,uint256)'].decode(log) const staker = await _getStaker(ctx, user, result) staker.outputAmount += stakedAmount staker.rewardAmount += amount - stakedAmount diff --git a/src/mainnet/processors/uniswap.ts b/src/mainnet/processors/uniswap.ts index 3c7d2ccd..029f38f6 100644 --- a/src/mainnet/processors/uniswap.ts +++ b/src/mainnet/processors/uniswap.ts @@ -1,5 +1,5 @@ import { LiquiditySourceType } from '@model' -import { addresses } from '@utils/addresses' +import { UNISWAP_V3_OETH_WEH_ADDRESS, addresses } from '@utils/addresses' import { addERC20Processing } from './erc20s' import { registerLiquiditySource } from './liquidity-sources' @@ -18,7 +18,7 @@ const pools = [ tokens: ['wstETH', 'WETH'], }, { - address: '0x52299416c469843f4e0d54688099966a6c7d720f', + address: UNISWAP_V3_OETH_WEH_ADDRESS, tokens: ['OETH', 'WETH'], }, ] as const @@ -26,11 +26,7 @@ const pools = [ export const initialize = () => { for (const pool of pools) { for (const token of pool.tokens) { - registerLiquiditySource( - pool.address, - LiquiditySourceType.UniswapPool, - addresses.tokens[token], - ) + registerLiquiditySource(pool.address, LiquiditySourceType.UniswapPool, addresses.tokens[token]) addERC20Processing(token, pool.address) } } diff --git a/src/model/generated/_oTokenActivityType.ts b/src/model/generated/_oTokenActivityType.ts new file mode 100644 index 00000000..8b482960 --- /dev/null +++ b/src/model/generated/_oTokenActivityType.ts @@ -0,0 +1,18 @@ +export enum OTokenActivityType { + Approval = "Approval", + Bridge = "Bridge", + ClaimRewards = "ClaimRewards", + DelegateVote = "DelegateVote", + ExtendStake = "ExtendStake", + Migrate = "Migrate", + Stake = "Stake", + Transfer = "Transfer", + Swap = "Swap", + Wrap = "Wrap", + Unwrap = "Unwrap", + Mint = "Mint", + Redeem = "Redeem", + Zap = "Zap", + Unstake = "Unstake", + Vote = "Vote", +} diff --git a/src/model/generated/index.ts b/src/model/generated/index.ts index 56efea1c..ed1a278c 100644 --- a/src/model/generated/index.ts +++ b/src/model/generated/index.ts @@ -82,6 +82,7 @@ export * from "./oTokenRebaseOption.model" export * from "./oTokenApy.model" export * from "./oTokenVault.model" export * from "./oTokenActivity.model" +export * from "./_oTokenActivityType" export * from "./ousdVault.model" export * from "./ousdMorphoAave.model" export * from "./ousdMorphoCompound.model" diff --git a/src/model/generated/oTokenActivity.model.ts b/src/model/generated/oTokenActivity.model.ts index 47426ab0..e4557e69 100644 --- a/src/model/generated/oTokenActivity.model.ts +++ b/src/model/generated/oTokenActivity.model.ts @@ -1,4 +1,5 @@ -import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, BigIntColumn as BigIntColumn_} from "@subsquid/typeorm-store" +import {Entity as Entity_, Column as Column_, PrimaryColumn as PrimaryColumn_, IntColumn as IntColumn_, Index as Index_, StringColumn as StringColumn_, DateTimeColumn as DateTimeColumn_, JSONColumn as JSONColumn_} from "@subsquid/typeorm-store" +import {OTokenActivityType} from "./_oTokenActivityType" @Entity_() export class OTokenActivity { @@ -29,30 +30,9 @@ export class OTokenActivity { @StringColumn_({nullable: false}) txHash!: string - @StringColumn_({nullable: false}) - callDataLast4Bytes!: string - - @StringColumn_({nullable: true}) - address!: string | undefined | null - - @StringColumn_({nullable: true}) - sighash!: string | undefined | null - - @StringColumn_({nullable: true}) - action!: string | undefined | null - - @StringColumn_({nullable: true}) - exchange!: string | undefined | null - - @StringColumn_({nullable: true}) - interface!: string | undefined | null - - @StringColumn_({nullable: true}) - fromSymbol!: string | undefined | null - - @StringColumn_({nullable: true}) - toSymbol!: string | undefined | null + @Column_("varchar", {length: 12, nullable: true}) + type!: OTokenActivityType | undefined | null - @BigIntColumn_({nullable: true}) - amount!: bigint | undefined | null + @JSONColumn_({nullable: true}) + data!: unknown | undefined | null } diff --git a/src/oeth/post-processors/daily-stats/daily-stats.ts b/src/oeth/post-processors/daily-stats/daily-stats.ts index 39a54ad1..bd56701a 100644 --- a/src/oeth/post-processors/daily-stats/daily-stats.ts +++ b/src/oeth/post-processors/daily-stats/daily-stats.ts @@ -1,11 +1,6 @@ import dayjs from 'dayjs' import utc from 'dayjs/plugin/utc' -import { - EntityManager, - FindOptionsOrderValue, - LessThanOrEqual, - MoreThanOrEqual, -} from 'typeorm' +import { EntityManager, FindOptionsOrderValue, LessThanOrEqual, MoreThanOrEqual } from 'typeorm' import { ExchangeRate, @@ -26,7 +21,7 @@ import { } from '@model' import { Context } from '@processor' import { EvmBatchProcessor } from '@subsquid/evm-processor' -import { OETH_ADDRESS } from '@utils/addresses' +import { OETH_ADDRESS, WOETH_ADDRESS } from '@utils/addresses' import { applyCoingeckoData } from '@utils/coingecko' dayjs.extend(utc) @@ -38,8 +33,7 @@ export const setup = async (processor: EvmBatchProcessor) => { } export const process = async (ctx: Context) => { - const firstBlockTimestamp = ctx.blocks.find((b) => b.header.height >= from) - ?.header.timestamp + const firstBlockTimestamp = ctx.blocks.find((b) => b.header.height >= from)?.header.timestamp if (!firstBlockTimestamp) return const firstBlock = ctx.blocks[0] @@ -48,11 +42,7 @@ export const process = async (ctx: Context) => { const endDate = dayjs.utc(lastBlock.header.timestamp).endOf('day') let dates: Date[] = [] - for ( - let date = startDate; - !date.isAfter(endDate); - date = date.add(1, 'day').endOf('day') - ) { + for (let date = startDate; !date.isAfter(endDate); date = date.add(1, 'day').endOf('day')) { // ctx.log.info({ date, startDate, endDate }) dates.push(date.toDate()) } @@ -80,9 +70,7 @@ export const process = async (ctx: Context) => { vsCurrency: 'eth', })) as OETHDailyStat[] const existingIds = dailyStats.map((stat) => stat.id) - dailyStats.push( - ...updatedStats.filter((stat) => existingIds.indexOf(stat.id) < 0), - ) + dailyStats.push(...updatedStats.filter((stat) => existingIds.indexOf(stat.id) < 0)) } await ctx.store.upsert(dailyStats) @@ -142,7 +130,7 @@ async function updateDailyStats(ctx: Context, date: Date) { chainId: ctx.chain.id, otoken: OETH_ADDRESS, timestamp: LessThanOrEqual(date), - address: { address: '0xdcee70654261af21c44c093c300ed3bb97b78192' }, + address: { address: WOETH_ADDRESS }, }, order: { timestamp: 'desc' as FindOptionsOrderValue }, }), @@ -238,10 +226,7 @@ async function updateDailyStats(ctx: Context, date: Date) { // Collateral totals const ETH = lastCurve?.ethOwned || 0n const OETHOwned = lastCurve?.oethOwned || 0n - const WETH = - (lastVault?.weth || 0n) + - (lastMorpho?.weth || 0n) + - (lastBalancer?.weth || 0n) + const WETH = (lastVault?.weth || 0n) + (lastMorpho?.weth || 0n) + (lastBalancer?.weth || 0n) const stETH = lastVault?.stETH || 0n const rETHRaw = (lastVault?.rETH || 0n) + (lastBalancer?.rETH || 0n) @@ -250,15 +235,11 @@ async function updateDailyStats(ctx: Context, date: Date) { const sfrxEthExchangeRate = lastSfrxEthRate?.rate || 1000000000000000000n const sfrxETH = lastFrax?.sfrxETH || 0n - const convertedSfrxEth = - (sfrxETH * sfrxEthExchangeRate) / 1000000000000000000n + const convertedSfrxEth = (sfrxETH * sfrxEthExchangeRate) / 1000000000000000000n // Strategy totals const vaultTotal = - (lastVault?.frxETH || 0n) + - (lastVault?.weth || 0n) + - (lastVault?.stETH || 0n) + - (lastVault?.rETH || 0n) + (lastVault?.frxETH || 0n) + (lastVault?.weth || 0n) + (lastVault?.stETH || 0n) + (lastVault?.rETH || 0n) const balancerTotal = (lastBalancer?.weth || 0n) + (lastBalancer?.rETH || 0n) diff --git a/src/oeth/processors/ccip.ts b/src/oeth/processors/ccip.ts index e267be4e..5734e855 100644 --- a/src/oeth/processors/ccip.ts +++ b/src/oeth/processors/ccip.ts @@ -3,9 +3,11 @@ import * as ccipOnRampAbi from '@abi/ccip-evm2evmonramp' import * as ccipRouter from '@abi/ccip-router' import * as erc20Abi from '@abi/erc20' import { BridgeTransfer, BridgeTransferState } from '@model' -import { Context } from '@processor' +import { Block, Context, Log } from '@processor' import { EvmBatchProcessor } from '@subsquid/evm-processor' +import { WOETH_ADDRESS, WOETH_ARBITRUM_ADDRESS } from '@utils/addresses' import { logFilter } from '@utils/logFilter' +import { publishProcessorState } from '@utils/state' import { traceFilter } from '@utils/traceFilter' // Code Reference: https://github.com/smartcontractkit/smart-contract-examples/tree/main/ccip-offchain @@ -16,8 +18,9 @@ import { traceFilter } from '@utils/traceFilter' // These can be retrieved using the chain selector id on the router function `getOffRamps` // States: https://github.com/smartcontractkit/smart-contract-examples/blob/main/ccip-offchain/config/messageState.json -interface ProcessResult { +export interface CCIPProcessorResult { transfers: Map + transfersWithLogs: Map bridgeTransferStates: Map } @@ -36,10 +39,9 @@ const ccipConfig = { offRampAddresses: { '42161': '0xefc4a18af59398ff23bfe7325f2401ad44286f4d', }, - tokens: ['0xdcee70654261af21c44c093c300ed3bb97b78192'], + tokens: [WOETH_ADDRESS], tokenMappings: { - '0xdcee70654261af21c44c093c300ed3bb97b78192': - '0xd8724322f44e5c58d7a815f542036fb17dbbf839', // wOETH + [WOETH_ADDRESS]: WOETH_ARBITRUM_ADDRESS, } as Record, }, '42161': { @@ -51,24 +53,16 @@ const ccipConfig = { offRampAddresses: { '1': '0x542ba1902044069330e8c5b36a84ec503863722f', }, - tokens: ['0xd8724322f44e5c58d7a815f542036fb17dbbf839'], + tokens: [WOETH_ARBITRUM_ADDRESS], tokenMappings: { - '0xd8724322f44e5c58d7a815f542036fb17dbbf839': - '0xdcee70654261af21c44c093c300ed3bb97b78192', // wOETH + [WOETH_ARBITRUM_ADDRESS]: WOETH_ADDRESS, } as Record, }, } export const ccip = (params: { chainId: 1 | 42161 }) => { - const { - from, - tokens, - tokenMappings, - tokenPoolAddress, - ccipRouterAddress, - onRampAddress, - offRampAddresses, - } = ccipConfig[params.chainId] + const { from, tokens, tokenMappings, tokenPoolAddress, ccipRouterAddress, onRampAddress, offRampAddresses } = + ccipConfig[params.chainId] const transfersToLockReleasePool = logFilter({ address: tokens, topic0: [erc20Abi.events.Transfer.topic], @@ -104,8 +98,9 @@ export const ccip = (params: { chainId: 1 | 42161 }) => { } const process = async (ctx: Context) => { - const result: ProcessResult = { + const result: CCIPProcessorResult = { transfers: new Map(), + transfersWithLogs: new Map(), bridgeTransferStates: new Map(), } @@ -130,39 +125,26 @@ export const ccip = (params: { chainId: 1 | 42161 }) => { bridgeTransfer.txHashOut = log.transactionHash bridgeTransfer.state = data.state result.transfers.set(state.id, bridgeTransfer) + result.transfersWithLogs.set(state.id, { block, log, transfer: bridgeTransfer }) } // console.log(state) } if (transfersToLockReleasePool.matches(log)) { // console.log('match transfersToOnramp') const logSendRequested = block.logs.find( - (l) => - log.transactionHash === l.transactionHash && - ccipSendRequested.matches(l), + (l) => log.transactionHash === l.transactionHash && ccipSendRequested.matches(l), ) const traceSendRequested = block.traces.find( - (t) => - log.transactionHash === t.transaction?.hash && - ccipSendFunction.matches(t), + (t) => log.transactionHash === t.transaction?.hash && ccipSendFunction.matches(t), ) - if ( - logSendRequested && - traceSendRequested && - traceSendRequested.type === 'call' - ) { + if (logSendRequested && traceSendRequested && traceSendRequested.type === 'call') { // console.log('match ccipSendRequested') - const logData = - ccipOnRampAbi.events.CCIPSendRequested.decode(logSendRequested) + const logData = ccipOnRampAbi.events.CCIPSendRequested.decode(logSendRequested) const message = logData.message - const functionData = ccipRouter.functions.ccipSend.decode( - traceSendRequested.action.input, - ) + const functionData = ccipRouter.functions.ccipSend.decode(traceSendRequested.action.input) // A `BridgeTransferState` may already exist. // If so, we should pull the `state` for it. - const bridgeTransferState = await ctx.store.get( - BridgeTransferState, - message.messageId, - ) + const bridgeTransferState = await ctx.store.get(BridgeTransferState, message.messageId) for (let i = 0; i < message.tokenAmounts.length; i++) { const tokenAmount = message.tokenAmounts[i] @@ -175,10 +157,7 @@ export const ccip = (params: { chainId: 1 | 42161 }) => { messageId: message.messageId, bridge: 'ccip', chainIn: params.chainId, - chainOut: - chainSelectorIdMappings[ - functionData.destinationChainSelector.toString() - ], + chainOut: chainSelectorIdMappings[functionData.destinationChainSelector.toString()], tokenIn: tokenAmount.token.toLowerCase(), tokenOut: tokenMappings[tokenAmount.token.toLowerCase()], amountIn: tokenAmount.amount, @@ -190,12 +169,14 @@ export const ccip = (params: { chainId: 1 | 42161 }) => { }) // console.log(transfer) result.transfers.set(transfer.id, transfer) + result.transfersWithLogs.set(transfer.id, { block, log, transfer }) } } } } } + publishProcessorState(ctx, 'ccip', result) await ctx.store.upsert([...result.transfers.values()]) await ctx.store.upsert([...result.bridgeTransferStates.values()]) } diff --git a/src/oeth/processors/curve-lp.ts b/src/oeth/processors/curve-lp.ts index 019ea1d9..7396fbe4 100644 --- a/src/oeth/processors/curve-lp.ts +++ b/src/oeth/processors/curve-lp.ts @@ -5,11 +5,7 @@ import * as curveLpToken from '@abi/curve-lp-token' import { OETHCurveLP } from '@model' import { Context } from '@processor' import { EvmBatchProcessor } from '@subsquid/evm-processor' -import { - OETH_CONVEX_ADDRESS, - OETH_CURVE_LP_ADDRESS, - OETH_CURVE_REWARD_LP_ADDRESS, -} from '@utils/addresses' +import { CURVE_ETH_OETH_POOL_ADDRESS, OETH_CONVEX_ADDRESS, OETH_CURVE_REWARD_LP_ADDRESS } from '@utils/addresses' import { getLatestEntity } from '@utils/utils' interface ProcessResult { @@ -23,7 +19,7 @@ export const from = Math.min( export const setup = (processor: EvmBatchProcessor) => { processor.addLog({ - address: [OETH_CURVE_LP_ADDRESS], + address: [CURVE_ETH_OETH_POOL_ADDRESS], topic0: [ curveLpToken.events.AddLiquidity.topic, curveLpToken.events.RemoveLiquidity.topic, @@ -35,10 +31,7 @@ export const setup = (processor: EvmBatchProcessor) => { }) processor.addLog({ address: [OETH_CURVE_REWARD_LP_ADDRESS], - topic0: [ - baseRewardPool.events.Staked.topic, - baseRewardPool.events.Withdrawn.topic, - ], + topic0: [baseRewardPool.events.Staked.topic, baseRewardPool.events.Withdrawn.topic], topic1: [pad(OETH_CONVEX_ADDRESS)], range: { from }, }) @@ -50,9 +43,7 @@ export const process = async (ctx: Context) => { } for (const block of ctx.blocks) { - const haveCurveLpEvent = block.logs.find( - (log) => log.address === OETH_CURVE_LP_ADDRESS, - ) + const haveCurveLpEvent = block.logs.find((log) => log.address === CURVE_ETH_OETH_POOL_ADDRESS) if (haveCurveLpEvent) { await updateCurveValues(ctx, result, block) } @@ -66,30 +57,15 @@ export const process = async (ctx: Context) => { await ctx.store.insert(result.curveLPs) } -const updateCurveValues = async ( - ctx: Context, - result: ProcessResult, - block: Context['blocks']['0'], -) => { +const updateCurveValues = async (ctx: Context, result: ProcessResult, block: Context['blocks']['0']) => { const { curveLP } = await getLatestCurveLP(ctx, result, block) - const poolContract = new curveLpToken.Contract( - ctx, - block.header, - OETH_CURVE_LP_ADDRESS, - ) - const [totalSupply, balances] = await Promise.all([ - poolContract.totalSupply(), - poolContract.get_balances(), - ]) + const poolContract = new curveLpToken.Contract(ctx, block.header, CURVE_ETH_OETH_POOL_ADDRESS) + const [totalSupply, balances] = await Promise.all([poolContract.totalSupply(), poolContract.get_balances()]) curveLP.totalSupply = totalSupply curveLP.eth = balances[0] curveLP.oeth = balances[1] - curveLP.ethOwned = curveLP.totalSupply - ? (curveLP.eth * curveLP.totalSupplyOwned) / curveLP.totalSupply - : 0n - curveLP.oethOwned = curveLP.totalSupply - ? (curveLP.oeth * curveLP.totalSupplyOwned) / curveLP.totalSupply - : 0n + curveLP.ethOwned = curveLP.totalSupply ? (curveLP.eth * curveLP.totalSupplyOwned) / curveLP.totalSupply : 0n + curveLP.oethOwned = curveLP.totalSupply ? (curveLP.oeth * curveLP.totalSupplyOwned) / curveLP.totalSupply : 0n } const processCurveRewardEvents = async ( @@ -103,37 +79,20 @@ const processCurveRewardEvents = async ( const { amount } = baseRewardPool.events.Staked.decode(log) const { curveLP } = await getLatestCurveLP(ctx, result, block) curveLP.totalSupplyOwned += amount - curveLP.ethOwned = curveLP.totalSupply - ? (curveLP.eth * curveLP.totalSupplyOwned) / curveLP.totalSupply - : 0n - curveLP.oethOwned = curveLP.totalSupply - ? (curveLP.oeth * curveLP.totalSupplyOwned) / curveLP.totalSupply - : 0n + curveLP.ethOwned = curveLP.totalSupply ? (curveLP.eth * curveLP.totalSupplyOwned) / curveLP.totalSupply : 0n + curveLP.oethOwned = curveLP.totalSupply ? (curveLP.oeth * curveLP.totalSupplyOwned) / curveLP.totalSupply : 0n } else if (log.topics[0] === baseRewardPool.events.Withdrawn.topic) { const { amount } = baseRewardPool.events.Withdrawn.decode(log) const { curveLP } = await getLatestCurveLP(ctx, result, block) curveLP.totalSupplyOwned -= amount - curveLP.ethOwned = curveLP.totalSupply - ? (curveLP.eth * curveLP.totalSupplyOwned) / curveLP.totalSupply - : 0n - curveLP.oethOwned = curveLP.totalSupply - ? (curveLP.oeth * curveLP.totalSupplyOwned) / curveLP.totalSupply - : 0n + curveLP.ethOwned = curveLP.totalSupply ? (curveLP.eth * curveLP.totalSupplyOwned) / curveLP.totalSupply : 0n + curveLP.oethOwned = curveLP.totalSupply ? (curveLP.oeth * curveLP.totalSupplyOwned) / curveLP.totalSupply : 0n } } -const getLatestCurveLP = async ( - ctx: Context, - result: ProcessResult, - block: Context['blocks']['0'], -) => { +const getLatestCurveLP = async (ctx: Context, result: ProcessResult, block: Context['blocks']['0']) => { const timestampId = new Date(block.header.timestamp).toISOString() - const { latest, current } = await getLatestEntity( - ctx, - OETHCurveLP, - result.curveLPs, - timestampId, - ) + const { latest, current } = await getLatestEntity(ctx, OETHCurveLP, result.curveLPs, timestampId) let isNew = false let curveLP = current diff --git a/src/oeth/processors/oeth.ts b/src/oeth/processors/oeth.ts index 61a99ac7..283dec6c 100644 --- a/src/oeth/processors/oeth.ts +++ b/src/oeth/processors/oeth.ts @@ -1,31 +1,27 @@ -import { createOTokenProcessor, createOTokenSetup } from '@templates/otoken' +import { Context } from '@processor' +import { EvmBatchProcessor } from '@subsquid/evm-processor' +import { createOTokenProcessor } from '@templates/otoken' +import { createOTokenActivityProcessor } from '@templates/otoken/activity-processor/activity-processor' import { + CURVE_ETH_OETH_POOL_ADDRESS, + CURVE_FRXETH_OETH_POOL_ADDRESS, ETH_ADDRESS, FRXETH_ADDRESS, OETH_ADDRESS, OETH_VAULT_ADDRESS, + OETH_ZAPPER_ADDRESS, RETH_ADDRESS, SFRXETH_ADDRESS, STETH_ADDRESS, + UNISWAP_V3_OETH_WEH_ADDRESS, WETH_ADDRESS, WOETH_ADDRESS, + WOETH_ARBITRUM_ADDRESS, WSTETH_ADDRESS, } from '@utils/addresses' -export const from = 16933090 // https://etherscan.io/tx/0x3b4ece4f5fef04bf7ceaec4f6c6edf700540d7597589f8da0e3a8c94264a3b50 - -export const setup = createOTokenSetup({ - address: OETH_ADDRESS, - wrappedAddress: WOETH_ADDRESS, - vaultAddress: OETH_VAULT_ADDRESS, - from, - upgrades: { - rebaseOptEvents: 18872285, - }, -}) - -export const process = createOTokenProcessor({ - from, +const otokenProcessor = createOTokenProcessor({ + from: 16933090, // https://etherscan.io/tx/0x3b4ece4f5fef04bf7ceaec4f6c6edf700540d7597589f8da0e3a8c94264a3b50 vaultFrom: 17084107, otokenAddress: OETH_ADDRESS, wotokenAddress: WOETH_ADDRESS, @@ -40,4 +36,40 @@ export const process = createOTokenProcessor({ { asset: WSTETH_ADDRESS, symbol: 'wstETH' }, { asset: OETH_ADDRESS, symbol: 'OETH' }, ], + upgrades: { + rebaseOptEvents: 18872285, + }, +}) + +const otokenActivityProcessor = createOTokenActivityProcessor({ + from: 16933090, + otokenAddress: OETH_ADDRESS, + vaultAddress: OETH_VAULT_ADDRESS, + wotokenAddress: WOETH_ADDRESS, + wotokenArbitrumAddress: WOETH_ARBITRUM_ADDRESS, + zapperAddress: OETH_ZAPPER_ADDRESS, + curvePools: [ + { + address: CURVE_ETH_OETH_POOL_ADDRESS, + tokens: [ETH_ADDRESS, OETH_ADDRESS], + }, + { + address: CURVE_FRXETH_OETH_POOL_ADDRESS, + tokens: [FRXETH_ADDRESS, OETH_ADDRESS], + }, + ], + balancerPools: ['0x7056c8dfa8182859ed0d4fb0ef0886fdf3d2edcf000200000000000000000623'], + uniswapV3: { + address: UNISWAP_V3_OETH_WEH_ADDRESS, + tokens: [WETH_ADDRESS, OETH_ADDRESS], + }, }) + +export const from = Math.min(otokenProcessor.from, otokenActivityProcessor.from) +export const setup = (processor: EvmBatchProcessor) => { + otokenProcessor.setup(processor) + otokenActivityProcessor.setup(processor) +} +export const process = async (ctx: Context) => { + await Promise.all([otokenProcessor.process(ctx), otokenActivityProcessor.process(ctx)]) +} diff --git a/src/ousd/processors/ousd/ousd.ts b/src/ousd/processors/ousd/ousd.ts index 3aed8c93..ff3058bf 100644 --- a/src/ousd/processors/ousd/ousd.ts +++ b/src/ousd/processors/ousd/ousd.ts @@ -1,24 +1,12 @@ -import { createOTokenProcessor, createOTokenSetup } from '@templates/otoken' -import { - DAI_ADDRESS, - OUSD_ADDRESS, - OUSD_VAULT_ADDRESS, - USDC_ADDRESS, - USDT_ADDRESS, -} from '@utils/addresses' +import { createOTokenProcessor } from '@templates/otoken' +import { DAI_ADDRESS, OUSD_ADDRESS, OUSD_VAULT_ADDRESS, USDC_ADDRESS, USDT_ADDRESS } from '@utils/addresses' // export const from = 10884563 // https://etherscan.io/tx/0x9141921f5ebf072e58c00fe56332b6bee0c02f0ae4f54c42999b8a3a88662681 -export const from = 11585978 // OUSDReset +// export const from = 11585978 // OUSDReset // export const from = 13533937 // https://etherscan.io/tx/0xc9b6fc6a4fad18dad197ff7d0636f74bf066671d75656849a1c45122e00d54cf -export const setup = createOTokenSetup({ - address: OUSD_ADDRESS, - vaultAddress: OUSD_VAULT_ADDRESS, - from, -}) - -export const process = createOTokenProcessor({ - from, +export const { from, setup, process } = createOTokenProcessor({ + from: 11585978, // OUSDReset vaultFrom: 11596942, Upgrade_CreditsBalanceOfHighRes: 13533937, // https://etherscan.io/tx/0xc9b6fc6a4fad18dad197ff7d0636f74bf066671d75656849a1c45122e00d54cf otokenAddress: OUSD_ADDRESS, diff --git a/src/templates/otoken/activity-processor/activity-processor.ts b/src/templates/otoken/activity-processor/activity-processor.ts new file mode 100644 index 00000000..66d5d290 --- /dev/null +++ b/src/templates/otoken/activity-processor/activity-processor.ts @@ -0,0 +1,103 @@ +import { compact, groupBy } from 'lodash' + +import { OTokenActivity, OTokenActivityType } from '@model' +import { Context } from '@processor' +import { EvmBatchProcessor } from '@subsquid/evm-processor' +import { approvalActivityProcessor } from '@templates/otoken/activity-processor/sub/approval' +import { balancerActivityProcessor } from '@templates/otoken/activity-processor/sub/balancer' +import { ccipBridgeActivityProcessor } from '@templates/otoken/activity-processor/sub/ccip-bridge' +import { cowSwapActivityProcessor } from '@templates/otoken/activity-processor/sub/cow-swap' +import { curveActivityProcessor } from '@templates/otoken/activity-processor/sub/curve' +import { transferActivityProcessor } from '@templates/otoken/activity-processor/sub/transfer' +import { uniswapV3ActivityProcessor } from '@templates/otoken/activity-processor/sub/uniswap-v3' +import { vaultActivityProcessor } from '@templates/otoken/activity-processor/sub/vault' +import { wrappedActivityProcessor } from '@templates/otoken/activity-processor/sub/wrapped' +import { zapperActivityProcessor } from '@templates/otoken/activity-processor/sub/zapper' +import { ActivityProcessor } from '@templates/otoken/activity-processor/types' +import { Activity } from '@templates/otoken/activity-types' + +export const createOTokenActivityProcessor = (params: { + from: number + otokenAddress: string + vaultAddress: string + wotokenAddress?: string + wotokenArbitrumAddress?: string + + zapperAddress: string + curvePools: { + address: string + tokens: string[] + }[] + balancerPools: string[] + uniswapV3: { address: string; tokens: [string, string] } +}) => { + const processors: ActivityProcessor[] = compact([ + // TODO: Morpho Blue: https://etherscan.io/tx/0xde3e7e991f70979ffdfaf0652b4c2722773416341ca78dcdaabd3cae98f8204d#eventlog + + // Approvals + approvalActivityProcessor(params), + + // Bridges + params.wotokenAddress && + ccipBridgeActivityProcessor({ + otokenAddress: params.otokenAddress, + wotokenAddresses: compact([params.wotokenAddress, params.wotokenArbitrumAddress]), + }), + + // Zaps + zapperActivityProcessor({ otokenAddress: params.otokenAddress, zapperAddress: params.zapperAddress }), + + // Swaps + uniswapV3ActivityProcessor({ otokenAddress: params.otokenAddress, ...params.uniswapV3 }), + ...params.curvePools.map((pool) => curveActivityProcessor({ otokenAddress: params.otokenAddress, ...pool })), + balancerActivityProcessor({ otokenAddress: params.otokenAddress, pools: params.balancerPools }), + cowSwapActivityProcessor({ otokenAddress: params.otokenAddress, address: params.otokenAddress }), + params.wotokenAddress && + cowSwapActivityProcessor({ + otokenAddress: params.otokenAddress, + address: params.wotokenAddress, + }), + + // Wraps & Unwraps + params.wotokenAddress && + wrappedActivityProcessor({ + otokenAddress: params.otokenAddress, + wotokenAddress: params.wotokenAddress, + }), + + // Mints & Redeems + vaultActivityProcessor({ otokenAddress: params.otokenAddress, vaultAddress: params.vaultAddress }), + + // Transfers & Swaps + transferActivityProcessor({ otokenAddress: params.otokenAddress }), + ]).filter((p) => p.name.includes('Approval')) + + const from = params.from + const setup = (processor: EvmBatchProcessor) => { + for (const p of processors) { + for (const filter of p.filters) { + processor.addLog(filter.value) + } + } + } + const process = async (ctx: Context) => { + const activities: OTokenActivity[] = [] + // Loop through each block + for (const block of ctx.blocks) { + // Group logs by transaction + const transactions = groupBy(block.logs, (l) => l.transactionHash) + // Loop through each transaction's set of logs. + for (const logs of Object.values(transactions)) { + for (const p of processors) { + const filterMatch = p.filters.find((f) => logs.find((l) => f.matches(l))) + if (filterMatch) { + const results = await p.process(ctx, block, logs) + activities.push(...results) + } + } + } + } + await ctx.store.insert(activities) + } + return { from, setup, process } +} diff --git a/src/templates/otoken/activity-processor/index.ts b/src/templates/otoken/activity-processor/index.ts new file mode 100644 index 00000000..f3809c4c --- /dev/null +++ b/src/templates/otoken/activity-processor/index.ts @@ -0,0 +1,8 @@ +export * from './activity-processor' +export { createActivity } from '@templates/otoken/activity-processor/utils' +export { transferActivityProcessor } from '@templates/otoken/activity-processor/sub/transfer' +export { vaultActivityProcessor } from '@templates/otoken/activity-processor/sub/vault' +export { wrappedActivityProcessor } from '@templates/otoken/activity-processor/sub/wrapped' +export { cowSwapActivityProcessor } from '@templates/otoken/activity-processor/sub/cow-swap' +export { balancerActivityProcessor } from '@templates/otoken/activity-processor/sub/balancer' +export { curveActivityProcessor } from '@templates/otoken/activity-processor/sub/curve' diff --git a/src/templates/otoken/activity-processor/sub/approval.ts b/src/templates/otoken/activity-processor/sub/approval.ts new file mode 100644 index 00000000..893fdf4e --- /dev/null +++ b/src/templates/otoken/activity-processor/sub/approval.ts @@ -0,0 +1,35 @@ +import * as otokenAbi from '@abi/otoken' +import { OTokenActivity } from '@model' +import { ActivityProcessor } from '@templates/otoken/activity-processor/types' +import { createActivity } from '@templates/otoken/activity-processor/utils' +import { ApprovalActivity } from '@templates/otoken/activity-types' +import { logFilter } from '@utils/logFilter' + +export const approvalActivityProcessor = ({ otokenAddress }: { otokenAddress: string }): ActivityProcessor => { + const approvalFilter = logFilter({ address: [otokenAddress], topic0: [otokenAbi.events.Approval.topic] }) + return { + name: 'Approval Processor', + filters: [approvalFilter], + process: async (ctx, block, logs) => { + const result: OTokenActivity[] = [] + const approvalLogs = logs.filter((l) => approvalFilter.matches(l)) + result.push( + ...approvalLogs.map((log) => { + const data = otokenAbi.events.Approval.decode(log) + return createActivity( + { ctx, block, log, otokenAddress }, + { + processor: 'approval', + type: 'Approval', + owner: data.owner, + spender: data.spender, + token: otokenAddress, + value: data.value.toString(), + }, + ) + }), + ) + return result + }, + } +} diff --git a/src/templates/otoken/activity-processor/sub/balancer.ts b/src/templates/otoken/activity-processor/sub/balancer.ts new file mode 100644 index 00000000..f7a9a542 --- /dev/null +++ b/src/templates/otoken/activity-processor/sub/balancer.ts @@ -0,0 +1,48 @@ +import * as balancerVaultAbi from '@abi/balancer-vault' +import { OTokenActivity } from '@model' +import { Block, Context, Log } from '@processor' +import { ActivityProcessor } from '@templates/otoken/activity-processor/types' +import { createActivity } from '@templates/otoken/activity-processor/utils' +import { SwapActivity } from '@templates/otoken/activity-types' +import { BALANCER_VAULT_ADDRESS } from '@utils/addresses' +import { logFilter } from '@utils/logFilter' + +export const balancerActivityProcessor = ({ + otokenAddress, + pools, +}: { + otokenAddress: string + pools: string[] +}): ActivityProcessor => { + return { + name: 'Balancer Pool Processor', + filters: [ + logFilter({ + address: [BALANCER_VAULT_ADDRESS], + topic0: [balancerVaultAbi.events.Swap.topic], + topic1: pools, + transaction: true, + }), + ], + async process(ctx: Context, block: Block, logs: Log[]): Promise { + const [swapFilter] = this.filters + return logs + .filter((l) => swapFilter.matches(l)) + .map((log) => { + const swap = balancerVaultAbi.events.Swap.decode(log) + return createActivity( + { ctx, block, log, otokenAddress }, + { + processor: 'balancer', + type: 'Swap', + account: log.transaction!.from, + exchange: 'Balancer', + contract: swap.poolId, + tokensIn: [{ token: swap.tokenIn, amount: swap.amountIn.toString() }], + tokensOut: [{ token: swap.tokenOut, amount: swap.amountOut.toString() }], + }, + ) + }) + }, + } +} diff --git a/src/templates/otoken/activity-processor/sub/ccip-bridge.ts b/src/templates/otoken/activity-processor/sub/ccip-bridge.ts new file mode 100644 index 00000000..77cb9ae9 --- /dev/null +++ b/src/templates/otoken/activity-processor/sub/ccip-bridge.ts @@ -0,0 +1,57 @@ +import { OTokenActivity } from '@model' +import { Context } from '@processor' +import { ActivityProcessor } from '@templates/otoken/activity-processor/types' +import { createActivity } from '@templates/otoken/activity-processor/utils' +import { BridgeActivity } from '@templates/otoken/activity-types' +import { waitForProcessorState } from '@utils/state' + +import { CCIPProcessorResult } from '../../../../oeth/processors/ccip' + +export const ccipBridgeActivityProcessor = (params: { + otokenAddress: string + wotokenAddresses: string[] +}): ActivityProcessor => { + return { + name: 'CCIP Bridge Processor', + filters: [], + async process(ctx: Context): Promise { + const results: OTokenActivity[] = [] + const ccipResult = await waitForProcessorState(ctx, 'ccip') + for (const { block, log, transfer } of ccipResult.transfersWithLogs.values()) { + if ( + !params.wotokenAddresses.includes(transfer.tokenIn) && + !params.wotokenAddresses.includes(transfer.tokenOut) + ) { + // Skip the transfer if it is not one of our wotoken addresses. + continue + } + results.push( + createActivity( + { ctx, block, log, otokenAddress: params.otokenAddress }, + { + processor: 'ccip-bridge', + type: 'Bridge', + status: (['signed', 'signed', 'success', 'error'] as const)[transfer.state], + txHashIn: transfer.txHashIn, + txHashOut: transfer.txHashOut, + messageId: transfer.messageId, + bridge: transfer.bridge, + transactor: transfer.transactor, + sender: transfer.sender, + receiver: transfer.receiver, + chainIn: transfer.chainIn, + chainOut: transfer.chainOut, + tokenIn: transfer.tokenIn, + tokenOut: transfer.tokenOut, + amountIn: transfer.amountIn.toString(), + amountOut: transfer.amountOut.toString(), + state: transfer.state, + }, + ), + ) + } + + return results + }, + } +} diff --git a/src/templates/otoken/activity-processor/sub/cow-swap.ts b/src/templates/otoken/activity-processor/sub/cow-swap.ts new file mode 100644 index 00000000..6b29134c --- /dev/null +++ b/src/templates/otoken/activity-processor/sub/cow-swap.ts @@ -0,0 +1,50 @@ +import * as cowswapSettlementAbi from '@abi/cow-swap-settlement' +import { OTokenActivity } from '@model' +import { Block, Context, Log } from '@processor' +import { ActivityProcessor } from '@templates/otoken/activity-processor/types' +import { createActivity } from '@templates/otoken/activity-processor/utils' +import { SwapActivity } from '@templates/otoken/activity-types' +import { COWSWAP_SETTLEMENT_ADDRESS } from '@utils/addresses' +import { logFilter } from '@utils/logFilter' + +export const cowSwapActivityProcessor = ({ + otokenAddress, + address, +}: { + otokenAddress: string + address: string +}): ActivityProcessor => { + const tradeFilter = logFilter({ + address: [COWSWAP_SETTLEMENT_ADDRESS], + topic0: [cowswapSettlementAbi.events.Trade.topic], + transaction: true, + }) + return { + name: 'Cowswap Activity Processor', + filters: [tradeFilter], + async process(ctx: Context, block: Block, logs: Log[]): Promise { + const tradeLogs = logs + .filter((l) => tradeFilter.matches(l)) + .map((log) => ({ + log, + data: cowswapSettlementAbi.events.Trade.decode(log), + })) + return tradeLogs + .filter(({ data }) => data.buyToken.toLowerCase() === address || data.sellToken.toLowerCase() === address) + .map(({ log, data }) => { + return createActivity( + { ctx, block, log, otokenAddress }, + { + processor: 'cow-swap', + type: 'Swap', + account: log.transaction!.from, + exchange: 'Balancer', + contract: COWSWAP_SETTLEMENT_ADDRESS, + tokensIn: [{ token: data.sellToken, amount: data.sellAmount.toString() }], + tokensOut: [{ token: data.buyToken, amount: data.buyAmount.toString() }], + }, + ) + }) + }, + } +} diff --git a/src/templates/otoken/activity-processor/sub/curve.ts b/src/templates/otoken/activity-processor/sub/curve.ts new file mode 100644 index 00000000..199729fe --- /dev/null +++ b/src/templates/otoken/activity-processor/sub/curve.ts @@ -0,0 +1,49 @@ +import * as curvePoolAbi from '@abi/curve-lp-token' +import { OTokenActivity } from '@model' +import { Block, Context, Log } from '@processor' +import { ActivityProcessor } from '@templates/otoken/activity-processor/types' +import { createActivity } from '@templates/otoken/activity-processor/utils' +import { SwapActivity } from '@templates/otoken/activity-types' +import { logFilter } from '@utils/logFilter' + +export const curveActivityProcessor = ({ + otokenAddress, + address, + tokens, +}: { + otokenAddress: string + address: string + tokens: string[] +}): ActivityProcessor => { + return { + name: 'Curve Pool Processor', + filters: [logFilter({ address: [address], topic0: [curvePoolAbi.events.TokenExchange.topic] })], + async process(ctx: Context, block: Block, logs: Log[]): Promise { + const [tokenExchangeFilter] = this.filters + return logs + .filter((l) => tokenExchangeFilter.matches(l)) + .map((log) => { + const tokenExchange = curvePoolAbi.events.TokenExchange.decode(log) + return createActivity( + { ctx, block, log, otokenAddress }, + { + processor: 'curve', + type: 'Swap', + account: tokenExchange.buyer, + exchange: 'Curve', + contract: log.address, + tokensIn: [ + { token: tokens[Number(tokenExchange.sold_id)], amount: tokenExchange.tokens_sold.toString() }, + ], + tokensOut: [ + { + token: tokens[Number(tokenExchange.bought_id)], + amount: tokenExchange.tokens_bought.toString(), + }, + ], + }, + ) + }) + }, + } +} diff --git a/src/templates/otoken/activity-processor/sub/transfer.ts b/src/templates/otoken/activity-processor/sub/transfer.ts new file mode 100644 index 00000000..036c246e --- /dev/null +++ b/src/templates/otoken/activity-processor/sub/transfer.ts @@ -0,0 +1,118 @@ +import * as otokenAbi from '@abi/otoken' +import * as wotokenAbi from '@abi/woeth' +import { OTokenActivity } from '@model' +import { Block, Context, Log } from '@processor' +import { ActivityProcessor } from '@templates/otoken/activity-processor/types' +import { createActivity } from '@templates/otoken/activity-processor/utils' +import { SwapActivity, TransferActivity } from '@templates/otoken/activity-types' +import { ONEINCH_AGGREGATION_ROUTER_ADDRESS } from '@utils/addresses' +import { logFilter } from '@utils/logFilter' + +export const transferActivityProcessor = ({ otokenAddress }: { otokenAddress: string }): ActivityProcessor => { + const transferFilter = logFilter({ + address: [otokenAddress], + topic0: [otokenAbi.events.Transfer.topic], + }) + return { + name: 'Transfer Activity', + filters: [transferFilter], + process: async (ctx, block, logs) => { + const transferLogs = logs + .filter((l) => transferFilter.matches(l)) + .map((log) => ({ + log, + data: otokenAbi.events.Transfer.decode(log), + })) + + const swapActivity = calculateTransferActivityAsSwap(ctx, block, transferLogs, otokenAddress) + if (swapActivity) return swapActivity + + return transferLogs.map(({ log, data }) => { + return createActivity( + { ctx, block, log, otokenAddress }, + { + processor: 'transfer', + type: 'Transfer', + token: log.address, + from: data.from.toLowerCase(), + to: data.to.toLowerCase(), + amount: data.value.toString(), + }, + ) + }) + }, + } +} + +const getExchangeName = ( + logs: { + log: Log + data: ReturnType + }[], +) => { + if (logs[0].log.transaction?.to === '0x6131b5fae19ea4f9d964eac0408e4408b66337b5') return 'Kyber Swap' + return logs.find((l) => l.log.address === ONEINCH_AGGREGATION_ROUTER_ADDRESS) ? '1inch' : 'other' +} + +const calculateTransferActivityAsSwap = ( + ctx: Context, + block: Block, + logs: { + log: Log + data: ReturnType + }[], + otokenAddress: string, +) => { + if (logs.length === 1) return undefined + const resultMap: Record = {} + const tokens = new Set() + const exchange = getExchangeName(logs) + for (const { log, data } of logs) { + tokens.add(log.address) + // To + const toActivity = + resultMap[data.to.toLowerCase()] ?? + createActivity( + { ctx, block, log: logs[0].log, otokenAddress }, + { + processor: 'transfer', + type: 'Swap', + exchange, + contract: log.address, + account: data.to.toLowerCase(), + tokensOut: [], + tokensIn: [], + }, + ) + const toSwapActivity = toActivity.data as SwapActivity + toSwapActivity.tokensIn.push({ token: log.address, amount: data.value.toString() }) + resultMap[data.to.toLowerCase()] = toActivity + + // From + const fromActivity = + resultMap[data.from.toLowerCase()] ?? + createActivity( + { ctx, block, log: logs[0].log, otokenAddress }, + { + processor: 'transfer', + type: 'Swap', + exchange, + contract: log.address, + account: data.to.toLowerCase(), + tokensOut: [], + tokensIn: [], + }, + ) + const fromSwapActivity = fromActivity.data as SwapActivity + resultMap[data.from.toLowerCase()] = fromActivity + fromSwapActivity.tokensOut.push({ token: log.address, amount: data.value.toString() }) + } + if (tokens.size <= 1) return undefined + // We are a swap if we sent and received more than one token + const results = Object.values(resultMap).filter((r) => { + const activity = r.data as SwapActivity + return activity.tokensIn.length > 0 && activity.tokensOut.length > 0 + }) + if (results.length > 0) return results + return undefined +} diff --git a/src/templates/otoken/activity-processor/sub/uniswap-v3.ts b/src/templates/otoken/activity-processor/sub/uniswap-v3.ts new file mode 100644 index 00000000..5573638f --- /dev/null +++ b/src/templates/otoken/activity-processor/sub/uniswap-v3.ts @@ -0,0 +1,65 @@ +import * as uniswapV3Abi from '@abi/uniswap-v3' +import { OTokenActivity } from '@model' +import { Block, Context, Log } from '@processor' +import { ActivityProcessor } from '@templates/otoken/activity-processor/types' +import { createActivity } from '@templates/otoken/activity-processor/utils' +import { SwapActivity } from '@templates/otoken/activity-types' +import { logFilter } from '@utils/logFilter' + +export const uniswapV3ActivityProcessor = ({ + otokenAddress, + address, + tokens, +}: { + otokenAddress: string + address: string + tokens: [string, string] +}): ActivityProcessor => { + const tradeFilter = logFilter({ + address: [address], + topic0: [uniswapV3Abi.events.Swap.topic], + transaction: true, + }) + return { + name: 'UniswapV3 Activity Processor', + filters: [tradeFilter], + async process(ctx: Context, block: Block, logs: Log[]): Promise { + const tradeLogs = logs + .filter((l) => tradeFilter.matches(l)) + .map((log) => ({ + log, + data: uniswapV3Abi.events.Swap.decode(log), + })) + return tradeLogs.flatMap(({ log, data }) => { + const senderTokens0 = { token: tokens[0], amount: data.amount0.toString() } + const senderTokens1 = { token: tokens[1], amount: data.amount1.toString() } + return [ + createActivity( + { ctx, block, log, otokenAddress }, + { + processor: 'uniswap-v3', + type: 'Swap', + account: data.sender.toLowerCase(), + exchange: 'UniswapV3', + contract: address, + tokensIn: [data.amount0 < 0n ? senderTokens0 : senderTokens1], + tokensOut: [data.amount0 > 0n ? senderTokens0 : senderTokens1], + }, + ), + createActivity( + { ctx, block, log, otokenAddress }, + { + processor: 'cow-swap', + type: 'Swap', + account: data.recipient.toLowerCase(), + exchange: 'Balancer', + contract: address, + tokensIn: [data.amount0 > 0n ? senderTokens0 : senderTokens1], + tokensOut: [data.amount0 < 0n ? senderTokens0 : senderTokens1], + }, + ), + ] + }) + }, + } +} diff --git a/src/templates/otoken/activity-processor/sub/vault.ts b/src/templates/otoken/activity-processor/sub/vault.ts new file mode 100644 index 00000000..9b4834de --- /dev/null +++ b/src/templates/otoken/activity-processor/sub/vault.ts @@ -0,0 +1,81 @@ +import { uniq } from 'lodash' + +import * as otokenVaultAbi from '@abi/otoken-vault' +import * as wotokenAbi from '@abi/woeth' +import { OTokenActivity } from '@model' +import { ActivityProcessor } from '@templates/otoken/activity-processor/types' +import { createActivity } from '@templates/otoken/activity-processor/utils' +import { MintActivity, RedeemActivity } from '@templates/otoken/activity-types' +import { ETH_ADDRESS } from '@utils/addresses' +import { logFilter } from '@utils/logFilter' + +export const vaultActivityProcessor = ({ + otokenAddress, + vaultAddress, +}: { + otokenAddress: string + vaultAddress: string +}): ActivityProcessor => { + const mintFilter = logFilter({ address: [vaultAddress], topic0: [otokenVaultAbi.events.Mint.topic] }) + const redeemFilter = logFilter({ address: [vaultAddress], topic0: [otokenVaultAbi.events.Redeem.topic] }) + const transferInFilter = logFilter({ topic0: [wotokenAbi.events.Transfer.topic], topic2: [vaultAddress] }) + const transferOutFilter = logFilter({ topic0: [wotokenAbi.events.Transfer.topic], topic1: [vaultAddress] }) + return { + name: 'Vault Processor', + filters: [mintFilter, redeemFilter, transferInFilter, transferOutFilter], + process: async (ctx, block, logs) => { + const result: OTokenActivity[] = [] + // Mint + const mintLogs = logs.filter((l) => mintFilter.matches(l)) + if (mintLogs.length) { + const transferInLogs = logs.filter((l) => transferInFilter.matches(l)) + const tokenIn = transferInLogs[0]?.address ?? ETH_ADDRESS + const amountIn = mintLogs.reduce((sum, l) => sum + otokenVaultAbi.events.Mint.decode(l)._value, 0n) + result.push( + ...mintLogs.map((log) => { + const data = otokenVaultAbi.events.Mint.decode(log) + return createActivity( + { ctx, block, log, otokenAddress }, + { + processor: 'vault', + type: 'Mint', + contract: log.address, + account: data._addr, + tokenIn, + amountIn: amountIn.toString(), + tokenOut: otokenAddress, + amountOut: data._value.toString(), + }, + ) + }), + ) + } + // Redeem + const redeemLogs = logs.filter((l) => redeemFilter.matches(l)) + if (redeemLogs.length) { + const transferOutLogs = logs.filter((l) => transferOutFilter.matches(l)) + const tokensOut = uniq(transferOutLogs.map((l) => l.address)) + const amountOut = redeemLogs.reduce((sum, l) => sum + otokenVaultAbi.events.Redeem.decode(l)._value, 0n) + result.push( + ...redeemLogs.map((log) => { + const data = otokenVaultAbi.events.Redeem.decode(log) + return createActivity( + { ctx, block, log, otokenAddress }, + { + processor: 'vault', + type: 'Redeem', + contract: log.address, + account: data._addr, + tokenIn: otokenAddress, + amountIn: data._value.toString(), + tokenOut: tokensOut.length > 1 ? 'MIX' : tokensOut[0] ?? ETH_ADDRESS, + amountOut: amountOut.toString(), + }, + ) + }), + ) + } + return result + }, + } +} diff --git a/src/templates/otoken/activity-processor/sub/wrapped.ts b/src/templates/otoken/activity-processor/sub/wrapped.ts new file mode 100644 index 00000000..3f46cee7 --- /dev/null +++ b/src/templates/otoken/activity-processor/sub/wrapped.ts @@ -0,0 +1,76 @@ +import * as wotokenAbi from '@abi/woeth' +import { OTokenActivity } from '@model' +import { Block, Context, Log } from '@processor' +import { ActivityProcessor } from '@templates/otoken/activity-processor/types' +import { createActivity, useActivityState } from '@templates/otoken/activity-processor/utils' +import { UnwrapActivity, WrapActivity } from '@templates/otoken/activity-types' +import { logFilter } from '@utils/logFilter' + +export const wrappedActivityProcessor = ({ + otokenAddress, + wotokenAddress, +}: { + otokenAddress: string + wotokenAddress: string +}): ActivityProcessor => { + const depositFilter = logFilter({ address: [wotokenAddress], topic0: [wotokenAbi.events.Deposit.topic] }) + const withdrawFilter = logFilter({ address: [wotokenAddress], topic0: [wotokenAbi.events.Withdraw.topic] }) + const transferInFilter = logFilter({ topic0: [wotokenAbi.events.Transfer.topic], topic2: [wotokenAddress] }) + const transferOutFilter = logFilter({ topic0: [wotokenAbi.events.Transfer.topic], topic1: [wotokenAddress] }) + return { + name: 'Wrapped Processor', + filters: [depositFilter, withdrawFilter, transferInFilter, transferOutFilter], + async process(ctx: Context, block: Block, logs: Log[]) { + const result: OTokenActivity[] = [] + // Wrap + const depositLogs = logs.filter((l) => depositFilter.matches(l)) + if (depositLogs.length) { + const transferInLog = logs.find((l) => transferInFilter.matches(l)) + result.push( + ...depositLogs.map((log) => { + const data = wotokenAbi.events.Deposit.decode(log) + const tokenIn = transferInLog?.address ?? 'unknown' + return createActivity( + { ctx, block, log, otokenAddress }, + { + processor: 'wrapped', + type: 'Wrap', + contract: wotokenAddress, + account: data.owner, + tokenIn, + tokenOut: wotokenAddress, + amountIn: data.assets.toString(), + amountOut: data.shares.toString(), + }, + ) + }), + ) + } + // Unwrap + const withdrawLogs = logs.filter((l) => withdrawFilter.matches(l)) + if (withdrawLogs.length) { + const transferOutLog = logs.find((l) => transferOutFilter.matches(l)) + result.push( + ...withdrawLogs.map((log) => { + const data = wotokenAbi.events.Withdraw.decode(log) + const tokenOut = transferOutLog?.address ?? 'unknown' + return createActivity( + { ctx, block, log, otokenAddress }, + { + processor: 'wrapped', + type: 'Unwrap', + contract: wotokenAddress, + account: data.owner, + tokenIn: wotokenAddress, + tokenOut, + amountIn: data.shares.toString(), + amountOut: data.assets.toString(), + }, + ) + }), + ) + } + return result + }, + } +} diff --git a/src/templates/otoken/activity-processor/sub/zapper.ts b/src/templates/otoken/activity-processor/sub/zapper.ts new file mode 100644 index 00000000..4fb660aa --- /dev/null +++ b/src/templates/otoken/activity-processor/sub/zapper.ts @@ -0,0 +1,47 @@ +import * as zapperAbi from '@abi/oeth-zapper' +import { OTokenActivity } from '@model' +import { Block, Context, Log } from '@processor' +import { ActivityProcessor } from '@templates/otoken/activity-processor/types' +import { createActivity } from '@templates/otoken/activity-processor/utils' +import { ZapActivity } from '@templates/otoken/activity-types' +import { logFilter } from '@utils/logFilter' + +export const zapperActivityProcessor = ({ + zapperAddress, + otokenAddress, +}: { + zapperAddress: string + otokenAddress: string +}): ActivityProcessor => { + return { + name: 'Zapper Processor', + filters: [ + logFilter({ + address: [zapperAddress], + topic0: [zapperAbi.events.Zap.topic], + transaction: true, + }), + ], + async process(ctx: Context, block: Block, logs: Log[]): Promise { + const [zapFilter] = this.filters + return logs + .filter((l) => zapFilter.matches(l)) + .map((log) => { + const zap = zapperAbi.events.Zap.decode(log) + return createActivity( + { ctx, block, log, otokenAddress }, + { + processor: 'zapper', + type: 'Zap', + account: zap.minter, + contract: zapperAddress, + tokenIn: zap.asset, + amountIn: zap.amount.toString(), + tokenOut: otokenAddress, + amountOut: zap.amount.toString(), + }, + ) + }) + }, + } +} diff --git a/src/templates/otoken/activity-processor/types.ts b/src/templates/otoken/activity-processor/types.ts new file mode 100644 index 00000000..a7da88f5 --- /dev/null +++ b/src/templates/otoken/activity-processor/types.ts @@ -0,0 +1,9 @@ +import { OTokenActivity } from '@model' +import { Block, Context, Log } from '@processor' +import { LogFilter } from '@utils/logFilter' + +export interface ActivityProcessor { + name: string + filters: LogFilter[] + process: (ctx: Context, block: Block, logs: Log[]) => Promise +} diff --git a/src/templates/otoken/activity-processor/utils.ts b/src/templates/otoken/activity-processor/utils.ts new file mode 100644 index 00000000..d0c47960 --- /dev/null +++ b/src/templates/otoken/activity-processor/utils.ts @@ -0,0 +1,50 @@ +import crypto from 'crypto' + +import { OTokenActivity, OTokenActivityType } from '@model' +import { Block, Context, Log } from '@processor' +import { Activity } from '@templates/otoken/activity-types' +import { useProcessorState } from '@utils/state' + +export const useActivityState = (ctx: Context) => + useProcessorState(ctx, 'activity-state', { + processedLogs: new Set(), + }) + +export const createActivity = ( + { + ctx, + block, + log, + otokenAddress, + }: { + ctx: Context + block: Block + log: Log + otokenAddress: string + }, + partial: { + processor: string + status?: T['status'] + } & Omit, +) => { + const activity = new OTokenActivity({ + chainId: ctx.chain.id, + blockNumber: block.header.height, + timestamp: new Date(block.header.timestamp), + txHash: log.transactionHash, + type: OTokenActivityType[partial.type], + otoken: otokenAddress, + data: { + status: 'success', + ...partial, + } as T, + }) + + activity.id = `${partial.processor}:${ctx.chain.id}:${log.id}:${crypto + .createHash('sha256') + .update(JSON.stringify(activity)) + .digest('hex') + .substring(0, 8)}` + + return activity +} diff --git a/src/templates/otoken/activity-types.ts b/src/templates/otoken/activity-types.ts new file mode 100644 index 00000000..b199d26c --- /dev/null +++ b/src/templates/otoken/activity-types.ts @@ -0,0 +1,195 @@ +export type ActivityStatus = 'idle' | 'pending' | 'signed' | 'success' | 'error' +export type Exchange = 'Curve' | 'Balancer' | '1inch' | 'other' | 'UniswapV2' | 'UniswapV3' | 'Kyber Swap' + +export interface ActivityBase { + id: string + blockNumber: number + timestamp: number + status: ActivityStatus + txHash: string + chainId: number + processor: string +} + +export interface ApprovalActivity extends ActivityBase { + type: 'Approval' + owner: string + spender: string + token: string + value: string +} + +export interface BridgeActivity extends ActivityBase { + type: 'Bridge' + txHashIn: string + txHashOut: string | undefined | null + messageId: string + bridge: string + transactor: string + sender: string + receiver: string + chainIn: number + chainOut: number + tokenIn: string + tokenOut: string + amountIn: string + amountOut: string + /** + * 0 = untouched + * 1 = processing + * 2 = complete + * 3 = failed + */ + state: number +} + +// TODO +export interface ClaimRewardsActivity extends ActivityBase { + type: 'ClaimRewards' + account: string + tokenIn: string + amountIn: string +} + +// TODO +export interface DelegateVoteActivity extends ActivityBase { + type: 'DelegateVote' + account: string + tokenIn: string + votingPower: string + delegateTo: string +} + +// TODO +export interface MigrateActivity extends ActivityBase { + type: 'Migrate' + account: string + amountIn: string + tokenIn: string + tokenIdStaked: string + tokenIdLiquid: string + liquid?: string + staked?: string +} + +// TODO +export interface StakeActivity extends ActivityBase { + type: 'Stake' + account: string + tokenIn: string + amountIn: string + monthDuration: number +} + +// TODO +export interface UnstakeActivity extends ActivityBase { + type: 'Unstake' + account: string + tokenIn: string + tokenOut: string + lockupId: string +} + +// TODO +export interface ExtendStakeActivity extends ActivityBase { + type: 'ExtendStake' + account: string + amountIn: string + tokenIn: string + monthDuration: number + lockupId: string +} + +export interface SwapActivity extends ActivityBase { + type: 'Swap' + account: string + exchange: Exchange + contract: string + tokensIn: { token: string; amount: string }[] + tokensOut: { token: string; amount: string }[] +} + +export interface TransferActivity extends ActivityBase { + type: 'Transfer' + token: string + from: string + to: string + amount: string +} + +export interface WrapActivity extends ActivityBase { + type: 'Wrap' + account: string + contract: string + tokenIn: string + tokenOut: string + amountIn: string + amountOut: string +} + +export interface UnwrapActivity extends ActivityBase { + type: 'Unwrap' + account: string + contract: string + tokenIn: string + tokenOut: string + amountIn: string + amountOut: string +} + +export interface MintActivity extends ActivityBase { + type: 'Mint' + account: string + contract: string + tokenIn: string + tokenOut: string + amountIn: string + amountOut: string +} + +export interface RedeemActivity extends ActivityBase { + type: 'Redeem' + account: string + contract: string + tokenIn: string + tokenOut: string + amountIn: string + amountOut: string +} + +export interface ZapActivity extends ActivityBase { + type: 'Zap' + account: string + contract: string + tokenIn: string + tokenOut: string + amountIn: string + amountOut: string +} + +// TODO +export interface VoteActivity extends ActivityBase { + type: 'Vote' + account: string + tokenIn: string + choice: string + proposalId: string +} + +export type Activity = + | ApprovalActivity + | BridgeActivity + | ClaimRewardsActivity + | DelegateVoteActivity + | ExtendStakeActivity + | MigrateActivity + | StakeActivity + | UnstakeActivity + | TransferActivity + | SwapActivity + | WrapActivity + | UnwrapActivity + | MintActivity + | RedeemActivity + | ZapActivity + | VoteActivity diff --git a/src/templates/otoken/otoken.ts b/src/templates/otoken/otoken.ts index 2b7e891a..f0a8d674 100644 --- a/src/templates/otoken/otoken.ts +++ b/src/templates/otoken/otoken.ts @@ -1,6 +1,3 @@ -import { groupBy } from 'lodash' -import { GetTransactionReceiptReturnType } from 'viem' - import * as erc20 from '@abi/erc20' import * as otoken from '@abi/otoken' import * as otokenVault from '@abi/otoken-vault' @@ -19,12 +16,8 @@ import { } from '@model' import { Context } from '@processor' import { ensureExchangeRate } from '@shared/post-processors/exchange-rates' -import { - CurrencyAddress, - CurrencySymbol, -} from '@shared/post-processors/exchange-rates/currencies' +import { CurrencyAddress, CurrencySymbol } from '@shared/post-processors/exchange-rates/currencies' import { EvmBatchProcessor } from '@subsquid/evm-processor' -import { type Transaction, activityFromTx } from '@utils/activityFromTx' import { ADDRESS_ZERO } from '@utils/addresses' import { blockFrequencyUpdater } from '@utils/blockFrequencyUpdater' import { DECIMALS_18 } from '@utils/constants' @@ -33,35 +26,28 @@ import { getLatestEntity } from '@utils/utils' import { createAddress, createRebaseAPY } from './utils' -export const createOTokenSetup = - ({ - address, - wrappedAddress, - vaultAddress, - from, - upgrades, - }: { - address: string - wrappedAddress?: string - vaultAddress: string - from: number - upgrades?: { - rebaseOptEvents: number - } - }) => - (processor: EvmBatchProcessor) => { +export const createOTokenProcessor = (params: { + from: number + vaultFrom: number + Upgrade_CreditsBalanceOfHighRes?: number + otokenAddress: string + wotokenAddress?: string + otokenVaultAddress: string + oTokenAssets: { asset: CurrencyAddress; symbol: CurrencySymbol }[] + upgrades?: { + rebaseOptEvents: number + } +}) => { + const setup = (processor: EvmBatchProcessor) => { processor.addTrace({ type: ['call'], - callTo: [address], - callSighash: [ - otoken.functions.rebaseOptOut.selector, - otoken.functions.rebaseOptIn.selector, - ], + callTo: [params.otokenAddress], + callSighash: [otoken.functions.rebaseOptOut.selector, otoken.functions.rebaseOptIn.selector], transaction: true, - range: { from, to: upgrades?.rebaseOptEvents }, // First AccountRebasing appears on 18872285, on OETH + range: { from: params.from, to: params.upgrades?.rebaseOptEvents }, // First AccountRebasing appears on 18872285, on OETH }) processor.addLog({ - address: [address], + address: [params.otokenAddress], topic0: [ otoken.events.Transfer.topic, otoken.events.TotalSupplyUpdatedHighres.topic, @@ -69,31 +55,22 @@ export const createOTokenSetup = otoken.events.AccountRebasingDisabled.topic, ], transaction: true, - range: { from }, + range: { from: params.from }, }) - if (wrappedAddress) { + if (params.wotokenAddress) { processor.addLog({ - address: [wrappedAddress], + address: [params.wotokenAddress], topic0: [erc20.events.Transfer.topic], - range: { from }, + range: { from: params.from }, }) } processor.addLog({ - address: [vaultAddress], + address: [params.otokenVaultAddress], topic0: [otokenVault.events.YieldDistribution.topic], - range: { from }, + range: { from: params.from }, }) } -export const createOTokenProcessor = (params: { - from: number - vaultFrom: number - Upgrade_CreditsBalanceOfHighRes?: number - otokenAddress: string - wotokenAddress?: string - otokenVaultAddress: string - oTokenAssets: { asset: CurrencyAddress; symbol: CurrencySymbol }[] -}) => { interface ProcessResult { initialized: boolean initialize: () => Promise @@ -176,15 +153,10 @@ export const createOTokenProcessor = (params: { await processTotalSupplyUpdatedHighres(ctx, result, block, log) await processRebaseOptEvent(ctx, result, block, log) } - await processActivity(ctx, result, block) } await frequencyUpdate(ctx, async (ctx, block) => { - const vaultContract = new otokenVault.Contract( - ctx, - block.header, - params.otokenVaultAddress, - ) + const vaultContract = new otokenVault.Contract(ctx, block.header, params.otokenVaultAddress) result.vaults.push( new OTokenVault({ id: `${ctx.chain.id}-${params.otokenAddress}-${block.header.height}-${params.otokenVaultAddress}`, @@ -247,13 +219,8 @@ export const createOTokenProcessor = (params: { return entity } - const afterHighResUpgrade = - block.header.height >= (params.Upgrade_CreditsBalanceOfHighRes ?? 0) - const [ - addressSub, - addressAdd, - [fromCreditsBalanceOf, toCreditsBalanceOf], - ] = await Promise.all([ + const afterHighResUpgrade = block.header.height >= (params.Upgrade_CreditsBalanceOfHighRes ?? 0) + const [addressSub, addressAdd, [fromCreditsBalanceOf, toCreditsBalanceOf]] = await Promise.all([ ensureAddress(data.from), ensureAddress(data.to), multicall( @@ -261,8 +228,7 @@ export const createOTokenProcessor = (params: { block.header, afterHighResUpgrade ? otoken.functions.creditsBalanceOfHighres - : (otoken.functions - .creditsBalanceOf as unknown as typeof otoken.functions.creditsBalanceOfHighres), + : (otoken.functions.creditsBalanceOf as unknown as typeof otoken.functions.creditsBalanceOfHighres), params.otokenAddress, [{ _account: data.from }, { _account: data.to }], ).then((results) => { @@ -279,24 +245,15 @@ export const createOTokenProcessor = (params: { * "0017708038-000327-29fec:0xd2cdf18b60a5cdb634180d5615df7a58a597247c:Sent","0","49130257489166670","2023-07-16T19:50:11.000Z",17708038,"0x0e3ac28945d45993e3d8e1f716b6e9ec17bfc000418a1091a845b7a00c7e3280","Sent","0xd2cdf18b60a5cdb634180d5615df7a58a597247c", */ - const updateAddressBalance = ({ - address, - credits, - }: { - address: OTokenAddress - credits: [bigint, bigint] - }) => { + const updateAddressBalance = ({ address, credits }: { address: OTokenAddress; credits: [bigint, bigint] }) => { const newBalance = (credits[0] * DECIMALS_18) / credits[1] const change = newBalance - address.balance if (change === 0n) return - const type = - addressSub === address ? HistoryType.Sent : HistoryType.Received + const type = addressSub === address ? HistoryType.Sent : HistoryType.Received result.history.push( new OTokenHistory({ // we can't use {t.id} because it's not unique - id: getUniqueId( - `${ctx.chain.id}-${params.otokenAddress}-${log.id}-${address.address}`, - ), + id: getUniqueId(`${ctx.chain.id}-${params.otokenAddress}-${log.id}-${address.address}`), chainId: ctx.chain.id, otoken: params.otokenAddress, address: address, @@ -321,17 +278,11 @@ export const createOTokenProcessor = (params: { credits: toCreditsBalanceOf, }) - if ( - addressAdd.rebasingOption === RebasingOption.OptOut && - data.from === ADDRESS_ZERO - ) { + if (addressAdd.rebasingOption === RebasingOption.OptOut && data.from === ADDRESS_ZERO) { // If it's a mint and minter has opted out of rebasing, // add to non-rebasing supply otokenObject.nonRebasingSupply += data.value - } else if ( - data.to === ADDRESS_ZERO && - addressSub.rebasingOption === RebasingOption.OptOut - ) { + } else if (data.to === ADDRESS_ZERO && addressSub.rebasingOption === RebasingOption.OptOut) { // If it's a redeem and redeemer has opted out of rebasing, // subtract non-rebasing supply otokenObject.nonRebasingSupply -= data.value @@ -352,55 +303,7 @@ export const createOTokenProcessor = (params: { } // Update rebasing supply in all cases - otokenObject.rebasingSupply = - otokenObject.totalSupply - otokenObject.nonRebasingSupply - } - } - - const processActivity = async ( - ctx: Context, - result: ProcessResult, - block: Context['blocks']['0'], - ) => { - await result.initialize() - const logs = block.logs - const groupedLogs = groupBy(logs, (log) => log.transactionHash) - for (const [txHash, logs] of Object.entries(groupedLogs)) { - const log = logs.find((l) => l.address === params.otokenAddress) - const transaction = log?.transaction as unknown as Transaction - if (log && transaction) { - // We need to get the whole transaction receipt for all related logs. - // This shouldn't slow things down too much since it's only done for - // OToken transactions. - const txReceipt = await ctx._chain.client.call( - 'eth_getTransactionReceipt', - [log.transactionHash], - ) - - const activity = await activityFromTx( - transaction, - txReceipt.logs as unknown as GetTransactionReceiptReturnType['logs'], - ) - if (activity) { - for (const item of activity) { - result.activity.push( - new OTokenActivity({ - id: getUniqueId( - `${ctx.chain.id}-${params.otokenAddress}-${log.id}`, - ), - chainId: ctx.chain.id, - otoken: params.otokenAddress, - timestamp: new Date(block.header.timestamp), - blockNumber: block.header.height, - txHash: log.transactionHash, - address: transaction.to, - sighash: transaction.input.slice(0, 10), - ...item, - }), - ) - } - } - } + otokenObject.rebasingSupply = otokenObject.totalSupply - otokenObject.nonRebasingSupply } } @@ -419,8 +322,7 @@ export const createOTokenProcessor = (params: { // OToken Object const otokenObject = await getLatestOTokenObject(ctx, result, block) otokenObject.totalSupply = data.totalSupply - otokenObject.rebasingSupply = - otokenObject.totalSupply - otokenObject.nonRebasingSupply + otokenObject.rebasingSupply = otokenObject.totalSupply - otokenObject.nonRebasingSupply if (!result.lastYieldDistributionEvent) { throw new Error('lastYieldDistributionEvent is not set') @@ -444,22 +346,16 @@ export const createOTokenProcessor = (params: { ) for (const address of owners!.values()) { - if ( - !address.credits || - address.rebasingOption === RebasingOption.OptOut - ) { + if (!address.credits || address.rebasingOption === RebasingOption.OptOut) { continue } - const newBalance = - (address.credits * DECIMALS_18) / data.rebasingCreditsPerToken + const newBalance = (address.credits * DECIMALS_18) / data.rebasingCreditsPerToken const earned = newBalance - address.balance if (earned === 0n) continue result.history.push( new OTokenHistory({ - id: getUniqueId( - `${ctx.chain.id}-${params.otokenAddress}-${log.id}-${address.address}`, - ), + id: getUniqueId(`${ctx.chain.id}-${params.otokenAddress}-${log.id}-${address.address}`), // we can't use {t.id} because it's not unique chainId: ctx.chain.id, otoken: params.otokenAddress, @@ -503,8 +399,7 @@ export const createOTokenProcessor = (params: { if ( trace.type === 'call' && params.otokenAddress === trace.action.to && - (trace.action.sighash === - otoken.functions.governanceRebaseOptIn.selector || + (trace.action.sighash === otoken.functions.governanceRebaseOptIn.selector || trace.action.sighash === otoken.functions.rebaseOptIn.selector || trace.action.sighash === otoken.functions.rebaseOptOut.selector) ) { @@ -513,26 +408,17 @@ export const createOTokenProcessor = (params: { const blockNumber = block.header.height const address = trace.action.sighash === otoken.functions.governanceRebaseOptIn.selector - ? otoken.functions.governanceRebaseOptIn.decode(trace.action.input) - ._account + ? otoken.functions.governanceRebaseOptIn.decode(trace.action.input)._account : trace.action.from.toLowerCase() const otokenObject = await getLatestOTokenObject(ctx, result, block) let owner = owners!.get(address) if (!owner) { - owner = await createAddress( - ctx, - params.otokenAddress, - address, - timestamp, - ) + owner = await createAddress(ctx, params.otokenAddress, address, timestamp) owners!.set(address, owner) } const rebaseOption = new OTokenRebaseOption({ - id: getUniqueId( - `${ctx.chain.id}-${params.otokenAddress}-${trace.transaction - ?.hash!}-${owner.address}`, - ), + id: getUniqueId(`${ctx.chain.id}-${params.otokenAddress}-${trace.transaction?.hash!}-${owner.address}`), chainId: ctx.chain.id, otoken: params.otokenAddress, timestamp, @@ -543,41 +429,28 @@ export const createOTokenProcessor = (params: { }) result.rebaseOptions.push(rebaseOption) if (trace.action.sighash === otoken.functions.rebaseOptIn.selector) { - const afterHighResUpgrade = - block.header.height >= (params.Upgrade_CreditsBalanceOfHighRes ?? 0) - const otokenContract = new otoken.Contract( - ctx, - block.header, - params.otokenAddress, - ) + const afterHighResUpgrade = block.header.height >= (params.Upgrade_CreditsBalanceOfHighRes ?? 0) + const otokenContract = new otoken.Contract(ctx, block.header, params.otokenAddress) owner.credits = afterHighResUpgrade - ? await otokenContract - .creditsBalanceOfHighres(owner.address) - .then((c) => c._0) - : await otokenContract - .creditsBalanceOf(owner.address) - .then((c) => c._0 * 1000000000n) + ? await otokenContract.creditsBalanceOfHighres(owner.address).then((c) => c._0) + : await otokenContract.creditsBalanceOf(owner.address).then((c) => c._0 * 1000000000n) owner.rebasingOption = RebasingOption.OptIn rebaseOption.status = RebasingOption.OptIn otokenObject.nonRebasingSupply -= owner.balance - otokenObject.rebasingSupply = - otokenObject.totalSupply - otokenObject.nonRebasingSupply + otokenObject.rebasingSupply = otokenObject.totalSupply - otokenObject.nonRebasingSupply } if (trace.action.sighash === otoken.functions.rebaseOptOut.selector) { owner.rebasingOption = RebasingOption.OptOut rebaseOption.status = RebasingOption.OptOut otokenObject.nonRebasingSupply += owner.balance - otokenObject.rebasingSupply = - otokenObject.totalSupply - otokenObject.nonRebasingSupply + otokenObject.rebasingSupply = otokenObject.totalSupply - otokenObject.nonRebasingSupply } } } const rebaseEventTopics = { - [otoken.events.AccountRebasingEnabled.topic]: - otoken.events.AccountRebasingEnabled, - [otoken.events.AccountRebasingDisabled.topic]: - otoken.events.AccountRebasingDisabled, + [otoken.events.AccountRebasingEnabled.topic]: otoken.events.AccountRebasingEnabled, + [otoken.events.AccountRebasingDisabled.topic]: otoken.events.AccountRebasingDisabled, } const processRebaseOptEvent = async ( ctx: Context, @@ -595,21 +468,12 @@ export const createOTokenProcessor = (params: { const address = data.account.toLowerCase() let owner = owners!.get(address) if (!owner) { - owner = await createAddress( - ctx, - params.otokenAddress, - address, - timestamp, - ) + owner = await createAddress(ctx, params.otokenAddress, address, timestamp) owners!.set(address, owner) } const rebaseOption = new OTokenRebaseOption({ - id: getUniqueId( - `${ctx.chain.id}-${params.otokenAddress}-${log.transactionHash!}-${ - owner.address - }`, - ), + id: getUniqueId(`${ctx.chain.id}-${params.otokenAddress}-${log.transactionHash!}-${owner.address}`), chainId: ctx.chain.id, otoken: params.otokenAddress, timestamp, @@ -623,33 +487,24 @@ export const createOTokenProcessor = (params: { owner.rebasingOption = RebasingOption.OptIn rebaseOption.status = RebasingOption.OptIn otokenObject.nonRebasingSupply -= owner.balance - otokenObject.rebasingSupply = - otokenObject.totalSupply - otokenObject.nonRebasingSupply + otokenObject.rebasingSupply = otokenObject.totalSupply - otokenObject.nonRebasingSupply } if (log.topics[0] === otoken.events.AccountRebasingDisabled.topic) { owner.rebasingOption = RebasingOption.OptOut rebaseOption.status = RebasingOption.OptOut otokenObject.nonRebasingSupply += owner.balance - otokenObject.rebasingSupply = - otokenObject.totalSupply - otokenObject.nonRebasingSupply + otokenObject.rebasingSupply = otokenObject.totalSupply - otokenObject.nonRebasingSupply } } } - const getLatestOTokenObject = async ( - ctx: Context, - result: ProcessResult, - block: Context['blocks']['0'], - ) => { + const getLatestOTokenObject = async (ctx: Context, result: ProcessResult, block: Context['blocks']['0']) => { const timestamp = new Date(block.header.timestamp).toISOString() const otokenId = `${ctx.chain.id}-${params.otokenAddress}-${timestamp}` - const { latest, current } = await getLatestEntity( - ctx, - OToken, - result.otokens, - otokenId, - { chainId: ctx.chain.id, otoken: params.otokenAddress }, - ) + const { latest, current } = await getLatestEntity(ctx, OToken, result.otokens, otokenId, { + chainId: ctx.chain.id, + otoken: params.otokenAddress, + }) let otokenObject = current if (!otokenObject) { @@ -669,5 +524,5 @@ export const createOTokenProcessor = (params: { return otokenObject } - return process + return { from: params.from, setup, process } } diff --git a/src/utils/activityFromTx.ts b/src/utils/activityFromTx.ts index 3eaafdb1..1fec7e36 100644 --- a/src/utils/activityFromTx.ts +++ b/src/utils/activityFromTx.ts @@ -1,301 +1,76 @@ -import { compact } from 'lodash' -import { GetTransactionReceiptReturnType, decodeEventLog, parseAbi } from 'viem' - -import * as balancerVaultAbi from '@abi/balancer-vault.abi' -import * as curveLpAbi from '@abi/curve-lp-token.abi' -import * as oethAbi from '@abi/oeth.abi' -import * as oethVaultAbi from '@abi/otoken-vault.abi' - -import { - OETH_ADDRESS, - OETH_VAULT_ADDRESS, - OETH_ZAPPER_ADDRESS, -} from './addresses' - -const UniswapV3SwapAbi = parseAbi([ - 'event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick)', -]) -const GnosisSafeAbi = parseAbi([ - 'event ExecutionSuccess(bytes32 txHash, uint256 payment)', -]) -const WrappedOETHAbi = parseAbi([ - 'event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares)', - 'event Withdraw(address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares)', -]) - -const tryDecodeEventLog = (...params: Parameters) => { - try { - return decodeEventLog(...params) - } catch (err: unknown) { - return undefined - } -} - -export interface Transaction { - to: string - from: string - input: string - value: bigint -} - -type Transfer = { - eventName: string - args: { - from: string - to: string - value: bigint - } -} - -type NetTransfers = { - [address: string]: bigint -} - -export async function activityFromTx( - transaction: Transaction, - logs: GetTransactionReceiptReturnType['logs'], -) { - const activity = [] - if (!transaction) return - - const curveEvents = compact( - logs - .filter((l) => - addressEq(l.address, '0x94B17476A93b3262d87B9a326965D1E91f9c13E7'), - ) - .map((log) => - tryDecodeEventLog({ - abi: curveLpAbi.ABI_JSON, - data: log.data, - topics: log.topics, - }), - ), - ) - - const sansGnosisSafeEvents = logs.filter(({ data, topics }) => { - try { - decodeEventLog({ - abi: GnosisSafeAbi, - data, - topics, - strict: false, - }) - return false - } catch (e) { - return true - } - }) - - const oethEvents = compact( - logs - .filter((l) => l.address === OETH_ADDRESS) - .map((log) => { - return tryDecodeEventLog({ - abi: oethAbi.ABI_JSON, - data: log.data, - topics: log.topics, - }) - }), - ) - - const balancerVaultEvents = compact( - logs - .filter((l) => - addressEq(l.address, '0xBA12222222228d8Ba445958a75a0704d566BF2C8'), - ) - .map((log) => { - return tryDecodeEventLog({ - abi: balancerVaultAbi.ABI_JSON, - data: log.data, - topics: log.topics, - }) - }), - ) - - const oethVaultEvents = compact( - logs - .filter((l) => l.address === OETH_VAULT_ADDRESS) - .map((log) => { - return tryDecodeEventLog({ - abi: oethVaultAbi.ABI_JSON, - data: log.data, - topics: log.topics, - }) - }), - ) - - const woethEvents = compact( - logs - .filter((l) => - addressEq(l.address, '0xdcee70654261af21c44c093c300ed3bb97b78192'), - ) - .map(({ data, topics }) => - tryDecodeEventLog({ abi: WrappedOETHAbi, data, topics }), - ), - ) - - const oneInchEvents = logs.filter((l) => - addressEq(l.address, '0x1111111254eeb25477b68fb85ed929f73a960582'), - ) - const uniswapWethEvents = compact( - logs - .filter((l) => - addressEq(l.address, '0x52299416c469843f4e0d54688099966a6c7d720f'), - ) - .map((log) => - tryDecodeEventLog({ - abi: UniswapV3SwapAbi, - data: log.data, - topics: log.topics, - }), - ), - ) - - const frxEthOETHCurvePoolEvents = logs.filter((l) => - addressEq(l.address, '0xfa0bbb0a5815f6648241c9221027b70914dd8949'), - ) - - const oethTransfers = compact(oethEvents).filter( - (log) => log.eventName === 'Transfer', - ) as Transfer[] - - const netTransfers = oethTransfers.reduce( - (acc, { args: { from, to, value } }) => { - acc[from] = (acc[from] || 0n) - value - acc[to] = (acc[to] || 0n) + value - return acc - }, - {}, - ) - const nonZeroBalances: { [address: string]: bigint } = Object.keys( - netTransfers, - ).reduce( - (acc, key) => { - if (netTransfers[key] !== 0n) { - acc[key] = netTransfers[key] - } - return acc - }, - {} as { [address: string]: bigint }, - ) - - const sumPositiveBalances = (balances: { - [address: string]: bigint - }): bigint => { - return Object.values(balances).reduce((sum, value) => { - if (value > 0n) { - return sum + value - } - return sum - }, 0n) - } - - const totalPositiveBalance = sumPositiveBalances(nonZeroBalances) - - let data: - | { - callDataLast4Bytes?: string - exchange?: string - action?: string - fromSymbol?: string - toSymbol?: string - interface?: string - amount?: bigint - } - | undefined = {} - - data.callDataLast4Bytes = transaction?.input.slice(-8) - data.amount = totalPositiveBalance - - if (oethVaultEvents.some((e) => e.eventName === 'Redeem')) { - data.action = 'Redeem' - } else if ( - oethEvents.some((e) => e.eventName === 'TotalSupplyUpdatedHighres') - ) { - data.action = 'Rebase' - } - - if ( - addressEq(transaction.to, '0x1111111254EEB25477B68fb85Ed929f73A960582') || - oneInchEvents.length > 0 - ) { - data.action = 'Swap' - data.interface = '1inch' - } - if (addressEq(transaction.to, '0x9008d19f58aabd9ed0d60971565aa8510560ab41')) { - data.action = 'Swap' - data.exchange = 'CoW Swap' - } - if (addressEq(transaction.to, '0x6131b5fae19ea4f9d964eac0408e4408b66337b5')) { - data.action = 'Swap' - data.exchange = 'Kyber Swap' - } - - if (curveEvents.length > 0) { - data.action = 'Swap' - data.exchange = 'Curve' - } - if (frxEthOETHCurvePoolEvents.length > 0) { - data.action = 'Swap' - data.exchange = 'Curve' - } - if (balancerVaultEvents.length > 0) { - data.action = 'Swap' - data.exchange = 'Balancer' - } - - if (uniswapWethEvents.length > 0) { - data.action = 'Swap' - data.exchange = 'UniswapV3' - } - if (woethEvents.find((e) => e?.eventName === 'Deposit')) { - data.action = 'Wrap' - data.exchange = 'WOETH' - } else if (woethEvents.find((e) => e?.eventName === 'Withdraw')) { - data.action = 'Un-wrap' - data.exchange = 'WOETH' - } - - if ( - oethTransfers.some( - (t) => - addressEq(t.args.from, '0x9008d19f58aabd9ed0d60971565aa8510560ab41') || - addressEq(t.args.to, '0x9008d19f58aabd9ed0d60971565aa8510560ab41'), - ) - ) { - data.exchange = 'CoW Swap' - } else if ( - oethTransfers.some( - (t) => - addressEq(t.args.from, '0x94b17476a93b3262d87b9a326965d1e91f9c13e7') || - addressEq(t.args.to, '0x94b17476a93b3262d87b9a326965d1e91f9c13e7'), - ) - ) { - data.exchange = 'Curve' - } - if (oethTransfers.length === 1 && sansGnosisSafeEvents.length === 1) { - data.action = 'Transfer' - } - - if (transaction.to === OETH_ZAPPER_ADDRESS) { - data = decodeOethZapperTx(transaction) - } - - activity.push(data) - - return activity -} - -function decodeOethZapperTx(transaction: Transaction) { - return { - callDataLast4Bytes: transaction?.input.slice(-8), - exchange: 'OETHZapper', - action: 'Swap', - fromSymbol: 'ETH', - toSymbol: 'OETH', - } -} - -function addressEq(a: string | undefined, b: string | undefined) { - return a?.toLowerCase() === b?.toLowerCase() -} +// import { compact } from 'lodash' +// import { GetTransactionReceiptReturnType, decodeEventLog, parseAbi } from 'viem' +// +// import * as balancerVaultAbi from '@abi/balancer-vault.abi' +// import * as curveLp from '@abi/curve-lp-token' +// import * as curveLpAbi from '@abi/curve-lp-token.abi' +// import * as oethAbi from '@abi/oeth.abi' +// import * as oethVaultAbi from '@abi/otoken-vault.abi' +// import { Block, Context, Log } from '@processor' +// import { Activity, SwapActivity } from '@templates/otoken/activity-types' +// import { logFilter } from '@utils/logFilter' +// +// import { +// BALANCER_VAULT_ADDRESS, +// COWSWAP_SETTLEMENT_ADDRESS, +// CURVE_ETH_OETH_POOL_ADDRESS, +// CURVE_FRXETH_OETH_POOL_ADDRESS, +// OETH_ADDRESS, +// OETH_VAULT_ADDRESS, +// OETH_ZAPPER_ADDRESS, +// ONEINCH_AGGREGATION_ROUTER_ADDRESS, +// UNISWAP_OETH_WEH_ADDRESS, +// WOETH_ADDRESS, +// } from './addresses' +// +// const UniswapV3SwapAbi = parseAbi([ +// 'event Swap(address indexed sender, address indexed recipient, int256 amount0, int256 amount1, uint160 sqrtPriceX96, uint128 liquidity, int24 tick)', +// ]) +// const GnosisSafeAbi = parseAbi(['event ExecutionSuccess(bytes32 txHash, uint256 payment)']) +// const WrappedOETHAbi = parseAbi([ +// 'event Deposit(address indexed caller, address indexed owner, uint256 assets, uint256 shares)', +// 'event Withdraw(address indexed caller, address indexed receiver, address indexed owner, uint256 assets, uint256 shares)', +// ]) +// +// const tryDecodeEventLog = (...params: Parameters) => { +// try { +// return decodeEventLog(...params) +// } catch (err: unknown) { +// return undefined +// } +// } +// +// export interface Transaction { +// to: string +// from: string +// input: string +// value: bigint +// } +// +// type Transfer = { +// eventName: string +// args: { +// from: string +// to: string +// value: bigint +// } +// } +// +// type NetTransfers = { +// [address: string]: bigint +// } +// +// export async function activityFromTx(ctx: Context, block: Block, log: Log) { +// const sansGnosisSafeEvents = logs.filter(({ data, topics }) => { +// try { +// decodeEventLog({ +// abi: GnosisSafeAbi, +// data, +// topics, +// strict: false, +// }) +// return false +// } catch (e) { +// return true +// } +// }) diff --git a/src/utils/addresses.ts b/src/utils/addresses.ts index c033a9ea..479239f2 100644 --- a/src/utils/addresses.ts +++ b/src/utils/addresses.ts @@ -2,7 +2,11 @@ export const ADDRESS_ZERO = '0x0000000000000000000000000000000000000000' export const ETH_ADDRESS = '0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee' -export const CURVE_EXCHANGE_ADDRESS = `0x99a58482bd75cbab83b27ec03ca68ff489b5788f` +export const COWSWAP_SETTLEMENT_ADDRESS = '0x9008d19f58aabd9ed0d60971565aa8510560ab41' +export const ONEINCH_AGGREGATION_ROUTER_ADDRESS = '0x1111111254eeb25477b68fb85ed929f73a960582' +export const UNISWAP_V3_OETH_WEH_ADDRESS = '0x52299416c469843f4e0d54688099966a6c7d720f' +export const BALANCER_VAULT_ADDRESS = '0xba12222222228d8ba445958a75a0704d566bf2c8' +export const CURVE_FRXETH_OETH_POOL_ADDRESS = '0xfa0bbb0a5815f6648241c9221027b70914dd8949' export const OUSD_ADDRESS = '0x2a8e1e676ec238d8a992307b495b45b3feaa5e86' export const DAI_ADDRESS = '0x6b175474e89094c44da98b954eedeac495271d0f' @@ -40,10 +44,7 @@ export const OETH_VAULT_ERC20_ADDRESSES = [WETH_ADDRESS, STETH_ADDRESS, RETH_ADD export const OETH_CONVEX_ADDRESS = '0x1827f9ea98e0bf96550b2fc20f7233277fcd7e63' export const OETH_CURVE_REWARD_LP_ADDRESS = '0x24b65dc1cf053a8d96872c323d29e86ec43eb33a' -export const OETH_CURVE_LP_ADDRESS = '0x94b17476a93b3262d87b9a326965d1e91f9c13e7' - -// export const OETH_CURVE_LP_OWNER_ADDRESS = '0xd03be91b1932715709e18021734fcb91bb431715' -// export const CONVEX_DEPOSIT = '0xf403c135812408bfbe8713b5a23a04b3d48aae31' +export const CURVE_ETH_OETH_POOL_ADDRESS = '0x94b17476a93b3262d87b9a326965d1e91f9c13e7' export const OETH_FRAX_STAKING_ADDRESS = '0x3ff8654d633d4ea0fae24c52aec73b4a20d0d0e5' diff --git a/src/utils/logFilter.ts b/src/utils/logFilter.ts index 83b1df99..278203b5 100644 --- a/src/utils/logFilter.ts +++ b/src/utils/logFilter.ts @@ -10,9 +10,7 @@ const prepare = (hex: string) => pad(lower(hex)) /** * Helper to create and match logs, ensuring hex values are lowercase and properly padded. */ -export const logFilter = ( - filter: Parameters[0], -) => { +export const logFilter = (filter: Parameters[0]) => { filter = { address: filter.address?.map(lower), topic0: filter.topic0?.map(prepare), @@ -21,6 +19,8 @@ export const logFilter = ( topic3: filter.topic3?.map(prepare), range: filter.range, transaction: filter.transaction, + transactionLogs: filter.transactionLogs, + transactionTraces: filter.transactionTraces, } return { value: filter, @@ -42,8 +42,7 @@ export const logFilter = ( } if ( filter.range && - (log.block.height < filter.range.from || - (filter.range.to && log.block.height > filter.range.to)) + (log.block.height < filter.range.from || (filter.range.to && log.block.height > filter.range.to)) ) { return false } diff --git a/src/utils/state.ts b/src/utils/state.ts index 1f6305fe..6b99381c 100644 --- a/src/utils/state.ts +++ b/src/utils/state.ts @@ -15,6 +15,11 @@ export const useProcessorState = (ctx: Context, key: string, defaultValue?: T ] as const } +/** + * Not for continuously updating state within a single context. + * Use this to distribute state throughout processors one time. + * *Not for gradual/continuous update within the context.* + */ export const publishProcessorState = (ctx: Context, key: string, state: T) => { const [, setState] = useProcessorState(ctx, `waitForProcessorState:${key}`) const [listeners] = useProcessorState<((state: T) => void)[]>(ctx, `waitForProcessorState-listeners:${key}`, []) @@ -22,6 +27,9 @@ export const publishProcessorState = (ctx: Context, key: string, state: T) => listeners.forEach((listener) => listener(state)) } +/** + * Wait for processor state to be set and retrieve it. + */ export const waitForProcessorState = (ctx: Context, key: string) => { return new Promise((resolve) => { const [state] = useProcessorState(ctx, `waitForProcessorState:${key}`)