From 775dc46000cdcae9126e724c6e3818e5c6f618b8 Mon Sep 17 00:00:00 2001 From: Josh Guha Date: Wed, 22 Nov 2023 11:51:28 +0000 Subject: [PATCH 1/4] Add Gyro2V2 pool --- abis/Gyro2V2Pool.json | 1371 ++++++++++++++++++++++++++++++++++ abis/Gyro2V2PoolFactory.json | 205 +++++ manifest.template.yaml | 39 +- networks.yaml | 5 +- src/mappings/poolFactory.ts | 25 +- 5 files changed, 1640 insertions(+), 5 deletions(-) create mode 100644 abis/Gyro2V2Pool.json create mode 100644 abis/Gyro2V2PoolFactory.json diff --git a/abis/Gyro2V2Pool.json b/abis/Gyro2V2Pool.json new file mode 100644 index 00000000..5872e82a --- /dev/null +++ b/abis/Gyro2V2Pool.json @@ -0,0 +1,1371 @@ +[ + { + "inputs": [ + { + "components": [ + { + "components": [ + { + "internalType": "contract IVault", + "name": "vault", + "type": "address" + }, + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "contract IERC20", + "name": "token0", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token1", + "type": "address" + }, + { + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "pauseWindowDuration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bufferPeriodDuration", + "type": "uint256" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "internalType": "struct ExtensibleWeightedPool2Tokens.NewPoolParams", + "name": "baseParams", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "sqrtAlpha", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sqrtBeta", + "type": "uint256" + }, + { + "internalType": "address", + "name": "rateProvider0", + "type": "address" + }, + { + "internalType": "address", + "name": "rateProvider1", + "type": "address" + }, + { + "internalType": "address", + "name": "capManager", + "type": "address" + }, + { + "components": [ + { + "internalType": "bool", + "name": "capEnabled", + "type": "bool" + }, + { + "internalType": "uint120", + "name": "perAddressCap", + "type": "uint120" + }, + { + "internalType": "uint128", + "name": "globalCap", + "type": "uint128" + } + ], + "internalType": "struct ICappedLiquidity.CapParams", + "name": "capParams", + "type": "tuple" + }, + { + "internalType": "address", + "name": "pauseManager", + "type": "address" + } + ], + "internalType": "struct Gyro2CLPPool.GyroParams", + "name": "params", + "type": "tuple" + }, + { + "internalType": "address", + "name": "configAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Approval", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "capManager", + "type": "address" + } + ], + "name": "CapManagerUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "capEnabled", + "type": "bool" + }, + { + "internalType": "uint120", + "name": "perAddressCap", + "type": "uint120" + }, + { + "internalType": "uint128", + "name": "globalCap", + "type": "uint128" + } + ], + "indexed": false, + "internalType": "struct ICappedLiquidity.CapParams", + "name": "params", + "type": "tuple" + } + ], + "name": "CapParamsUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "oldPauseManager", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newPauseManager", + "type": "address" + } + ], + "name": "PauseManagerChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "PausedLocally", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bool", + "name": "paused", + "type": "bool" + } + ], + "name": "PausedStateChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + } + ], + "name": "SwapFeePercentageChanged", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "Transfer", + "type": "event" + }, + { + "anonymous": false, + "inputs": [], + "name": "UnpausedLocally", + "type": "event" + }, + { + "inputs": [], + "name": "DOMAIN_SEPARATOR", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "allowance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "approve", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "balanceTokenIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceTokenOut", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "tokenInIsToken0", + "type": "bool" + } + ], + "name": "calculateCurrentValues", + "outputs": [ + { + "internalType": "uint256", + "name": "currentInvariant", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "virtualParamIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "virtualParamOut", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "capManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "capParams", + "outputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "capEnabled", + "type": "bool" + }, + { + "internalType": "uint120", + "name": "perAddressCap", + "type": "uint120" + }, + { + "internalType": "uint128", + "name": "globalCap", + "type": "uint128" + } + ], + "internalType": "struct ICappedLiquidity.CapParams", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_pauseManager", + "type": "address" + } + ], + "name": "changePauseManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "decreaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes4", + "name": "selector", + "type": "bytes4" + } + ], + "name": "getActionId", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getActualSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getAuthorizer", + "outputs": [ + { + "internalType": "contract IAuthorizer", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getInvariant", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getInvariantDivActualSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getLastInvariant", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getMiscData", + "outputs": [ + { + "internalType": "int256", + "name": "logInvariant", + "type": "int256" + }, + { + "internalType": "int256", + "name": "logTotalSupply", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "oracleSampleCreationTimestamp", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "oracleIndex", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "oracleEnabled", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getNormalizedWeights", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPausedState", + "outputs": [ + { + "internalType": "bool", + "name": "paused", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "pauseWindowEndTime", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bufferPeriodEndTime", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPoolId", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "spotPrice", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSqrtParameters", + "outputs": [ + { + "internalType": "uint256[2]", + "name": "", + "type": "uint256[2]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getSwapFeePercentage", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getTokenRates", + "outputs": [ + { + "internalType": "uint256", + "name": "rate0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "rate1", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVault", + "outputs": [ + { + "internalType": "contract IVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVirtualParameters", + "outputs": [ + { + "internalType": "uint256[]", + "name": "virtualParams", + "type": "uint256[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gyroConfig", + "outputs": [ + { + "internalType": "contract IGyroConfig", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "addedValue", + "type": "uint256" + } + ], + "name": "increaseAllowance", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "nonces", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "balances", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "protocolSwapFeePercentage", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "name": "onExitPool", + "outputs": [ + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "balances", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "protocolSwapFeePercentage", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "name": "onJoinPool", + "outputs": [ + { + "internalType": "uint256[]", + "name": "amountsIn", + "type": "uint256[]" + }, + { + "internalType": "uint256[]", + "name": "dueProtocolFeeAmounts", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "enum IVault.SwapKind", + "name": "kind", + "type": "uint8" + }, + { + "internalType": "contract IERC20", + "name": "tokenIn", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "tokenOut", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "internalType": "struct IPoolSwapStructs.SwapRequest", + "name": "request", + "type": "tuple" + }, + { + "internalType": "uint256", + "name": "balanceTokenIn", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "balanceTokenOut", + "type": "uint256" + } + ], + "name": "onSwap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "pauseManager", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "deadline", + "type": "uint256" + }, + { + "internalType": "uint8", + "name": "v", + "type": "uint8" + }, + { + "internalType": "bytes32", + "name": "r", + "type": "bytes32" + }, + { + "internalType": "bytes32", + "name": "s", + "type": "bytes32" + } + ], + "name": "permit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "balances", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "protocolSwapFeePercentage", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "name": "queryExit", + "outputs": [ + { + "internalType": "uint256", + "name": "bptIn", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "amountsOut", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "poolId", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "balances", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "lastChangeBlock", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "protocolSwapFeePercentage", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "userData", + "type": "bytes" + } + ], + "name": "queryJoin", + "outputs": [ + { + "internalType": "uint256", + "name": "bptOut", + "type": "uint256" + }, + { + "internalType": "uint256[]", + "name": "amountsIn", + "type": "uint256[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "rateProvider0", + "outputs": [ + { + "internalType": "contract IRateProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rateProvider1", + "outputs": [ + { + "internalType": "contract IRateProvider", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_capManager", + "type": "address" + } + ], + "name": "setCapManager", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "components": [ + { + "internalType": "bool", + "name": "capEnabled", + "type": "bool" + }, + { + "internalType": "uint120", + "name": "perAddressCap", + "type": "uint120" + }, + { + "internalType": "uint128", + "name": "globalCap", + "type": "uint128" + } + ], + "internalType": "struct ICappedLiquidity.CapParams", + "name": "params", + "type": "tuple" + } + ], + "name": "setCapParams", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "paused", + "type": "bool" + } + ], + "name": "setPaused", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + } + ], + "name": "setSwapFeePercentage", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/abis/Gyro2V2PoolFactory.json b/abis/Gyro2V2PoolFactory.json new file mode 100644 index 00000000..02efbc26 --- /dev/null +++ b/abis/Gyro2V2PoolFactory.json @@ -0,0 +1,205 @@ +[ + { + "inputs": [ + { + "internalType": "contract IVault", + "name": "vault", + "type": "address" + }, + { + "internalType": "address", + "name": "_gyroConfigAddress", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "PoolCreated", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "string", + "name": "name", + "type": "string" + }, + { + "internalType": "string", + "name": "symbol", + "type": "string" + }, + { + "internalType": "contract IERC20[]", + "name": "tokens", + "type": "address[]" + }, + { + "internalType": "uint256[]", + "name": "sqrts", + "type": "uint256[]" + }, + { + "internalType": "address[]", + "name": "rateProviders", + "type": "address[]" + }, + { + "internalType": "uint256", + "name": "swapFeePercentage", + "type": "uint256" + }, + { + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "internalType": "address", + "name": "capManager", + "type": "address" + }, + { + "components": [ + { + "internalType": "bool", + "name": "capEnabled", + "type": "bool" + }, + { + "internalType": "uint120", + "name": "perAddressCap", + "type": "uint120" + }, + { + "internalType": "uint128", + "name": "globalCap", + "type": "uint128" + } + ], + "internalType": "struct ICappedLiquidity.CapParams", + "name": "capParams", + "type": "tuple" + }, + { + "internalType": "address", + "name": "pauseManager", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "pauseWindowDuration", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "bufferPeriodDuration", + "type": "uint256" + } + ], + "internalType": "struct ILocallyPausable.PauseParams", + "name": "pauseParams", + "type": "tuple" + } + ], + "name": "create", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "getCreationCode", + "outputs": [ + { + "internalType": "bytes", + "name": "", + "type": "bytes" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getCreationCodeContracts", + "outputs": [ + { + "internalType": "address", + "name": "contractA", + "type": "address" + }, + { + "internalType": "address", + "name": "contractB", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "getVault", + "outputs": [ + { + "internalType": "contract IVault", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gyroConfigAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "pool", + "type": "address" + } + ], + "name": "isPoolFromFactory", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + } +] diff --git a/manifest.template.yaml b/manifest.template.yaml index 03aa6702..bc9e8faa 100644 --- a/manifest.template.yaml +++ b/manifest.template.yaml @@ -1438,12 +1438,45 @@ dataSources: file: ./abis/WeightedPool.json - name: Gyro2Pool file: ./abis/Gyro2Pool.json + - name: Gyro2V2Pool + file: ./abis/Gyro2V2Pool.json - name: Gyro2PoolFactory file: ./abis/Gyro2PoolFactory.json eventHandlers: - event: PoolCreated(indexed address) handler: handleNewGyro2Pool {{/if}} + {{#if Gyro2V2PoolFactory}} + - kind: ethereum/contract + name: Gyro2V2PoolFactory + network: {{network}} + source: + address: '{{Gyro2V2PoolFactory.address}}' + abi: Gyro2V2PoolFactory + startBlock: {{Gyro2V2PoolFactory.startBlock}} + mapping: + kind: ethereum/events + apiVersion: 0.0.5 + language: wasm/assemblyscript + file: ./src/mappings/poolFactory.ts + entities: + - Balancer + - Pool + abis: + - name: Vault + file: ./abis/Vault.json + - name: ERC20 + file: ./abis/ERC20.json + - name: WeightedPool + file: ./abis/WeightedPool.json + - name: Gyro2V2Pool + file: ./abis/Gyro2V2Pool.json + - name: Gyro2V2PoolFactory + file: ./abis/Gyro2V2PoolFactory.json + eventHandlers: + - event: PoolCreated(indexed address) + handler: handleNewGyro2V2Pool + {{/if}} {{#if Gyro3PoolFactory}} - kind: ethereum/contract name: Gyro3PoolFactory @@ -2057,7 +2090,7 @@ templates: name: Gyro2Pool network: {{network}} source: - abi: Gyro2Pool + abi: Gyro2V2Pool mapping: kind: ethereum/events apiVersion: 0.0.5 @@ -2070,8 +2103,8 @@ templates: - PoolToken - GradualWeightUpdate abis: - - name: Gyro2Pool - file: ./abis/Gyro2Pool.json + - name: Gyro2V2Pool + file: ./abis/Gyro2V2Pool.json - name: Vault file: ./abis/Vault.json eventHandlers: diff --git a/networks.yaml b/networks.yaml index f45bef7f..699d0750 100644 --- a/networks.yaml +++ b/networks.yaml @@ -129,6 +129,9 @@ mainnet: GyroEV2PoolFactory: address: "0x412a5B2e7a678471985542757A6855847D4931D5" startBlock: 17672894 + Gyro2V2PoolFactory: + address: "0x579653927BF509B361F6e3813f5D4B95331d98c9" + startBlock: 18577307 goerli: network: goerli EventEmitter: @@ -351,7 +354,7 @@ polygon: arbitrum: network: arbitrum-one graft: - # GyroEV2 startBlock + # GyroEV2 startBlock block: 124858976 # always make sure the base subgraph has not been pruned # it should be possible to run time travel queries on it going back to the vault's startBlock diff --git a/src/mappings/poolFactory.ts b/src/mappings/poolFactory.ts index 42a6dfb9..7f44cbd3 100644 --- a/src/mappings/poolFactory.ts +++ b/src/mappings/poolFactory.ts @@ -456,7 +456,7 @@ function handleNewLinearPool(event: PoolCreated, poolType: string, poolTypeVersi LinearPoolTemplate.create(poolAddress); } -export function handleNewGyro2Pool(event: PoolCreated): void { +function createGyro2Pool(event: PoolCreated, poolTypeVersion: i32 = 1): void { let poolAddress: Address = event.params.pool; let poolContract = Gyro2Pool.bind(poolAddress); @@ -470,6 +470,7 @@ export function handleNewGyro2Pool(event: PoolCreated): void { let pool = handleNewPool(event, poolId, swapFee); pool.poolType = PoolType.Gyro2; + pool.poolTypeVersion = poolTypeVersion; let sqrtParamsCall = poolContract.try_getSqrtParameters(); pool.sqrtAlpha = scaleDown(sqrtParamsCall.value[0], 18); pool.sqrtBeta = scaleDown(sqrtParamsCall.value[1], 18); @@ -478,6 +479,20 @@ export function handleNewGyro2Pool(event: PoolCreated): void { if (tokens == null) return; pool.tokensList = tokens; + if (poolTypeVersion == 2) { + let rateProvider0Call = poolContract.try_rateProvider0(); + let rateProvider1Call = poolContract.try_rateProvider1(); + + let blockTimestamp = event.block.timestamp.toI32(); + + if (!rateProvider0Call.reverted) { + setPriceRateProvider(poolId.toHex(), changetype
(tokens[0]), rateProvider0Call.value, 0, blockTimestamp); + } + if (!rateProvider1Call.reverted) { + setPriceRateProvider(poolId.toHex(), changetype
(tokens[1]), rateProvider1Call.value, 0, blockTimestamp); + } + } + pool.save(); handleNewPoolTokens(pool, tokens); @@ -485,6 +500,14 @@ export function handleNewGyro2Pool(event: PoolCreated): void { Gyro2PoolTemplate.create(event.params.pool); } +export function handleNewGyro2Pool(event: PoolCreated): void { + createGyro2Pool(event); +} + +export function handleNewGyro2V2Pool(event: PoolCreated): void { + createGyro2Pool(event, 2); +} + export function handleNewGyro3Pool(event: PoolCreated): void { let poolAddress: Address = event.params.pool; From 9b4bf4022ac19dfb9d87b6f69c0300cc2f53da98 Mon Sep 17 00:00:00 2001 From: mendesfabio Date: Fri, 24 Nov 2023 14:29:11 -0300 Subject: [PATCH 2/4] deploy only to mainnet --- .github/workflows/graph-beta.yml | 368 +++++++++++++++---------------- 1 file changed, 184 insertions(+), 184 deletions(-) diff --git a/.github/workflows/graph-beta.yml b/.github/workflows/graph-beta.yml index ccb3c618..b45476e7 100644 --- a/.github/workflows/graph-beta.yml +++ b/.github/workflows/graph-beta.yml @@ -28,189 +28,189 @@ jobs: graph_subgraph_name: "balancer-v2-beta" graph_account: "balancer-labs" graph_config_file: "subgraph.yaml" - deploy-goerli-beta: - runs-on: ubuntu-latest - environment: graph - steps: - - uses: actions/checkout@v2 - - name: Install node - uses: actions/setup-node@v1 - with: - node-version: 16 - - name: Install - run: yarn --frozen-lockfile - - name: Assets - run: yarn generate-assets goerli - - name: Codegen - run: yarn codegen - - name: Build - run: yarn build - - uses: balancer-labs/graph-deploy@v0.0.1 - with: - graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} - graph_subgraph_name: "balancer-goerli-v2-beta" - graph_account: "balancer-labs" - graph_config_file: "subgraph.goerli.yaml" - deploy-polygon-beta: - runs-on: ubuntu-latest - environment: graph - steps: - - uses: actions/checkout@v2 - - name: Install node - uses: actions/setup-node@v1 - with: - node-version: 16 - - name: Install - run: yarn --frozen-lockfile - - name: Assets - run: yarn generate-assets polygon - - name: Codegen - run: yarn codegen - - name: Build - run: yarn build - - uses: balancer-labs/graph-deploy@v0.0.1 - with: - graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} - graph_subgraph_name: "balancer-polygon-v2-beta" - graph_account: "balancer-labs" - graph_config_file: "subgraph.polygon.yaml" - deploy-polygon-prune-beta: - runs-on: ubuntu-latest - environment: graph - steps: - - uses: actions/checkout@v2 - - name: Install node - uses: actions/setup-node@v1 - with: - node-version: 16 - - name: Install - run: yarn --frozen-lockfile - - name: Assets - run: yarn generate-assets polygon-prune - - name: Codegen - run: yarn codegen - - name: Build - run: yarn build - - uses: balancer-labs/graph-deploy@v0.0.1 - with: - graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} - graph_subgraph_name: "balancer-polygon-prune-v2-beta" - graph_account: "balancer-labs" - graph_config_file: "subgraph.polygon.pruned.yaml" - deploy-arbitrum-beta: - runs-on: ubuntu-latest - environment: graph - steps: - - uses: actions/checkout@v2 - - name: Install node - uses: actions/setup-node@v1 - with: - node-version: 16 - - name: Install - run: yarn --frozen-lockfile - - name: Assets - run: yarn generate-assets arbitrum - - name: Codegen - run: yarn codegen - - name: Build - run: yarn build - - uses: balancer-labs/graph-deploy@v0.0.1 - with: - graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} - graph_subgraph_name: "balancer-arbitrum-v2-beta" - graph_account: "balancer-labs" - graph_config_file: "subgraph.arbitrum.yaml" - deploy-gnosis-beta: - runs-on: ubuntu-latest - environment: graph - steps: - - uses: actions/checkout@v2 - - name: Install node - uses: actions/setup-node@v1 - with: - node-version: 16 - - name: Install - run: yarn --frozen-lockfile - - name: Assets - run: yarn generate-assets gnosis - - name: Codegen - run: yarn codegen - - name: Build - run: yarn build - - uses: balancer-labs/graph-deploy@v0.0.1 - with: - graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} - graph_subgraph_name: "balancer-gnosis-chain-v2-beta" - graph_account: "balancer-labs" - graph_config_file: "subgraph.gnosis.yaml" - deploy-bnb-beta: - runs-on: ubuntu-latest - environment: graph - steps: - - uses: actions/checkout@v2 - - name: Install node - uses: actions/setup-node@v1 - with: - node-version: 16 - - name: Install - run: yarn --frozen-lockfile - - name: Assets - run: yarn generate-assets bnb - - name: Codegen - run: yarn codegen - - name: Build - run: yarn build - - uses: balancer-labs/graph-deploy@v0.0.1 - with: - graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} - graph_subgraph_name: "balancer-bnbchain-v2-beta" - graph_account: "balancer-labs" - graph_config_file: "subgraph.bnb.yaml" - deploy-avalanche-beta: - runs-on: ubuntu-latest - environment: graph - steps: - - uses: actions/checkout@v2 - - name: Install node - uses: actions/setup-node@v1 - with: - node-version: 16 - - name: Install - run: yarn --frozen-lockfile - - name: Assets - run: yarn generate-assets avalanche - - name: Codegen - run: yarn codegen - - name: Build - run: yarn build - - uses: balancer-labs/graph-deploy@v0.0.1 - with: - graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} - graph_subgraph_name: "balancer-avalanche-v2-beta" - graph_account: "balancer-labs" - graph_config_file: "subgraph.avalanche.yaml" - deploy-optimism-beta: - runs-on: ubuntu-latest - environment: graph - steps: - - uses: actions/checkout@v2 - - name: Install node - uses: actions/setup-node@v1 - with: - node-version: 16 - - name: Install - run: yarn --frozen-lockfile - - name: Assets - run: yarn generate-assets optimism - - name: Codegen - run: yarn codegen - - name: Build - run: yarn build - - uses: balancer-labs/graph-deploy@v0.0.1 - with: - graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} - graph_subgraph_name: "balancer-optimism-v2-beta" - graph_account: "balancer-labs" - graph_config_file: "subgraph.optimism.yaml" + # deploy-goerli-beta: + # runs-on: ubuntu-latest + # environment: graph + # steps: + # - uses: actions/checkout@v2 + # - name: Install node + # uses: actions/setup-node@v1 + # with: + # node-version: 16 + # - name: Install + # run: yarn --frozen-lockfile + # - name: Assets + # run: yarn generate-assets goerli + # - name: Codegen + # run: yarn codegen + # - name: Build + # run: yarn build + # - uses: balancer-labs/graph-deploy@v0.0.1 + # with: + # graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} + # graph_subgraph_name: "balancer-goerli-v2-beta" + # graph_account: "balancer-labs" + # graph_config_file: "subgraph.goerli.yaml" + # deploy-polygon-beta: + # runs-on: ubuntu-latest + # environment: graph + # steps: + # - uses: actions/checkout@v2 + # - name: Install node + # uses: actions/setup-node@v1 + # with: + # node-version: 16 + # - name: Install + # run: yarn --frozen-lockfile + # - name: Assets + # run: yarn generate-assets polygon + # - name: Codegen + # run: yarn codegen + # - name: Build + # run: yarn build + # - uses: balancer-labs/graph-deploy@v0.0.1 + # with: + # graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} + # graph_subgraph_name: "balancer-polygon-v2-beta" + # graph_account: "balancer-labs" + # graph_config_file: "subgraph.polygon.yaml" + # deploy-polygon-prune-beta: + # runs-on: ubuntu-latest + # environment: graph + # steps: + # - uses: actions/checkout@v2 + # - name: Install node + # uses: actions/setup-node@v1 + # with: + # node-version: 16 + # - name: Install + # run: yarn --frozen-lockfile + # - name: Assets + # run: yarn generate-assets polygon-prune + # - name: Codegen + # run: yarn codegen + # - name: Build + # run: yarn build + # - uses: balancer-labs/graph-deploy@v0.0.1 + # with: + # graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} + # graph_subgraph_name: "balancer-polygon-prune-v2-beta" + # graph_account: "balancer-labs" + # graph_config_file: "subgraph.polygon.pruned.yaml" + # deploy-arbitrum-beta: + # runs-on: ubuntu-latest + # environment: graph + # steps: + # - uses: actions/checkout@v2 + # - name: Install node + # uses: actions/setup-node@v1 + # with: + # node-version: 16 + # - name: Install + # run: yarn --frozen-lockfile + # - name: Assets + # run: yarn generate-assets arbitrum + # - name: Codegen + # run: yarn codegen + # - name: Build + # run: yarn build + # - uses: balancer-labs/graph-deploy@v0.0.1 + # with: + # graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} + # graph_subgraph_name: "balancer-arbitrum-v2-beta" + # graph_account: "balancer-labs" + # graph_config_file: "subgraph.arbitrum.yaml" + # deploy-gnosis-beta: + # runs-on: ubuntu-latest + # environment: graph + # steps: + # - uses: actions/checkout@v2 + # - name: Install node + # uses: actions/setup-node@v1 + # with: + # node-version: 16 + # - name: Install + # run: yarn --frozen-lockfile + # - name: Assets + # run: yarn generate-assets gnosis + # - name: Codegen + # run: yarn codegen + # - name: Build + # run: yarn build + # - uses: balancer-labs/graph-deploy@v0.0.1 + # with: + # graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} + # graph_subgraph_name: "balancer-gnosis-chain-v2-beta" + # graph_account: "balancer-labs" + # graph_config_file: "subgraph.gnosis.yaml" + # deploy-bnb-beta: + # runs-on: ubuntu-latest + # environment: graph + # steps: + # - uses: actions/checkout@v2 + # - name: Install node + # uses: actions/setup-node@v1 + # with: + # node-version: 16 + # - name: Install + # run: yarn --frozen-lockfile + # - name: Assets + # run: yarn generate-assets bnb + # - name: Codegen + # run: yarn codegen + # - name: Build + # run: yarn build + # - uses: balancer-labs/graph-deploy@v0.0.1 + # with: + # graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} + # graph_subgraph_name: "balancer-bnbchain-v2-beta" + # graph_account: "balancer-labs" + # graph_config_file: "subgraph.bnb.yaml" + # deploy-avalanche-beta: + # runs-on: ubuntu-latest + # environment: graph + # steps: + # - uses: actions/checkout@v2 + # - name: Install node + # uses: actions/setup-node@v1 + # with: + # node-version: 16 + # - name: Install + # run: yarn --frozen-lockfile + # - name: Assets + # run: yarn generate-assets avalanche + # - name: Codegen + # run: yarn codegen + # - name: Build + # run: yarn build + # - uses: balancer-labs/graph-deploy@v0.0.1 + # with: + # graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} + # graph_subgraph_name: "balancer-avalanche-v2-beta" + # graph_account: "balancer-labs" + # graph_config_file: "subgraph.avalanche.yaml" + # deploy-optimism-beta: + # runs-on: ubuntu-latest + # environment: graph + # steps: + # - uses: actions/checkout@v2 + # - name: Install node + # uses: actions/setup-node@v1 + # with: + # node-version: 16 + # - name: Install + # run: yarn --frozen-lockfile + # - name: Assets + # run: yarn generate-assets optimism + # - name: Codegen + # run: yarn codegen + # - name: Build + # run: yarn build + # - uses: balancer-labs/graph-deploy@v0.0.1 + # with: + # graph_access_token: ${{secrets.GRAPH_ACCESS_TOKEN}} + # graph_subgraph_name: "balancer-optimism-v2-beta" + # graph_account: "balancer-labs" + # graph_config_file: "subgraph.optimism.yaml" env: CI: true From 02fe3ed0e83e049af40c2d6df447a6ee7717a736 Mon Sep 17 00:00:00 2001 From: mendesfabio Date: Fri, 24 Nov 2023 14:32:51 -0300 Subject: [PATCH 3/4] fix gyro2 pool binding --- src/mappings/poolFactory.ts | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/mappings/poolFactory.ts b/src/mappings/poolFactory.ts index 7f44cbd3..ff1b369f 100644 --- a/src/mappings/poolFactory.ts +++ b/src/mappings/poolFactory.ts @@ -50,7 +50,7 @@ import { WeightedPoolV2 } from '../types/templates/WeightedPoolV2/WeightedPoolV2 import { StablePool } from '../types/templates/StablePool/StablePool'; import { ConvergentCurvePool } from '../types/templates/ConvergentCurvePool/ConvergentCurvePool'; import { LinearPool } from '../types/templates/LinearPool/LinearPool'; -import { Gyro2Pool } from '../types/templates/Gyro2Pool/Gyro2Pool'; +import { Gyro2V2Pool } from '../types/templates/Gyro2Pool/Gyro2V2Pool'; import { Gyro3Pool } from '../types/templates/Gyro3Pool/Gyro3Pool'; import { GyroEV2Pool } from '../types/templates/GyroEPool/GyroEV2Pool'; import { FXPool } from '../types/templates/FXPool/FXPool'; @@ -459,7 +459,7 @@ function handleNewLinearPool(event: PoolCreated, poolType: string, poolTypeVersi function createGyro2Pool(event: PoolCreated, poolTypeVersion: i32 = 1): void { let poolAddress: Address = event.params.pool; - let poolContract = Gyro2Pool.bind(poolAddress); + let poolContract = Gyro2V2Pool.bind(poolAddress); let poolIdCall = poolContract.try_getPoolId(); let poolId = poolIdCall.value; From 8553bf5a0de641508e8d6db7dc2563f5b975d677 Mon Sep 17 00:00:00 2001 From: mendesfabio Date: Fri, 24 Nov 2023 14:37:00 -0300 Subject: [PATCH 4/4] fix gyro2 events import --- src/mappings/poolController.ts | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/mappings/poolController.ts b/src/mappings/poolController.ts index 4977d75c..beb3f96e 100644 --- a/src/mappings/poolController.ts +++ b/src/mappings/poolController.ts @@ -63,7 +63,7 @@ import { ProtocolFeePercentageCacheUpdated, RecoveryModeStateChanged, } from '../types/WeightedPoolV2Factory/WeightedPoolV2'; -import { PausedLocally, UnpausedLocally } from '../types/templates/Gyro2Pool/Gyro2Pool'; +import { PausedLocally, UnpausedLocally } from '../types/templates/Gyro2Pool/Gyro2V2Pool'; import { WeightedPoolV2 } from '../types/templates/WeightedPoolV2/WeightedPoolV2'; import { Transfer } from '../types/Vault/ERC20'; import { valueInUSD } from './pricing';