diff --git a/package.json b/package.json index 6e0ee61..97d3248 100644 --- a/package.json +++ b/package.json @@ -27,6 +27,10 @@ "format": "prettier --write .", "typecheck": "tsc --noEmit" }, + "dependencies": { + "dnum": "^2.13.1", + "viem": "^2.13.2" + }, "devDependencies": { "@commitlint/cli": "^19.3.0", "@commitlint/config-conventional": "^19.2.2", @@ -47,9 +51,6 @@ "typescript": "^5.4.5", "typescript-eslint": "^7.9.0" }, - "dependencies": { - "viem": "^2.13.2" - }, "config": { "commitizen": { "path": "@commitlint/cz-commitlint" diff --git a/pnpm-lock.yaml b/pnpm-lock.yaml index 95ebe3a..1c13432 100644 --- a/pnpm-lock.yaml +++ b/pnpm-lock.yaml @@ -8,6 +8,9 @@ importers: .: dependencies: + dnum: + specifier: ^2.13.1 + version: 2.13.1 viem: specifier: ^2.13.2 version: 2.13.2(typescript@5.4.5) @@ -657,6 +660,9 @@ packages: resolution: {integrity: sha512-WkrWp9GR4KXfKGYzOLmTuGVi1UWFfws377n9cc55/tb6DuqyF6pcQ5AbiHEshaDpY9v6oaSr2XCDidGmMwdzIA==} engines: {node: '>=8'} + dnum@2.13.1: + resolution: {integrity: sha512-4oZ+BtlvNtKFJji1Fc5073LyJFvgioBQ0PNu/C+r1A8P09Yvka/aXYYD5bsUHMTUPEu01iv4bk+5nPQmt5AA8A==} + doctrine@2.1.0: resolution: {integrity: sha512-35mSku4ZXK0vfCuHEDAwt55dg2jNajHZ1odvF+8SSr82EsZY4QmXfuWso8oEd8zRhVObSN18aM0CjSdoBX7zIw==} engines: {node: '>=0.10.0'} @@ -899,6 +905,9 @@ packages: for-each@0.3.3: resolution: {integrity: sha512-jqYfLp7mo9vIyQf8ykW2v7A+2N4QjeCeI5+Dz9XraiO1ign81wjiH7Fb9vSOWvQfNtmSa4H2RoQTrrXivdUZmw==} + from-exponential@1.1.1: + resolution: {integrity: sha512-VBE7f5OVnYwdgB3LHa+Qo29h8qVpxhVO9Trlc+AWm+/XNAgks1tAwMFHb33mjeiof77GglsJzeYF7OqXrROP/A==} + fs-extra@9.1.0: resolution: {integrity: sha512-hcg3ZmepS30/7BSFqRvoo3DOMQu7IjqxO5nCDt+zM9XWjb33Wg7ziNT+Qvqbuc3+gWpzO02JubVyk2G4Zvo1OQ==} engines: {node: '>=10'} @@ -2670,6 +2679,10 @@ snapshots: dependencies: path-type: 4.0.0 + dnum@2.13.1: + dependencies: + from-exponential: 1.1.1 + doctrine@2.1.0: dependencies: esutils: 2.0.3 @@ -3045,6 +3058,8 @@ snapshots: dependencies: is-callable: 1.2.7 + from-exponential@1.1.1: {} + fs-extra@9.1.0: dependencies: at-least-node: 1.0.0 diff --git a/src/chains/evm/hub/constants/abi/hub-pool-abi.ts b/src/chains/evm/hub/constants/abi/hub-pool-abi.ts new file mode 100644 index 0000000..380d40c --- /dev/null +++ b/src/chains/evm/hub/constants/abi/hub-pool-abi.ts @@ -0,0 +1,1348 @@ +export const HubPoolAbi = [ + { inputs: [], name: "AccessControlBadConfirmation", type: "error" }, + { + inputs: [{ internalType: "uint48", name: "schedule", type: "uint48" }], + name: "AccessControlEnforcedDefaultAdminDelay", + type: "error", + }, + { inputs: [], name: "AccessControlEnforcedDefaultAdminRules", type: "error" }, + { + inputs: [ + { internalType: "address", name: "defaultAdmin", type: "address" }, + ], + name: "AccessControlInvalidDefaultAdmin", + type: "error", + }, + { + inputs: [ + { internalType: "address", name: "account", type: "address" }, + { internalType: "bytes32", name: "neededRole", type: "bytes32" }, + ], + name: "AccessControlUnauthorizedAccount", + type: "error", + }, + { + 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: [{ internalType: "uint256", name: "maxLoan", type: "uint256" }], + name: "ERC3156ExceededMaxLoan", + type: "error", + }, + { + inputs: [{ internalType: "address", name: "receiver", type: "address" }], + name: "ERC3156InvalidReceiver", + type: "error", + }, + { + inputs: [{ internalType: "address", name: "token", type: "address" }], + name: "ERC3156UnsupportedToken", + type: "error", + }, + { + inputs: [{ internalType: "uint16", name: "chainId", type: "uint16" }], + name: "ExistingChainSpoke", + type: "error", + }, + { inputs: [], name: "FlashLoanFeeTooHigh", type: "error" }, + { inputs: [], name: "MathOverflowedMulDiv", type: "error" }, + { inputs: [], name: "MaxStableInterestRateTooHigh", type: "error" }, + { inputs: [], name: "MaxVariableInterestRateTooHigh", type: "error" }, + { + inputs: [{ internalType: "uint16", name: "chainId", type: "uint16" }], + name: "NoChainSpoke", + type: "error", + }, + { inputs: [], name: "OptimalStableToTotalDebtRatioTooHigh", type: "error" }, + { inputs: [], name: "OptimalUtilisationRatioTooHigh", type: "error" }, + { inputs: [], name: "OptimalUtilisationRatioTooLow", type: "error" }, + { inputs: [], name: "RebalanceUpDepositInterestRateTooHigh", type: "error" }, + { inputs: [], name: "RebalanceUpUtilisationRatioTooHigh", type: "error" }, + { inputs: [], name: "RetentionRateTooHigh", type: "error" }, + { + inputs: [ + { internalType: "uint8", name: "bits", type: "uint8" }, + { internalType: "uint256", name: "value", type: "uint256" }, + ], + name: "SafeCastOverflowedUintDowncast", + type: "error", + }, + { inputs: [], name: "StableBorrowPercentageTooHigh", type: "error" }, + { + inputs: [ + { internalType: "uint16", name: "chainId", type: "uint16" }, + { internalType: "bytes32", name: "expected", type: "bytes32" }, + { internalType: "bytes32", name: "actual", type: "bytes32" }, + ], + name: "UnmatchedChainSpoke", + 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: "uint256", + name: "amount", + type: "uint256", + }, + ], + name: "ClearTokenFees", + type: "event", + }, + { + anonymous: false, + inputs: [], + name: "DefaultAdminDelayChangeCanceled", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint48", + name: "newDelay", + type: "uint48", + }, + { + indexed: false, + internalType: "uint48", + name: "effectSchedule", + type: "uint48", + }, + ], + name: "DefaultAdminDelayChangeScheduled", + type: "event", + }, + { + anonymous: false, + inputs: [], + name: "DefaultAdminTransferCanceled", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "newAdmin", + type: "address", + }, + { + indexed: false, + internalType: "uint48", + name: "acceptSchedule", + type: "uint48", + }, + ], + name: "DefaultAdminTransferScheduled", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "variableBorrowInterestIndex", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "depositInterestIndex", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "lastUpdateTimestamp", + type: "uint256", + }, + ], + name: "InterestIndexesUpdated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint256", + name: "variableBorrowInterestRate", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "stableBorrowInterestRate", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "depositInterestRate", + type: "uint256", + }, + ], + name: "InterestRatesUpdated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, + { + indexed: true, + internalType: "bytes32", + name: "previousAdminRole", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "newAdminRole", + type: "bytes32", + }, + ], + name: "RoleAdminChanged", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, + { + indexed: true, + internalType: "address", + name: "account", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "RoleGranted", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, + { + indexed: true, + internalType: "address", + name: "account", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "RoleRevoked", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "address", name: "from", type: "address" }, + { indexed: true, internalType: "address", name: "to", type: "address" }, + { + indexed: false, + internalType: "uint256", + name: "value", + type: "uint256", + }, + ], + name: "Transfer", + type: "event", + }, + { + inputs: [], + name: "DEFAULT_ADMIN_ROLE", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "HUB_ROLE", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "LOAN_MANAGER_ROLE", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "ORACLE_ROLE", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "PARAM_ROLE", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "acceptDefaultAdminTransfer", + 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: "address", name: "newAdmin", type: "address" }], + name: "beginDefaultAdminTransfer", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "sender", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + ], + name: "burnFToken", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "cancelDefaultAdminTransfer", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "uint48", name: "newDelay", type: "uint48" }], + name: "changeDefaultAdminDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "clearTokenFees", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "decimals", + outputs: [{ internalType: "uint8", name: "", type: "uint8" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "defaultAdmin", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "defaultAdminDelay", + outputs: [{ internalType: "uint48", name: "", type: "uint48" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "defaultAdminDelayIncreaseWait", + outputs: [{ internalType: "uint48", name: "", type: "uint48" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "token", type: "address" }, + { internalType: "uint256", name: "value", type: "uint256" }, + ], + name: "flashFee", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "contract IERC3156FlashBorrower", + name: "receiver", + type: "address", + }, + { internalType: "address", name: "token", type: "address" }, + { internalType: "uint256", name: "value", type: "uint256" }, + { internalType: "bytes", name: "data", type: "bytes" }, + ], + name: "flashLoan", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "getCapsData", + outputs: [ + { + components: [ + { internalType: "uint64", name: "deposit", type: "uint64" }, + { internalType: "uint64", name: "borrow", type: "uint64" }, + { + internalType: "uint64", + name: "stableBorrowPercentage", + type: "uint64", + }, + ], + internalType: "struct HubPoolState.CapsData", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "uint16", name: "chainId", type: "uint16" }], + name: "getChainSpoke", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getConfigData", + outputs: [ + { + components: [ + { internalType: "bool", name: "deprecated", type: "bool" }, + { internalType: "bool", name: "stableBorrowSupported", type: "bool" }, + { internalType: "bool", name: "canMintFToken", type: "bool" }, + { internalType: "bool", name: "flashLoanSupported", type: "bool" }, + ], + internalType: "struct HubPoolState.ConfigData", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getDepositData", + outputs: [ + { + components: [ + { + internalType: "uint16", + name: "optimalUtilisationRatio", + type: "uint16", + }, + { internalType: "uint256", name: "totalAmount", type: "uint256" }, + { internalType: "uint256", name: "interestRate", type: "uint256" }, + { internalType: "uint256", name: "interestIndex", type: "uint256" }, + ], + internalType: "struct HubPoolState.DepositData", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getFeeData", + outputs: [ + { + components: [ + { internalType: "uint32", name: "flashLoanFee", type: "uint32" }, + { internalType: "uint32", name: "retentionRate", type: "uint32" }, + { + internalType: "address", + name: "fTokenFeeRecipient", + type: "address", + }, + { internalType: "address", name: "tokenFeeClaimer", type: "address" }, + { + internalType: "uint256", + name: "totalRetainedAmount", + type: "uint256", + }, + { + internalType: "bytes32", + name: "tokenFeeRecipient", + type: "bytes32", + }, + ], + internalType: "struct HubPoolState.FeeData", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getLastUpdateTimestamp", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getOracleManager", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getPoolId", + outputs: [{ internalType: "uint8", name: "", type: "uint8" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }], + name: "getRoleAdmin", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { + internalType: "contract IBridgeRouter", + name: "bridgeRouter", + type: "address", + }, + { internalType: "uint16", name: "adapterId", type: "uint16" }, + { internalType: "uint256", name: "gasLimit", type: "uint256" }, + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + { internalType: "uint16", name: "chainId", type: "uint16" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "bytes32", name: "recipient", type: "bytes32" }, + ], + name: "getSendTokenMessage", + outputs: [ + { + components: [ + { + components: [ + { internalType: "uint16", name: "adapterId", type: "uint16" }, + { + internalType: "uint16", + name: "returnAdapterId", + type: "uint16", + }, + { + internalType: "uint256", + name: "receiverValue", + type: "uint256", + }, + { internalType: "uint256", name: "gasLimit", type: "uint256" }, + { + internalType: "uint256", + name: "returnGasLimit", + type: "uint256", + }, + ], + internalType: "struct Messages.MessageParams", + name: "params", + type: "tuple", + }, + { internalType: "bytes32", name: "sender", type: "bytes32" }, + { + internalType: "uint16", + name: "destinationChainId", + type: "uint16", + }, + { internalType: "bytes32", name: "handler", type: "bytes32" }, + { internalType: "bytes", name: "payload", type: "bytes" }, + { internalType: "uint64", name: "finalityLevel", type: "uint64" }, + { internalType: "bytes", name: "extraArgs", type: "bytes" }, + ], + internalType: "struct Messages.MessageToSend", + name: "", + type: "tuple", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "getStableBorrowData", + outputs: [ + { + components: [ + { internalType: "uint32", name: "sr0", type: "uint32" }, + { internalType: "uint32", name: "sr1", type: "uint32" }, + { internalType: "uint32", name: "sr2", type: "uint32" }, + { internalType: "uint32", name: "sr3", type: "uint32" }, + { + internalType: "uint16", + name: "optimalStableToTotalDebtRatio", + type: "uint16", + }, + { + internalType: "uint16", + name: "rebalanceUpUtilisationRatio", + type: "uint16", + }, + { + internalType: "uint16", + name: "rebalanceUpDepositInterestRate", + type: "uint16", + }, + { + internalType: "uint16", + name: "rebalanceDownDelta", + type: "uint16", + }, + { internalType: "uint256", name: "totalAmount", type: "uint256" }, + { internalType: "uint256", name: "interestRate", type: "uint256" }, + { + internalType: "uint256", + name: "averageInterestRate", + type: "uint256", + }, + ], + internalType: "struct HubPoolState.StableBorrowData", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getTokenFeeClaimer", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getTokenFeeRecipient", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getUpdatedDepositInterestIndex", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getUpdatedVariableBorrowInterestIndex", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getVariableBorrowData", + outputs: [ + { + components: [ + { internalType: "uint32", name: "vr0", type: "uint32" }, + { internalType: "uint32", name: "vr1", type: "uint32" }, + { internalType: "uint32", name: "vr2", type: "uint32" }, + { internalType: "uint256", name: "totalAmount", type: "uint256" }, + { internalType: "uint256", name: "interestRate", type: "uint256" }, + { internalType: "uint256", name: "interestIndex", type: "uint256" }, + ], + internalType: "struct HubPoolState.VariableBorrowData", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "role", type: "bytes32" }, + { internalType: "address", name: "account", type: "address" }, + ], + name: "grantRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "role", type: "bytes32" }, + { internalType: "address", name: "account", type: "address" }, + ], + name: "hasRole", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "address", name: "token", type: "address" }], + name: "maxFlashLoan", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "address", name: "recipient", type: "address" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + ], + name: "mintFToken", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "uint256", name: "amount", type: "uint256" }], + name: "mintFTokenForFeeRecipient", + outputs: [], + stateMutability: "nonpayable", + 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: "pendingDefaultAdmin", + outputs: [ + { internalType: "address", name: "newAdmin", type: "address" }, + { internalType: "uint48", name: "schedule", type: "uint48" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pendingDefaultAdminDelay", + outputs: [ + { internalType: "uint48", name: "newDelay", type: "uint48" }, + { internalType: "uint48", name: "schedule", type: "uint48" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "poolId", + outputs: [{ internalType: "uint8", name: "", type: "uint8" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "uint256", name: "maxStableRate", type: "uint256" }, + ], + name: "preparePoolForBorrow", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "variableInterestIndex", + type: "uint256", + }, + { + internalType: "uint256", + name: "stableInterestRate", + type: "uint256", + }, + ], + internalType: "struct DataTypes.BorrowPoolParams", + name: "borrowPoolParams", + type: "tuple", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "preparePoolForRebalanceDown", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "variableInterestIndex", + type: "uint256", + }, + { + internalType: "uint256", + name: "stableInterestRate", + type: "uint256", + }, + { internalType: "uint256", name: "threshold", type: "uint256" }, + ], + internalType: "struct DataTypes.RebalanceDownPoolParams", + name: "rebalanceDownPoolParams", + type: "tuple", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "preparePoolForRebalanceUp", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "variableInterestIndex", + type: "uint256", + }, + { + internalType: "uint256", + name: "stableInterestRate", + type: "uint256", + }, + ], + internalType: "struct DataTypes.BorrowPoolParams", + name: "borrowPoolParams", + type: "tuple", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "preparePoolForRepay", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "variableInterestIndex", + type: "uint256", + }, + { + internalType: "uint256", + name: "stableInterestRate", + type: "uint256", + }, + ], + internalType: "struct DataTypes.BorrowPoolParams", + name: "", + type: "tuple", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "uint256", name: "maxStableRate", type: "uint256" }, + ], + name: "preparePoolForSwitchBorrowType", + outputs: [ + { + components: [ + { + internalType: "uint256", + name: "variableInterestIndex", + type: "uint256", + }, + { + internalType: "uint256", + name: "stableInterestRate", + type: "uint256", + }, + ], + internalType: "struct DataTypes.BorrowPoolParams", + name: "borrowPoolParams", + type: "tuple", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "preparePoolForWithdrawFToken", + outputs: [], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "role", type: "bytes32" }, + { internalType: "address", name: "account", type: "address" }, + ], + name: "renounceRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "role", type: "bytes32" }, + { internalType: "address", name: "account", type: "address" }, + ], + name: "revokeRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "rollbackDefaultAdminDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }], + name: "supportsInterface", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + 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: "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: [ + { + components: [ + { internalType: "uint64", name: "deposit", type: "uint64" }, + { internalType: "uint64", name: "borrow", type: "uint64" }, + { + internalType: "uint64", + name: "stableBorrowPercentage", + type: "uint64", + }, + ], + internalType: "struct HubPoolState.CapsData", + name: "capsData", + type: "tuple", + }, + ], + name: "updateCapsData", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + components: [ + { internalType: "bool", name: "deprecated", type: "bool" }, + { internalType: "bool", name: "stableBorrowSupported", type: "bool" }, + { internalType: "bool", name: "canMintFToken", type: "bool" }, + { internalType: "bool", name: "flashLoanSupported", type: "bool" }, + ], + internalType: "struct HubPoolState.ConfigData", + name: "configData", + type: "tuple", + }, + ], + name: "updateConfigData", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "uint16", + name: "optimalUtilisationRatio", + type: "uint16", + }, + ], + name: "updateDepositData", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint32", name: "flashLoanFee", type: "uint32" }, + { internalType: "uint32", name: "retentionRate", type: "uint32" }, + { internalType: "address", name: "fTokenFeeRecipient", type: "address" }, + { internalType: "address", name: "tokenFeeClaimer", type: "address" }, + { internalType: "bytes32", name: "tokenFeeRecipient", type: "bytes32" }, + ], + name: "updateFeeData", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "updateInterestIndexes", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "contract IOracleManager", + name: "newOracleManager", + type: "address", + }, + ], + name: "updateOracleManager", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "bool", name: "isStable", type: "bool" }, + ], + name: "updatePoolWithBorrow", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "uint256", name: "amount", type: "uint256" }], + name: "updatePoolWithDeposit", + outputs: [ + { + components: [ + { internalType: "uint256", name: "fAmount", type: "uint256" }, + { + internalType: "uint256", + name: "depositInterestIndex", + type: "uint256", + }, + { + components: [ + { internalType: "uint256", name: "price", type: "uint256" }, + { internalType: "uint8", name: "decimals", type: "uint8" }, + ], + internalType: "struct DataTypes.PriceFeed", + name: "priceFeed", + type: "tuple", + }, + ], + internalType: "struct DataTypes.DepositPoolParams", + name: "", + type: "tuple", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "updatePoolWithLiquidation", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint256", name: "amount", type: "uint256" }, + { + internalType: "uint256", + name: "oldLoanStableInterestRate", + type: "uint256", + }, + ], + name: "updatePoolWithRebalanceDown", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint256", name: "amount", type: "uint256" }, + { + internalType: "uint256", + name: "oldLoanStableInterestRate", + type: "uint256", + }, + ], + name: "updatePoolWithRebalanceUp", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint256", name: "principalPaid", type: "uint256" }, + { internalType: "uint256", name: "interestPaid", type: "uint256" }, + { internalType: "uint256", name: "loanStableRate", type: "uint256" }, + { internalType: "uint256", name: "excessAmount", type: "uint256" }, + ], + name: "updatePoolWithRepay", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint256", name: "principalPaid", type: "uint256" }, + { internalType: "uint256", name: "interestPaid", type: "uint256" }, + { internalType: "uint256", name: "loanStableRate", type: "uint256" }, + ], + name: "updatePoolWithRepayWithCollateral", + outputs: [ + { + components: [ + { internalType: "uint256", name: "fAmount", type: "uint256" }, + ], + internalType: "struct DataTypes.RepayWithCollateralPoolParams", + name: "", + type: "tuple", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint256", name: "loanBorrowAmount", type: "uint256" }, + { internalType: "bool", name: "switchingToStable", type: "bool" }, + { + internalType: "uint256", + name: "oldLoanBorrowStableRate", + type: "uint256", + }, + ], + name: "updatePoolWithSwitchBorrowType", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "bool", name: "isFAmount", type: "bool" }, + ], + name: "updatePoolWithWithdraw", + outputs: [ + { + components: [ + { internalType: "uint256", name: "underlingAmount", type: "uint256" }, + { internalType: "uint256", name: "fAmount", type: "uint256" }, + ], + internalType: "struct DataTypes.WithdrawPoolParams", + name: "", + type: "tuple", + }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint32", name: "sr0", type: "uint32" }, + { internalType: "uint32", name: "sr1", type: "uint32" }, + { internalType: "uint32", name: "sr2", type: "uint32" }, + { internalType: "uint32", name: "sr3", type: "uint32" }, + { + internalType: "uint16", + name: "optimalStableToTotalDebtRatio", + type: "uint16", + }, + { + internalType: "uint16", + name: "rebalanceUpUtilisationRatio", + type: "uint16", + }, + { + internalType: "uint16", + name: "rebalanceUpDepositInterestRate", + type: "uint16", + }, + { internalType: "uint16", name: "rebalanceDownDelta", type: "uint16" }, + ], + name: "updateStableBorrowData", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint32", name: "vr0", type: "uint32" }, + { internalType: "uint32", name: "vr1", type: "uint32" }, + { internalType: "uint32", name: "vr2", type: "uint32" }, + ], + name: "updateVariableBorrowData", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint16", name: "chainId", type: "uint16" }, + { internalType: "bytes32", name: "source", type: "bytes32" }, + ], + name: "verifyReceiveToken", + outputs: [], + stateMutability: "view", + type: "function", + }, +] as const; diff --git a/src/chains/evm/hub/constants/abi/loan-manager-abi.ts b/src/chains/evm/hub/constants/abi/loan-manager-abi.ts new file mode 100644 index 0000000..f70b015 --- /dev/null +++ b/src/chains/evm/hub/constants/abi/loan-manager-abi.ts @@ -0,0 +1,1037 @@ +export const LoanManagerAbi = [ + { + inputs: [ + { internalType: "address", name: "admin", type: "address" }, + { + internalType: "contract IOracleManager", + name: "oracleManager", + type: "address", + }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { inputs: [], name: "AccessControlBadConfirmation", type: "error" }, + { + inputs: [{ internalType: "uint48", name: "schedule", type: "uint48" }], + name: "AccessControlEnforcedDefaultAdminDelay", + type: "error", + }, + { inputs: [], name: "AccessControlEnforcedDefaultAdminRules", type: "error" }, + { + inputs: [ + { internalType: "address", name: "defaultAdmin", type: "address" }, + ], + name: "AccessControlInvalidDefaultAdmin", + type: "error", + }, + { + inputs: [ + { internalType: "address", name: "account", type: "address" }, + { internalType: "bytes32", name: "neededRole", type: "bytes32" }, + ], + name: "AccessControlUnauthorizedAccount", + type: "error", + }, + { + inputs: [{ internalType: "uint8", name: "poolId", type: "uint8" }], + name: "BorrowCapReached", + type: "error", + }, + { inputs: [], name: "BorrowFactorTooLow", type: "error" }, + { inputs: [], name: "BorrowRewardIndexTooHigh", type: "error" }, + { + inputs: [{ internalType: "uint8", name: "poolId", type: "uint8" }], + name: "CollateralCapReached", + type: "error", + }, + { inputs: [], name: "CollateralFactorTooHigh", type: "error" }, + { inputs: [], name: "CollateralRewardIndexTooHigh", type: "error" }, + { inputs: [], name: "LiquidationBonusTooHigh", type: "error" }, + { inputs: [], name: "LiquidationFeeTooHigh", type: "error" }, + { + inputs: [{ internalType: "bytes32", name: "loanId", type: "bytes32" }], + name: "LoanNotEmpty", + type: "error", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + ], + name: "LoanPoolAlreadyAdded", + type: "error", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + ], + name: "LoanPoolAlreadyDeprecated", + type: "error", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + ], + name: "LoanPoolDeprecated", + type: "error", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + ], + name: "LoanPoolUnknown", + type: "error", + }, + { inputs: [], name: "LoanTargetHealthTooLow", type: "error" }, + { + inputs: [{ internalType: "uint16", name: "loanTypeId", type: "uint16" }], + name: "LoanTypeAlreadyCreated", + type: "error", + }, + { + inputs: [{ internalType: "uint16", name: "loanTypeId", type: "uint16" }], + name: "LoanTypeAlreadyDeprecated", + type: "error", + }, + { + inputs: [{ internalType: "uint16", name: "loanTypeId", type: "uint16" }], + name: "LoanTypeDeprecated", + type: "error", + }, + { + inputs: [{ internalType: "uint16", name: "loanTypeId", type: "uint16" }], + name: "LoanTypeUnknown", + type: "error", + }, + { inputs: [], name: "MathOverflowedMulDiv", type: "error" }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + ], + name: "NotAccountOwner", + type: "error", + }, + { + inputs: [{ internalType: "uint8", name: "poolId", type: "uint8" }], + name: "PoolAlreadyAdded", + type: "error", + }, + { + inputs: [{ internalType: "uint8", name: "poolId", type: "uint8" }], + name: "PoolUnknown", + type: "error", + }, + { + inputs: [ + { internalType: "uint8", name: "bits", type: "uint8" }, + { internalType: "uint256", name: "value", type: "uint256" }, + ], + name: "SafeCastOverflowedUintDowncast", + type: "error", + }, + { + inputs: [{ internalType: "bytes32", name: "loanId", type: "bytes32" }], + name: "SameLoan", + type: "error", + }, + { + inputs: [{ internalType: "bytes32", name: "loanId", type: "bytes32" }], + name: "UnknownUserLoan", + type: "error", + }, + { + inputs: [{ internalType: "bytes32", name: "loanId", type: "bytes32" }], + name: "UserLoanAlreadyCreated", + type: "error", + }, + { + inputs: [{ internalType: "bytes32", name: "loanId", type: "bytes32" }], + name: "UserLoanInactive", + type: "error", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bytes32", + name: "loanId", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "accountId", + type: "bytes32", + }, + { + indexed: false, + internalType: "uint16", + name: "loanTypeId", + type: "uint16", + }, + ], + name: "CreateUserLoan", + type: "event", + }, + { + anonymous: false, + inputs: [], + name: "DefaultAdminDelayChangeCanceled", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint48", + name: "newDelay", + type: "uint48", + }, + { + indexed: false, + internalType: "uint48", + name: "effectSchedule", + type: "uint48", + }, + ], + name: "DefaultAdminDelayChangeScheduled", + type: "event", + }, + { + anonymous: false, + inputs: [], + name: "DefaultAdminTransferCanceled", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "newAdmin", + type: "address", + }, + { + indexed: false, + internalType: "uint48", + name: "acceptSchedule", + type: "uint48", + }, + ], + name: "DefaultAdminTransferScheduled", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bytes32", + name: "loanId", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "accountId", + type: "bytes32", + }, + ], + name: "DeleteUserLoan", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: false, internalType: "uint8", name: "poolId", type: "uint8" }, + { + indexed: false, + internalType: "uint256", + name: "collateralRewardIndex", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "borrowRewardIndex", + type: "uint256", + }, + { + indexed: false, + internalType: "uint256", + name: "lastUpdateTimestamp", + type: "uint256", + }, + ], + name: "RewardIndexesUpdated", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, + { + indexed: true, + internalType: "bytes32", + name: "previousAdminRole", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "newAdminRole", + type: "bytes32", + }, + ], + name: "RoleAdminChanged", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, + { + indexed: true, + internalType: "address", + name: "account", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "RoleGranted", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, + { + indexed: true, + internalType: "address", + name: "account", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "RoleRevoked", + type: "event", + }, + { + inputs: [], + name: "DEFAULT_ADMIN_ROLE", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "HUB_ROLE", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "LISTING_ROLE", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "ORACLE_ROLE", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "acceptDefaultAdminTransfer", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "contract IHubPool", name: "pool", type: "address" }, + ], + name: "addPool", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "uint16", name: "collateralFactor", type: "uint16" }, + { internalType: "uint64", name: "collateralCap", type: "uint64" }, + { internalType: "uint16", name: "borrowFactor", type: "uint16" }, + { internalType: "uint64", name: "borrowCap", type: "uint64" }, + { internalType: "uint16", name: "liquidationBonus", type: "uint16" }, + { internalType: "uint16", name: "liquidationFee", type: "uint16" }, + { + internalType: "uint256", + name: "rewardCollateralSpeed", + type: "uint256", + }, + { internalType: "uint256", name: "rewardBorrowSpeed", type: "uint256" }, + { internalType: "uint256", name: "rewardMinimumAmount", type: "uint256" }, + ], + name: "addPoolToLoanType", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "address", name: "newAdmin", type: "address" }], + name: "beginDefaultAdminTransfer", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "uint256", name: "maxStableRate", type: "uint256" }, + ], + name: "borrow", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "cancelDefaultAdminTransfer", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "uint48", name: "newDelay", type: "uint48" }], + name: "changeDefaultAdminDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint32", name: "loanTargetHealth", type: "uint32" }, + ], + name: "createLoanType", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + ], + name: "createUserLoan", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "defaultAdmin", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "defaultAdminDelay", + outputs: [{ internalType: "uint48", name: "", type: "uint48" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "defaultAdminDelayIncreaseWait", + outputs: [{ internalType: "uint48", name: "", type: "uint48" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + ], + name: "deleteUserLoan", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + ], + name: "deposit", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "address", name: "sender", type: "address" }, + { internalType: "uint256", name: "fAmount", type: "uint256" }, + ], + name: "depositFToken", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "uint16", name: "loanTypeId", type: "uint16" }], + name: "deprecateLoanType", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + ], + name: "deprecatePoolInLoanType", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + ], + name: "getLoanPool", + outputs: [ + { + components: [ + { internalType: "uint256", name: "collateralUsed", type: "uint256" }, + { internalType: "uint256", name: "borrowUsed", type: "uint256" }, + { internalType: "uint64", name: "collateralCap", type: "uint64" }, + { internalType: "uint64", name: "borrowCap", type: "uint64" }, + { internalType: "uint16", name: "collateralFactor", type: "uint16" }, + { internalType: "uint16", name: "borrowFactor", type: "uint16" }, + { internalType: "uint16", name: "liquidationBonus", type: "uint16" }, + { internalType: "uint16", name: "liquidationFee", type: "uint16" }, + { internalType: "bool", name: "isAdded", type: "bool" }, + { internalType: "bool", name: "isDeprecated", type: "bool" }, + { + components: [ + { + internalType: "uint64", + name: "lastUpdateTimestamp", + type: "uint64", + }, + { + internalType: "uint256", + name: "minimumAmount", + type: "uint256", + }, + { + internalType: "uint256", + name: "collateralSpeed", + type: "uint256", + }, + { internalType: "uint256", name: "borrowSpeed", type: "uint256" }, + { + internalType: "uint256", + name: "collateralRewardIndex", + type: "uint256", + }, + { + internalType: "uint256", + name: "borrowRewardIndex", + type: "uint256", + }, + ], + internalType: "struct LoanManagerState.LoanPoolReward", + name: "reward", + type: "tuple", + }, + ], + internalType: "struct LoanManagerState.LoanPool", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "uint16", name: "loanTypeId", type: "uint16" }], + name: "getLoanTypeLoanTargetHealth", + outputs: [{ internalType: "uint256", name: "", type: "uint256" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getOracleManager", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "uint8", name: "poolId", type: "uint8" }], + name: "getPool", + outputs: [{ internalType: "contract IHubPool", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }], + name: "getRoleAdmin", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "bytes32", name: "loanId", type: "bytes32" }], + name: "getType", + outputs: [{ internalType: "uint16", name: "", type: "uint16" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "bytes32", name: "loanId", type: "bytes32" }], + name: "getUserLoan", + outputs: [ + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8[]", name: "colPools", type: "uint8[]" }, + { internalType: "uint8[]", name: "borPools", type: "uint8[]" }, + { + components: [ + { internalType: "uint256", name: "balance", type: "uint256" }, + { internalType: "uint256", name: "rewardIndex", type: "uint256" }, + ], + internalType: "struct LoanManagerState.UserLoanCollateral[]", + name: "", + type: "tuple[]", + }, + { + components: [ + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "uint256", name: "balance", type: "uint256" }, + { + internalType: "uint256", + name: "lastInterestIndex", + type: "uint256", + }, + { + internalType: "uint256", + name: "stableInterestRate", + type: "uint256", + }, + { + internalType: "uint256", + name: "lastStableUpdateTimestamp", + type: "uint256", + }, + { internalType: "uint256", name: "rewardIndex", type: "uint256" }, + ], + internalType: "struct LoanManagerState.UserLoanBorrow[]", + name: "", + type: "tuple[]", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + ], + name: "getUserPoolRewards", + outputs: [ + { + components: [ + { internalType: "uint256", name: "collateral", type: "uint256" }, + { internalType: "uint256", name: "borrow", type: "uint256" }, + { internalType: "uint256", name: "interestPaid", type: "uint256" }, + ], + internalType: "struct LoanManagerState.UserPoolRewards", + name: "", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "role", type: "bytes32" }, + { internalType: "address", name: "account", type: "address" }, + ], + name: "grantRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "role", type: "bytes32" }, + { internalType: "address", name: "account", type: "address" }, + ], + name: "hasRole", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "uint16", name: "loanTypeId", type: "uint16" }], + name: "isLoanTypeCreated", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "uint16", name: "loanTypeId", type: "uint16" }], + name: "isLoanTypeDeprecated", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "uint8", name: "poolId", type: "uint8" }], + name: "isPoolAdded", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + ], + name: "isPoolInLoanType", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + ], + name: "isPoolInLoanTypeDeprecated", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "bytes32", name: "loanId", type: "bytes32" }], + name: "isUserLoanActive", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + ], + name: "isUserLoanOwner", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "violatorLoanId", type: "bytes32" }, + { internalType: "bytes32", name: "liquidatorLoanId", type: "bytes32" }, + { internalType: "bytes32", name: "liquidatorAccountId", type: "bytes32" }, + { internalType: "uint8", name: "colPoolId", type: "uint8" }, + { internalType: "uint8", name: "borPoolId", type: "uint8" }, + { internalType: "uint256", name: "maxRepayAmount", type: "uint256" }, + { internalType: "uint256", name: "minSeizedAmount", type: "uint256" }, + ], + name: "liquidate", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "owner", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pendingDefaultAdmin", + outputs: [ + { internalType: "address", name: "newAdmin", type: "address" }, + { internalType: "uint48", name: "schedule", type: "uint48" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pendingDefaultAdminDelay", + outputs: [ + { internalType: "uint48", name: "newDelay", type: "uint48" }, + { internalType: "uint48", name: "schedule", type: "uint48" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + ], + name: "rebalanceDown", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + ], + name: "rebalanceUp", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "role", type: "bytes32" }, + { internalType: "address", name: "account", type: "address" }, + ], + name: "renounceRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "uint256", name: "maxOverRepayment", type: "uint256" }, + ], + name: "repay", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + ], + name: "repayWithCollateral", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "role", type: "bytes32" }, + { internalType: "address", name: "account", type: "address" }, + ], + name: "revokeRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "rollbackDefaultAdminDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }], + name: "supportsInterface", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "uint256", name: "maxStableRate", type: "uint256" }, + ], + name: "switchBorrowType", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "uint16", name: "borrowFactor", type: "uint16" }, + ], + name: "updateLoanPoolBorrowFactor", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "uint64", name: "collateralCap", type: "uint64" }, + { internalType: "uint64", name: "borrowCap", type: "uint64" }, + ], + name: "updateLoanPoolCaps", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "uint16", name: "collateralFactor", type: "uint16" }, + ], + name: "updateLoanPoolCollateralFactor", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "uint16", name: "liquidationBonus", type: "uint16" }, + { internalType: "uint16", name: "liquidationFee", type: "uint16" }, + ], + name: "updateLoanPoolLiquidation", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint16[]", name: "loanTypeIds", type: "uint16[]" }, + { + internalType: "uint8[][]", + name: "poolIdsForLoanType", + type: "uint8[][]", + }, + ], + name: "updateLoanPoolsRewardIndexes", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint32", name: "loanTargetHealth", type: "uint32" }, + ], + name: "updateLoanTypeLoanTargetHealth", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { + internalType: "contract IOracleManager", + name: "newOracleManager", + type: "address", + }, + ], + name: "updateOracleManager", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint16", name: "loanTypeId", type: "uint16" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "uint256", name: "collateralSpeed", type: "uint256" }, + { internalType: "uint256", name: "borrowSpeed", type: "uint256" }, + { internalType: "uint256", name: "minimumAmount", type: "uint256" }, + ], + name: "updateRewardParams", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "bytes32[]", name: "loanIds", type: "bytes32[]" }], + name: "updateUserLoansPoolsRewards", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "uint256", name: "amount", type: "uint256" }, + { internalType: "bool", name: "isFAmount", type: "bool" }, + ], + name: "withdraw", + outputs: [ + { internalType: "uint256", name: "underlingAmount", type: "uint256" }, + ], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "loanId", type: "bytes32" }, + { internalType: "bytes32", name: "accountId", type: "bytes32" }, + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "address", name: "recipient", type: "address" }, + { internalType: "uint256", name: "fAmount", type: "uint256" }, + ], + name: "withdrawFToken", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, +] as const; diff --git a/src/chains/evm/hub/constants/abi/oracle-manager-abi.ts b/src/chains/evm/hub/constants/abi/oracle-manager-abi.ts new file mode 100644 index 0000000..e098fca --- /dev/null +++ b/src/chains/evm/hub/constants/abi/oracle-manager-abi.ts @@ -0,0 +1,390 @@ +export const OracleManagerAbi = [ + { + inputs: [ + { internalType: "address", name: "admin", type: "address" }, + { internalType: "address", name: "nodeManager", type: "address" }, + ], + stateMutability: "nonpayable", + type: "constructor", + }, + { inputs: [], name: "AccessControlBadConfirmation", type: "error" }, + { + inputs: [{ internalType: "uint48", name: "schedule", type: "uint48" }], + name: "AccessControlEnforcedDefaultAdminDelay", + type: "error", + }, + { inputs: [], name: "AccessControlEnforcedDefaultAdminRules", type: "error" }, + { + inputs: [ + { internalType: "address", name: "defaultAdmin", type: "address" }, + ], + name: "AccessControlInvalidDefaultAdmin", + type: "error", + }, + { + inputs: [ + { internalType: "address", name: "account", type: "address" }, + { internalType: "bytes32", name: "neededRole", type: "bytes32" }, + ], + name: "AccessControlUnauthorizedAccount", + type: "error", + }, + { + inputs: [{ internalType: "address", name: "nodeManager", type: "address" }], + name: "InvalidNodeManager", + type: "error", + }, + { + inputs: [{ internalType: "uint8", name: "poolId", type: "uint8" }], + name: "NoNodeIdForPool", + type: "error", + }, + { + inputs: [ + { internalType: "uint8", name: "bits", type: "uint8" }, + { internalType: "uint256", name: "value", type: "uint256" }, + ], + name: "SafeCastOverflowedUintDowncast", + type: "error", + }, + { + anonymous: false, + inputs: [], + name: "DefaultAdminDelayChangeCanceled", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "uint48", + name: "newDelay", + type: "uint48", + }, + { + indexed: false, + internalType: "uint48", + name: "effectSchedule", + type: "uint48", + }, + ], + name: "DefaultAdminDelayChangeScheduled", + type: "event", + }, + { + anonymous: false, + inputs: [], + name: "DefaultAdminTransferCanceled", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: "address", + name: "newAdmin", + type: "address", + }, + { + indexed: false, + internalType: "uint48", + name: "acceptSchedule", + type: "uint48", + }, + ], + name: "DefaultAdminTransferScheduled", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "bytes32", + name: "nodeId", + type: "bytes32", + }, + { indexed: false, internalType: "uint8", name: "poolId", type: "uint8" }, + ], + name: "NodeIdSetForPool", + type: "event", + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: "address", + name: "nodeManager", + type: "address", + }, + ], + name: "NodeManagerSet", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, + { + indexed: true, + internalType: "bytes32", + name: "previousAdminRole", + type: "bytes32", + }, + { + indexed: true, + internalType: "bytes32", + name: "newAdminRole", + type: "bytes32", + }, + ], + name: "RoleAdminChanged", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, + { + indexed: true, + internalType: "address", + name: "account", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "RoleGranted", + type: "event", + }, + { + anonymous: false, + inputs: [ + { indexed: true, internalType: "bytes32", name: "role", type: "bytes32" }, + { + indexed: true, + internalType: "address", + name: "account", + type: "address", + }, + { + indexed: true, + internalType: "address", + name: "sender", + type: "address", + }, + ], + name: "RoleRevoked", + type: "event", + }, + { + inputs: [], + name: "DEFAULT_ADMIN_ROLE", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "MANAGER_ROLE", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "acceptDefaultAdminTransfer", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "address", name: "newAdmin", type: "address" }], + name: "beginDefaultAdminTransfer", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "cancelDefaultAdminTransfer", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "uint48", name: "newDelay", type: "uint48" }], + name: "changeDefaultAdminDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "defaultAdmin", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "defaultAdminDelay", + outputs: [{ internalType: "uint48", name: "", type: "uint48" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "defaultAdminDelayIncreaseWait", + outputs: [{ internalType: "uint48", name: "", type: "uint48" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "getNodeManager", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "bytes32", name: "role", type: "bytes32" }], + name: "getRoleAdmin", + outputs: [{ internalType: "bytes32", name: "", type: "bytes32" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "role", type: "bytes32" }, + { internalType: "address", name: "account", type: "address" }, + ], + name: "grantRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "role", type: "bytes32" }, + { internalType: "address", name: "account", type: "address" }, + ], + name: "hasRole", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "owner", + outputs: [{ internalType: "address", name: "", type: "address" }], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pendingDefaultAdmin", + outputs: [ + { internalType: "address", name: "newAdmin", type: "address" }, + { internalType: "uint48", name: "schedule", type: "uint48" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [], + name: "pendingDefaultAdminDelay", + outputs: [ + { internalType: "uint48", name: "newDelay", type: "uint48" }, + { internalType: "uint48", name: "schedule", type: "uint48" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "uint8", name: "poolId", type: "uint8" }], + name: "poolIdToNode", + outputs: [ + { internalType: "bytes32", name: "nodeId", type: "bytes32" }, + { internalType: "uint8", name: "decimals", type: "uint8" }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [{ internalType: "uint8", name: "poolId", type: "uint8" }], + name: "processPriceFeed", + outputs: [ + { + components: [ + { internalType: "uint256", name: "price", type: "uint256" }, + { internalType: "uint8", name: "decimals", type: "uint8" }, + ], + internalType: "struct DataTypes.PriceFeed", + name: "priceFeed", + type: "tuple", + }, + ], + stateMutability: "view", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "role", type: "bytes32" }, + { internalType: "address", name: "account", type: "address" }, + ], + name: "renounceRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "bytes32", name: "role", type: "bytes32" }, + { internalType: "address", name: "account", type: "address" }, + ], + name: "revokeRole", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [], + name: "rollbackDefaultAdminDelay", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [ + { internalType: "uint8", name: "poolId", type: "uint8" }, + { internalType: "bytes32", name: "nodeId", type: "bytes32" }, + { internalType: "uint8", name: "decimals", type: "uint8" }, + ], + name: "setNodeId", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "address", name: "nodeManager", type: "address" }], + name: "setNodeManager", + outputs: [], + stateMutability: "nonpayable", + type: "function", + }, + { + inputs: [{ internalType: "bytes4", name: "interfaceId", type: "bytes4" }], + name: "supportsInterface", + outputs: [{ internalType: "bool", name: "", type: "bool" }], + stateMutability: "view", + type: "function", + }, +] as const; diff --git a/src/chains/evm/hub/constants/chain.ts b/src/chains/evm/hub/constants/chain.ts index afa7111..46b7cd0 100644 --- a/src/chains/evm/hub/constants/chain.ts +++ b/src/chains/evm/hub/constants/chain.ts @@ -12,7 +12,6 @@ import type { } from "../../../../common/types/address.js"; import type { FolksChainId } from "../../../../common/types/chain.js"; import type { HubChain } from "../types/chain.js"; -import type { HubTokenData } from "../types/token.js"; export const HUB_CHAIN: Record = { [NetworkType.MAINNET]: { @@ -30,7 +29,7 @@ export const HUB_CHAIN: Record = { spokeManagerAddress: "0x" as GenericAddress, accountManagerAddress: "0x" as GenericAddress, loanManagerAddress: "0x" as GenericAddress, - tokens: {} as Record, + tokens: {}, }, [NetworkType.TESTNET]: { folksChainId: FOLKS_CHAIN_ID.AVALANCHE_FUJI, diff --git a/src/chains/evm/hub/modules/folks-hub-loan.ts b/src/chains/evm/hub/modules/folks-hub-loan.ts index 08964f3..c20fafd 100644 --- a/src/chains/evm/hub/modules/folks-hub-loan.ts +++ b/src/chains/evm/hub/modules/folks-hub-loan.ts @@ -1,3 +1,6 @@ +import * as dn from "dnum"; +import { multicall } from "viem/actions"; + import { UINT256_LENGTH } from "../../../../common/constants/bytes.js"; import { FINALITY } from "../../../../common/constants/message.js"; import { Action } from "../../../../common/types/message.js"; @@ -7,6 +10,18 @@ import { getSpokeChain, getSpokeTokenData, } from "../../../../common/utils/chain.js"; +import { + calcBorrowAssetLoanValue, + calcBorrowBalance, + calcBorrowInterestIndex, + calcBorrowUtilisationRatio, + calcCollateralAssetLoanValue, + calcLiquidationMargin, + calcLtvRatio, + calcRewardIndex, + toUnderlyingAmount, +} from "../../../../common/utils/formulae.js"; +import { compoundEverySecond } from "../../../../common/utils/math-lib.js"; import { buildMessageParams, buildMessagePayload, @@ -17,21 +32,42 @@ import { getHubTokenAddress, getHubTokenData, } from "../utils/chain.js"; -import { getBridgeRouterHubContract } from "../utils/contract.js"; +import { + getBridgeRouterHubContract, + getLoanManagerContract, +} from "../utils/contract.js"; +import { fetchUserLoanIds } from "../utils/events.js"; import type { FolksChainId, NetworkType, } from "../../../../common/types/chain.js"; -import type { AccountId } from "../../../../common/types/lending.js"; +import type { AccountId, LoanId } from "../../../../common/types/lending.js"; import type { MessageAdapters, MessageToSend, OptionalFeeParams, AdapterType, } from "../../../../common/types/message.js"; +import type { LoanType } from "../../../../common/types/module.js"; import type { FolksTokenId } from "../../../../common/types/token.js"; -import type { Client } from "viem"; +import type { LoanManagerAbi } from "../constants/abi/loan-manager-abi.js"; +import type { + LoanPoolInfo, + LoanTypeInfo, + UserLoanInfo, + UserLoanInfoBorrow, + UserLoanInfoCollateral, +} from "../types/loan.js"; +import type { OraclePrices } from "../types/oracle.js"; +import type { PoolInfo } from "../types/pool.js"; +import type { HubTokenData } from "../types/token.js"; +import type { Dnum } from "dnum"; +import type { + Client, + ContractFunctionParameters, + ReadContractReturnType, +} from "viem"; export async function getSendTokenAdapterFees( provider: Client, @@ -84,3 +120,398 @@ export async function getSendTokenAdapterFees( // get return adapter fee return await hubBridgeRouter.read.getSendFee([returnMessage]); } + +export async function getLoanTypeInfo( + provider: Client, + network: NetworkType, + loanTypeId: LoanType, + tokens: Array, +): Promise { + const hubChain = getHubChain(network); + const loanManager = getLoanManagerContract( + provider, + hubChain.loanManagerAddress, + ); + + const getLoanPools: Array = tokens.map( + (token) => ({ + address: loanManager.address, + abi: loanManager.abi, + functionName: "getLoanPool", + args: [loanTypeId, token.poolId], + }), + ); + + const [deprecated, loanTargetHealth, ...loanPools] = (await multicall( + provider, + { + contracts: [ + { + address: loanManager.address, + abi: loanManager.abi, + functionName: "isLoanTypeDeprecated", + args: [loanTypeId], + }, + { + address: loanManager.address, + abi: loanManager.abi, + functionName: "getLoanTypeLoanTargetHealth", + args: [loanTypeId], + }, + ...getLoanPools, + ], + allowFailure: false, + }, + )) as [ + ReadContractReturnType, + ReadContractReturnType< + typeof LoanManagerAbi, + "getLoanTypeLoanTargetHealth" + >, + ...Array>, + ]; + + const pools: Partial> = {}; + for (const [ + i, + { + collateralUsed, + borrowUsed, + collateralCap, + borrowCap, + collateralFactor, + borrowFactor, + liquidationBonus, + liquidationFee, + isDeprecated, + reward, + }, + ] of loanPools.entries()) { + const token = tokens[i]; + + const { + lastUpdateTimestamp, + minimumAmount, + collateralSpeed, + borrowSpeed, + collateralRewardIndex: oldCollateralRewardIndex, + borrowRewardIndex: oldBorrowRewardIndex, + } = reward; + + pools[token.folksTokenId] = { + folksTokenId: token.folksTokenId, + poolId: token.poolId, + collateralUsed, + borrowUsed, + collateralCap, + borrowCap, + collateralFactor: [BigInt(collateralFactor), 4], + borrowFactor: [BigInt(borrowFactor), 4], + liquidationBonus: [BigInt(liquidationBonus), 4], + liquidationFee: [BigInt(liquidationFee), 4], + isDeprecated, + reward: { + minimumAmount, + collateralSpeed: [BigInt(collateralSpeed), 18], + borrowSpeed: [BigInt(borrowSpeed), 18], + collateralRewardIndex: calcRewardIndex( + collateralUsed, + minimumAmount, + [BigInt(oldCollateralRewardIndex), 18], + [BigInt(collateralSpeed), 18], + lastUpdateTimestamp, + ), + borrowRewardIndex: calcRewardIndex( + borrowUsed, + minimumAmount, + [BigInt(oldBorrowRewardIndex), 18], + [BigInt(borrowSpeed), 18], + lastUpdateTimestamp, + ), + }, + }; + } + + return { + loanTypeId, + deprecated, + loanTargetHealth: [BigInt(loanTargetHealth), 4], + pools, + }; +} + +export async function getUserLoanIds( + provider: Client, + network: NetworkType, + accountId: AccountId, + loanTypeIdFilter?: LoanType, +): Promise> { + const hubChain = getHubChain(network); + const loanManager = getLoanManagerContract( + provider, + hubChain.loanManagerAddress, + ); + + return fetchUserLoanIds({ + loanManager, + accountId, + loanTypeId: loanTypeIdFilter, + }); +} + +export async function getUserLoansInfo( + provider: Client, + network: NetworkType, + loanIds: Array, + poolsInfo: Partial>, + loanTypesInfo: Partial>, + oraclePrices: OraclePrices, +): Promise> { + const hubChain = getHubChain(network); + const loanManager = getLoanManagerContract( + provider, + hubChain.loanManagerAddress, + ); + const poolIdToFolksTokenId = new Map( + Object.values(poolsInfo).map(({ folksTokenId, poolId }) => [ + poolId, + folksTokenId, + ]), + ); + + const getUserLoans: Array = loanIds.map( + (loanId) => ({ + address: loanManager.address, + abi: loanManager.abi, + functionName: "getUserLoan", + args: [loanId], + }), + ); + + const userLoans = (await multicall(provider, { + contracts: getUserLoans, + allowFailure: false, + })) as Array>; + + const userLoansInfo: Record = {}; + for (let i = 0; i < userLoans.length; i++) { + const loanId = loanIds[i]; + const [accountId, loanTypeId, colPools, borPools, cols, bors] = + userLoans[i]; + + const loanTypeInfo = loanTypesInfo[loanTypeId as LoanType]; + if (!loanTypeInfo) throw new Error(`Unknown loan type id ${loanTypeId}`); + + // common to collaterals and borrows + let netRate = dn.from(0, 18); + let netYield = dn.from(0, 18); + + // collaterals + const collaterals: Partial> = + {}; + let totalCollateralBalanceValue: Dnum = dn.from(0, 8); + let totalEffectiveCollateralBalanceValue: Dnum = dn.from(0, 8); + for (let j = 0; j < cols.length; i++) { + const poolId = colPools[j]; + const { balance: fTokenBalance } = cols[j]; + + const folksTokenId = poolIdToFolksTokenId.get(poolId); + if (!folksTokenId) throw new Error(`Unknown pool id ${poolId}`); + + const poolInfo = poolsInfo[folksTokenId]; + const loanPoolInfo = loanTypeInfo.pools[folksTokenId]; + const tokenPrice = oraclePrices[folksTokenId]; + if (!poolInfo || !loanPoolInfo || !tokenPrice) + throw new Error(`Unknown folks token id ${folksTokenId}`); + + const { tokenDecimals, depositData } = poolInfo; + const { interestRate, interestIndex, interestYield } = depositData; + const { collateralFactor } = loanPoolInfo; + + const tokenBalance = toUnderlyingAmount(fTokenBalance, interestIndex); + const balanceValue = calcCollateralAssetLoanValue( + tokenBalance, + tokenPrice, + tokenDecimals, + dn.from(1, 4), + ); + const effectiveBalanceValue = calcCollateralAssetLoanValue( + tokenBalance, + tokenPrice, + tokenDecimals, + collateralFactor, + ); + + totalCollateralBalanceValue = dn.add( + totalCollateralBalanceValue, + balanceValue, + ); + totalEffectiveCollateralBalanceValue = dn.add( + totalEffectiveCollateralBalanceValue, + effectiveBalanceValue, + ); + netRate = dn.add(netRate, dn.mul(balanceValue, interestRate)); + netYield = dn.add(netYield, dn.mul(balanceValue, interestYield)); + + collaterals[folksTokenId] = { + folksTokenId, + poolId, + tokenDecimals, + tokenPrice, + collateralFactor, + fTokenBalance, + tokenBalance, + balanceValue, + effectiveBalanceValue, + interestRate, + interestYield, + }; + } + + // borrows + const borrows: Partial> = {}; + let totalBorrowedAmountValue: Dnum = dn.from(0, 8); + let totalBorrowBalanceValue: Dnum = dn.from(0, 8); + let totalEffectiveBorrowBalanceValue: Dnum = dn.from(0, 8); + for (let j = 0; j < bors.length; i++) { + const poolId = borPools[j]; + const { + amount: borrowedAmount, + balance: oldBorrowBalance, + lastInterestIndex: lii, + stableInterestRate: sbir, + lastStableUpdateTimestamp, + } = bors[j]; + const lastBorrowInterestIndex: Dnum = [lii, 18]; + const stableBorrowInterestRate: Dnum = [sbir, 18]; + + const folksTokenId = poolIdToFolksTokenId.get(poolId); + if (!folksTokenId) throw new Error(`Unknown pool id ${poolId}`); + + const poolInfo = poolsInfo[folksTokenId]; + const loanPoolInfo = loanTypeInfo.pools[folksTokenId]; + const tokenPrice = oraclePrices[folksTokenId]; + if (!poolInfo || !loanPoolInfo || !tokenPrice) + throw new Error(`Unknown folks token id ${folksTokenId}`); + + const { tokenDecimals, variableBorrowData } = poolInfo; + const { + interestRate: variableBorrowInterestRate, + interestIndex: variableBorrowInterestIndex, + } = variableBorrowData; + const { borrowFactor } = loanPoolInfo; + + const isStable = lastStableUpdateTimestamp > 0n; + const bororwInterestIndex = isStable + ? calcBorrowInterestIndex( + stableBorrowInterestRate, + lastBorrowInterestIndex, + lastStableUpdateTimestamp, + ) + : variableBorrowInterestIndex; + const borrowedAmountValue = calcBorrowAssetLoanValue( + borrowedAmount, + tokenPrice, + tokenDecimals, + dn.from(1, 4), + ); + const borrowBalance = calcBorrowBalance( + oldBorrowBalance, + bororwInterestIndex, + lastBorrowInterestIndex, + ); + const borrowBalanceValue = calcBorrowAssetLoanValue( + borrowBalance, + tokenPrice, + tokenDecimals, + dn.from(1, 4), + ); + const effectiveBorrowBalanceValue = calcBorrowAssetLoanValue( + borrowBalance, + tokenPrice, + tokenDecimals, + borrowFactor, + ); + const accruedInterest = borrowBalance - borrowedAmount; + const accruedInterestValue = dn.sub( + borrowBalanceValue, + borrowedAmountValue, + ); + const interestRate = isStable + ? stableBorrowInterestRate + : variableBorrowInterestRate; + const interestYield = compoundEverySecond(interestRate); + + totalBorrowedAmountValue = dn.add( + totalBorrowedAmountValue, + borrowedAmountValue, + ); + totalBorrowBalanceValue = dn.add( + totalBorrowBalanceValue, + borrowBalanceValue, + ); + totalEffectiveBorrowBalanceValue = dn.add( + totalEffectiveBorrowBalanceValue, + effectiveBorrowBalanceValue, + ); + netRate = dn.sub(netRate, dn.mul(borrowBalanceValue, interestRate)); + netYield = dn.sub(netYield, dn.mul(borrowBalanceValue, interestYield)); + + borrows[folksTokenId] = { + folksTokenId, + poolId, + tokenDecimals, + tokenPrice, + isStable, + borrowFactor, + borrowedAmount, + borrowedAmountValue, + borrowBalance, + borrowBalanceValue, + effectiveBorrowBalanceValue, + accruedInterest, + accruedInterestValue, + interestRate, + interestYield, + }; + } + + if (dn.greaterThan(totalCollateralBalanceValue, 0)) { + netRate = dn.div(netRate, totalCollateralBalanceValue); + netYield = dn.div(netRate, totalCollateralBalanceValue); + } + + const loanToValueRatio = calcLtvRatio( + totalBorrowBalanceValue, + totalCollateralBalanceValue, + ); + const borrowUtilisationRatio = calcBorrowUtilisationRatio( + totalEffectiveBorrowBalanceValue, + totalEffectiveCollateralBalanceValue, + ); + const liquidationMargin = calcLiquidationMargin( + totalEffectiveBorrowBalanceValue, + totalEffectiveCollateralBalanceValue, + ); + + userLoansInfo[loanId] = { + loanId, + loanTypeId, + accountId: accountId as AccountId, + collaterals, + borrows, + netRate, + netYield, + totalCollateralBalanceValue, + totalBorrowedAmountValue, + totalBorrowBalanceValue, + totalEffectiveCollateralBalanceValue, + totalEffectiveBorrowBalanceValue, + loanToValueRatio, + borrowUtilisationRatio, + liquidationMargin, + }; + } + + return userLoansInfo; +} diff --git a/src/chains/evm/hub/modules/folks-hub-oracle.ts b/src/chains/evm/hub/modules/folks-hub-oracle.ts new file mode 100644 index 0000000..71c0c1b --- /dev/null +++ b/src/chains/evm/hub/modules/folks-hub-oracle.ts @@ -0,0 +1,49 @@ +import { multicall } from "viem/actions"; + +import { getHubChain } from "../utils/chain.js"; +import { getOracleManagerContract } from "../utils/contract.js"; + +import type { NetworkType } from "../../../../common/types/chain.js"; +import type { OracleManagerAbi } from "../constants/abi/oracle-manager-abi.js"; +import type { OraclePrices } from "../types/oracle.js"; +import type { HubTokenData } from "../types/token.js"; +import type { + Client, + ContractFunctionParameters, + ReadContractReturnType, +} from "viem"; + +export async function getOraclePrices( + provider: Client, + network: NetworkType, + tokens: Array, +): Promise { + const hubChain = getHubChain(network); + const oracleManager = getOracleManagerContract( + provider, + hubChain.oracleManagerAddress, + ); + + const processPriceFeeds: Array = tokens.map( + ({ poolId }) => ({ + address: oracleManager.address, + abi: oracleManager.abi, + functionName: "processPriceFeed", + args: [poolId], + }), + ); + + const priceFeeds = (await multicall(provider, { + contracts: processPriceFeeds, + allowFailure: false, + })) as Array< + ReadContractReturnType + >; + + const oraclePrices: OraclePrices = {}; + for (const [i, { price }] of priceFeeds.entries()) { + const token = tokens[i]; + oraclePrices[token.folksTokenId] = [price, 18]; + } + return oraclePrices; +} diff --git a/src/chains/evm/hub/modules/folks-hub-pool.ts b/src/chains/evm/hub/modules/folks-hub-pool.ts new file mode 100644 index 0000000..4bdd178 --- /dev/null +++ b/src/chains/evm/hub/modules/folks-hub-pool.ts @@ -0,0 +1,189 @@ +import { multicall } from "viem/actions"; + +import { + calcBorrowInterestIndex, + calcDepositInterestIndex, +} from "../../../../common/utils/formulae.js"; +import { + compoundEveryHour, + compoundEverySecond, +} from "../../../../common/utils/math-lib.js"; +import { getHubTokenData } from "../utils/chain.js"; +import { getHubPoolContract } from "../utils/contract.js"; + +import type { NetworkType } from "../../../../common/types/chain.js"; +import type { FolksTokenId } from "../../../../common/types/token.js"; +import type { PoolInfo } from "../types/pool.js"; +import type { Client } from "viem"; + +export async function getPoolInfo( + provider: Client, + network: NetworkType, + folksTokenId: FolksTokenId, +): Promise { + const { poolAddress, tokenDecimals } = getHubTokenData(folksTokenId, network); + const hubPool = getHubPoolContract(provider, poolAddress); + + // get pool data + const [ + poolId, + lastUpdateTimestamp, + feeData, + depositData, + variableBorrowData, + stableBorrowData, + capsData, + configData, + ] = await multicall(provider, { + contracts: [ + { + address: hubPool.address, + abi: hubPool.abi, + functionName: "getPoolId", + }, + { + address: hubPool.address, + abi: hubPool.abi, + functionName: "getLastUpdateTimestamp", + }, + { + address: hubPool.address, + abi: hubPool.abi, + functionName: "getFeeData", + }, + { + address: hubPool.address, + abi: hubPool.abi, + functionName: "getDepositData", + }, + { + address: hubPool.address, + abi: hubPool.abi, + functionName: "getVariableBorrowData", + }, + { + address: hubPool.address, + abi: hubPool.abi, + functionName: "getStableBorrowData", + }, + { + address: hubPool.address, + abi: hubPool.abi, + functionName: "getCapsData", + }, + { + address: hubPool.address, + abi: hubPool.abi, + functionName: "getConfigData", + }, + ], + allowFailure: false, + }); + + const { flashLoanFee, retentionRate } = feeData; + const { + optimalUtilisationRatio, + totalAmount: depositTotalAmount, + interestRate: depositInterestRate, + interestIndex: oldDepositInterestIndex, + } = depositData; + const { + vr0, + vr1, + vr2, + totalAmount: variableBorrowTotalAmount, + interestRate: variableBorrowInterestRate, + interestIndex: oldVariableBorrowInterestsIndex, + } = variableBorrowData; + const { + sr0, + sr1, + sr2, + sr3, + optimalStableToTotalDebtRatio, + rebalanceUpUtilisationRatio, + rebalanceUpDepositInterestRate, + rebalanceDownDelta, + totalAmount: stableBorrowTotalAmount, + interestRate: stableBorrowInterestRate, + averageInterestRate: stableBorrowAverageInterestRate, + } = stableBorrowData; + const { + deposit: depositCap, + borrow: borrowCap, + stableBorrowPercentage: stableBorrowPercentageCap, + } = capsData; + const { + deprecated, + stableBorrowSupported, + canMintFToken, + flashLoanSupported, + } = configData; + + // build pool info + return { + folksTokenId, + poolId, + tokenDecimals, + feeData: { + flashLoanFee: [BigInt(flashLoanFee), 6], + retentionRate: [BigInt(retentionRate), 6], + }, + depositData: { + optimalUtilisationRatio: [BigInt(optimalUtilisationRatio), 4], + totalAmount: depositTotalAmount, + interestRate: [depositInterestRate, 18], + interestYield: compoundEveryHour([depositInterestRate, 18]), + interestIndex: calcDepositInterestIndex( + [depositInterestRate, 18], + [oldDepositInterestIndex, 18], + lastUpdateTimestamp, + ), + }, + variableBorrowData: { + vr0: [BigInt(vr0), 6], + vr1: [BigInt(vr1), 6], + vr2: [BigInt(vr2), 6], + totalAmount: variableBorrowTotalAmount, + interestRate: [variableBorrowInterestRate, 18], + interestYield: compoundEverySecond([variableBorrowInterestRate, 18]), + interestIndex: calcBorrowInterestIndex( + [variableBorrowInterestRate, 18], + [oldVariableBorrowInterestsIndex, 18], + lastUpdateTimestamp, + ), + }, + stableBorrowData: { + sr0: [BigInt(sr0), 6], + sr1: [BigInt(sr1), 6], + sr2: [BigInt(sr2), 6], + sr3: [BigInt(sr3), 6], + optimalStableToTotalDebtRatio: [BigInt(optimalStableToTotalDebtRatio), 4], + rebalanceUpUtilisationRatio: [BigInt(rebalanceUpUtilisationRatio), 4], + rebalanceUpDepositInterestRate: [ + BigInt(rebalanceUpDepositInterestRate), + 4, + ], + rebalanceDownDelta: [BigInt(rebalanceDownDelta), 4], + totalAmount: stableBorrowTotalAmount, + interestRate: [stableBorrowInterestRate, 18], + interestYield: compoundEverySecond([stableBorrowInterestRate, 18]), + averageInterestRate: [stableBorrowAverageInterestRate, 18], + averageInterestYield: compoundEverySecond([ + stableBorrowAverageInterestRate, + 18, + ]), + }, + capsData: { + deposit: BigInt(depositCap), + borrow: BigInt(borrowCap), + stableBorrowPercentage: [BigInt(stableBorrowPercentageCap), 18], + }, + configData: { + deprecated, + stableBorrowSupported, + canMintFToken, + flashLoanSupported, + }, + }; +} diff --git a/src/chains/evm/hub/modules/index.ts b/src/chains/evm/hub/modules/index.ts index 67482fc..7b44cfc 100644 --- a/src/chains/evm/hub/modules/index.ts +++ b/src/chains/evm/hub/modules/index.ts @@ -1,2 +1,4 @@ export * as FolksHubAccount from "./folks-hub-account.js"; export * as FolksHubLoan from "./folks-hub-loan.js"; +export * as FolksHubOracle from "./folks-hub-oracle.js"; +export * as FolksHubPool from "./folks-hub-pool.js"; diff --git a/src/chains/evm/hub/types/chain.ts b/src/chains/evm/hub/types/chain.ts index 7d03811..a37e26f 100644 --- a/src/chains/evm/hub/types/chain.ts +++ b/src/chains/evm/hub/types/chain.ts @@ -12,5 +12,5 @@ export type HubChain = { spokeManagerAddress: GenericAddress; accountManagerAddress: GenericAddress; loanManagerAddress: GenericAddress; - tokens: Record; + tokens: Partial>; } & IFolksChain; diff --git a/src/chains/evm/hub/types/loan.ts b/src/chains/evm/hub/types/loan.ts new file mode 100644 index 0000000..ea9f086 --- /dev/null +++ b/src/chains/evm/hub/types/loan.ts @@ -0,0 +1,95 @@ +import type { AccountId, LoanId } from "../../../../common/types/lending.js"; +import type { LoanType } from "../../../../common/types/module.js"; +import type { FolksTokenId } from "../../../../common/types/token.js"; +import type { GetReadContractReturnType } from "../../common/types/contract.js"; +import type { LoanManagerAbi } from "../constants/abi/loan-manager-abi.js"; +import type { Dnum } from "dnum"; + +export type LoanPoolInfo = { + folksTokenId: FolksTokenId; + poolId: number; + collateralUsed: bigint; // in f token + borrowUsed: bigint; // in token + collateralCap: bigint; // $ amount + borrowCap: bigint; // $ amount + collateralFactor: Dnum; + borrowFactor: Dnum; + liquidationBonus: Dnum; + liquidationFee: Dnum; + isDeprecated: boolean; + reward: { + minimumAmount: bigint; // in token + collateralSpeed: Dnum; + borrowSpeed: Dnum; + collateralRewardIndex: Dnum; + borrowRewardIndex: Dnum; + }; +}; + +export type LoanTypeInfo = { + loanTypeId: LoanType; + deprecated: boolean; + loanTargetHealth: Dnum; + pools: Partial>; +}; + +export type UserLoanInfoCollateral = { + folksTokenId: FolksTokenId; + poolId: number; + tokenDecimals: number; + tokenPrice: Dnum; + collateralFactor: Dnum; + fTokenBalance: bigint; + tokenBalance: bigint; + balanceValue: Dnum; + effectiveBalanceValue: Dnum; + interestRate: Dnum; + interestYield: Dnum; +}; + +export type UserLoanInfoBorrow = { + folksTokenId: FolksTokenId; + poolId: number; + tokenDecimals: number; + tokenPrice: Dnum; + isStable: boolean; + borrowFactor: Dnum; + borrowedAmount: bigint; + borrowedAmountValue: Dnum; + borrowBalance: bigint; + borrowBalanceValue: Dnum; + effectiveBorrowBalanceValue: Dnum; + accruedInterest: bigint; + accruedInterestValue: Dnum; + interestRate: Dnum; + interestYield: Dnum; +}; + +export type UserLoanInfo = { + loanId: LoanId; + loanTypeId: LoanType; + accountId: AccountId; + collaterals: Partial>; + borrows: Partial>; + netRate: Dnum; + netYield: Dnum; + totalCollateralBalanceValue: Dnum; + totalBorrowedAmountValue: Dnum; + totalBorrowBalanceValue: Dnum; + totalEffectiveCollateralBalanceValue: Dnum; + totalEffectiveBorrowBalanceValue: Dnum; + loanToValueRatio: Dnum; + borrowUtilisationRatio: Dnum; + liquidationMargin: Dnum; +}; + +export type CreateUserLoanEventParams = { + loanManager: GetReadContractReturnType; + accountId: AccountId; + loanTypeId?: LoanType; +}; + +export type DeleteUserLoanEventParams = { + loanManager: GetReadContractReturnType; + accountId: AccountId; +}; diff --git a/src/chains/evm/hub/types/oracle.ts b/src/chains/evm/hub/types/oracle.ts new file mode 100644 index 0000000..cacf61d --- /dev/null +++ b/src/chains/evm/hub/types/oracle.ts @@ -0,0 +1,6 @@ +import type { FolksTokenId } from "../../../../common/types/token.js"; +import type { Dnum } from "dnum"; + +export type OraclePrice = Dnum; + +export type OraclePrices = Partial>; diff --git a/src/chains/evm/hub/types/pool.ts b/src/chains/evm/hub/types/pool.ts new file mode 100644 index 0000000..1eb0cbf --- /dev/null +++ b/src/chains/evm/hub/types/pool.ts @@ -0,0 +1,66 @@ +import type { FolksTokenId } from "../../../../common/types/token.js"; +import type { Dnum } from "dnum"; + +type FeeData = { + flashLoanFee: Dnum; + retentionRate: Dnum; +}; + +type DepositData = { + optimalUtilisationRatio: Dnum; + totalAmount: bigint; + interestRate: Dnum; + interestYield: Dnum; + interestIndex: Dnum; +}; + +type VariableBorrowData = { + vr0: Dnum; + vr1: Dnum; + vr2: Dnum; + totalAmount: bigint; + interestRate: Dnum; + interestYield: Dnum; + interestIndex: Dnum; +}; + +type StableBorrowData = { + sr0: Dnum; + sr1: Dnum; + sr2: Dnum; + sr3: Dnum; + optimalStableToTotalDebtRatio: Dnum; + rebalanceUpUtilisationRatio: Dnum; + rebalanceUpDepositInterestRate: Dnum; + rebalanceDownDelta: Dnum; + totalAmount: bigint; + interestRate: Dnum; + interestYield: Dnum; + averageInterestRate: Dnum; + averageInterestYield: Dnum; +}; + +type CapsData = { + deposit: bigint; // $ amount + borrow: bigint; // $ amount + stableBorrowPercentage: Dnum; +}; + +type ConfigData = { + deprecated: boolean; + stableBorrowSupported: boolean; + canMintFToken: boolean; + flashLoanSupported: boolean; +}; + +export type PoolInfo = { + folksTokenId: FolksTokenId; + poolId: number; + tokenDecimals: number; + feeData: FeeData; + depositData: DepositData; + variableBorrowData: VariableBorrowData; + stableBorrowData: StableBorrowData; + capsData: CapsData; + configData: ConfigData; +}; diff --git a/src/chains/evm/hub/utils/chain.ts b/src/chains/evm/hub/utils/chain.ts index ba6aa64..1caaa3c 100644 --- a/src/chains/evm/hub/utils/chain.ts +++ b/src/chains/evm/hub/utils/chain.ts @@ -22,11 +22,19 @@ export function getHubChain(network: NetworkType): HubChain { return HUB_CHAIN[network]; } +export function getHubTokensData( + network: NetworkType, +): Partial> { + return HUB_CHAIN[network].tokens; +} + export function getHubTokenData( folksTokenId: FolksTokenId, network: NetworkType, ): HubTokenData { const token = HUB_CHAIN[network].tokens[folksTokenId]; + if (!token) + throw new Error(`Hub token not found for folksTokenId: ${folksTokenId}`); return token; } diff --git a/src/chains/evm/hub/utils/contract.ts b/src/chains/evm/hub/utils/contract.ts index 3d42a8b..0e82f58 100644 --- a/src/chains/evm/hub/utils/contract.ts +++ b/src/chains/evm/hub/utils/contract.ts @@ -4,6 +4,9 @@ import { ChainType } from "../../../../common/types/chain.js"; import { convertFromGenericAddress } from "../../../../common/utils/address.js"; import { AccountManagerAbi } from "../constants/abi/account-manager-abi.js"; import { BridgeRouterHubAbi } from "../constants/abi/bridge-router-hub-abi.js"; +import { HubPoolAbi } from "../constants/abi/hub-pool-abi.js"; +import { LoanManagerAbi } from "../constants/abi/loan-manager-abi.js"; +import { OracleManagerAbi } from "../constants/abi/oracle-manager-abi.js"; import type { GenericAddress } from "../../../../common/types/address.js"; import type { GetReadContractReturnType } from "../../common/types/contract.js"; @@ -31,3 +34,36 @@ export function getBridgeRouterHubContract( client: { public: provider }, }); } + +export function getHubPoolContract( + provider: Client, + address: GenericAddress, +): GetReadContractReturnType { + return getContract({ + abi: HubPoolAbi, + address: convertFromGenericAddress(address, ChainType.EVM), + client: { public: provider }, + }); +} + +export function getLoanManagerContract( + provider: Client, + address: GenericAddress, +): GetReadContractReturnType { + return getContract({ + abi: LoanManagerAbi, + address: convertFromGenericAddress(address, ChainType.EVM), + client: { public: provider }, + }); +} + +export function getOracleManagerContract( + provider: Client, + address: GenericAddress, +): GetReadContractReturnType { + return getContract({ + abi: OracleManagerAbi, + address: convertFromGenericAddress(address, ChainType.EVM), + client: { public: provider }, + }); +} diff --git a/src/chains/evm/hub/utils/events.ts b/src/chains/evm/hub/utils/events.ts new file mode 100644 index 0000000..f64210f --- /dev/null +++ b/src/chains/evm/hub/utils/events.ts @@ -0,0 +1,60 @@ +import type { LoanId } from "../../../../common/types/lending.js"; +import type { + CreateUserLoanEventParams, + DeleteUserLoanEventParams, +} from "../types/loan.js"; + +export async function fetchCreateUserLoanEvents( + params: CreateUserLoanEventParams, +) { + const { loanManager, accountId, loanTypeId } = params; + const logs = await loanManager.getEvents.CreateUserLoan( + { accountId }, + { strict: true }, + ); + return logs + .filter( + (log) => loanTypeId === undefined || loanTypeId === log.args.loanTypeId, + ) + .map((log) => ({ + blockNumber: log.blockNumber, + loanId: log.args.loanId, + accountId, + loanTypeId: log.args.loanTypeId, + })); +} + +export async function fetchDeleteUserLoanEvents( + params: DeleteUserLoanEventParams, +) { + const { loanManager, accountId } = params; + const logs = await loanManager.getEvents.DeleteUserLoan( + { accountId }, + { strict: true }, + ); + return logs.map((log) => ({ + blockNumber: log.blockNumber, + loanId: log.args.loanId, + accountId, + })); +} + +export async function fetchUserLoanIds(params: CreateUserLoanEventParams) { + const createdUserLoans = await fetchCreateUserLoanEvents(params); + const deletedUserLoans = await fetchDeleteUserLoanEvents(params); + + // add created and remove deleted through counting + const loanIds = new Map(); + for (const userLoan of createdUserLoans) { + const loanId = userLoan.loanId as LoanId; + const num = loanIds.get(loanId) ?? 0; + loanIds.set(loanId, num + 1); + } + for (const userLoan of deletedUserLoans) { + const loanId = userLoan.loanId as LoanId; + const num = loanIds.get(loanId) ?? 1; + num === 1 ? loanIds.delete(loanId) : loanIds.set(loanId, num - 1); + } + + return Array.from(loanIds.keys()); +} diff --git a/src/chains/evm/spoke/modules/folks-evm-loan.ts b/src/chains/evm/spoke/modules/folks-evm-loan.ts index adac32b..ace79d2 100644 --- a/src/chains/evm/spoke/modules/folks-evm-loan.ts +++ b/src/chains/evm/spoke/modules/folks-evm-loan.ts @@ -1,4 +1,10 @@ +import { multicall } from "viem/actions"; + import { TokenType } from "../../../../common/types/token.js"; +import { + calcNextPeriodReset, + calcPeriodNumber, +} from "../../../../common/utils/formulae.js"; import { getEvmSignerAccount } from "../../common/utils/chain.js"; import { sendERC20Approve } from "../../common/utils/contract.js"; import { getHubTokenData } from "../../hub/utils/chain.js"; @@ -31,6 +37,7 @@ import type { PrepareDepositCall, PrepareWithdrawCall, } from "../../common/types/module.js"; +import type { TokenRateLimit } from "../types/pool.js"; import type { Client, EstimateGasParameters, WalletClient } from "viem"; export const prepare = { @@ -402,3 +409,60 @@ export const write = { ); }, }; + +export const read = { + async rateLimitInfo( + provider: Client, + token: SpokeTokenData, + ): Promise { + const spokeToken = getSpokeTokenContract(provider, token.spokeAddress); + + // get rate limit data + const [bucketConfig, oldPeriodNumber, oldCurrentCapacity] = await multicall( + provider, + { + contracts: [ + { + address: spokeToken.address, + abi: spokeToken.abi, + functionName: "bucketConfig", + }, + { + address: spokeToken.address, + abi: spokeToken.abi, + functionName: "currentPeriodNumber", + }, + { + address: spokeToken.address, + abi: spokeToken.abi, + functionName: "currentCapacity", + }, + ], + allowFailure: false, + }, + ); + + // TODO consider min limit + const [periodLength, periodOffset, periodLimit] = bucketConfig; + const newPeriodNumber = calcPeriodNumber( + BigInt(periodOffset), + BigInt(periodLength), + ); + const isNewPeriod = newPeriodNumber !== BigInt(oldPeriodNumber); + const currentCapacity = isNewPeriod ? periodLimit : oldCurrentCapacity; + const nextPeriodReset = calcNextPeriodReset( + newPeriodNumber, + BigInt(periodOffset), + BigInt(periodLength), + ); + + // build rate limit info + return { + periodLength: BigInt(periodLength), + periodOffset: BigInt(periodOffset), + periodLimit: BigInt(periodLimit), + currentCapacity, + nextPeriodReset, + }; + }, +}; diff --git a/src/chains/evm/spoke/types/pool.ts b/src/chains/evm/spoke/types/pool.ts new file mode 100644 index 0000000..b2f90a3 --- /dev/null +++ b/src/chains/evm/spoke/types/pool.ts @@ -0,0 +1,7 @@ +export type TokenRateLimit = { + periodLength: bigint; + periodOffset: bigint; + periodLimit: bigint; + currentCapacity: bigint; + nextPeriodReset: bigint; +}; diff --git a/src/common/utils/formulae.ts b/src/common/utils/formulae.ts new file mode 100644 index 0000000..8427c65 --- /dev/null +++ b/src/common/utils/formulae.ts @@ -0,0 +1,172 @@ +import * as dn from "dnum"; + +import { SECONDS_IN_YEAR, expBySquaring, unixTime } from "./math-lib.js"; + +import type { Dnum } from "dnum"; + +export function calcPeriodNumber(offset: bigint, length: bigint): bigint { + return (BigInt(unixTime()) + offset) / length; +} + +export function calcNextPeriodReset( + periodNumber: bigint, + offset: bigint, + length: bigint, +): bigint { + return (periodNumber + BigInt(1)) * length - offset; +} + +export function calcDepositInterestIndex( + dirt1: Dnum, + diit1: Dnum, + latestUpdate: bigint, +): Dnum { + const dt = BigInt(unixTime()) - latestUpdate; + return dn.mul( + diit1, + dn.add( + dn.from(1, 18), + dn.div(dn.mul(dirt1, dt, { rounding: "ROUND_DOWN" }), SECONDS_IN_YEAR, { + rounding: "ROUND_DOWN", + }), + ), + { rounding: "ROUND_DOWN" }, + ); +} + +export function calcBorrowInterestIndex( + birt1: Dnum, + biit1: Dnum, + latestUpdate: bigint, +): Dnum { + const dt = BigInt(unixTime()) - latestUpdate; + return dn.mul( + biit1, + expBySquaring( + dn.add( + dn.from(1, 18), + dn.div(birt1, SECONDS_IN_YEAR, { rounding: "ROUND_DOWN" }), + ), + dt, + ), + { rounding: "ROUND_DOWN" }, + ); +} + +export function calcRewardIndex( + used: bigint, + ma: bigint, + rit1: Dnum, + rs: Dnum, + latestUpdate: bigint, +): Dnum { + if (used <= ma) return rit1; + const dt = BigInt(unixTime()) - latestUpdate; + return dn.add( + rit1, + dn.div(dn.mul(rs, dt, { rounding: "ROUND_DOWN" }), used, { + rounding: "ROUND_DOWN", + }), + ); +} + +export function toFAmount(underlyingAmount: bigint, diit: Dnum): bigint { + const [fAmount] = dn.div(underlyingAmount, diit, { rounding: "ROUND_DOWN" }); + return fAmount; +} + +export function toUnderlyingAmount(fAmount: bigint, diit: Dnum): bigint { + const [underlyingAmount] = dn.mul(fAmount, diit, { rounding: "ROUND_DOWN" }); + return underlyingAmount; +} + +function calcAssetDollarValue( + amount: bigint, + tokenPrice: Dnum, + tokenDecimals: number, +): Dnum { + return dn.mul([amount, tokenDecimals], tokenPrice, { + rounding: "ROUND_DOWN", + }); +} + +export function calcCollateralAssetLoanValue( + amount: bigint, + tokenPrice: Dnum, + tokenDecimals: number, + collateralFactor: Dnum, +): Dnum { + return dn.mul( + calcAssetDollarValue(amount, tokenPrice, tokenDecimals), + collateralFactor, + { rounding: "ROUND_DOWN" }, + ); +} + +export function calcBorrowAssetLoanValue( + amount: bigint, + tokenPrice: Dnum, + tokenDecimals: number, + borrowFactor: Dnum, +): Dnum { + return dn.mul( + calcAssetDollarValue(amount, tokenPrice, tokenDecimals), + borrowFactor, + { rounding: "ROUND_UP" }, + ); +} + +export function calcBorrowBalance( + bbtn1: bigint, + biit: Dnum, + biitn1: Dnum, +): bigint { + const [borrowBalance] = dn.mul( + bbtn1, + dn.div(biit, biitn1, { rounding: "ROUND_UP" }), + { rounding: "ROUND_UP" }, + ); + return borrowBalance; +} + +export function calcLtvRatio( + totalBorrowBalanceValue: Dnum, + totalCollateralBalanceValue: Dnum, +): Dnum { + const [, decimals] = totalBorrowBalanceValue; + if (dn.equal(totalCollateralBalanceValue, 0)) return dn.from(0, decimals); + return dn.div(totalBorrowBalanceValue, totalCollateralBalanceValue, { + rounding: "ROUND_UP", + }); +} + +export function calcBorrowUtilisationRatio( + totalEffectiveBorrowBalanceValue: Dnum, + totalEffectiveCollateralBalanceValue: Dnum, +): Dnum { + const [, decimals] = totalEffectiveBorrowBalanceValue; + if (dn.equal(totalEffectiveCollateralBalanceValue, 0)) + return dn.from(0, decimals); + return dn.div( + totalEffectiveBorrowBalanceValue, + totalEffectiveCollateralBalanceValue, + { rounding: "ROUND_UP" }, + ); +} + +export function calcLiquidationMargin( + totalEffectiveBorrowBalanceValue: Dnum, + totalEffectiveCollateralBalanceValue: Dnum, +): Dnum { + const [, decimals] = totalEffectiveBorrowBalanceValue; + if (dn.equal(totalEffectiveCollateralBalanceValue, 0)) + return dn.from(0, decimals); + return dn.div( + dn.sub( + totalEffectiveCollateralBalanceValue, + totalEffectiveBorrowBalanceValue, + ), + totalEffectiveCollateralBalanceValue, + { rounding: "ROUND_DOWN" }, + ); +} diff --git a/src/common/utils/math-lib.ts b/src/common/utils/math-lib.ts new file mode 100644 index 0000000..095d636 --- /dev/null +++ b/src/common/utils/math-lib.ts @@ -0,0 +1,43 @@ +import * as dn from "dnum"; + +import type { Dnum } from "dnum"; + +export const SECONDS_IN_YEAR = BigInt(365 * 24 * 60 * 60); +export const HOURS_IN_YEAR = BigInt(365 * 24); + +export function unixTime(): number { + return Math.floor(Date.now() / 1000); +} + +export function expBySquaring(x: Dnum, n: bigint): Dnum { + const [, decimals] = x; + const one = dn.from(1, decimals); + + if (n === BigInt(0)) return one; + + let y = one; + while (n > BigInt(1)) { + if (n % BigInt(2)) { + y = dn.mul(x, y, { rounding: "ROUND_DOWN" }); + n = (n - BigInt(1)) / BigInt(2); + } else { + n = n / BigInt(2); + } + x = dn.mul(x, x, { rounding: "ROUND_DOWN" }); + } + return dn.mul(x, y, { rounding: "ROUND_DOWN" }); +} + +function compound(rate: Dnum, period: bigint): Dnum { + const [, decimals] = rate; + const one = dn.from(1, decimals); + return dn.sub(expBySquaring(dn.add(one, dn.div(rate, period)), period), one); +} + +export function compoundEverySecond(rate: Dnum): Dnum { + return compound(rate, SECONDS_IN_YEAR); +} + +export function compoundEveryHour(rate: Dnum): Dnum { + return compound(rate, HOURS_IN_YEAR); +} diff --git a/src/xchain/modules/folks-loan.ts b/src/xchain/modules/folks-loan.ts index eacfeeb..db15926 100644 --- a/src/xchain/modules/folks-loan.ts +++ b/src/xchain/modules/folks-loan.ts @@ -3,6 +3,7 @@ import { assertLoanTypeSupported, getHubChain, getHubTokenData, + getHubTokensData, } from "../../chains/evm/hub/utils/chain.js"; import { FolksEvmLoan } from "../../chains/evm/spoke/modules/index.js"; import { ChainType } from "../../common/types/chain.js"; @@ -29,6 +30,10 @@ import { import { exhaustiveCheck } from "../../utils/exhaustive-check.js"; import { FolksCore } from "../core/folks-core.js"; +import type { LoanTypeInfo } from "../../chains/evm/hub/types/loan.js"; +import type { OraclePrices } from "../../chains/evm/hub/types/oracle.js"; +import type { PoolInfo } from "../../chains/evm/hub/types/pool.js"; +import type { TokenRateLimit } from "../../chains/evm/spoke/types/pool.js"; import type { FolksChainId } from "../../common/types/chain.js"; import type { AccountId, LoanId } from "../../common/types/lending.js"; import type { @@ -505,4 +510,77 @@ export const write = { }, }; -export const read = {}; +export const read = { + async rateLimit( + folksTokenId: FolksTokenId, + folksChainId: FolksChainId, + ): Promise { + const network = FolksCore.getSelectedNetwork(); + const folksChain = getFolksChain(folksChainId, network); + + assertSpokeChainSupportFolksToken( + folksChain.folksChainId, + folksTokenId, + folksChain.network, + ); + const spokeChain = getSpokeChain( + folksChain.folksChainId, + folksChain.network, + ); + const spokeTokenData = getSpokeTokenData(spokeChain, folksTokenId); + + switch (folksChain.chainType) { + case ChainType.EVM: + return await FolksEvmLoan.read.rateLimitInfo( + FolksCore.getProvider(folksChain.folksChainId), + spokeTokenData, + ); + default: + return exhaustiveCheck(folksChain.chainType); + } + }, + + async loanTypeInfo(loanTypeId: LoanType): Promise { + const network = FolksCore.getSelectedNetwork(); + + // filter for all tokens supported in loan type + const tokensData = Object.values(getHubTokensData(network)).filter( + (tokenData) => tokenData.supportedLoanTypes.has(loanTypeId), + ); + + return await FolksHubLoan.getLoanTypeInfo( + FolksCore.getHubProvider(), + network, + loanTypeId, + tokensData, + ); + }, + + async userLoansInfo( + accountId: AccountId, + poolsInfo: Partial>, + loanTypesInfo: Partial>, + oraclePrices: OraclePrices, + loanTypeIdFilter?: LoanType, + ) { + const network = FolksCore.getSelectedNetwork(); + + // get active user loans + const loanIds = await FolksHubLoan.getUserLoanIds( + FolksCore.getHubProvider(), + network, + accountId, + loanTypeIdFilter, + ); + + // get info of each user loan + return await FolksHubLoan.getUserLoansInfo( + FolksCore.getHubProvider(), + network, + loanIds, + poolsInfo, + loanTypesInfo, + oraclePrices, + ); + }, +}; diff --git a/src/xchain/modules/folks-oracle.ts b/src/xchain/modules/folks-oracle.ts new file mode 100644 index 0000000..8e74f1d --- /dev/null +++ b/src/xchain/modules/folks-oracle.ts @@ -0,0 +1,19 @@ +import { FolksHubOracle } from "../../chains/evm/hub/modules/index.js"; +import { getHubTokensData } from "../../chains/evm/hub/utils/chain.js"; +import { FolksCore } from "../core/folks-core.js"; + +import type { OraclePrices } from "../../chains/evm/hub/types/oracle.js"; + +export const read = { + async oraclePrices(): Promise { + const network = FolksCore.getSelectedNetwork(); + + const tokensData = Object.values(getHubTokensData(network)); + + return FolksHubOracle.getOraclePrices( + FolksCore.getHubProvider(), + network, + tokensData, + ); + }, +}; diff --git a/src/xchain/modules/folks-pool.ts b/src/xchain/modules/folks-pool.ts new file mode 100644 index 0000000..dd976a8 --- /dev/null +++ b/src/xchain/modules/folks-pool.ts @@ -0,0 +1,15 @@ +import { FolksHubPool } from "../../chains/evm/hub/modules/index.js"; +import { FolksCore } from "../core/folks-core.js"; + +import type { PoolInfo } from "../../chains/evm/hub/types/pool.js"; +import type { FolksTokenId } from "../../common/types/token.js"; + +export const read = { + async poolInfo(folksTokenId: FolksTokenId): Promise { + return FolksHubPool.getPoolInfo( + FolksCore.getHubProvider(), + FolksCore.getSelectedNetwork(), + folksTokenId, + ); + }, +}; diff --git a/src/xchain/modules/index.ts b/src/xchain/modules/index.ts index 7ebec57..251f6a5 100644 --- a/src/xchain/modules/index.ts +++ b/src/xchain/modules/index.ts @@ -1,2 +1,4 @@ export * as FolksAccount from "./folks-account.js"; export * as FolksLoan from "./folks-loan.js"; +export * as FolksOracle from "./folks-oracle.js"; +export * as FolksPool from "./folks-pool.js";