diff --git a/src/adaptors/gloop/Constants.js b/src/adaptors/gloop/Constants.js new file mode 100644 index 0000000000..6e061ecb1d --- /dev/null +++ b/src/adaptors/gloop/Constants.js @@ -0,0 +1,15 @@ +module.exports = { + ADDRESSES: { + USDC: '0xaf88d065e77c8cC2239327C5EDb3A432268e5831', + GLOOP: '0x4d48d503ed04d50418C9aBF163b1168FF834E47c', + GMI: '0xAad4187a81689AF72d91966c8119756E425cD7CF', + RECEIVED_TOKEN: '0xFe81b0866a8fBBd7c00f5AaB84E4e531eA7591c2', // USDC receipt token + LENDING_POOL: '0x9BE2e5739B1a6A175d36Ce043f44E66965a433EB', + ORACLE: '0x277e3531d2b697E572E8b4Aa363571836ecA55be', + GM_INCENTIVES: '0x5B28fde611Ed40FFf4d933971fdF975dC6191f9f', + INTEREST_RATE_MODEL: '0x991c54E99a4612d90AA21d675C89a1752Da7c233', + GLOOP_GMI_V3_POOL: '0x84ef1190ba2be3fadded470642520b7f8948aded', + }, + CHAIN: 'arbitrum', + SECONDS_PER_YEAR: 31557600, // 365.25 * 24 * 60 * 60, +}; diff --git a/src/adaptors/gloop/abi/abiGMI.json b/src/adaptors/gloop/abi/abiGMI.json new file mode 100644 index 0000000000..5a38f6676e --- /dev/null +++ b/src/adaptors/gloop/abi/abiGMI.json @@ -0,0 +1,1261 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_protocolFeeRecipient", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "allowance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientAllowance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "needed", + "type": "uint256" + } + ], + "name": "ERC20InsufficientBalance", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "approver", + "type": "address" + } + ], + "name": "ERC20InvalidApprover", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "receiver", + "type": "address" + } + ], + "name": "ERC20InvalidReceiver", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "sender", + "type": "address" + } + ], + "name": "ERC20InvalidSender", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "spender", + "type": "address" + } + ], + "name": "ERC20InvalidSpender", + "type": "error" + }, + { + "inputs": [], + "name": "EnforcedPause", + "type": "error" + }, + { + "inputs": [], + "name": "ExpectedPause", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "owner", + "type": "address" + } + ], + "name": "OwnableInvalidOwner", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "OwnableUnauthorizedAccount", + "type": "error" + }, + { + "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": "", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "fee", + "type": "uint256" + } + ], + "name": "FeeUpdate", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "NewFeeRecipient", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "NewProtocolFeeRatio", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "address", + "name": "oracle", + "type": "address" + } + ], + "name": "OracleUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferStarted", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "previousOwner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Paused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "TokenRemoved", + "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": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + } + ], + "name": "TreasuryTokenRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + } + ], + "name": "TreasuryVaultRemoved", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "account", + "type": "address" + } + ], + "name": "Unpaused", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "token", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "weight", + "type": "uint256" + } + ], + "name": "UpdateTokenWeight", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "weight", + "type": "uint256" + } + ], + "name": "UpdateVaultWeight", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "", + "type": "address" + }, + { + "indexed": false, + "internalType": "bytes32", + "name": "", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [], + "name": "acceptOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "internalType": "contract IERC20", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_weight", + "type": "uint256" + }, + { + "internalType": "contract ITokenOracle", + "name": "oracle", + "type": "address" + }, + { + "internalType": "contract IBank", + "name": "bank", + "type": "address" + } + ], + "name": "addToken", + "outputs": [], + "stateMutability": "nonpayable", + "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": "value", + "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": "bytes32", + "name": "name", + "type": "bytes32" + } + ], + "name": "bankBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "burn", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "burnFrom", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "isWithdraw", + "type": "bool" + } + ], + "name": "calculateFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "internalType": "bool", + "name": "roundUp", + "type": "bool" + } + ], + "name": "controlledValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "decimals", + "outputs": [ + { + "internalType": "uint8", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "internalType": "address", + "name": "_recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "_minAmountOut", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "feeBase", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "internalType": "bool", + "name": "roundUp", + "type": "bool" + } + ], + "name": "getPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + } + ], + "name": "getTargetAmount", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minFee", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "paused", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "pendingOwner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "protocolFeeRatio", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "protocolFeeRecipient", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract IERC20", + "name": "_token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_to", + "type": "address" + } + ], + "name": "recoverUnsupported", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + } + ], + "name": "removeTreasuryVault", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "renounceOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_feeBase", + "type": "uint256" + } + ], + "name": "setFeeBase", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_minFee", + "type": "uint256" + } + ], + "name": "setMinFee", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_taxBase", + "type": "uint256" + } + ], + "name": "setTaxBase", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_weight", + "type": "uint256" + } + ], + "name": "setTokenWeight", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "symbol", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "internalType": "bool", + "name": "withdrawal", + "type": "bool" + }, + { + "internalType": "uint256", + "name": "tokenValue", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "roundUp", + "type": "bool" + } + ], + "name": "targetBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "balance", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "taxBase", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "roundUp", + "type": "bool" + } + ], + "name": "totalControlledValue", + "outputs": [ + { + "internalType": "uint256", + "name": "totalValue", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalSupply", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalTokenWeights", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transfer", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "internalType": "address", + "name": "to", + "type": "address" + }, + { + "internalType": "uint256", + "name": "value", + "type": "uint256" + } + ], + "name": "transferFrom", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "treasuryVaults", + "outputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "unpause", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_protocolFeeRecipient", + "type": "address" + } + ], + "name": "updateFeeRecipient", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "internalType": "contract ITokenOracle", + "name": "oracle", + "type": "address" + } + ], + "name": "updateOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_protocolFeeRatio", + "type": "uint256" + } + ], + "name": "updateProtocolFeeRatio", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "vaults", + "outputs": [ + { + "internalType": "contract IBank", + "name": "bank", + "type": "address" + }, + { + "internalType": "contract IERC20", + "name": "token", + "type": "address" + }, + { + "internalType": "uint256", + "name": "weight", + "type": "uint256" + }, + { + "internalType": "contract ITokenOracle", + "name": "oracle", + "type": "address" + }, + { + "internalType": "bool", + "name": "active", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "name", + "type": "bytes32" + }, + { + "internalType": "uint256", + "name": "_amount", + "type": "uint256" + }, + { + "internalType": "address", + "name": "_recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_minAmountOut", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/src/adaptors/gloop/abi/abiGMIncentives.json b/src/adaptors/gloop/abi/abiGMIncentives.json new file mode 100644 index 0000000000..fb050e688d --- /dev/null +++ b/src/adaptors/gloop/abi/abiGMIncentives.json @@ -0,0 +1,656 @@ +[ + { + "type": "constructor", + "inputs": [ + { + "name": "_usdcVault", + "type": "address", + "internalType": "address" + }, + { + "name": "_rewardsVault", + "type": "address", + "internalType": "address" + }, + { + "name": "_lendingPool", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "claimRewards", + "inputs": [], + "outputs": [ + { + "name": "rewardsList", + "type": "address[]", + "internalType": "address[]" + }, + { + "name": "claimedAmounts", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "configureReward", + "inputs": [ + { + "name": "rewardsInput", + "type": "tuple", + "internalType": "struct RewardsDataTypes.RewardsConfigInput", + "components": [ + { + "name": "rewardToken", + "type": "address", + "internalType": "address" + }, + { + "name": "emissionsPerSecond", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "distributionEnd", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "totalSupply", + "type": "uint256", + "internalType": "uint256" + } + ] + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "getAllUserRewards", + "inputs": [ + { + "name": "user", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "rewardsList", + "type": "address[]", + "internalType": "address[]" + }, + { + "name": "unclaimedAmounts", + "type": "uint256[]", + "internalType": "uint256[]" + }, + { + "name": "pendingAmounts", + "type": "uint256[]", + "internalType": "uint256[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getRewardsData", + "inputs": [ + { + "name": "reward", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getRewardsList", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address[]", + "internalType": "address[]" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getUserAccruedRewards", + "inputs": [ + { + "name": "user", + "type": "address", + "internalType": "address" + }, + { + "name": "reward", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getUserRewardIndex", + "inputs": [ + { + "name": "user", + "type": "address", + "internalType": "address" + }, + { + "name": "reward", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getUserUSDCBalance", + "inputs": [ + { + "name": "user", + "type": "address", + "internalType": "address" + } + ], + "outputs": [ + { + "name": "", + "type": "uint256", + "internalType": "uint256" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "getVaults", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + }, + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "lendingPool", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract LendingPool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "owner", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "pause", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "paused", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "bool", + "internalType": "bool" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "relayVaultAction", + "inputs": [ + { + "name": "user", + "type": "address", + "internalType": "address" + }, + { + "name": "assetAmount", + "type": "uint256", + "internalType": "uint256" + }, + { + "name": "isDeposit", + "type": "bool", + "internalType": "bool" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "removeReward", + "inputs": [ + { + "name": "rewardToRemove", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "renounceOwnership", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "rewardsVault", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "address" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "setVaults", + "inputs": [ + { + "name": "_usdcVault", + "type": "address", + "internalType": "address" + }, + { + "name": "_rewardsVault", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "transferOwnership", + "inputs": [ + { + "name": "newOwner", + "type": "address", + "internalType": "address" + } + ], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "unpause", + "inputs": [], + "outputs": [], + "stateMutability": "nonpayable" + }, + { + "type": "function", + "name": "usdcToken", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract ERC20" + } + ], + "stateMutability": "view" + }, + { + "type": "function", + "name": "usdcVault", + "inputs": [], + "outputs": [ + { + "name": "", + "type": "address", + "internalType": "contract IGMVault" + } + ], + "stateMutability": "view" + }, + { + "type": "event", + "name": "Accrued", + "inputs": [ + { + "name": "reward", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "user", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "assetIndex", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "userIndex", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "rewardsAccrued", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + } + ], + "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": "Paused", + "inputs": [ + { + "name": "account", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "RewardConfigUpdated", + "inputs": [ + { + "name": "reward", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "oldEmission", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "newEmission", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + }, + { + "name": "oldDistributionEnd", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "newDistributionEnd", + "type": "uint256", + "indexed": true, + "internalType": "uint256" + }, + { + "name": "oldTotalSupply", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "totalSupply", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + }, + { + "name": "rewardIndex", + "type": "uint256", + "indexed": false, + "internalType": "uint256" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "RewardRemoved", + "inputs": [ + { + "name": "reward", + "type": "address", + "indexed": true, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "RewardsClaimed", + "inputs": [ + { + "name": "user", + "type": "address", + "indexed": true, + "internalType": "address" + }, + { + "name": "rewards", + "type": "address[]", + "indexed": true, + "internalType": "address[]" + }, + { + "name": "amount", + "type": "uint256[]", + "indexed": true, + "internalType": "uint256[]" + } + ], + "anonymous": false + }, + { + "type": "event", + "name": "Unpaused", + "inputs": [ + { + "name": "account", + "type": "address", + "indexed": false, + "internalType": "address" + } + ], + "anonymous": false + }, + { + "type": "error", + "name": "EmissionsAreActive", + "inputs": [] + }, + { + "type": "error", + "name": "EnforcedPause", + "inputs": [] + }, + { + "type": "error", + "name": "ExpectedPause", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidInputs", + "inputs": [] + }, + { + "type": "error", + "name": "InvalidToken", + "inputs": [] + }, + { + "type": "error", + "name": "NoRewardsToClaim", + "inputs": [] + }, + { + "type": "error", + "name": "OnlyVaultCanCall", + "inputs": [] + }, + { + "type": "error", + "name": "OwnableInvalidOwner", + "inputs": [ + { + "name": "owner", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "OwnableUnauthorizedAccount", + "inputs": [ + { + "name": "account", + "type": "address", + "internalType": "address" + } + ] + }, + { + "type": "error", + "name": "ReentrancyGuardReentrantCall", + "inputs": [] + }, + { + "type": "error", + "name": "SafeERC20FailedOperation", + "inputs": [ + { + "name": "token", + "type": "address", + "internalType": "address" + } + ] + } +] \ No newline at end of file diff --git a/src/adaptors/gloop/abi/abiInterestRateModel.json b/src/adaptors/gloop/abi/abiInterestRateModel.json new file mode 100644 index 0000000000..d00e119922 --- /dev/null +++ b/src/adaptors/gloop/abi/abiInterestRateModel.json @@ -0,0 +1,139 @@ +[ + { + "inputs": [], + "name": "vertexUtilization", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "blocksInOneYear", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "minRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "vertexRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "cash", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrows", + "type": "uint256" + } + ], + "name": "getBorrowRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "cash", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrows", + "type": "uint256" + } + ], + "name": "utilizationRate", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "availableLiquidity", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrows", + "type": "uint256" + } + ], + "name": "getCurrentBorrowAPY", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/src/adaptors/gloop/abi/abiLendingPool.json b/src/adaptors/gloop/abi/abiLendingPool.json new file mode 100644 index 0000000000..4e48527399 --- /dev/null +++ b/src/adaptors/gloop/abi/abiLendingPool.json @@ -0,0 +1,1622 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_owner", + "type": "address" + }, + { + "internalType": "address", + "name": "_authority", + "type": "address" + }, + { + "internalType": "string", + "name": "_name", + "type": "string" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "BonusMustBeBelowTenPercent", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "liquidationsRestoredTime", + "type": "uint256" + } + ], + "name": "LiquidationsDisabled", + "type": "error" + }, + { + "inputs": [], + "name": "ReentrancyGuardReentrantCall", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "token", + "type": "address" + } + ], + "name": "SafeERC20FailedOperation", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract AddressStore", + "name": "newAddressStore", + "type": "address" + } + ], + "name": "AddressStoreUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract ERC4626", + "name": "vault", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "lendFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCap", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCap", + "type": "uint256" + } + ], + "indexed": false, + "internalType": "struct LendingPool.Configuration", + "name": "newConfiguration", + "type": "tuple" + } + ], + "name": "AssetConfigurationUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract ERC4626", + "name": "vault", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "lendFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCap", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCap", + "type": "uint256" + } + ], + "indexed": false, + "internalType": "struct LendingPool.Configuration", + "name": "configuration", + "type": "tuple" + } + ], + "name": "AssetConfigured", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + } + ], + "name": "AssetDisabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + } + ], + "name": "AssetEnabled", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract Authority", + "name": "newAuthority", + "type": "address" + } + ], + "name": "AuthorityUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Borrow", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Deposit", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newGMPointsContract", + "type": "address" + } + ], + "name": "GMPointsContractUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newWallet", + "type": "address" + } + ], + "name": "GloopStakersWalletUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newGloopStakersYieldRatio", + "type": "uint256" + } + ], + "name": "GloopStakersYieldUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "contract InterestRateModel", + "name": "newInterestRateModel", + "type": "address" + } + ], + "name": "InterestRateModelUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "liquidator", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "liquidated", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "seizedValue", + "type": "uint256" + } + ], + "name": "Liquidation", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newLiquidationBonus", + "type": "uint256" + } + ], + "name": "LiquidationBonusUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "liquidated", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "LiquidationOfBadDebt", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "newGMToken", + "type": "address" + } + ], + "name": "NewGMToken", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "address[]", + "name": "newGMTokens", + "type": "address[]" + } + ], + "name": "NewGMTokenArray", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract PriceOracle", + "name": "newOracle", + "type": "address" + } + ], + "name": "OracleUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Repay", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "newReserveFactor", + "type": "uint256" + } + ], + "name": "ReserveFactorUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "from", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Withdraw", + "type": "event" + }, + { + "inputs": [], + "name": "MAX_GM_TOKENS_SUPPORTED", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "MAX_LIQUIDATION_BONUS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newGMToken", + "type": "address" + } + ], + "name": "addNewGMToken", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "addressStore", + "outputs": [ + { + "internalType": "contract AddressStore", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "authority", + "outputs": [ + { + "internalType": "contract Authority", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + } + ], + "name": "availableLiquidity", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "balanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "", + "type": "address" + } + ], + "name": "baseUnits", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "borrow", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "borrowBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "collAmount", + "type": "uint256" + }, + { + "internalType": "bool", + "name": "collIncrease", + "type": "bool" + } + ], + "name": "calculateHFAfterCollChange", + "outputs": [ + { + "internalType": "uint256", + "name": "hypotheticalHF", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "calculateHealthFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "", + "type": "address" + } + ], + "name": "configurations", + "outputs": [ + { + "internalType": "uint256", + "name": "lendFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCap", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCap", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "contract ERC4626", + "name": "vault", + "type": "address" + }, + { + "components": [ + { + "internalType": "uint256", + "name": "lendFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "supplyCap", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowFactor", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "borrowCap", + "type": "uint256" + } + ], + "internalType": "struct LendingPool.Configuration", + "name": "configuration", + "type": "tuple" + }, + { + "internalType": "bool", + "name": "updateVault", + "type": "bool" + } + ], + "name": "configureAsset", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + } + ], + "name": "disableAsset", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + } + ], + "name": "enableAsset", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "contract ERC20", + "name": "", + "type": "address" + } + ], + "name": "enabledCollateral", + "outputs": [ + { + "internalType": "bool", + "name": "", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getCollateral", + "outputs": [ + { + "internalType": "contract ERC20[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "getEffectiveUSDCBalanceOf", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "asset", + "type": "address" + } + ], + "name": "getInternalCachedTotalBorrows", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + } + ], + "name": "getUserCollateralValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gloopStakersWallet", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gloopStakersYield", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gloopStakersYieldFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "gmPointsContract", + "outputs": [ + { + "internalType": "contract GMPoints", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "gmTokensAddresses", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "", + "type": "address" + } + ], + "name": "interestRateModels", + "outputs": [ + { + "internalType": "contract InterestRateModel", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + } + ], + "name": "isValidGMToken", + "outputs": [ + { + "internalType": "bool", + "name": "isValid", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "liquidateBadDebt", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "borrowAsset", + "type": "address" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint256", + "name": "repayAmount", + "type": "uint256" + } + ], + "name": "liquidateUser", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "liquidationBonus", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "user", + "type": "address" + } + ], + "name": "maxBorrowableValue", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "name", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "oracle", + "outputs": [ + { + "internalType": "contract PriceOracle", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "repay", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "reserveFactor", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract AddressStore", + "name": "newAddressStore", + "type": "address" + } + ], + "name": "setAddressStore", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract Authority", + "name": "newAuthority", + "type": "address" + } + ], + "name": "setAuthority", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newPointsAddress", + "type": "address" + } + ], + "name": "setGMPointsContract", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address[]", + "name": "newGMTokensAddress", + "type": "address[]" + } + ], + "name": "setGMTokens", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_newWallet", + "type": "address" + } + ], + "name": "setGloopStakersWallet", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newGSYFactor", + "type": "uint256" + } + ], + "name": "setGloopStakersYieldFactor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "contract InterestRateModel", + "name": "newInterestRateModel", + "type": "address" + }, + { + "internalType": "bool", + "name": "accrue", + "type": "bool" + } + ], + "name": "setInterestRateModel", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract PriceOracle", + "name": "newOracle", + "type": "address" + } + ], + "name": "setOracle", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + } + ], + "name": "totalBorrows", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "totalReserves", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + } + ], + "name": "totalUnderlying", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "_newLiquidationBonus", + "type": "uint256" + } + ], + "name": "updateLiquidationBonus", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "newReserveFactor", + "type": "uint256" + } + ], + "name": "updateReserveFactor", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "usdcTokenAddress", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "userCollateral", + "outputs": [ + { + "internalType": "contract ERC20", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bool", + "name": "willBePaused", + "type": "bool" + } + ], + "name": "vaultPauseInterestAccrual", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "", + "type": "address" + } + ], + "name": "vaults", + "outputs": [ + { + "internalType": "contract ERC4626", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "withdraw", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "withdrawReserves", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "withdrawStakersYield", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/src/adaptors/gloop/abi/abiOracle.json b/src/adaptors/gloop/abi/abiOracle.json new file mode 100644 index 0000000000..055eef103e --- /dev/null +++ b/src/adaptors/gloop/abi/abiOracle.json @@ -0,0 +1,196 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "_authorityContract", + "type": "address" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "GracePeriodNotOver", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAsset", + "type": "error" + }, + { + "inputs": [], + "name": "SequencerIsDown", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "lastUpdateTime", + "type": "uint256" + } + ], + "name": "StalePriceFeed", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "contract Authority", + "name": "newAuthority", + "type": "address" + } + ], + "name": "AuthorityUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sequencerFeed", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "usdcFeed", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "usdcFeedHeartbeat", + "type": "uint256" + } + ], + "name": "OracleFeedsUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "user", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "OwnershipTransferred", + "type": "event" + }, + { + "inputs": [], + "name": "authority", + "outputs": [ + { + "internalType": "contract Authority", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract ERC20", + "name": "asset", + "type": "address" + } + ], + "name": "getUnderlyingPrice", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "owner", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "contract Authority", + "name": "newAuthority", + "type": "address" + } + ], + "name": "setAuthority", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "newOwner", + "type": "address" + } + ], + "name": "transferOwnership", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "_sequencerUptimeFeed", + "type": "address" + }, + { + "internalType": "address", + "name": "_usdcPriceFeed", + "type": "address" + }, + { + "internalType": "uint256", + "name": "_usdcFeedHeartbeat", + "type": "uint256" + } + ], + "name": "updateChainlinkFeeds", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] \ No newline at end of file diff --git a/src/adaptors/gloop/abi/abiUniswapV3Pool.json b/src/adaptors/gloop/abi/abiUniswapV3Pool.json new file mode 100644 index 0000000000..49cc338ed3 --- /dev/null +++ b/src/adaptors/gloop/abi/abiUniswapV3Pool.json @@ -0,0 +1,988 @@ +[ + { + "inputs": [], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "Burn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": false, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount0", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount1", + "type": "uint128" + } + ], + "name": "Collect", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount0", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount1", + "type": "uint128" + } + ], + "name": "CollectProtocol", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "paid0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "paid1", + "type": "uint256" + } + ], + "name": "Flash", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint16", + "name": "observationCardinalityNextOld", + "type": "uint16" + }, + { + "indexed": false, + "internalType": "uint16", + "name": "observationCardinalityNextNew", + "type": "uint16" + } + ], + "name": "IncreaseObservationCardinalityNext", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + }, + { + "indexed": false, + "internalType": "int24", + "name": "tick", + "type": "int24" + } + ], + "name": "Initialize", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "owner", + "type": "address" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "indexed": true, + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "name": "Mint", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint8", + "name": "feeProtocol0Old", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "feeProtocol1Old", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "feeProtocol0New", + "type": "uint8" + }, + { + "indexed": false, + "internalType": "uint8", + "name": "feeProtocol1New", + "type": "uint8" + } + ], + "name": "SetFeeProtocol", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "sender", + "type": "address" + }, + { + "indexed": true, + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "indexed": false, + "internalType": "int256", + "name": "amount0", + "type": "int256" + }, + { + "indexed": false, + "internalType": "int256", + "name": "amount1", + "type": "int256" + }, + { + "indexed": false, + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + }, + { + "indexed": false, + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "int24", + "name": "tick", + "type": "int24" + } + ], + "name": "Swap", + "type": "event" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + } + ], + "name": "burn", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint128", + "name": "amount0Requested", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "amount1Requested", + "type": "uint128" + } + ], + "name": "collect", + "outputs": [ + { + "internalType": "uint128", + "name": "amount0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "amount1", + "type": "uint128" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint128", + "name": "amount0Requested", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "amount1Requested", + "type": "uint128" + } + ], + "name": "collectProtocol", + "outputs": [ + { + "internalType": "uint128", + "name": "amount0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "amount1", + "type": "uint128" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "factory", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "fee", + "outputs": [ + { + "internalType": "uint24", + "name": "", + "type": "uint24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeGrowthGlobal0X128", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "feeGrowthGlobal1X128", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "flash", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint16", + "name": "observationCardinalityNext", + "type": "uint16" + } + ], + "name": "increaseObservationCardinalityNext", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "liquidity", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "maxLiquidityPerTick", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + }, + { + "internalType": "uint128", + "name": "amount", + "type": "uint128" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "mint", + "outputs": [ + { + "internalType": "uint256", + "name": "amount0", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount1", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "name": "observations", + "outputs": [ + { + "internalType": "uint32", + "name": "blockTimestamp", + "type": "uint32" + }, + { + "internalType": "int56", + "name": "tickCumulative", + "type": "int56" + }, + { + "internalType": "uint160", + "name": "secondsPerLiquidityCumulativeX128", + "type": "uint160" + }, + { + "internalType": "bool", + "name": "initialized", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32[]", + "name": "secondsAgos", + "type": "uint32[]" + } + ], + "name": "observe", + "outputs": [ + { + "internalType": "int56[]", + "name": "tickCumulatives", + "type": "int56[]" + }, + { + "internalType": "uint160[]", + "name": "secondsPerLiquidityCumulativeX128s", + "type": "uint160[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "", + "type": "bytes32" + } + ], + "name": "positions", + "outputs": [ + { + "internalType": "uint128", + "name": "liquidity", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "feeGrowthInside0LastX128", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeGrowthInside1LastX128", + "type": "uint256" + }, + { + "internalType": "uint128", + "name": "tokensOwed0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "tokensOwed1", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "protocolFees", + "outputs": [ + { + "internalType": "uint128", + "name": "token0", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "token1", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint8", + "name": "feeProtocol0", + "type": "uint8" + }, + { + "internalType": "uint8", + "name": "feeProtocol1", + "type": "uint8" + } + ], + "name": "setFeeProtocol", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "slot0", + "outputs": [ + { + "internalType": "uint160", + "name": "sqrtPriceX96", + "type": "uint160" + }, + { + "internalType": "int24", + "name": "tick", + "type": "int24" + }, + { + "internalType": "uint16", + "name": "observationIndex", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "observationCardinality", + "type": "uint16" + }, + { + "internalType": "uint16", + "name": "observationCardinalityNext", + "type": "uint16" + }, + { + "internalType": "uint8", + "name": "feeProtocol", + "type": "uint8" + }, + { + "internalType": "bool", + "name": "unlocked", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "tickLower", + "type": "int24" + }, + { + "internalType": "int24", + "name": "tickUpper", + "type": "int24" + } + ], + "name": "snapshotCumulativesInside", + "outputs": [ + { + "internalType": "int56", + "name": "tickCumulativeInside", + "type": "int56" + }, + { + "internalType": "uint160", + "name": "secondsPerLiquidityInsideX128", + "type": "uint160" + }, + { + "internalType": "uint32", + "name": "secondsInside", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "bool", + "name": "zeroForOne", + "type": "bool" + }, + { + "internalType": "int256", + "name": "amountSpecified", + "type": "int256" + }, + { + "internalType": "uint160", + "name": "sqrtPriceLimitX96", + "type": "uint160" + }, + { + "internalType": "bytes", + "name": "data", + "type": "bytes" + } + ], + "name": "swap", + "outputs": [ + { + "internalType": "int256", + "name": "amount0", + "type": "int256" + }, + { + "internalType": "int256", + "name": "amount1", + "type": "int256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int16", + "name": "", + "type": "int16" + } + ], + "name": "tickBitmap", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "tickSpacing", + "outputs": [ + { + "internalType": "int24", + "name": "", + "type": "int24" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "int24", + "name": "", + "type": "int24" + } + ], + "name": "ticks", + "outputs": [ + { + "internalType": "uint128", + "name": "liquidityGross", + "type": "uint128" + }, + { + "internalType": "int128", + "name": "liquidityNet", + "type": "int128" + }, + { + "internalType": "uint256", + "name": "feeGrowthOutside0X128", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "feeGrowthOutside1X128", + "type": "uint256" + }, + { + "internalType": "int56", + "name": "tickCumulativeOutside", + "type": "int56" + }, + { + "internalType": "uint160", + "name": "secondsPerLiquidityOutsideX128", + "type": "uint160" + }, + { + "internalType": "uint32", + "name": "secondsOutside", + "type": "uint32" + }, + { + "internalType": "bool", + "name": "initialized", + "type": "bool" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token0", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "token1", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + } +] \ No newline at end of file diff --git a/src/adaptors/gloop/getGMIPrice.js b/src/adaptors/gloop/getGMIPrice.js new file mode 100644 index 0000000000..468c011142 --- /dev/null +++ b/src/adaptors/gloop/getGMIPrice.js @@ -0,0 +1,54 @@ +const abiGMI = require('./abi/abiGMI.json'); + +const sdk = require('@defillama/sdk'); +const BigNumber = require('bignumber.js'); +const {ADDRESSES, CHAIN} = require('./Constants'); + +/** + * Gets GMI price in USD from GMI token contract + * Formula: GMI price = totalControlledValue / totalSupply + */ +const getGMIPrice = async () => { + try { + // Get total supply of GMI tokens + const totalSupplyResult = await sdk.api.abi.call({ + target: ADDRESSES.GMI, + abi: abiGMI.find((m) => m.name === 'totalSupply'), + chain: CHAIN, + }); + + // Get total controlled value (in USD, with 18 decimals) + const totalControlledValueResult = await sdk.api.abi.call({ + target: ADDRESSES.GMI, + abi: abiGMI.find((m) => m.name === 'totalControlledValue'), + params: [false], // roundUp = false + chain: CHAIN, + }); + + const totalSupply = new BigNumber(totalSupplyResult.output); + const totalControlledValue = new BigNumber( + totalControlledValueResult.output + ); + + if (totalSupply.isZero()) { + console.warn('GMI total supply is zero'); + return 0; + } + + // GMI price = (totalControlledValue * 100000) / totalSupply / 100000 + // This matches the frontend calculation + const gmiPrice = totalControlledValue + .multipliedBy(100000) + .dividedBy(totalSupply) + .dividedBy(100000); + + return gmiPrice.toNumber(); + } catch (error) { + console.error('Error fetching GMI price:', error); + return 0; + } +}; + +module.exports = { + getGMIPrice, +}; diff --git a/src/adaptors/gloop/getGloopPrice.js b/src/adaptors/gloop/getGloopPrice.js new file mode 100644 index 0000000000..cd4e2f7c5f --- /dev/null +++ b/src/adaptors/gloop/getGloopPrice.js @@ -0,0 +1,82 @@ +const sdk = require('@defillama/sdk'); +const axios = require('axios'); +const BigNumber = require('bignumber.js'); + +const abiUniswapV3Pool = require('./abi/abiUniswapV3Pool.json'); + +const {getGMIPrice} = require('./getGMIPrice'); + +const {ADDRESSES, CHAIN} = require('./Constants'); +/** + * Fetches the GLOOP token price using Uniswap V3 pool and GMI contract + * Route: GLOOP -> GMI (from V3 pool) -> USD (from GMI contract) + */ +const getGloopPrice = async () => { + try { + // Not listed on DefiLlama so this approach not used + // const priceKey = `${CHAIN}:${ADDRESSES.GLOOP}`; + // const priceData = await axios.get( + // `https://coins.llama.fi/prices/current/${priceKey}` + // ); + + // if (priceData.data?.coins?.[priceKey]?.price) { + // console.log('Using GLOOP price from DeFiLlama:', priceData.data.coins[priceKey].price); + // return priceData.data.coins[priceKey].price; + // } + + // Step 1: Get GMI price in USD from GMI contract + const gmiPriceInUSD = await getGMIPrice(); + + if (!gmiPriceInUSD || gmiPriceInUSD <= 0) { + console.warn('GMI price not available'); + return 0; + } + + console.log('GMI price in USD:', gmiPriceInUSD); + + // Step 2: Get GLOOP/GMI price from Uniswap V3 pool + const slot0Result = await sdk.api.abi.call({ + target: ADDRESSES.GLOOP_GMI_V3_POOL, + abi: abiUniswapV3Pool.find((m) => m.name === 'slot0'), + chain: CHAIN, + }); + + if (!slot0Result.output || !Array.isArray(slot0Result.output)) { + console.warn('Unable to fetch slot0 from GLOOP/GMI V3 pool'); + return 0; + } + + const sqrtPriceX96 = new BigNumber(slot0Result.output[0].toString()); + + if (sqrtPriceX96.isZero()) { + console.warn('Invalid sqrtPriceX96 (zero) from GLOOP/GMI V3 pool'); + return 0; + } + + // Convert sqrtPriceX96 to price + // price = (sqrtPriceX96 / 2^96)^2 + const twoPow96 = new BigNumber(2).pow(96); + const sqrtPrice = sqrtPriceX96.dividedBy(twoPow96); + const gloopGmiPrice = sqrtPrice.pow(2); + + console.log('GLOOP/GMI price from V3 pool:', gloopGmiPrice.toString()); + + // Step 3: Calculate GLOOP price in USD + // GLOOP/USD = GLOOP/GMI * GMI/USD + const gloopUsdPrice = gloopGmiPrice.multipliedBy(gmiPriceInUSD); + + console.log('Calculated GLOOP/USD price:', gloopUsdPrice.toNumber()); + + return gloopUsdPrice.toNumber(); + } catch (error) { + console.error('Error fetching GLOOP price:', error); + return 0; + } +}; + +module.exports = { + getGloopPrice, +}; + + +getGloopPrice(); \ No newline at end of file diff --git a/src/adaptors/gloop/getRewardAPY.js b/src/adaptors/gloop/getRewardAPY.js new file mode 100644 index 0000000000..61f41ef3db --- /dev/null +++ b/src/adaptors/gloop/getRewardAPY.js @@ -0,0 +1,68 @@ +const sdk = require('@defillama/sdk'); + +const abiGMIncentives = require('./abi/abiGMIncentives.json'); +const {ADDRESSES, CHAIN, SECONDS_PER_YEAR} = require('./Constants'); + +/** + * Calculates the reward APY from GLOOP emissions + */ +const getRewardAPY = async (gloopPrice, totalLendingPoolUSDCValue) => { + try { + if (!gloopPrice || gloopPrice <= 0) { + return 0; + } + + if (!totalLendingPoolUSDCValue || totalLendingPoolUSDCValue <= 0) { + return 0; + } + + // Get GLOOP rewards data + const rewardsDataResult = await sdk.api.abi.call({ + target: ADDRESSES.GM_INCENTIVES, + abi: abiGMIncentives.find((m) => m.name === 'getRewardsData'), + params: [ADDRESSES.GLOOP], + chain: CHAIN, + }); + + const rewardsData = rewardsDataResult.output; + + if (!rewardsData || !Array.isArray(rewardsData) || rewardsData.length < 3) { + return 0; + } + + // Check if reward distribution has ended + // rewardsData[2] is distributionEnd timestamp + const distributionEnd = BigInt(rewardsData[2]); + const currentTimestamp = BigInt(Math.floor(Date.now() / 1000)); + + if (currentTimestamp > distributionEnd) { + // Reward distribution has ended + return 0; + } + + // Get emissions per second (rewardsData[1]) + const emissionsPerSecond = BigInt(rewardsData[1]); + + if (emissionsPerSecond === 0n) { + return 0; + } + + // Convert emissions from 18 decimals to decimal + const emissionsPerSecondDecimal = Number(emissionsPerSecond) / 1e18; + + // Formula: Reward APY = ((GLOOP Emissions Rate * Seconds per year * GLOOP Token Price) / total USDC lent) * 100% + const annualRewardValue = + emissionsPerSecondDecimal * SECONDS_PER_YEAR * gloopPrice; + const aprDecimal = annualRewardValue / totalLendingPoolUSDCValue; + const aprPercentage = aprDecimal * 100; + + return aprPercentage; + } catch (error) { + console.error('Error calculating reward APY:', error); + return 0; + } +}; + +module.exports = { + getRewardAPY, +}; diff --git a/src/adaptors/gloop/getSupplyAPY.js b/src/adaptors/gloop/getSupplyAPY.js new file mode 100644 index 0000000000..0f928e525d --- /dev/null +++ b/src/adaptors/gloop/getSupplyAPY.js @@ -0,0 +1,67 @@ +const sdk = require('@defillama/sdk'); +const BigNumber = require('bignumber.js'); + +const abiInterestRateModel = require('./abi/abiInterestRateModel.json'); +const abiLendingPool = require('./abi/abiLendingPool.json'); + +const {ADDRESSES, CHAIN, SECONDS_PER_YEAR} = require('./Constants'); + +/** + * + * Calculates the supply APY for USDC lending + */ +const getSupplyAPY = async (availableLiquidity, totalBorrows) => { + try { + // Get raw borrow rate from interest rate model + const rawBorrowRateResult = await sdk.api.abi.call({ + target: ADDRESSES.INTEREST_RATE_MODEL, + abi: abiInterestRateModel.find((m) => m.name === 'getBorrowRate'), + params: [availableLiquidity, totalBorrows], + chain: CHAIN, + }); + + const rawBorrowRate = BigInt(rawBorrowRateResult.output); + + // Get reserve factor and gloop stakers yield factor + const [reserveFactorResult, gloopStakersYieldFactorResult] = + await Promise.all([ + sdk.api.abi.call({ + target: ADDRESSES.LENDING_POOL, + abi: abiLendingPool.find((m) => m.name === 'reserveFactor'), + chain: CHAIN, + }), + sdk.api.abi.call({ + target: ADDRESSES.LENDING_POOL, + abi: abiLendingPool.find((m) => m.name === 'gloopStakersYieldFactor'), + chain: CHAIN, + }), + ]); + + const reserveFactor = BigInt(reserveFactorResult.output); + const gloopStakersYieldFactor = BigInt( + gloopStakersYieldFactorResult.output + ); + const oneE18 = BigInt('1000000000000000000'); // 1e18 + + // Calculate the multiplier: 1 - (gloopStakersYieldFactor + reserveFactor) / 1e18 + const reductionFactor = gloopStakersYieldFactor + reserveFactor; + const multiplierNumerator = oneE18 - reductionFactor; + + // Calculate raw supply rate: rawBorrowRate * multiplier + const rawSupplyRate = (rawBorrowRate * multiplierNumerator) / oneE18; + + // Convert to APY percentage + // APY = (rawSupplyRate * secondsPerYear / 1e18) * 100 + const supplyApyBigInt = + (rawSupplyRate * BigInt(SECONDS_PER_YEAR) * BigInt(100)) / oneE18; + + return Number(supplyApyBigInt) / 100; // Convert back to decimal percentage + } catch (error) { + console.error('Error calculating supply APY:', error); + return 0; + } +}; + +module.exports = { + getSupplyAPY, +}; diff --git a/src/adaptors/gloop/index.js b/src/adaptors/gloop/index.js new file mode 100644 index 0000000000..8b10817df3 --- /dev/null +++ b/src/adaptors/gloop/index.js @@ -0,0 +1,128 @@ +const sdk = require('@defillama/sdk'); +const { ethers } = require('ethers'); +const axios = require('axios'); +const BigNumber = require('bignumber.js'); + +const utils = require('../utils'); + +const abiLendingPool = require('./abi/abiLendingPool.json'); +const abiOracle = require('./abi/abiOracle.json'); +const abiGMIncentives = require('./abi/abiGMIncentives.json'); +const abiInterestRateModel = require('./abi/abiInterestRateModel.json'); +const abiUniswapV3Pool = require('./abi/abiUniswapV3Pool.json'); +const abiGMI = require('./abi/abiGMI.json'); + +const { getGloopPrice } = require('./getGloopPrice'); +const { getSupplyAPY } = require('./getSupplyAPY'); +const { getRewardAPY } = require('./getRewardAPY'); + +// Contract addresses on Arbitrum +const {ADDRESSES, CHAIN} = require('./Constants'); + +/** + * Main function to fetch pool data + */ +const apy = async () => { + try { + // Fetch total underlying USDC in the lending pool + const totalUnderlyingResult = await sdk.api.abi.call({ + target: ADDRESSES.LENDING_POOL, + abi: abiLendingPool.find((m) => m.name === 'totalUnderlying'), + params: [ADDRESSES.USDC], + chain: CHAIN, + }); + + const totalUnderlying = BigInt(totalUnderlyingResult.output); + + // Fetch total borrows + const totalBorrowsResult = await sdk.api.abi.call({ + target: ADDRESSES.LENDING_POOL, + abi: abiLendingPool.find((m) => m.name === 'totalBorrows'), + params: [ADDRESSES.USDC], + chain: CHAIN, + }); + + const totalBorrows = BigInt(totalBorrowsResult.output); + + // Fetch available liquidity + const availableLiquidityResult = await sdk.api.abi.call({ + target: ADDRESSES.LENDING_POOL, + abi: abiLendingPool.find((m) => m.name === 'availableLiquidity'), + params: [ADDRESSES.USDC], + chain: CHAIN, + }); + + const availableLiquidity = BigInt(availableLiquidityResult.output); + + // Get USDC price (should be ~$1, but fetch from oracle to be accurate) + const usdcPriceResult = await sdk.api.abi.call({ + target: ADDRESSES.ORACLE, + abi: abiOracle.find((m) => m.name === 'getUnderlyingPrice'), + params: [ADDRESSES.USDC], + chain: CHAIN, + }); + + // Oracle returns price in 1e18 format, convert to decimal + const usdcPrice = Number(BigInt(usdcPriceResult.output)) / 1e18; + + // Calculate TVL in USD + // For lending protocols: tvlUsd = totalSupplyUsd - totalBorrowUsd + // totalSupplyUsd = totalUnderlying * price + // totalBorrowUsd = totalBorrows * price + const totalUnderlyingDecimal = Number(totalUnderlying) / 1e6; // USDC has 6 decimals + const totalBorrowsDecimal = Number(totalBorrows) / 1e6; + + const totalSupplyUsd = totalUnderlyingDecimal * usdcPrice; + const totalBorrowUsd = totalBorrowsDecimal * usdcPrice; + const tvlUsd = totalSupplyUsd - totalBorrowUsd; + + // Get GLOOP price + const gloopPrice = await getGloopPrice(); + + // Calculate supply APY + const apyBase = await getSupplyAPY( + availableLiquidity.toString(), + totalBorrows.toString() + ); + + // Calculate reward APY + const apyReward = await getRewardAPY(gloopPrice, totalUnderlyingDecimal); + + // Create pool identifier + const poolIdentifier = `${ADDRESSES.RECEIVED_TOKEN}-${CHAIN}`.toLowerCase(); + + const pool = { + pool: poolIdentifier, + chain: utils.formatChain(CHAIN), + project: 'gloop', + symbol: 'USDC', + tvlUsd: tvlUsd, + apyBase: apyBase * 100, + apyReward: apyReward > 0 ? apyReward * 100 : null, + rewardTokens: apyReward > 0 ? [ADDRESSES.GLOOP] : null, + underlyingTokens: [ADDRESSES.USDC], + poolMeta: 'V1 market', + url: 'https://gloop.finance/', + // Lending protocol specific fields + totalSupplyUsd: totalSupplyUsd, + totalBorrowUsd: totalBorrowUsd, + }; + + return [pool]; + } catch (error) { + console.error('Error in Gloop adapter:', error); + return []; + } +}; + +module.exports = { + timetravel: false, + apy, + url: 'https://app.gloop.finance/loop', +}; + +// async function main() { +// console.log(await apy()); +// } + +// main()