From 9c9c9e9714e042f8182bb73288b97e9941c0294a Mon Sep 17 00:00:00 2001 From: gs8nrv <55771972+GuillaumeNervoXS@users.noreply.github.com> Date: Thu, 25 Apr 2024 18:55:08 +0200 Subject: [PATCH] try to narrow down why event tests before upgrade fails --- src/abi/angle-transmuter/TransmuterOld.json | 1706 +++++++++++++++++ .../angle-transmuter-events.test.ts | 245 ++- .../angle-transmuter-integration.test.ts | 4 +- .../angle-transmuter/angle-transmuter-pool.ts | 34 +- src/dex/angle-transmuter/transmuter.ts | 69 +- 5 files changed, 1874 insertions(+), 184 deletions(-) create mode 100644 src/abi/angle-transmuter/TransmuterOld.json diff --git a/src/abi/angle-transmuter/TransmuterOld.json b/src/abi/angle-transmuter/TransmuterOld.json new file mode 100644 index 000000000..e5e1029ba --- /dev/null +++ b/src/abi/angle-transmuter/TransmuterOld.json @@ -0,0 +1,1706 @@ +[ + { + "type": "event", + "name": "Swap", + "inputs": [ + { + "name": "tokenIn", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "tokenOut", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "amountIn", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "amountOut", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Redeemed", + "inputs": [ + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "tokens", + "type": "address[]", + "indexed": false, + "internalType": "address[]" + }, + { + "name": "amounts", + "type": "uint256[]", + "indexed": false, + "internalType": "uint256[]" + }, + { + "name": "forfeitTokens", + "type": "address[]", + "indexed": false, + "internalType": "address[]" + }, + { + "name": "from", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "to", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "CollateralAdded", + "inputs": [ + { + "name": "collateral", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "CollateralManagerSet", + "inputs": [ + { + "name": "collateral", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "managerData", + "type": "tuple", + "indexed": false, + "internalType": "struct ManagerStorage", + "components": [ + { + "name": "subCollaterals", + "type": "address[]", + "internalType": "contract IERC20[]" + }, + { + "name": "config", + "type": "bytes", + "internalType": "bytes" + } + ] + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "CollateralRevoked", + "inputs": [ + { + "name": "collateral", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "CollateralWhitelistStatusUpdated", + "inputs": [ + { + "name": "collateral", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "whitelistData", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + }, + { + "name": "whitelistStatus", + "type": "uint8", + "indexed": false, + "internalType": "uint8" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "FeesSet", + "inputs": [ + { + "name": "collateral", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "xFee", + "type": "uint64[]", + "indexed": false, + "internalType": "uint64[]" + }, + { + "name": "yFee", + "type": "int64[]", + "indexed": false, + "internalType": "int64[]" + }, + { + "name": "mint", + "type": "bool", + "indexed": false, + "internalType": "bool" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OracleSet", + "inputs": [ + { + "name": "collateral", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "oracleConfig", + "type": "bytes", + "indexed": false, + "internalType": "bytes" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "OwnershipTransferred", + "inputs": [ + { + "name": "previousOwner", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "newOwner", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "PauseToggled", + "inputs": [ + { + "name": "collateral", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "pausedType", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "isPaused", + "type": "bool", + "indexed": false, + "internalType": "bool" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "RedemptionCurveParamsSet", + "inputs": [ + { + "name": "xFee", + "type": "uint64[]", + "indexed": false, + "internalType": "uint64[]" + }, + { + "name": "yFee", + "type": "int64[]", + "indexed": false, + "internalType": "int64[]" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "ReservesAdjusted", + "inputs": [ + { + "name": "collateral", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "amount", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "increase", + "type": "bool", + "indexed": false, + "internalType": "bool" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "TrustedToggled", + "inputs": [ + { + "name": "sender", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "isTrusted", + "type": "bool", + "indexed": false, + "internalType": "bool" + }, + { + "name": "trustedType", + "type": "uint8", + "indexed": false, + "internalType": "enum TrustedType" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "WhitelistStatusToggled", + "inputs": [ + { + "name": "whitelistType", + "type": "uint8", + "indexed": false, + "internalType": "enum WhitelistType" + }, + { + "name": "who", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "whitelistStatus", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "inputs": [], + "name": "accessControlManager", + "outputs": [ + { + "internalType": "contract IAccessControlManager", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "addCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "internalType": "bool", + "name": "increase", + "type": "bool" + } + ], + "name": "adjustStablecoins", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "agToken", + "outputs": [ + { + "internalType": "contract IAgToken", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "changeAllowance", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "enum FacetCutAction", + "name": "action", + "type": "uint8" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct FacetCut[]", + "name": "_diamondCut", + "type": "tuple[]" + }, + { + "internalType": "address", + "name": "_init", + "type": "address" + }, + { + "internalType": "bytes", + "name": "_calldata", + "type": "bytes" + } + ], + "name": "diamondCut", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "_functionSelector", + "type": "bytes4" + } + ], + "name": "facetAddress", + "outputs": [ + { + "internalType": "address", + "name": "facetAddress_", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facetAddresses", + "outputs": [ + { + "internalType": "address[]", + "name": "facetAddresses_", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_facet", + "type": "address" + } + ], + "name": "facetFunctionSelectors", + "outputs": [ + { + "internalType": "bytes4[]", + "name": "facetFunctionSelectors_", + "type": "bytes4[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "facets", + "outputs": [ + { + "components": [ + { + "internalType": "address", + "name": "facetAddress", + "type": "address" + }, + { + "internalType": "bytes4[]", + "name": "functionSelectors", + "type": "bytes4[]" + } + ], + "internalType": "struct Facet[]", + "name": "facets_", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "getCollateralBurnFees", + "outputs": [ + { + "internalType": "uint64[]", + "name": "xFeeBurn", + "type": "uint64[]" + }, + { + "internalType": "int64[]", + "name": "yFeeBurn", + "type": "int64[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "getCollateralDecimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "getCollateralInfo", + "outputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "isManaged", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "isMintLive", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "isBurnLive", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "decimals", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "onlyWhitelisted", + "type": "uint8" + }, + { + "internalType": "uint216", + "name": "normalizedStables", + "type": "uint216" + }, + { + "internalType": "uint64[]", + "name": "xFeeMint", + "type": "uint64[]" + }, + { + "internalType": "int64[]", + "name": "yFeeMint", + "type": "int64[]" + }, + { + "internalType": "uint64[]", + "name": "xFeeBurn", + "type": "uint64[]" + }, + { + "internalType": "int64[]", + "name": "yFeeBurn", + "type": "int64[]" + }, + { + "internalType": "bytes", + "name": "oracleConfig", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "whitelistData", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "contract IERC20[]", + "name": "subCollaterals", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "config", + "type": "bytes" + } + ], + "internalType": "struct ManagerStorage", + "name": "managerData", + "type": "tuple" + } + ], + "internalType": "struct Collateral", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCollateralList", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "getCollateralMintFees", + "outputs": [ + { + "internalType": "uint64[]", + "name": "xFeeMint", + "type": "uint64[]" + }, + { + "internalType": "int64[]", + "name": "yFeeMint", + "type": "int64[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCollateralRatio", + "outputs": [ + { + "internalType": "uint64", + "name": "collatRatio", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "stablecoinsIssued", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "getCollateralWhitelistData", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "getIssuedByCollateral", + "outputs": [ + { + "internalType": "uint256", + "name": "stablecoinsFromCollateral", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "stablecoinsIssued", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "getManagerData", + "outputs": [ + { + "internalType": "bool", + "name": "isManaged", + "type": "bool" + }, + { + "internalType": "contract IERC20[]", + "name": "subCollaterals", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "config", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "getOracle", + "outputs": [ + { + "internalType": "uint8", + "name": "oracleType", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "targetType", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "oracleData", + "type": "bytes" + }, + { + "internalType": "bytes", + "name": "targetData", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "getOracleValues", + "outputs": [ + { + "internalType": "uint256", + "name": "mint", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "burn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "ratio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minRatio", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "redemption", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRedemptionFees", + "outputs": [ + { + "internalType": "uint64[]", + "name": "xRedemptionCurve", + "type": "uint64[]" + }, + { + "internalType": "int64[]", + "name": "yRedemptionCurve", + "type": "int64[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTotalIssued", + "outputs": [ + { + "internalType": "uint256", + "name": "stablecoinsIssued", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "enum ActionType", + "name": "action", + "type": "uint8" + } + ], + "name": "isPaused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "isTrusted", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "isTrustedSeller", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + } + ], + "name": "isValidSelector", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "isWhitelistedCollateral", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "isWhitelistedForCollateral", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "enum WhitelistType", + "name": "whitelistType", + "type": "uint8" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "isWhitelistedForType", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + } + ], + "name": "quoteIn", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + } + ], + "name": "quoteOut", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "quoteRedemptionCurve", + "outputs": [ + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "recoverERC20", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "minAmountOuts", + "type": "uint256[]" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "receiver", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "minAmountOuts", + "type": "uint256[]" + }, + { + "internalType": "address[]", + "name": "forfeitTokens", + "type": "address[]" + } + ], + "name": "redeemWithForfeit", + "outputs": [ + { + "internalType": "address[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "amounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + } + ], + "name": "revokeCollateral", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "minAmountOut", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "payload", + "type": "bytes" + } + ], + "name": "sellRewards", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newAccessControlManager", + "type": "address" + } + ], + "name": "setAccessControlManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "components": [ + { + "internalType": "contract IERC20[]", + "name": "subCollaterals", + "type": "address[]" + }, + { + "internalType": "bytes", + "name": "config", + "type": "bytes" + } + ], + "internalType": "struct ManagerStorage", + "name": "managerData", + "type": "tuple" + } + ], + "name": "setCollateralManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "uint64[]", + "name": "xFee", + "type": "uint64[]" + }, + { + "internalType": "int64[]", + "name": "yFee", + "type": "int64[]" + }, + { + "internalType": "bool", + "name": "mint", + "type": "bool" + } + ], + "name": "setFees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "bytes", + "name": "oracleConfig", + "type": "bytes" + } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint64[]", + "name": "xFee", + "type": "uint64[]" + }, + { + "internalType": "int64[]", + "name": "yFee", + "type": "int64[]" + } + ], + "name": "setRedemptionCurveParams", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "uint8", + "name": "whitelistStatus", + "type": "uint8" + }, + { + "internalType": "bytes", + "name": "whitelistData", + "type": "bytes" + } + ], + "name": "setWhitelistStatus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swapExactInput", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountOutMin", + "type": "uint256" + }, + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permitData", + "type": "bytes" + } + ], + "name": "swapExactInputWithPermit", + "outputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountInMax", + "type": "uint256" + }, + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + } + ], + "name": "swapExactOutput", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amountOut", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amountInMax", + "type": "uint256" + }, + { + "internalType": "address", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "permitData", + "type": "bytes" + } + ], + "name": "swapExactOutputWithPermit", + "outputs": [ + { + "internalType": "uint256", + "name": "amountIn", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "collateral", + "type": "address" + }, + { + "internalType": "uint8", + "name": "pausedType", + "type": "uint8" + } + ], + "name": "togglePause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "enum TrustedType", + "name": "t", + "type": "uint8" + } + ], + "name": "toggleTrusted", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "type": "function", + "name": "updateOracle", + "inputs": [ + { + "name": "collateral", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "inputs": [ + { + "internalType": "enum WhitelistType", + "name": "whitelistType", + "type": "uint8" + }, + { + "internalType": "address", + "name": "who", + "type": "address" + } + ], + "name": "toggleWhitelist", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "increase", + "type": "bool" + } + ], + "name": "updateNormalizer", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/dex/angle-transmuter/angle-transmuter-events.test.ts b/src/dex/angle-transmuter/angle-transmuter-events.test.ts index 8a35b8656..7d2836aaf 100644 --- a/src/dex/angle-transmuter/angle-transmuter-events.test.ts +++ b/src/dex/angle-transmuter/angle-transmuter-events.test.ts @@ -41,9 +41,8 @@ describe('AngleTransmuter EventPool Mainnet', () => { RedemptionCurveParamsSet: [], OracleSet: [], Swap: [ - 19582703, 19583592, 19584048, 19589408, 19602964, 19607526, 19611131, - 19614332, 19616567, 19623965, 19625332, 19631246, 19631653, 19633515, - 19638468, 19648373, 19653214, 19656178, 19657413, 19667310, 19667763, + 19582703, 19584048, 19589408, 19602964, 19607526, 19614332, 19623965, + 19625332, 19631653, 19633515, 19638468, 19667763, ], Redeemed: [], ReservesAdjusted: [], @@ -81,110 +80,92 @@ describe('AngleTransmuter EventPool Mainnet', () => { const eventsToTestUSD: Record = { //Transmuter Events '0x222222fD79264BBE280b4986F6FEfBC3524d0137': { - // FeesSet: [19539192, 19539193, 19539198, 19539199], - RedemptionCurveParamsSet: [], + // FeesSet: [ + // 19539192, + // 19539193, 19539198, 19539199 + // ], + // RedemptionCurveParamsSet: [], // OracleSet: [19539189, 19539191, 19539197], - // Swap: [ - // 19609442, 19609442, 19612088, 19612720, 19612970, 19613233, - // 19613417, 19613466, 19614093, 19615163, 19615653, 19616187, - // 19616247, 19616257, 19616459, 19616597, 19616723, 19616850, - // 19616966, 19616990, 19617295, 19617327, 19617327, 19617335, - // 19617394, 19617406, 19617508, 19617521, 19617543, 19618077, - // 19618185, 19618395, 19619660, 19619853, 19620424, 19620631, - // 19620917, 19620950, 19621140, 19621187, 19621308, 19622224, - // 19622628, 19622951, 19622974, 19623084, 19623835, 19624153, - // 19624153, 19624236, 19624376, 19624955, 19625166, 19625524, - // 19625679, 19627173, 19627831, 19628073, 19628437, 19629497, - // 19630262, 19630452, 19630453, 19630569, 19630846, 19630998, - // 19631045, 19631072, 19631089, 19631246, 19631277, 19631526, - // 19631561, 19631603, 19631653, 19631772, 19631838, 19632250, - // 19633153, 19633215, 19633259, 19633531, 19633556, 19633605, - // 19634664, 19634767, 19635043, 19635866, 19636522, 19636596, - // 19637181, 19637803, 19637913, 19638541, 19639245, 19639420, - // 19639420, 19639995, 19640181, 19640895, - // ], - Redeemed: [], - ReservesAdjusted: [], + Swap: [ + 19609442, 19609442, 19612088, 19612720, 19612970, 19613233, 19613417, + 19613466, 19614093, 19615163, 19615653, 19616187, 19616247, 19616257, + 19616459, 19616597, 19616723, 19616850, 19616966, 19616990, 19617295, + 19617327, 19617327, 19617335, 19617394, 19617406, 19617508, 19617521, + 19617543, 19618077, 19618185, 19618395, 19619660, 19619853, 19620424, + 19620631, 19620917, 19620950, 19621140, 19621187, 19621308, 19622224, + 19622628, 19622951, 19622974, 19623084, 19623835, 19624153, 19624153, + 19624236, 19624376, 19624955, 19625166, 19625524, 19625679, 19627173, + 19627831, 19628073, 19628437, 19629497, 19630262, 19630452, 19630453, + 19630569, 19630846, 19630998, 19631045, 19631072, 19631089, 19631277, + 19631526, 19631561, 19631603, 19631653, 19631772, 19631838, 19632250, + 19633153, 19633215, 19633259, 19633531, 19633556, 19633605, 19634664, + 19634767, 19635043, 19635866, 19636522, 19636596, 19637181, 19637803, + 19637913, 19638541, 19639245, 19639420, 19639420, 19639995, 19640181, + 19640895, + ], + // Redeemed: [], + // ReservesAdjusted: [], // CollateralAdded: [19539190, 19539196], - CollateralRevoked: [], + // CollateralRevoked: [], // CollateralWhitelistStatusUpdated: [19539202], - WhitelistStatusToggled: [], + // WhitelistStatusToggled: [], + }, + // Chainlink + '0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6': { + AnswerUpdated: [ + 19573923, 19581071, 19588215, 19595354, 19602491, 19609623, 19616758, + 19623902, 19631050, 19638196, 19645326, 19652441, 19659587, 19666715, + 19673861, 19681014, 19688159, 19695297, 19702450, 19709605, 19716765, + ], + }, + '0x32d1463EB53b73C095625719Afa544D5426354cB': { + AnswerUpdated: [ + 19574020, 19581171, 19588315, 19595453, 19602589, 19609722, 19616859, + 19623999, 19631149, 19638297, 19645426, 19652545, 19652547, 19659686, + 19666816, 19673959, 19681115, 19688255, 19695398, 19702554, 19709707, + 19716863, + ], + }, + // Morpho + '0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB': { + UpdateLastTotalAssets: [ + 19581667, 19582915, 19585628, 19587407, 19588157, 19588208, 19590069, + 19590733, 19590797, 19592697, 19593362, 19593473, 19594011, 19595306, + 19596519, 19597364, 19599063, 19599206, 19602087, 19602936, 19603096, + 19603429, 19608399, 19608426, 19610964, 19612913, 19617893, 19618624, + 19619754, 19620051, 19621535, 19623267, 19624153, 19624164, 19629126, + 19630421, 19630643, 19630671, 19631025, 19633145, 19637639, 19638537, + 19638655, 19639050, 19639147, 19639164, 19639420, 19641771, 19642216, + 19643013, 19644465, 19646888, 19648977, 19649555, 19649742, 19651107, + 19651169, 19651577, 19652313, 19652647, 19657982, 19660275, 19662862, + 19667407, 19669210, 19669302, 19670406, 19674048, 19676127, 19677576, + 19680251, 19680544, 19681017, 19682815, 19689659, 19689880, 19692533, + 19697311, 19697903, 19698704, 19698867, 19701099, 19701428, 19702068, + 19703302, 19703569, 19704999, 19705931, 19705954, 19706402, 19706567, + 19708213, 19708713, 19708727, 19712712, 19713229, 19714392, 19720091, + 19720560, 19722127, + ], + Deposit: [ + 19582915, 19587407, 19588157, 19588208, 19590797, 19592697, 19593362, + 19594011, 19599063, 19602087, 19603096, 19610964, 19612913, 19618624, + 19620051, 19624153, 19629126, 19630421, 19630643, 19630671, 19633145, + 19638537, 19638655, 19639050, 19639147, 19639420, 19652647, 19657982, + 19660275, 19670406, 19674048, 19677576, 19689880, 19692533, 19697311, + 19697903, 19698704, 19698867, 19701099, 19701428, 19702068, 19703302, + 19703569, 19705931, 19705954, 19706402, 19706567, 19708213, 19708713, + 19708727, 19713229, 19714392, 19720091, 19720560, 19722127, 19723842, + 19724873, 19724886, 19727258, 19727832, 19727836, 19727900, + ], + Withdraw: [ + 19581667, 19585628, 19590069, 19590733, 19593473, 19595306, 19596519, + 19597364, 19599206, 19602936, 19603429, 19608399, 19608426, 19617893, + 19619754, 19621535, 19623267, 19624164, 19631025, 19637639, 19639164, + 19641771, 19642216, 19643013, 19644465, 19646888, 19648977, 19649555, + 19649742, 19651107, 19651169, 19651577, 19652313, 19662862, 19667407, + 19669210, 19669302, 19676127, 19680251, 19680544, 19681017, 19682815, + 19689659, 19704999, 19712712, 19723728, + ], }, - // // Chainlink - // '0x8fFfFfd4AfB6115b954Bd326cbe7B4BA576818f6': { - // AnswerUpdated: [ - // 19573923, 19581071, 19588215, - // 19595354, 19602491, 19609623, - // 19616758, 19623902, 19631050, - // 19638196, 19645326, 19652441, - // 19659587, 19666715, 19673861, - // 19681014, 19688159, 19695297, - // 19702450, 19709605, 19716765 - // ], - // }, - // '0x32d1463EB53b73C095625719Afa544D5426354cB': { - // AnswerUpdated: [ - // 19574020, 19581171, - // 19588315, 19595453, 19602589, - // 19609722, 19616859, 19623999, - // 19631149, 19638297, 19645426, - // 19652545, 19652547, 19659686, - // 19666816, 19673959, 19681115, - // 19688255, 19695398, 19702554, - // 19709707, 19716863 - // ], - // }, - // // Morpho - // '0xBEEF01735c132Ada46AA9aA4c54623cAA92A64CB':{ - // UpdateLastTotalAssets: [ - // 19581667, 19582915, 19585628, 19587407, 19588157, 19588208, - // 19590069, 19590733, 19590797, 19592697, 19593362, 19593473, - // 19594011, 19595306, 19596519, 19597364, 19599063, 19599206, - // 19602087, 19602936, 19603096, 19603429, 19608399, 19608426, - // 19610964, 19612913, 19617893, 19618624, 19619754, 19620051, - // 19621535, 19623267, 19624153, 19624164, 19629126, 19630421, - // 19630643, 19630671, 19631025, 19633145, 19637639, 19638537, - // 19638655, 19639050, 19639147, 19639164, 19639420, 19641771, - // 19642216, 19643013, 19644465, 19646888, 19648977, 19649555, - // 19649742, 19651107, 19651169, 19651577, 19652313, 19652647, - // 19657982, 19660275, 19662862, 19667407, 19669210, 19669302, - // 19670406, 19674048, 19676127, 19677576, 19680251, 19680544, - // 19681017, 19682815, 19689659, 19689880, 19692533, 19697311, - // 19697903, 19698704, 19698867, 19701099, 19701428, 19702068, - // 19703302, 19703569, 19704999, 19705931, 19705954, 19706402, - // 19706567, 19708213, 19708713, 19708727, 19712712, 19713229, - // 19714392, 19720091, 19720560, 19722127, - // ], - // Deposit: [ - // 19582915, 19587407, 19588157, 19588208, 19590797, - // 19592697, 19593362, 19594011, 19599063, 19602087, - // 19603096, 19610964, 19612913, 19618624, 19620051, - // 19624153, 19629126, 19630421, 19630643, 19630671, - // 19633145, 19638537, 19638655, 19639050, 19639147, - // 19639420, 19652647, 19657982, 19660275, 19670406, - // 19674048, 19677576, 19689880, 19692533, 19697311, - // 19697903, 19698704, 19698867, 19701099, 19701428, - // 19702068, 19703302, 19703569, 19705931, 19705954, - // 19706402, 19706567, 19708213, 19708713, 19708727, - // 19713229, 19714392, 19720091, 19720560, 19722127, - // 19723842, 19724873, 19724886, 19727258, 19727832, - // 19727836, 19727900 - // ], - // Withdraw: [ - // 19581667, 19585628, 19590069, 19590733, - // 19593473, 19595306, 19596519, 19597364, - // 19599206, 19602936, 19603429, 19608399, - // 19608426, 19617893, 19619754, 19621535, - // 19623267, 19624164, 19631025, 19637639, - // 19639164, 19641771, 19642216, 19643013, - // 19644465, 19646888, 19648977, 19649555, - // 19649742, 19651107, 19651169, 19651577, - // 19652313, 19662862, 19667407, 19669210, - // 19669302, 19676127, 19680251, 19680544, - // 19681017, 19682815, 19689659, 19704999, - // 19712712, 19723728 - // ], - // } }; beforeEach(async () => { @@ -197,35 +178,35 @@ describe('AngleTransmuter EventPool Mainnet', () => { ); }); - // Object.entries(eventsToTestEUR).forEach( - // ([poolAddress, events]: [string, EventMappings]) => { - // describe(`Events for ${poolAddress}`, () => { - // Object.entries(events).forEach( - // ([eventName, blockNumbers]: [string, number[]]) => { - // describe(`${eventName}`, () => { - // blockNumbers.forEach((blockNumber: number) => { - // it(`State after ${blockNumber}`, async () => { - // await testEventSubscriber( - // angleTransmuterPool, - // angleTransmuterPool.addressesSubscribed, - // (_blockNumber: number) => - // fetchPoolState( - // angleTransmuterPool, - // _blockNumber, - // poolAddress, - // ), - // blockNumber, - // `${dexKey}_${poolAddress}`, - // dexHelper.provider, - // ); - // }); - // }); - // }); - // }, - // ); - // }); - // }, - // ); + Object.entries(eventsToTestEUR).forEach( + ([poolAddress, events]: [string, EventMappings]) => { + describe(`Events for ${poolAddress}`, () => { + Object.entries(events).forEach( + ([eventName, blockNumbers]: [string, number[]]) => { + describe(`${eventName}`, () => { + blockNumbers.forEach((blockNumber: number) => { + it(`State after ${blockNumber}`, async () => { + await testEventSubscriber( + angleTransmuterPool, + angleTransmuterPool.addressesSubscribed, + (_blockNumber: number) => + fetchPoolState( + angleTransmuterPool, + _blockNumber, + poolAddress, + ), + blockNumber, + `${dexKey}_${poolAddress}`, + dexHelper.provider, + ); + }); + }); + }); + }, + ); + }); + }, + ); Object.entries(eventsToTestUSD).forEach( ([poolAddress, events]: [string, EventMappings]) => { diff --git a/src/dex/angle-transmuter/angle-transmuter-integration.test.ts b/src/dex/angle-transmuter/angle-transmuter-integration.test.ts index 6fc6c9b32..b31ebbfa4 100644 --- a/src/dex/angle-transmuter/angle-transmuter-integration.test.ts +++ b/src/dex/angle-transmuter/angle-transmuter-integration.test.ts @@ -13,9 +13,9 @@ import { checkConstantPoolPrices, } from '../../../tests/utils'; import { Tokens } from '../../../tests/constants-e2e'; -import { AngleTransmuterEventPool } from './angle-transmuter-pool'; import { Address } from '../../types'; import { SmartTokenParams } from '../../../tests/smart-tokens'; +import { TransmuterSubscriber } from './transmuter'; export type Collateral = { [stablecoin: string]: SmartTokenParams[] }; @@ -86,7 +86,7 @@ async function checkOnChainPricing( tokenOut: Address, ) { const exchangeAddress = getExchangeAddress(network, tokenIn, tokenOut); - const readerIface = AngleTransmuterEventPool.angleTransmuterIface; + const readerIface = TransmuterSubscriber.getTransmuterInterface(blockNumber); const readerCallData = getReaderCalldata( exchangeAddress, diff --git a/src/dex/angle-transmuter/angle-transmuter-pool.ts b/src/dex/angle-transmuter/angle-transmuter-pool.ts index 4d28f95a4..7609064c0 100644 --- a/src/dex/angle-transmuter/angle-transmuter-pool.ts +++ b/src/dex/angle-transmuter/angle-transmuter-pool.ts @@ -20,7 +20,6 @@ import { TransmuterParams, TransmuterState, } from './types'; -import TransmuterABI from '../../abi/angle-transmuter/Transmuter.json'; import { Contract } from 'web3-eth-contract'; import { TransmuterSubscriber } from './transmuter'; import { PythSubscriber } from './pyth'; @@ -47,8 +46,6 @@ import { bigIntify } from '../../utils'; import { MorphoVaultSubscriber } from './morphoVault'; export class AngleTransmuterEventPool extends ComposedEventSubscriber { - public transmuter: Contract; - static angleTransmuterIface = new Interface(TransmuterABI); readonly config: PoolConfig; constructor( @@ -172,12 +169,6 @@ export class AngleTransmuterEventPool extends ComposedEventSubscriber oracles: { chainlink: {}, pyth: {}, morphoVault: {} }, }, ); - - this.transmuter = new this.dexHelper.web3Provider.eth.Contract( - TransmuterABI as any, - config.transmuter, - ); - this.config = config; } @@ -268,24 +259,23 @@ export class AngleTransmuterEventPool extends ComposedEventSubscriber blockNumber: number | 'latest', multiContract: Contract, ) { + const transmuterInterface = + TransmuterSubscriber.getTransmuterInterface(blockNumber); const tokensResult = ( await multiContract.methods .aggregate([ { target: transmuterAddress, callData: - TransmuterSubscriber.interface.encodeFunctionData( - 'getCollateralList', - ), + transmuterInterface.encodeFunctionData('getCollateralList'), }, ]) .call({}, blockNumber) ).returnData; - const tokens: Address[] = - TransmuterSubscriber.interface.decodeFunctionResult( - 'getCollateralList', - tokensResult[0], - )[0]; + const tokens: Address[] = transmuterInterface.decodeFunctionResult( + 'getCollateralList', + tokensResult[0], + )[0]; // .map((t: any) => t.toLowerCase()); return tokens; } @@ -458,12 +448,11 @@ export class AngleTransmuterEventPool extends ComposedEventSubscriber blockNumber: number | 'latest', multiContract: Contract, ) { + const transmuterInterface = + TransmuterSubscriber.getTransmuterInterface(blockNumber); const getOracleConfigData = collaterals.map(collat => { return { - callData: TransmuterSubscriber.interface.encodeFunctionData( - 'getOracle', - [collat], - ), + callData: transmuterInterface.encodeFunctionData('getOracle', [collat]), target: transmuterAddress, }; }); @@ -474,8 +463,7 @@ export class AngleTransmuterEventPool extends ComposedEventSubscriber ).returnData; const oracleConfigs: DecodedOracleConfig[] = oracleConfigResult.map( - (p: any) => - TransmuterSubscriber.interface.decodeFunctionResult('getOracle', p), + (p: any) => transmuterInterface.decodeFunctionResult('getOracle', p), ); let chainlinkMap: ChainlinkConfig = {} as ChainlinkConfig; diff --git a/src/dex/angle-transmuter/transmuter.ts b/src/dex/angle-transmuter/transmuter.ts index 8ccccbc83..0217de8dd 100644 --- a/src/dex/angle-transmuter/transmuter.ts +++ b/src/dex/angle-transmuter/transmuter.ts @@ -12,6 +12,7 @@ import { BLOCK_UPGRADE_ORACLE, CBETH, RETH, SFRXETH, STETH } from './constants'; import { Lens } from '../../lens'; import { Interface } from '@ethersproject/abi'; import TransmuterABI from '../../abi/angle-transmuter/Transmuter.json'; +import TransmuterOldABI from '../../abi/angle-transmuter/TransmuterOld.json'; import { DecodedOracleConfig, Chainlink, @@ -35,6 +36,7 @@ export class TransmuterSubscriber extends PartialEventSubscriber< TransmuterState > { static readonly interface = new Interface(TransmuterABI); + static readonly interfaceOld = new Interface(TransmuterOldABI); constructor( private EURA: Address, @@ -46,13 +48,26 @@ export class TransmuterSubscriber extends PartialEventSubscriber< super([transmuter], lens, logger); } + static getTransmuterInterface(blockNumber?: number | 'latest'): Interface { + const processBlockNumber = + !blockNumber || blockNumber === 'latest' + ? BLOCK_UPGRADE_ORACLE + 1 + : blockNumber; + return processBlockNumber >= BLOCK_UPGRADE_ORACLE + ? TransmuterSubscriber.interface + : TransmuterSubscriber.interfaceOld; + } + public processLog( state: DeepReadonly, log: Readonly, blockHeader: Readonly, ): DeepReadonly | null { try { - const parsed = TransmuterSubscriber.interface.parseLog(log); + const transmuterInterface = TransmuterSubscriber.getTransmuterInterface( + blockHeader.number, + ); + const parsed = transmuterInterface.parseLog(log); const _state: TransmuterState = _.cloneDeep(state) as TransmuterState; switch (parsed.name) { case 'FeesSet': @@ -85,68 +100,67 @@ export class TransmuterSubscriber extends PartialEventSubscriber< } public getGenerateStateMultiCallInputs(): MultiCallInput[] { - return [ + const transmuterInterface = + TransmuterSubscriber.getTransmuterInterface(undefined); + const multicall = [ ...this.collaterals.map(collat => ({ target: this.transmuter, - callData: TransmuterSubscriber.interface.encodeFunctionData( + callData: transmuterInterface.encodeFunctionData( 'getIssuedByCollateral', [collat], ), })), ...this.collaterals.map(collat => ({ target: this.transmuter, - callData: TransmuterSubscriber.interface.encodeFunctionData( - 'getOracle', - [collat], - ), + callData: transmuterInterface.encodeFunctionData('getOracle', [collat]), })), ...this.collaterals.map(collat => ({ target: this.transmuter, - callData: TransmuterSubscriber.interface.encodeFunctionData( + callData: transmuterInterface.encodeFunctionData( 'getCollateralMintFees', [collat], ), })), ...this.collaterals.map(collat => ({ target: this.transmuter, - callData: TransmuterSubscriber.interface.encodeFunctionData( + callData: transmuterInterface.encodeFunctionData( 'getCollateralBurnFees', [collat], ), })), ...this.collaterals.map(collat => ({ target: this.transmuter, - callData: TransmuterSubscriber.interface.encodeFunctionData( + callData: transmuterInterface.encodeFunctionData( 'isWhitelistedCollateral', [collat], ), })), ...this.collaterals.map(collat => ({ target: this.transmuter, - callData: TransmuterSubscriber.interface.encodeFunctionData( + callData: transmuterInterface.encodeFunctionData( 'getCollateralWhitelistData', [collat], ), })), { target: this.transmuter, - callData: - TransmuterSubscriber.interface.encodeFunctionData( - 'getRedemptionFees', - ), + callData: transmuterInterface.encodeFunctionData('getRedemptionFees'), }, { target: this.transmuter, - callData: - TransmuterSubscriber.interface.encodeFunctionData('getTotalIssued'), + callData: transmuterInterface.encodeFunctionData('getTotalIssued'), }, ]; + + return multicall; } public generateState( multicallOutputs: MultiCallOutput[], blockNumber?: number | 'latest', ): DeepReadonly { + const transmuterInterface = + TransmuterSubscriber.getTransmuterInterface(blockNumber); const transmuterState = { collaterals: {} as { [token: string]: CollateralState; @@ -173,25 +187,25 @@ export class TransmuterSubscriber extends PartialEventSubscriber< (transmuterState.collaterals[collat] = { fees: { xFeeMint: ( - TransmuterSubscriber.interface.decodeFunctionResult( + transmuterInterface.decodeFunctionResult( 'getCollateralMintFees', multicallOutputs[indexMintFees * nbrCollaterals + i], )[0] as BigNumber[] ).map(f => Number.parseFloat(formatUnits(f, 9))), yFeeMint: ( - TransmuterSubscriber.interface.decodeFunctionResult( + transmuterInterface.decodeFunctionResult( 'getCollateralMintFees', multicallOutputs[indexMintFees * nbrCollaterals + i], )[1] as BigNumber[] ).map(f => Number.parseFloat(formatUnits(f, 9))), xFeeBurn: ( - TransmuterSubscriber.interface.decodeFunctionResult( + transmuterInterface.decodeFunctionResult( 'getCollateralBurnFees', multicallOutputs[indexBurnFees * nbrCollaterals + i], )[0] as BigNumber[] ).map(f => Number.parseFloat(formatUnits(f, 9))), yFeeBurn: ( - TransmuterSubscriber.interface.decodeFunctionResult( + transmuterInterface.decodeFunctionResult( 'getCollateralBurnFees', multicallOutputs[indexBurnFees * nbrCollaterals + i], )[1] as BigNumber[] @@ -199,13 +213,14 @@ export class TransmuterSubscriber extends PartialEventSubscriber< } as Fees, stablecoinsIssued: Number.parseFloat( formatUnits( - TransmuterSubscriber.interface.decodeFunctionResult( + transmuterInterface.decodeFunctionResult( 'getIssuedByCollateral', multicallOutputs[indexStableIssued * nbrCollaterals + i], )[0], 18, ), ), + // config: {} as Oracle, config: this._setOracleConfig( multicallOutputs[indexOracleFees * nbrCollaterals + i], blockNumber === undefined || blockNumber === 'latest' @@ -213,11 +228,11 @@ export class TransmuterSubscriber extends PartialEventSubscriber< : blockNumber, ), whitelist: { - status: TransmuterSubscriber.interface.decodeFunctionResult( + status: transmuterInterface.decodeFunctionResult( 'isWhitelistedCollateral', multicallOutputs[indexWhitelistStatus * nbrCollaterals + i], )[0] as boolean, - data: TransmuterSubscriber.interface.decodeFunctionResult( + data: transmuterInterface.decodeFunctionResult( 'getCollateralWhitelistData', multicallOutputs[indexWhitelistData * nbrCollaterals + i], )[0] as string, @@ -225,20 +240,20 @@ export class TransmuterSubscriber extends PartialEventSubscriber< }), ); transmuterState.xRedemptionCurve = ( - TransmuterSubscriber.interface.decodeFunctionResult( + transmuterInterface.decodeFunctionResult( 'getRedemptionFees', multicallOutputs[multicallOutputs.length - 2], )[0] as BigNumber[] ).map(f => Number.parseFloat(formatUnits(f, 9))); transmuterState.yRedemptionCurve = ( - TransmuterSubscriber.interface.decodeFunctionResult( + transmuterInterface.decodeFunctionResult( 'getRedemptionFees', multicallOutputs[multicallOutputs.length - 2], )[1] as BigNumber[] ).map(f => Number.parseFloat(formatUnits(f, 9))); transmuterState.totalStablecoinIssued = Number.parseFloat( formatUnits( - TransmuterSubscriber.interface.decodeFunctionResult( + transmuterInterface.decodeFunctionResult( 'getTotalIssued', multicallOutputs[multicallOutputs.length - 1], )[0],