diff --git a/src/apps/meta-street/assets/logo.png b/src/apps/meta-street/assets/logo.png new file mode 100644 index 000000000..4a65e8b8c Binary files /dev/null and b/src/apps/meta-street/assets/logo.png differ diff --git a/src/apps/meta-street/contracts/abis/pool-v-2-legacy.json b/src/apps/meta-street/contracts/abis/pool-v-2-legacy.json new file mode 100644 index 000000000..6545d5941 --- /dev/null +++ b/src/apps/meta-street/contracts/abis/pool-v-2-legacy.json @@ -0,0 +1,1231 @@ +[ + { + "inputs": [], + "name": "InactiveLiquidity", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientLiquidity", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientShares", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientTickSpacing", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidAddress", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBorrowOptions", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCaller", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLoanReceipt", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidReceiptEncoding", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidRedemptionStatus", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTick", + "type": "error" + }, + { + "inputs": [], + "name": "LoanNotExpired", + "type": "error" + }, + { + "inputs": [], + "name": "ParameterOutOfBounds", + "type": "error" + }, + { + "inputs": [], + "name": "RepaymentTooHigh", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "UnsupportedCollateral", + "type": "error" + }, + { + "inputs": [], + "name": "UnsupportedLoanDuration", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "AdminFeeRateUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "AdminFeesWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "loanReceiptHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "proceeds", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowerProceeds", + "type": "uint256" + } + ], + "name": "CollateralLiquidated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Deposited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "loanReceiptHash", + "type": "bytes32" + } + ], + "name": "LoanLiquidated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "loanReceiptHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "loanReceipt", + "type": "bytes" + } + ], + "name": "LoanOriginated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "loanReceiptHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "repayment", + "type": "uint256" + } + ], + "name": "LoanRepaid", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Redeemed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Withdrawn", + "type": "event" + }, + { + "inputs": [], + "name": "BORROWER_SURPLUS_SPLIT_BASIS_POINTS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "COLLATERAL_FILTER_NAME", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "COLLATERAL_FILTER_VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "IMPLEMENTATION_NAME", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "IMPLEMENTATION_VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "INTEREST_RATE_MODEL_NAME", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "INTEREST_RATE_MODEL_VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "TICK_LIMIT_SPACING_BASIS_POINTS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "adminFeeBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "adminFeeRate", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "principal", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "duration", + "type": "uint64" + }, + { + "internalType": "address", + "name": "collateralToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "collateralTokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxRepayment", + "type": "uint256" + }, + { + "internalType": "uint128[]", + "name": "ticks", + "type": "uint128[]" + }, + { + "internalType": "bytes", + "name": "options", + "type": "bytes" + } + ], + "name": "borrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collateralLiquidator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "collateralToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "collateralWrappers", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "currencyToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "loanReceipt", + "type": "bytes" + } + ], + "name": "decodeLoanReceipt", + "outputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "version", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "principal", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "repayment", + "type": "uint256" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint64", + "name": "maturity", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "duration", + "type": "uint64" + }, + { + "internalType": "address", + "name": "collateralToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "collateralTokenId", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "collateralWrapperContextLen", + "type": "uint16" + }, + { + "internalType": "bytes", + "name": "collateralWrapperContext", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "used", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "pending", + "type": "uint128" + } + ], + "internalType": "struct LoanReceipt.NodeReceipt[]", + "name": "nodeReceipts", + "type": "tuple[]" + } + ], + "internalType": "struct LoanReceipt.LoanReceiptV1", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "delegationRegistry", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minShares", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + } + ], + "name": "deposits", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "shares", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "redemptionPending", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "redemptionIndex", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "redemptionTarget", + "type": "uint128" + } + ], + "internalType": "struct Pool.Deposit", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "durations", + "outputs": [ + { + "internalType": "uint64[]", + "name": "", + "type": "uint64[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedLoanReceipt", + "type": "bytes" + } + ], + "name": "liquidate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + } + ], + "name": "liquidityNode", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "value", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "shares", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "available", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "pending", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "redemptions", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "prev", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "next", + "type": "uint128" + } + ], + "internalType": "struct ILiquidity.NodeInfo", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "startTick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "endTick", + "type": "uint128" + } + ], + "name": "liquidityNodes", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "value", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "shares", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "available", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "pending", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "redemptions", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "prev", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "next", + "type": "uint128" + } + ], + "internalType": "struct ILiquidity.NodeInfo[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "receiptHash", + "type": "bytes32" + } + ], + "name": "loans", + "outputs": [ + { + "internalType": "enum Pool.LoanStatus", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedLoanReceipt", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "proceeds", + "type": "uint256" + } + ], + "name": "onCollateralLiquidated", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "principal", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "duration", + "type": "uint64" + }, + { + "internalType": "address", + "name": "collateralToken", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "collateralTokenIds", + "type": "uint256[]" + }, + { + "internalType": "uint128[]", + "name": "ticks", + "type": "uint128[]" + }, + { + "internalType": "bytes", + "name": "options", + "type": "bytes" + } + ], + "name": "quote", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedLoanReceipt", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "principal", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "duration", + "type": "uint64" + }, + { + "internalType": "uint128[]", + "name": "ticks", + "type": "uint128[]" + } + ], + "name": "quoteRefinance", + "outputs": [ + { + "internalType": "int256", + "name": "", + "type": "int256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rates", + "outputs": [ + { + "internalType": "uint64[]", + "name": "", + "type": "uint64[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "srcTick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "dstTick", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "minShares", + "type": "uint256" + } + ], + "name": "rebalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + } + ], + "name": "redemptionAvailable", + "outputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedLoanReceipt", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "principal", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "duration", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "maxRepayment", + "type": "uint256" + }, + { + "internalType": "uint128[]", + "name": "ticks", + "type": "uint128[]" + } + ], + "name": "refinance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedLoanReceipt", + "type": "bytes" + } + ], + "name": "repay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "rate", + "type": "uint32" + } + ], + "name": "setAdminFeeRate", + "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": "uint128", + "name": "tick", + "type": "uint128" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "withdrawAdminFees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/apps/meta-street/contracts/abis/pool-v-2.json b/src/apps/meta-street/contracts/abis/pool-v-2.json new file mode 100644 index 000000000..f48f83b17 --- /dev/null +++ b/src/apps/meta-street/contracts/abis/pool-v-2.json @@ -0,0 +1,1413 @@ +[ + { + "inputs": [ + { + "internalType": "address", + "name": "collateralLiquidator", + "type": "address" + }, + { + "internalType": "address", + "name": "delegationRegistry", + "type": "address" + }, + { + "internalType": "address[]", + "name": "collateralWrappers", + "type": "address[]" + }, + { + "components": [ + { + "internalType": "uint64", + "name": "tickThreshold", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "tickExponential", + "type": "uint64" + } + ], + "internalType": "struct WeightedInterestRateModel.Parameters", + "name": "parameters", + "type": "tuple" + } + ], + "stateMutability": "nonpayable", + "type": "constructor" + }, + { + "inputs": [], + "name": "InactiveLiquidity", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientLiquidity", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientShares", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientTickSpacing", + "type": "error" + }, + { + "inputs": [], + "name": "InsufficientUtilization", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidBorrowOptions", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCaller", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidCollateralFilterParameters", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidInterestRateModelParameters", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidLoanReceipt", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidParameters", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidReceiptEncoding", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidRedemptionStatus", + "type": "error" + }, + { + "inputs": [], + "name": "InvalidTick", + "type": "error" + }, + { + "inputs": [], + "name": "LoanNotExpired", + "type": "error" + }, + { + "inputs": [], + "name": "RepaymentTooHigh", + "type": "error" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "index", + "type": "uint256" + } + ], + "name": "UnsupportedCollateral", + "type": "error" + }, + { + "inputs": [], + "name": "UnsupportedLoanDuration", + "type": "error" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": false, + "internalType": "uint256", + "name": "rate", + "type": "uint256" + } + ], + "name": "AdminFeeRateUpdated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "AdminFeesWithdrawn", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "loanReceiptHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "proceeds", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "borrowerProceeds", + "type": "uint256" + } + ], + "name": "CollateralLiquidated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Deposited", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "loanReceiptHash", + "type": "bytes32" + } + ], + "name": "LoanLiquidated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "loanReceiptHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "bytes", + "name": "loanReceipt", + "type": "bytes" + } + ], + "name": "LoanOriginated", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "bytes32", + "name": "loanReceiptHash", + "type": "bytes32" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "repayment", + "type": "uint256" + } + ], + "name": "LoanRepaid", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "redemptionId", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "Redeemed", + "type": "event" + }, + { + "anonymous": false, + "inputs": [ + { + "indexed": true, + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "indexed": true, + "internalType": "uint128", + "name": "redemptionId", + "type": "uint128" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "indexed": false, + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "Withdrawn", + "type": "event" + }, + { + "inputs": [], + "name": "BORROWER_SURPLUS_SPLIT_BASIS_POINTS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "COLLATERAL_FILTER_NAME", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "COLLATERAL_FILTER_VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "IMPLEMENTATION_NAME", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "IMPLEMENTATION_VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "INTEREST_RATE_MODEL_NAME", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "INTEREST_RATE_MODEL_VERSION", + "outputs": [ + { + "internalType": "string", + "name": "", + "type": "string" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "TICK_LIMIT_SPACING_BASIS_POINTS", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "admin", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "adminFeeBalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "adminFeeRate", + "outputs": [ + { + "internalType": "uint32", + "name": "", + "type": "uint32" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "principal", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "duration", + "type": "uint64" + }, + { + "internalType": "address", + "name": "collateralToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "collateralTokenId", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "maxRepayment", + "type": "uint256" + }, + { + "internalType": "uint128[]", + "name": "ticks", + "type": "uint128[]" + }, + { + "internalType": "bytes", + "name": "options", + "type": "bytes" + } + ], + "name": "borrow", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [], + "name": "collateralLiquidator", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "collateralToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "collateralWrappers", + "outputs": [ + { + "internalType": "address[]", + "name": "", + "type": "address[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "currencyToken", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "loanReceipt", + "type": "bytes" + } + ], + "name": "decodeLoanReceipt", + "outputs": [ + { + "components": [ + { + "internalType": "uint8", + "name": "version", + "type": "uint8" + }, + { + "internalType": "uint256", + "name": "principal", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "repayment", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "adminFee", + "type": "uint256" + }, + { + "internalType": "address", + "name": "borrower", + "type": "address" + }, + { + "internalType": "uint64", + "name": "maturity", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "duration", + "type": "uint64" + }, + { + "internalType": "address", + "name": "collateralToken", + "type": "address" + }, + { + "internalType": "uint256", + "name": "collateralTokenId", + "type": "uint256" + }, + { + "internalType": "uint16", + "name": "collateralWrapperContextLen", + "type": "uint16" + }, + { + "internalType": "bytes", + "name": "collateralWrapperContext", + "type": "bytes" + }, + { + "components": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "used", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "pending", + "type": "uint128" + } + ], + "internalType": "struct LoanReceipt.NodeReceipt[]", + "name": "nodeReceipts", + "type": "tuple[]" + } + ], + "internalType": "struct LoanReceipt.LoanReceiptV2", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "pure", + "type": "function" + }, + { + "inputs": [], + "name": "delegationRegistry", + "outputs": [ + { + "internalType": "address", + "name": "", + "type": "address" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "minShares", + "type": "uint256" + } + ], + "name": "deposit", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + } + ], + "name": "deposits", + "outputs": [ + { + "internalType": "uint128", + "name": "shares", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "redemptionId", + "type": "uint128" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "durations", + "outputs": [ + { + "internalType": "uint64[]", + "name": "", + "type": "uint64[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "params", + "type": "bytes" + } + ], + "name": "initialize", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedLoanReceipt", + "type": "bytes" + } + ], + "name": "liquidate", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + } + ], + "name": "liquidityNode", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "value", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "shares", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "available", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "pending", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "redemptions", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "prev", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "next", + "type": "uint128" + } + ], + "internalType": "struct ILiquidity.NodeInfo", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + } + ], + "name": "liquidityNodeWithAccrual", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "value", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "shares", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "available", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "pending", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "redemptions", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "prev", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "next", + "type": "uint128" + } + ], + "internalType": "struct ILiquidity.NodeInfo", + "name": "", + "type": "tuple" + }, + { + "components": [ + { + "internalType": "uint128", + "name": "accrued", + "type": "uint128" + }, + { + "internalType": "uint64", + "name": "rate", + "type": "uint64" + }, + { + "internalType": "uint64", + "name": "timestamp", + "type": "uint64" + } + ], + "internalType": "struct ILiquidity.AccrualInfo", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "startTick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "endTick", + "type": "uint128" + } + ], + "name": "liquidityNodes", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "value", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "shares", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "available", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "pending", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "redemptions", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "prev", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "next", + "type": "uint128" + } + ], + "internalType": "struct ILiquidity.NodeInfo[]", + "name": "", + "type": "tuple[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes32", + "name": "receiptHash", + "type": "bytes32" + } + ], + "name": "loans", + "outputs": [ + { + "internalType": "enum Pool.LoanStatus", + "name": "", + "type": "uint8" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes[]", + "name": "data", + "type": "bytes[]" + } + ], + "name": "multicall", + "outputs": [ + { + "internalType": "bytes[]", + "name": "results", + "type": "bytes[]" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedLoanReceipt", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "proceeds", + "type": "uint256" + } + ], + "name": "onCollateralLiquidated", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint256", + "name": "principal", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "duration", + "type": "uint64" + }, + { + "internalType": "address", + "name": "collateralToken", + "type": "address" + }, + { + "internalType": "uint256[]", + "name": "collateralTokenIds", + "type": "uint256[]" + }, + { + "internalType": "uint256", + "name": "collateralTokenCount", + "type": "uint256" + }, + { + "internalType": "uint128[]", + "name": "ticks", + "type": "uint128[]" + }, + { + "internalType": "bytes", + "name": "options", + "type": "bytes" + } + ], + "name": "quote", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [], + "name": "rates", + "outputs": [ + { + "internalType": "uint64[]", + "name": "", + "type": "uint64[]" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "srcTick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "dstTick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "redemptionId", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "minShares", + "type": "uint256" + } + ], + "name": "rebalance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + } + ], + "name": "redeem", + "outputs": [ + { + "internalType": "uint128", + "name": "", + "type": "uint128" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "redemptionId", + "type": "uint128" + } + ], + "name": "redemptionAvailable", + "outputs": [ + { + "internalType": "uint256", + "name": "shares", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "sharesAhead", + "type": "uint256" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "account", + "type": "address" + }, + { + "internalType": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "redemptionId", + "type": "uint128" + } + ], + "name": "redemptions", + "outputs": [ + { + "components": [ + { + "internalType": "uint128", + "name": "pending", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "index", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "target", + "type": "uint128" + } + ], + "internalType": "struct Pool.Redemption", + "name": "", + "type": "tuple" + } + ], + "stateMutability": "view", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedLoanReceipt", + "type": "bytes" + }, + { + "internalType": "uint256", + "name": "principal", + "type": "uint256" + }, + { + "internalType": "uint64", + "name": "duration", + "type": "uint64" + }, + { + "internalType": "uint256", + "name": "maxRepayment", + "type": "uint256" + }, + { + "internalType": "uint128[]", + "name": "ticks", + "type": "uint128[]" + } + ], + "name": "refinance", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "bytes", + "name": "encodedLoanReceipt", + "type": "bytes" + } + ], + "name": "repay", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "uint32", + "name": "rate", + "type": "uint32" + } + ], + "name": "setAdminFeeRate", + "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": "uint128", + "name": "tick", + "type": "uint128" + }, + { + "internalType": "uint128", + "name": "redemptionId", + "type": "uint128" + } + ], + "name": "withdraw", + "outputs": [ + { + "internalType": "uint256", + "name": "", + "type": "uint256" + }, + { + "internalType": "uint256", + "name": "", + "type": "uint256" + } + ], + "stateMutability": "nonpayable", + "type": "function" + }, + { + "inputs": [ + { + "internalType": "address", + "name": "recipient", + "type": "address" + }, + { + "internalType": "uint256", + "name": "amount", + "type": "uint256" + } + ], + "name": "withdrawAdminFees", + "outputs": [], + "stateMutability": "nonpayable", + "type": "function" + } +] diff --git a/src/apps/meta-street/contracts/ethers/PoolV2.ts b/src/apps/meta-street/contracts/ethers/PoolV2.ts new file mode 100644 index 000000000..63e8c98e5 --- /dev/null +++ b/src/apps/meta-street/contracts/ethers/PoolV2.ts @@ -0,0 +1,1464 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent, PromiseOrValue } from './common'; + +export declare namespace WeightedInterestRateModel { + export type ParametersStruct = { + tickThreshold: PromiseOrValue; + tickExponential: PromiseOrValue; + }; + + export type ParametersStructOutput = [BigNumber, BigNumber] & { + tickThreshold: BigNumber; + tickExponential: BigNumber; + }; +} + +export declare namespace LoanReceipt { + export type NodeReceiptStruct = { + tick: PromiseOrValue; + used: PromiseOrValue; + pending: PromiseOrValue; + }; + + export type NodeReceiptStructOutput = [BigNumber, BigNumber, BigNumber] & { + tick: BigNumber; + used: BigNumber; + pending: BigNumber; + }; + + export type LoanReceiptV2Struct = { + version: PromiseOrValue; + principal: PromiseOrValue; + repayment: PromiseOrValue; + adminFee: PromiseOrValue; + borrower: PromiseOrValue; + maturity: PromiseOrValue; + duration: PromiseOrValue; + collateralToken: PromiseOrValue; + collateralTokenId: PromiseOrValue; + collateralWrapperContextLen: PromiseOrValue; + collateralWrapperContext: PromiseOrValue; + nodeReceipts: LoanReceipt.NodeReceiptStruct[]; + }; + + export type LoanReceiptV2StructOutput = [ + number, + BigNumber, + BigNumber, + BigNumber, + string, + BigNumber, + BigNumber, + string, + BigNumber, + number, + string, + LoanReceipt.NodeReceiptStructOutput[], + ] & { + version: number; + principal: BigNumber; + repayment: BigNumber; + adminFee: BigNumber; + borrower: string; + maturity: BigNumber; + duration: BigNumber; + collateralToken: string; + collateralTokenId: BigNumber; + collateralWrapperContextLen: number; + collateralWrapperContext: string; + nodeReceipts: LoanReceipt.NodeReceiptStructOutput[]; + }; +} + +export declare namespace ILiquidity { + export type NodeInfoStruct = { + tick: PromiseOrValue; + value: PromiseOrValue; + shares: PromiseOrValue; + available: PromiseOrValue; + pending: PromiseOrValue; + redemptions: PromiseOrValue; + prev: PromiseOrValue; + next: PromiseOrValue; + }; + + export type NodeInfoStructOutput = [ + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + ] & { + tick: BigNumber; + value: BigNumber; + shares: BigNumber; + available: BigNumber; + pending: BigNumber; + redemptions: BigNumber; + prev: BigNumber; + next: BigNumber; + }; + + export type AccrualInfoStruct = { + accrued: PromiseOrValue; + rate: PromiseOrValue; + timestamp: PromiseOrValue; + }; + + export type AccrualInfoStructOutput = [BigNumber, BigNumber, BigNumber] & { + accrued: BigNumber; + rate: BigNumber; + timestamp: BigNumber; + }; +} + +export declare namespace Pool { + export type RedemptionStruct = { + pending: PromiseOrValue; + index: PromiseOrValue; + target: PromiseOrValue; + }; + + export type RedemptionStructOutput = [BigNumber, BigNumber, BigNumber] & { + pending: BigNumber; + index: BigNumber; + target: BigNumber; + }; +} + +export interface PoolV2Interface extends utils.Interface { + functions: { + 'BORROWER_SURPLUS_SPLIT_BASIS_POINTS()': FunctionFragment; + 'COLLATERAL_FILTER_NAME()': FunctionFragment; + 'COLLATERAL_FILTER_VERSION()': FunctionFragment; + 'IMPLEMENTATION_NAME()': FunctionFragment; + 'IMPLEMENTATION_VERSION()': FunctionFragment; + 'INTEREST_RATE_MODEL_NAME()': FunctionFragment; + 'INTEREST_RATE_MODEL_VERSION()': FunctionFragment; + 'TICK_LIMIT_SPACING_BASIS_POINTS()': FunctionFragment; + 'admin()': FunctionFragment; + 'adminFeeBalance()': FunctionFragment; + 'adminFeeRate()': FunctionFragment; + 'borrow(uint256,uint64,address,uint256,uint256,uint128[],bytes)': FunctionFragment; + 'collateralLiquidator()': FunctionFragment; + 'collateralToken()': FunctionFragment; + 'collateralWrappers()': FunctionFragment; + 'currencyToken()': FunctionFragment; + 'decodeLoanReceipt(bytes)': FunctionFragment; + 'delegationRegistry()': FunctionFragment; + 'deposit(uint128,uint256,uint256)': FunctionFragment; + 'deposits(address,uint128)': FunctionFragment; + 'durations()': FunctionFragment; + 'initialize(bytes)': FunctionFragment; + 'liquidate(bytes)': FunctionFragment; + 'liquidityNode(uint128)': FunctionFragment; + 'liquidityNodeWithAccrual(uint128)': FunctionFragment; + 'liquidityNodes(uint128,uint128)': FunctionFragment; + 'loans(bytes32)': FunctionFragment; + 'multicall(bytes[])': FunctionFragment; + 'onCollateralLiquidated(bytes,uint256)': FunctionFragment; + 'quote(uint256,uint64,address,uint256[],uint256,uint128[],bytes)': FunctionFragment; + 'rates()': FunctionFragment; + 'rebalance(uint128,uint128,uint128,uint256)': FunctionFragment; + 'redeem(uint128,uint256)': FunctionFragment; + 'redemptionAvailable(address,uint128,uint128)': FunctionFragment; + 'redemptions(address,uint128,uint128)': FunctionFragment; + 'refinance(bytes,uint256,uint64,uint256,uint128[])': FunctionFragment; + 'repay(bytes)': FunctionFragment; + 'setAdminFeeRate(uint32)': FunctionFragment; + 'supportsInterface(bytes4)': FunctionFragment; + 'withdraw(uint128,uint128)': FunctionFragment; + 'withdrawAdminFees(address,uint256)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'BORROWER_SURPLUS_SPLIT_BASIS_POINTS' + | 'COLLATERAL_FILTER_NAME' + | 'COLLATERAL_FILTER_VERSION' + | 'IMPLEMENTATION_NAME' + | 'IMPLEMENTATION_VERSION' + | 'INTEREST_RATE_MODEL_NAME' + | 'INTEREST_RATE_MODEL_VERSION' + | 'TICK_LIMIT_SPACING_BASIS_POINTS' + | 'admin' + | 'adminFeeBalance' + | 'adminFeeRate' + | 'borrow' + | 'collateralLiquidator' + | 'collateralToken' + | 'collateralWrappers' + | 'currencyToken' + | 'decodeLoanReceipt' + | 'delegationRegistry' + | 'deposit' + | 'deposits' + | 'durations' + | 'initialize' + | 'liquidate' + | 'liquidityNode' + | 'liquidityNodeWithAccrual' + | 'liquidityNodes' + | 'loans' + | 'multicall' + | 'onCollateralLiquidated' + | 'quote' + | 'rates' + | 'rebalance' + | 'redeem' + | 'redemptionAvailable' + | 'redemptions' + | 'refinance' + | 'repay' + | 'setAdminFeeRate' + | 'supportsInterface' + | 'withdraw' + | 'withdrawAdminFees', + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'BORROWER_SURPLUS_SPLIT_BASIS_POINTS', values?: undefined): string; + encodeFunctionData(functionFragment: 'COLLATERAL_FILTER_NAME', values?: undefined): string; + encodeFunctionData(functionFragment: 'COLLATERAL_FILTER_VERSION', values?: undefined): string; + encodeFunctionData(functionFragment: 'IMPLEMENTATION_NAME', values?: undefined): string; + encodeFunctionData(functionFragment: 'IMPLEMENTATION_VERSION', values?: undefined): string; + encodeFunctionData(functionFragment: 'INTEREST_RATE_MODEL_NAME', values?: undefined): string; + encodeFunctionData(functionFragment: 'INTEREST_RATE_MODEL_VERSION', values?: undefined): string; + encodeFunctionData(functionFragment: 'TICK_LIMIT_SPACING_BASIS_POINTS', values?: undefined): string; + encodeFunctionData(functionFragment: 'admin', values?: undefined): string; + encodeFunctionData(functionFragment: 'adminFeeBalance', values?: undefined): string; + encodeFunctionData(functionFragment: 'adminFeeRate', values?: undefined): string; + encodeFunctionData( + functionFragment: 'borrow', + values: [ + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue[], + PromiseOrValue, + ], + ): string; + encodeFunctionData(functionFragment: 'collateralLiquidator', values?: undefined): string; + encodeFunctionData(functionFragment: 'collateralToken', values?: undefined): string; + encodeFunctionData(functionFragment: 'collateralWrappers', values?: undefined): string; + encodeFunctionData(functionFragment: 'currencyToken', values?: undefined): string; + encodeFunctionData(functionFragment: 'decodeLoanReceipt', values: [PromiseOrValue]): string; + encodeFunctionData(functionFragment: 'delegationRegistry', values?: undefined): string; + encodeFunctionData( + functionFragment: 'deposit', + values: [PromiseOrValue, PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData( + functionFragment: 'deposits', + values: [PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData(functionFragment: 'durations', values?: undefined): string; + encodeFunctionData(functionFragment: 'initialize', values: [PromiseOrValue]): string; + encodeFunctionData(functionFragment: 'liquidate', values: [PromiseOrValue]): string; + encodeFunctionData(functionFragment: 'liquidityNode', values: [PromiseOrValue]): string; + encodeFunctionData(functionFragment: 'liquidityNodeWithAccrual', values: [PromiseOrValue]): string; + encodeFunctionData( + functionFragment: 'liquidityNodes', + values: [PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData(functionFragment: 'loans', values: [PromiseOrValue]): string; + encodeFunctionData(functionFragment: 'multicall', values: [PromiseOrValue[]]): string; + encodeFunctionData( + functionFragment: 'onCollateralLiquidated', + values: [PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData( + functionFragment: 'quote', + values: [ + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue[], + PromiseOrValue, + PromiseOrValue[], + PromiseOrValue, + ], + ): string; + encodeFunctionData(functionFragment: 'rates', values?: undefined): string; + encodeFunctionData( + functionFragment: 'rebalance', + values: [ + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + ], + ): string; + encodeFunctionData( + functionFragment: 'redeem', + values: [PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData( + functionFragment: 'redemptionAvailable', + values: [PromiseOrValue, PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData( + functionFragment: 'redemptions', + values: [PromiseOrValue, PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData( + functionFragment: 'refinance', + values: [ + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue[], + ], + ): string; + encodeFunctionData(functionFragment: 'repay', values: [PromiseOrValue]): string; + encodeFunctionData(functionFragment: 'setAdminFeeRate', values: [PromiseOrValue]): string; + encodeFunctionData(functionFragment: 'supportsInterface', values: [PromiseOrValue]): string; + encodeFunctionData( + functionFragment: 'withdraw', + values: [PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData( + functionFragment: 'withdrawAdminFees', + values: [PromiseOrValue, PromiseOrValue], + ): string; + + decodeFunctionResult(functionFragment: 'BORROWER_SURPLUS_SPLIT_BASIS_POINTS', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'COLLATERAL_FILTER_NAME', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'COLLATERAL_FILTER_VERSION', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'IMPLEMENTATION_NAME', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'IMPLEMENTATION_VERSION', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'INTEREST_RATE_MODEL_NAME', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'INTEREST_RATE_MODEL_VERSION', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'TICK_LIMIT_SPACING_BASIS_POINTS', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'admin', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'adminFeeBalance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'adminFeeRate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'borrow', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'collateralLiquidator', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'collateralToken', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'collateralWrappers', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'currencyToken', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'decodeLoanReceipt', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'delegationRegistry', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'deposit', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'deposits', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'durations', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'initialize', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'liquidate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'liquidityNode', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'liquidityNodeWithAccrual', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'liquidityNodes', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'loans', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'multicall', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'onCollateralLiquidated', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'quote', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'rates', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'rebalance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'redeem', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'redemptionAvailable', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'redemptions', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'refinance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'repay', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setAdminFeeRate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'supportsInterface', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'withdraw', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'withdrawAdminFees', data: BytesLike): Result; + + events: { + 'AdminFeeRateUpdated(uint256)': EventFragment; + 'AdminFeesWithdrawn(address,uint256)': EventFragment; + 'CollateralLiquidated(bytes32,uint256,uint256)': EventFragment; + 'Deposited(address,uint128,uint256,uint256)': EventFragment; + 'LoanLiquidated(bytes32)': EventFragment; + 'LoanOriginated(bytes32,bytes)': EventFragment; + 'LoanRepaid(bytes32,uint256)': EventFragment; + 'Redeemed(address,uint128,uint128,uint256)': EventFragment; + 'Withdrawn(address,uint128,uint128,uint256,uint256)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'AdminFeeRateUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'AdminFeesWithdrawn'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'CollateralLiquidated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Deposited'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LoanLiquidated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LoanOriginated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LoanRepaid'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Redeemed'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Withdrawn'): EventFragment; +} + +export interface AdminFeeRateUpdatedEventObject { + rate: BigNumber; +} +export type AdminFeeRateUpdatedEvent = TypedEvent<[BigNumber], AdminFeeRateUpdatedEventObject>; + +export type AdminFeeRateUpdatedEventFilter = TypedEventFilter; + +export interface AdminFeesWithdrawnEventObject { + account: string; + amount: BigNumber; +} +export type AdminFeesWithdrawnEvent = TypedEvent<[string, BigNumber], AdminFeesWithdrawnEventObject>; + +export type AdminFeesWithdrawnEventFilter = TypedEventFilter; + +export interface CollateralLiquidatedEventObject { + loanReceiptHash: string; + proceeds: BigNumber; + borrowerProceeds: BigNumber; +} +export type CollateralLiquidatedEvent = TypedEvent<[string, BigNumber, BigNumber], CollateralLiquidatedEventObject>; + +export type CollateralLiquidatedEventFilter = TypedEventFilter; + +export interface DepositedEventObject { + account: string; + tick: BigNumber; + amount: BigNumber; + shares: BigNumber; +} +export type DepositedEvent = TypedEvent<[string, BigNumber, BigNumber, BigNumber], DepositedEventObject>; + +export type DepositedEventFilter = TypedEventFilter; + +export interface LoanLiquidatedEventObject { + loanReceiptHash: string; +} +export type LoanLiquidatedEvent = TypedEvent<[string], LoanLiquidatedEventObject>; + +export type LoanLiquidatedEventFilter = TypedEventFilter; + +export interface LoanOriginatedEventObject { + loanReceiptHash: string; + loanReceipt: string; +} +export type LoanOriginatedEvent = TypedEvent<[string, string], LoanOriginatedEventObject>; + +export type LoanOriginatedEventFilter = TypedEventFilter; + +export interface LoanRepaidEventObject { + loanReceiptHash: string; + repayment: BigNumber; +} +export type LoanRepaidEvent = TypedEvent<[string, BigNumber], LoanRepaidEventObject>; + +export type LoanRepaidEventFilter = TypedEventFilter; + +export interface RedeemedEventObject { + account: string; + tick: BigNumber; + redemptionId: BigNumber; + shares: BigNumber; +} +export type RedeemedEvent = TypedEvent<[string, BigNumber, BigNumber, BigNumber], RedeemedEventObject>; + +export type RedeemedEventFilter = TypedEventFilter; + +export interface WithdrawnEventObject { + account: string; + tick: BigNumber; + redemptionId: BigNumber; + shares: BigNumber; + amount: BigNumber; +} +export type WithdrawnEvent = TypedEvent<[string, BigNumber, BigNumber, BigNumber, BigNumber], WithdrawnEventObject>; + +export type WithdrawnEventFilter = TypedEventFilter; + +export interface PoolV2 extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: PoolV2Interface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined, + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + BORROWER_SURPLUS_SPLIT_BASIS_POINTS(overrides?: CallOverrides): Promise<[BigNumber]>; + + COLLATERAL_FILTER_NAME(overrides?: CallOverrides): Promise<[string]>; + + COLLATERAL_FILTER_VERSION(overrides?: CallOverrides): Promise<[string]>; + + IMPLEMENTATION_NAME(overrides?: CallOverrides): Promise<[string]>; + + IMPLEMENTATION_VERSION(overrides?: CallOverrides): Promise<[string]>; + + INTEREST_RATE_MODEL_NAME(overrides?: CallOverrides): Promise<[string]>; + + INTEREST_RATE_MODEL_VERSION(overrides?: CallOverrides): Promise<[string]>; + + TICK_LIMIT_SPACING_BASIS_POINTS(overrides?: CallOverrides): Promise<[BigNumber]>; + + admin(overrides?: CallOverrides): Promise<[string]>; + + adminFeeBalance(overrides?: CallOverrides): Promise<[BigNumber]>; + + adminFeeRate(overrides?: CallOverrides): Promise<[number]>; + + borrow( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenId: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + collateralLiquidator(overrides?: CallOverrides): Promise<[string]>; + + collateralToken(overrides?: CallOverrides): Promise<[string]>; + + collateralWrappers(overrides?: CallOverrides): Promise<[string[]]>; + + currencyToken(overrides?: CallOverrides): Promise<[string]>; + + decodeLoanReceipt( + loanReceipt: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[LoanReceipt.LoanReceiptV2StructOutput]>; + + delegationRegistry(overrides?: CallOverrides): Promise<[string]>; + + deposit( + tick: PromiseOrValue, + amount: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + deposits( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { shares: BigNumber; redemptionId: BigNumber }>; + + durations(overrides?: CallOverrides): Promise<[BigNumber[]]>; + + initialize( + params: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + liquidate( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + liquidityNode( + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[ILiquidity.NodeInfoStructOutput]>; + + liquidityNodeWithAccrual( + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[ILiquidity.NodeInfoStructOutput, ILiquidity.AccrualInfoStructOutput]>; + + liquidityNodes( + startTick: PromiseOrValue, + endTick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[ILiquidity.NodeInfoStructOutput[]]>; + + loans(receiptHash: PromiseOrValue, overrides?: CallOverrides): Promise<[number]>; + + multicall( + data: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + onCollateralLiquidated( + encodedLoanReceipt: PromiseOrValue, + proceeds: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + quote( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenIds: PromiseOrValue[], + collateralTokenCount: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[BigNumber]>; + + rates(overrides?: CallOverrides): Promise<[BigNumber[]]>; + + rebalance( + srcTick: PromiseOrValue, + dstTick: PromiseOrValue, + redemptionId: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redeem( + tick: PromiseOrValue, + shares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redemptionAvailable( + account: PromiseOrValue, + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: CallOverrides, + ): Promise< + [BigNumber, BigNumber, BigNumber] & { + shares: BigNumber; + amount: BigNumber; + sharesAhead: BigNumber; + } + >; + + redemptions( + account: PromiseOrValue, + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[Pool.RedemptionStructOutput]>; + + refinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + repay( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + setAdminFeeRate( + rate: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + supportsInterface(interfaceId: PromiseOrValue, overrides?: CallOverrides): Promise<[boolean]>; + + withdraw( + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + withdrawAdminFees( + recipient: PromiseOrValue, + amount: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + }; + + BORROWER_SURPLUS_SPLIT_BASIS_POINTS(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_NAME(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_VERSION(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_NAME(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_VERSION(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_NAME(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_VERSION(overrides?: CallOverrides): Promise; + + TICK_LIMIT_SPACING_BASIS_POINTS(overrides?: CallOverrides): Promise; + + admin(overrides?: CallOverrides): Promise; + + adminFeeBalance(overrides?: CallOverrides): Promise; + + adminFeeRate(overrides?: CallOverrides): Promise; + + borrow( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenId: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + collateralLiquidator(overrides?: CallOverrides): Promise; + + collateralToken(overrides?: CallOverrides): Promise; + + collateralWrappers(overrides?: CallOverrides): Promise; + + currencyToken(overrides?: CallOverrides): Promise; + + decodeLoanReceipt( + loanReceipt: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + delegationRegistry(overrides?: CallOverrides): Promise; + + deposit( + tick: PromiseOrValue, + amount: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + deposits( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { shares: BigNumber; redemptionId: BigNumber }>; + + durations(overrides?: CallOverrides): Promise; + + initialize( + params: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + liquidate( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + liquidityNode( + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + liquidityNodeWithAccrual( + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[ILiquidity.NodeInfoStructOutput, ILiquidity.AccrualInfoStructOutput]>; + + liquidityNodes( + startTick: PromiseOrValue, + endTick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + loans(receiptHash: PromiseOrValue, overrides?: CallOverrides): Promise; + + multicall( + data: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + onCollateralLiquidated( + encodedLoanReceipt: PromiseOrValue, + proceeds: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + quote( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenIds: PromiseOrValue[], + collateralTokenCount: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + rates(overrides?: CallOverrides): Promise; + + rebalance( + srcTick: PromiseOrValue, + dstTick: PromiseOrValue, + redemptionId: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redeem( + tick: PromiseOrValue, + shares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redemptionAvailable( + account: PromiseOrValue, + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: CallOverrides, + ): Promise< + [BigNumber, BigNumber, BigNumber] & { + shares: BigNumber; + amount: BigNumber; + sharesAhead: BigNumber; + } + >; + + redemptions( + account: PromiseOrValue, + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + refinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + repay( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + setAdminFeeRate( + rate: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + supportsInterface(interfaceId: PromiseOrValue, overrides?: CallOverrides): Promise; + + withdraw( + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + withdrawAdminFees( + recipient: PromiseOrValue, + amount: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + callStatic: { + BORROWER_SURPLUS_SPLIT_BASIS_POINTS(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_NAME(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_VERSION(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_NAME(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_VERSION(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_NAME(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_VERSION(overrides?: CallOverrides): Promise; + + TICK_LIMIT_SPACING_BASIS_POINTS(overrides?: CallOverrides): Promise; + + admin(overrides?: CallOverrides): Promise; + + adminFeeBalance(overrides?: CallOverrides): Promise; + + adminFeeRate(overrides?: CallOverrides): Promise; + + borrow( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenId: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + collateralLiquidator(overrides?: CallOverrides): Promise; + + collateralToken(overrides?: CallOverrides): Promise; + + collateralWrappers(overrides?: CallOverrides): Promise; + + currencyToken(overrides?: CallOverrides): Promise; + + decodeLoanReceipt( + loanReceipt: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + delegationRegistry(overrides?: CallOverrides): Promise; + + deposit( + tick: PromiseOrValue, + amount: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + deposits( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { shares: BigNumber; redemptionId: BigNumber }>; + + durations(overrides?: CallOverrides): Promise; + + initialize(params: PromiseOrValue, overrides?: CallOverrides): Promise; + + liquidate(encodedLoanReceipt: PromiseOrValue, overrides?: CallOverrides): Promise; + + liquidityNode( + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + liquidityNodeWithAccrual( + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[ILiquidity.NodeInfoStructOutput, ILiquidity.AccrualInfoStructOutput]>; + + liquidityNodes( + startTick: PromiseOrValue, + endTick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + loans(receiptHash: PromiseOrValue, overrides?: CallOverrides): Promise; + + multicall(data: PromiseOrValue[], overrides?: CallOverrides): Promise; + + onCollateralLiquidated( + encodedLoanReceipt: PromiseOrValue, + proceeds: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + quote( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenIds: PromiseOrValue[], + collateralTokenCount: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + rates(overrides?: CallOverrides): Promise; + + rebalance( + srcTick: PromiseOrValue, + dstTick: PromiseOrValue, + redemptionId: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber, BigNumber]>; + + redeem( + tick: PromiseOrValue, + shares: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + redemptionAvailable( + account: PromiseOrValue, + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: CallOverrides, + ): Promise< + [BigNumber, BigNumber, BigNumber] & { + shares: BigNumber; + amount: BigNumber; + sharesAhead: BigNumber; + } + >; + + redemptions( + account: PromiseOrValue, + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + refinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: CallOverrides, + ): Promise; + + repay(encodedLoanReceipt: PromiseOrValue, overrides?: CallOverrides): Promise; + + setAdminFeeRate(rate: PromiseOrValue, overrides?: CallOverrides): Promise; + + supportsInterface(interfaceId: PromiseOrValue, overrides?: CallOverrides): Promise; + + withdraw( + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber]>; + + withdrawAdminFees( + recipient: PromiseOrValue, + amount: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + }; + + filters: { + 'AdminFeeRateUpdated(uint256)'(rate?: null): AdminFeeRateUpdatedEventFilter; + AdminFeeRateUpdated(rate?: null): AdminFeeRateUpdatedEventFilter; + + 'AdminFeesWithdrawn(address,uint256)'( + account?: PromiseOrValue | null, + amount?: null, + ): AdminFeesWithdrawnEventFilter; + AdminFeesWithdrawn(account?: PromiseOrValue | null, amount?: null): AdminFeesWithdrawnEventFilter; + + 'CollateralLiquidated(bytes32,uint256,uint256)'( + loanReceiptHash?: PromiseOrValue | null, + proceeds?: null, + borrowerProceeds?: null, + ): CollateralLiquidatedEventFilter; + CollateralLiquidated( + loanReceiptHash?: PromiseOrValue | null, + proceeds?: null, + borrowerProceeds?: null, + ): CollateralLiquidatedEventFilter; + + 'Deposited(address,uint128,uint256,uint256)'( + account?: PromiseOrValue | null, + tick?: PromiseOrValue | null, + amount?: null, + shares?: null, + ): DepositedEventFilter; + Deposited( + account?: PromiseOrValue | null, + tick?: PromiseOrValue | null, + amount?: null, + shares?: null, + ): DepositedEventFilter; + + 'LoanLiquidated(bytes32)'(loanReceiptHash?: PromiseOrValue | null): LoanLiquidatedEventFilter; + LoanLiquidated(loanReceiptHash?: PromiseOrValue | null): LoanLiquidatedEventFilter; + + 'LoanOriginated(bytes32,bytes)'( + loanReceiptHash?: PromiseOrValue | null, + loanReceipt?: null, + ): LoanOriginatedEventFilter; + LoanOriginated(loanReceiptHash?: PromiseOrValue | null, loanReceipt?: null): LoanOriginatedEventFilter; + + 'LoanRepaid(bytes32,uint256)'( + loanReceiptHash?: PromiseOrValue | null, + repayment?: null, + ): LoanRepaidEventFilter; + LoanRepaid(loanReceiptHash?: PromiseOrValue | null, repayment?: null): LoanRepaidEventFilter; + + 'Redeemed(address,uint128,uint128,uint256)'( + account?: PromiseOrValue | null, + tick?: PromiseOrValue | null, + redemptionId?: PromiseOrValue | null, + shares?: null, + ): RedeemedEventFilter; + Redeemed( + account?: PromiseOrValue | null, + tick?: PromiseOrValue | null, + redemptionId?: PromiseOrValue | null, + shares?: null, + ): RedeemedEventFilter; + + 'Withdrawn(address,uint128,uint128,uint256,uint256)'( + account?: PromiseOrValue | null, + tick?: PromiseOrValue | null, + redemptionId?: PromiseOrValue | null, + shares?: null, + amount?: null, + ): WithdrawnEventFilter; + Withdrawn( + account?: PromiseOrValue | null, + tick?: PromiseOrValue | null, + redemptionId?: PromiseOrValue | null, + shares?: null, + amount?: null, + ): WithdrawnEventFilter; + }; + + estimateGas: { + BORROWER_SURPLUS_SPLIT_BASIS_POINTS(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_NAME(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_VERSION(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_NAME(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_VERSION(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_NAME(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_VERSION(overrides?: CallOverrides): Promise; + + TICK_LIMIT_SPACING_BASIS_POINTS(overrides?: CallOverrides): Promise; + + admin(overrides?: CallOverrides): Promise; + + adminFeeBalance(overrides?: CallOverrides): Promise; + + adminFeeRate(overrides?: CallOverrides): Promise; + + borrow( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenId: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + collateralLiquidator(overrides?: CallOverrides): Promise; + + collateralToken(overrides?: CallOverrides): Promise; + + collateralWrappers(overrides?: CallOverrides): Promise; + + currencyToken(overrides?: CallOverrides): Promise; + + decodeLoanReceipt(loanReceipt: PromiseOrValue, overrides?: CallOverrides): Promise; + + delegationRegistry(overrides?: CallOverrides): Promise; + + deposit( + tick: PromiseOrValue, + amount: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + deposits( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + durations(overrides?: CallOverrides): Promise; + + initialize( + params: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + liquidate( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + liquidityNode(tick: PromiseOrValue, overrides?: CallOverrides): Promise; + + liquidityNodeWithAccrual(tick: PromiseOrValue, overrides?: CallOverrides): Promise; + + liquidityNodes( + startTick: PromiseOrValue, + endTick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + loans(receiptHash: PromiseOrValue, overrides?: CallOverrides): Promise; + + multicall( + data: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + onCollateralLiquidated( + encodedLoanReceipt: PromiseOrValue, + proceeds: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + quote( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenIds: PromiseOrValue[], + collateralTokenCount: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + rates(overrides?: CallOverrides): Promise; + + rebalance( + srcTick: PromiseOrValue, + dstTick: PromiseOrValue, + redemptionId: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redeem( + tick: PromiseOrValue, + shares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redemptionAvailable( + account: PromiseOrValue, + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + redemptions( + account: PromiseOrValue, + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + refinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + repay( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + setAdminFeeRate( + rate: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + supportsInterface(interfaceId: PromiseOrValue, overrides?: CallOverrides): Promise; + + withdraw( + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + withdrawAdminFees( + recipient: PromiseOrValue, + amount: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + }; + + populateTransaction: { + BORROWER_SURPLUS_SPLIT_BASIS_POINTS(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_NAME(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_VERSION(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_NAME(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_VERSION(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_NAME(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_VERSION(overrides?: CallOverrides): Promise; + + TICK_LIMIT_SPACING_BASIS_POINTS(overrides?: CallOverrides): Promise; + + admin(overrides?: CallOverrides): Promise; + + adminFeeBalance(overrides?: CallOverrides): Promise; + + adminFeeRate(overrides?: CallOverrides): Promise; + + borrow( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenId: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + collateralLiquidator(overrides?: CallOverrides): Promise; + + collateralToken(overrides?: CallOverrides): Promise; + + collateralWrappers(overrides?: CallOverrides): Promise; + + currencyToken(overrides?: CallOverrides): Promise; + + decodeLoanReceipt(loanReceipt: PromiseOrValue, overrides?: CallOverrides): Promise; + + delegationRegistry(overrides?: CallOverrides): Promise; + + deposit( + tick: PromiseOrValue, + amount: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + deposits( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + durations(overrides?: CallOverrides): Promise; + + initialize( + params: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + liquidate( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + liquidityNode(tick: PromiseOrValue, overrides?: CallOverrides): Promise; + + liquidityNodeWithAccrual( + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + liquidityNodes( + startTick: PromiseOrValue, + endTick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + loans(receiptHash: PromiseOrValue, overrides?: CallOverrides): Promise; + + multicall( + data: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + onCollateralLiquidated( + encodedLoanReceipt: PromiseOrValue, + proceeds: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + quote( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenIds: PromiseOrValue[], + collateralTokenCount: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + rates(overrides?: CallOverrides): Promise; + + rebalance( + srcTick: PromiseOrValue, + dstTick: PromiseOrValue, + redemptionId: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redeem( + tick: PromiseOrValue, + shares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redemptionAvailable( + account: PromiseOrValue, + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + redemptions( + account: PromiseOrValue, + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + refinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + repay( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + setAdminFeeRate( + rate: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + supportsInterface(interfaceId: PromiseOrValue, overrides?: CallOverrides): Promise; + + withdraw( + tick: PromiseOrValue, + redemptionId: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + withdrawAdminFees( + recipient: PromiseOrValue, + amount: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + }; +} diff --git a/src/apps/meta-street/contracts/ethers/PoolV2Legacy.ts b/src/apps/meta-street/contracts/ethers/PoolV2Legacy.ts new file mode 100644 index 000000000..25362d012 --- /dev/null +++ b/src/apps/meta-street/contracts/ethers/PoolV2Legacy.ts @@ -0,0 +1,1341 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { + BaseContract, + BigNumber, + BigNumberish, + BytesLike, + CallOverrides, + ContractTransaction, + Overrides, + PopulatedTransaction, + Signer, + utils, +} from 'ethers'; +import type { FunctionFragment, Result, EventFragment } from '@ethersproject/abi'; +import type { Listener, Provider } from '@ethersproject/providers'; +import type { TypedEventFilter, TypedEvent, TypedListener, OnEvent, PromiseOrValue } from './common'; + +export declare namespace LoanReceipt { + export type NodeReceiptStruct = { + tick: PromiseOrValue; + used: PromiseOrValue; + pending: PromiseOrValue; + }; + + export type NodeReceiptStructOutput = [BigNumber, BigNumber, BigNumber] & { + tick: BigNumber; + used: BigNumber; + pending: BigNumber; + }; + + export type LoanReceiptV1Struct = { + version: PromiseOrValue; + principal: PromiseOrValue; + repayment: PromiseOrValue; + borrower: PromiseOrValue; + maturity: PromiseOrValue; + duration: PromiseOrValue; + collateralToken: PromiseOrValue; + collateralTokenId: PromiseOrValue; + collateralWrapperContextLen: PromiseOrValue; + collateralWrapperContext: PromiseOrValue; + nodeReceipts: LoanReceipt.NodeReceiptStruct[]; + }; + + export type LoanReceiptV1StructOutput = [ + number, + BigNumber, + BigNumber, + string, + BigNumber, + BigNumber, + string, + BigNumber, + number, + string, + LoanReceipt.NodeReceiptStructOutput[], + ] & { + version: number; + principal: BigNumber; + repayment: BigNumber; + borrower: string; + maturity: BigNumber; + duration: BigNumber; + collateralToken: string; + collateralTokenId: BigNumber; + collateralWrapperContextLen: number; + collateralWrapperContext: string; + nodeReceipts: LoanReceipt.NodeReceiptStructOutput[]; + }; +} + +export declare namespace Pool { + export type DepositStruct = { + shares: PromiseOrValue; + redemptionPending: PromiseOrValue; + redemptionIndex: PromiseOrValue; + redemptionTarget: PromiseOrValue; + }; + + export type DepositStructOutput = [BigNumber, BigNumber, BigNumber, BigNumber] & { + shares: BigNumber; + redemptionPending: BigNumber; + redemptionIndex: BigNumber; + redemptionTarget: BigNumber; + }; +} + +export declare namespace ILiquidity { + export type NodeInfoStruct = { + tick: PromiseOrValue; + value: PromiseOrValue; + shares: PromiseOrValue; + available: PromiseOrValue; + pending: PromiseOrValue; + redemptions: PromiseOrValue; + prev: PromiseOrValue; + next: PromiseOrValue; + }; + + export type NodeInfoStructOutput = [ + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + BigNumber, + ] & { + tick: BigNumber; + value: BigNumber; + shares: BigNumber; + available: BigNumber; + pending: BigNumber; + redemptions: BigNumber; + prev: BigNumber; + next: BigNumber; + }; +} + +export interface PoolV2LegacyInterface extends utils.Interface { + functions: { + 'BORROWER_SURPLUS_SPLIT_BASIS_POINTS()': FunctionFragment; + 'COLLATERAL_FILTER_NAME()': FunctionFragment; + 'COLLATERAL_FILTER_VERSION()': FunctionFragment; + 'IMPLEMENTATION_NAME()': FunctionFragment; + 'IMPLEMENTATION_VERSION()': FunctionFragment; + 'INTEREST_RATE_MODEL_NAME()': FunctionFragment; + 'INTEREST_RATE_MODEL_VERSION()': FunctionFragment; + 'TICK_LIMIT_SPACING_BASIS_POINTS()': FunctionFragment; + 'admin()': FunctionFragment; + 'adminFeeBalance()': FunctionFragment; + 'adminFeeRate()': FunctionFragment; + 'borrow(uint256,uint64,address,uint256,uint256,uint128[],bytes)': FunctionFragment; + 'collateralLiquidator()': FunctionFragment; + 'collateralToken()': FunctionFragment; + 'collateralWrappers()': FunctionFragment; + 'currencyToken()': FunctionFragment; + 'decodeLoanReceipt(bytes)': FunctionFragment; + 'delegationRegistry()': FunctionFragment; + 'deposit(uint128,uint256,uint256)': FunctionFragment; + 'deposits(address,uint128)': FunctionFragment; + 'durations()': FunctionFragment; + 'liquidate(bytes)': FunctionFragment; + 'liquidityNode(uint128)': FunctionFragment; + 'liquidityNodes(uint128,uint128)': FunctionFragment; + 'loans(bytes32)': FunctionFragment; + 'multicall(bytes[])': FunctionFragment; + 'onCollateralLiquidated(bytes,uint256)': FunctionFragment; + 'quote(uint256,uint64,address,uint256[],uint128[],bytes)': FunctionFragment; + 'quoteRefinance(bytes,uint256,uint64,uint128[])': FunctionFragment; + 'rates()': FunctionFragment; + 'rebalance(uint128,uint128,uint256)': FunctionFragment; + 'redeem(uint128,uint256)': FunctionFragment; + 'redemptionAvailable(address,uint128)': FunctionFragment; + 'refinance(bytes,uint256,uint64,uint256,uint128[])': FunctionFragment; + 'repay(bytes)': FunctionFragment; + 'setAdminFeeRate(uint32)': FunctionFragment; + 'supportsInterface(bytes4)': FunctionFragment; + 'withdraw(uint128)': FunctionFragment; + 'withdrawAdminFees(address,uint256)': FunctionFragment; + }; + + getFunction( + nameOrSignatureOrTopic: + | 'BORROWER_SURPLUS_SPLIT_BASIS_POINTS' + | 'COLLATERAL_FILTER_NAME' + | 'COLLATERAL_FILTER_VERSION' + | 'IMPLEMENTATION_NAME' + | 'IMPLEMENTATION_VERSION' + | 'INTEREST_RATE_MODEL_NAME' + | 'INTEREST_RATE_MODEL_VERSION' + | 'TICK_LIMIT_SPACING_BASIS_POINTS' + | 'admin' + | 'adminFeeBalance' + | 'adminFeeRate' + | 'borrow' + | 'collateralLiquidator' + | 'collateralToken' + | 'collateralWrappers' + | 'currencyToken' + | 'decodeLoanReceipt' + | 'delegationRegistry' + | 'deposit' + | 'deposits' + | 'durations' + | 'liquidate' + | 'liquidityNode' + | 'liquidityNodes' + | 'loans' + | 'multicall' + | 'onCollateralLiquidated' + | 'quote' + | 'quoteRefinance' + | 'rates' + | 'rebalance' + | 'redeem' + | 'redemptionAvailable' + | 'refinance' + | 'repay' + | 'setAdminFeeRate' + | 'supportsInterface' + | 'withdraw' + | 'withdrawAdminFees', + ): FunctionFragment; + + encodeFunctionData(functionFragment: 'BORROWER_SURPLUS_SPLIT_BASIS_POINTS', values?: undefined): string; + encodeFunctionData(functionFragment: 'COLLATERAL_FILTER_NAME', values?: undefined): string; + encodeFunctionData(functionFragment: 'COLLATERAL_FILTER_VERSION', values?: undefined): string; + encodeFunctionData(functionFragment: 'IMPLEMENTATION_NAME', values?: undefined): string; + encodeFunctionData(functionFragment: 'IMPLEMENTATION_VERSION', values?: undefined): string; + encodeFunctionData(functionFragment: 'INTEREST_RATE_MODEL_NAME', values?: undefined): string; + encodeFunctionData(functionFragment: 'INTEREST_RATE_MODEL_VERSION', values?: undefined): string; + encodeFunctionData(functionFragment: 'TICK_LIMIT_SPACING_BASIS_POINTS', values?: undefined): string; + encodeFunctionData(functionFragment: 'admin', values?: undefined): string; + encodeFunctionData(functionFragment: 'adminFeeBalance', values?: undefined): string; + encodeFunctionData(functionFragment: 'adminFeeRate', values?: undefined): string; + encodeFunctionData( + functionFragment: 'borrow', + values: [ + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue[], + PromiseOrValue, + ], + ): string; + encodeFunctionData(functionFragment: 'collateralLiquidator', values?: undefined): string; + encodeFunctionData(functionFragment: 'collateralToken', values?: undefined): string; + encodeFunctionData(functionFragment: 'collateralWrappers', values?: undefined): string; + encodeFunctionData(functionFragment: 'currencyToken', values?: undefined): string; + encodeFunctionData(functionFragment: 'decodeLoanReceipt', values: [PromiseOrValue]): string; + encodeFunctionData(functionFragment: 'delegationRegistry', values?: undefined): string; + encodeFunctionData( + functionFragment: 'deposit', + values: [PromiseOrValue, PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData( + functionFragment: 'deposits', + values: [PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData(functionFragment: 'durations', values?: undefined): string; + encodeFunctionData(functionFragment: 'liquidate', values: [PromiseOrValue]): string; + encodeFunctionData(functionFragment: 'liquidityNode', values: [PromiseOrValue]): string; + encodeFunctionData( + functionFragment: 'liquidityNodes', + values: [PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData(functionFragment: 'loans', values: [PromiseOrValue]): string; + encodeFunctionData(functionFragment: 'multicall', values: [PromiseOrValue[]]): string; + encodeFunctionData( + functionFragment: 'onCollateralLiquidated', + values: [PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData( + functionFragment: 'quote', + values: [ + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue[], + PromiseOrValue[], + PromiseOrValue, + ], + ): string; + encodeFunctionData( + functionFragment: 'quoteRefinance', + values: [ + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue[], + ], + ): string; + encodeFunctionData(functionFragment: 'rates', values?: undefined): string; + encodeFunctionData( + functionFragment: 'rebalance', + values: [PromiseOrValue, PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData( + functionFragment: 'redeem', + values: [PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData( + functionFragment: 'redemptionAvailable', + values: [PromiseOrValue, PromiseOrValue], + ): string; + encodeFunctionData( + functionFragment: 'refinance', + values: [ + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue, + PromiseOrValue[], + ], + ): string; + encodeFunctionData(functionFragment: 'repay', values: [PromiseOrValue]): string; + encodeFunctionData(functionFragment: 'setAdminFeeRate', values: [PromiseOrValue]): string; + encodeFunctionData(functionFragment: 'supportsInterface', values: [PromiseOrValue]): string; + encodeFunctionData(functionFragment: 'withdraw', values: [PromiseOrValue]): string; + encodeFunctionData( + functionFragment: 'withdrawAdminFees', + values: [PromiseOrValue, PromiseOrValue], + ): string; + + decodeFunctionResult(functionFragment: 'BORROWER_SURPLUS_SPLIT_BASIS_POINTS', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'COLLATERAL_FILTER_NAME', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'COLLATERAL_FILTER_VERSION', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'IMPLEMENTATION_NAME', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'IMPLEMENTATION_VERSION', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'INTEREST_RATE_MODEL_NAME', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'INTEREST_RATE_MODEL_VERSION', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'TICK_LIMIT_SPACING_BASIS_POINTS', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'admin', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'adminFeeBalance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'adminFeeRate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'borrow', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'collateralLiquidator', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'collateralToken', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'collateralWrappers', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'currencyToken', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'decodeLoanReceipt', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'delegationRegistry', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'deposit', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'deposits', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'durations', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'liquidate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'liquidityNode', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'liquidityNodes', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'loans', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'multicall', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'onCollateralLiquidated', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'quote', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'quoteRefinance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'rates', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'rebalance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'redeem', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'redemptionAvailable', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'refinance', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'repay', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'setAdminFeeRate', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'supportsInterface', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'withdraw', data: BytesLike): Result; + decodeFunctionResult(functionFragment: 'withdrawAdminFees', data: BytesLike): Result; + + events: { + 'AdminFeeRateUpdated(uint256)': EventFragment; + 'AdminFeesWithdrawn(address,uint256)': EventFragment; + 'CollateralLiquidated(bytes32,uint256,uint256)': EventFragment; + 'Deposited(address,uint128,uint256,uint256)': EventFragment; + 'LoanLiquidated(bytes32)': EventFragment; + 'LoanOriginated(bytes32,bytes)': EventFragment; + 'LoanRepaid(bytes32,uint256)': EventFragment; + 'Redeemed(address,uint128,uint256)': EventFragment; + 'Withdrawn(address,uint128,uint256,uint256)': EventFragment; + }; + + getEvent(nameOrSignatureOrTopic: 'AdminFeeRateUpdated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'AdminFeesWithdrawn'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'CollateralLiquidated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Deposited'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LoanLiquidated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LoanOriginated'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'LoanRepaid'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Redeemed'): EventFragment; + getEvent(nameOrSignatureOrTopic: 'Withdrawn'): EventFragment; +} + +export interface AdminFeeRateUpdatedEventObject { + rate: BigNumber; +} +export type AdminFeeRateUpdatedEvent = TypedEvent<[BigNumber], AdminFeeRateUpdatedEventObject>; + +export type AdminFeeRateUpdatedEventFilter = TypedEventFilter; + +export interface AdminFeesWithdrawnEventObject { + account: string; + amount: BigNumber; +} +export type AdminFeesWithdrawnEvent = TypedEvent<[string, BigNumber], AdminFeesWithdrawnEventObject>; + +export type AdminFeesWithdrawnEventFilter = TypedEventFilter; + +export interface CollateralLiquidatedEventObject { + loanReceiptHash: string; + proceeds: BigNumber; + borrowerProceeds: BigNumber; +} +export type CollateralLiquidatedEvent = TypedEvent<[string, BigNumber, BigNumber], CollateralLiquidatedEventObject>; + +export type CollateralLiquidatedEventFilter = TypedEventFilter; + +export interface DepositedEventObject { + account: string; + tick: BigNumber; + amount: BigNumber; + shares: BigNumber; +} +export type DepositedEvent = TypedEvent<[string, BigNumber, BigNumber, BigNumber], DepositedEventObject>; + +export type DepositedEventFilter = TypedEventFilter; + +export interface LoanLiquidatedEventObject { + loanReceiptHash: string; +} +export type LoanLiquidatedEvent = TypedEvent<[string], LoanLiquidatedEventObject>; + +export type LoanLiquidatedEventFilter = TypedEventFilter; + +export interface LoanOriginatedEventObject { + loanReceiptHash: string; + loanReceipt: string; +} +export type LoanOriginatedEvent = TypedEvent<[string, string], LoanOriginatedEventObject>; + +export type LoanOriginatedEventFilter = TypedEventFilter; + +export interface LoanRepaidEventObject { + loanReceiptHash: string; + repayment: BigNumber; +} +export type LoanRepaidEvent = TypedEvent<[string, BigNumber], LoanRepaidEventObject>; + +export type LoanRepaidEventFilter = TypedEventFilter; + +export interface RedeemedEventObject { + account: string; + tick: BigNumber; + shares: BigNumber; +} +export type RedeemedEvent = TypedEvent<[string, BigNumber, BigNumber], RedeemedEventObject>; + +export type RedeemedEventFilter = TypedEventFilter; + +export interface WithdrawnEventObject { + account: string; + tick: BigNumber; + shares: BigNumber; + amount: BigNumber; +} +export type WithdrawnEvent = TypedEvent<[string, BigNumber, BigNumber, BigNumber], WithdrawnEventObject>; + +export type WithdrawnEventFilter = TypedEventFilter; + +export interface PoolV2Legacy extends BaseContract { + connect(signerOrProvider: Signer | Provider | string): this; + attach(addressOrName: string): this; + deployed(): Promise; + + interface: PoolV2LegacyInterface; + + queryFilter( + event: TypedEventFilter, + fromBlockOrBlockhash?: string | number | undefined, + toBlock?: string | number | undefined, + ): Promise>; + + listeners(eventFilter?: TypedEventFilter): Array>; + listeners(eventName?: string): Array; + removeAllListeners(eventFilter: TypedEventFilter): this; + removeAllListeners(eventName?: string): this; + off: OnEvent; + on: OnEvent; + once: OnEvent; + removeListener: OnEvent; + + functions: { + BORROWER_SURPLUS_SPLIT_BASIS_POINTS(overrides?: CallOverrides): Promise<[BigNumber]>; + + COLLATERAL_FILTER_NAME(overrides?: CallOverrides): Promise<[string]>; + + COLLATERAL_FILTER_VERSION(overrides?: CallOverrides): Promise<[string]>; + + IMPLEMENTATION_NAME(overrides?: CallOverrides): Promise<[string]>; + + IMPLEMENTATION_VERSION(overrides?: CallOverrides): Promise<[string]>; + + INTEREST_RATE_MODEL_NAME(overrides?: CallOverrides): Promise<[string]>; + + INTEREST_RATE_MODEL_VERSION(overrides?: CallOverrides): Promise<[string]>; + + TICK_LIMIT_SPACING_BASIS_POINTS(overrides?: CallOverrides): Promise<[BigNumber]>; + + admin(overrides?: CallOverrides): Promise<[string]>; + + adminFeeBalance(overrides?: CallOverrides): Promise<[BigNumber]>; + + adminFeeRate(overrides?: CallOverrides): Promise<[number]>; + + borrow( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenId: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + collateralLiquidator(overrides?: CallOverrides): Promise<[string]>; + + collateralToken(overrides?: CallOverrides): Promise<[string]>; + + collateralWrappers(overrides?: CallOverrides): Promise<[string[]]>; + + currencyToken(overrides?: CallOverrides): Promise<[string]>; + + decodeLoanReceipt( + loanReceipt: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[LoanReceipt.LoanReceiptV1StructOutput]>; + + delegationRegistry(overrides?: CallOverrides): Promise<[string]>; + + deposit( + tick: PromiseOrValue, + amount: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + deposits( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[Pool.DepositStructOutput]>; + + durations(overrides?: CallOverrides): Promise<[BigNumber[]]>; + + liquidate( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + liquidityNode( + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[ILiquidity.NodeInfoStructOutput]>; + + liquidityNodes( + startTick: PromiseOrValue, + endTick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[ILiquidity.NodeInfoStructOutput[]]>; + + loans(receiptHash: PromiseOrValue, overrides?: CallOverrides): Promise<[number]>; + + multicall( + data: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + onCollateralLiquidated( + encodedLoanReceipt: PromiseOrValue, + proceeds: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + quote( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenIds: PromiseOrValue[], + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[BigNumber]>; + + quoteRefinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber]>; + + rates(overrides?: CallOverrides): Promise<[BigNumber[]]>; + + rebalance( + srcTick: PromiseOrValue, + dstTick: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redeem( + tick: PromiseOrValue, + shares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redemptionAvailable( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { shares: BigNumber; amount: BigNumber }>; + + refinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + repay( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + setAdminFeeRate( + rate: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + supportsInterface(interfaceId: PromiseOrValue, overrides?: CallOverrides): Promise<[boolean]>; + + withdraw( + tick: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + withdrawAdminFees( + recipient: PromiseOrValue, + amount: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + }; + + BORROWER_SURPLUS_SPLIT_BASIS_POINTS(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_NAME(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_VERSION(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_NAME(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_VERSION(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_NAME(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_VERSION(overrides?: CallOverrides): Promise; + + TICK_LIMIT_SPACING_BASIS_POINTS(overrides?: CallOverrides): Promise; + + admin(overrides?: CallOverrides): Promise; + + adminFeeBalance(overrides?: CallOverrides): Promise; + + adminFeeRate(overrides?: CallOverrides): Promise; + + borrow( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenId: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + collateralLiquidator(overrides?: CallOverrides): Promise; + + collateralToken(overrides?: CallOverrides): Promise; + + collateralWrappers(overrides?: CallOverrides): Promise; + + currencyToken(overrides?: CallOverrides): Promise; + + decodeLoanReceipt( + loanReceipt: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + delegationRegistry(overrides?: CallOverrides): Promise; + + deposit( + tick: PromiseOrValue, + amount: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + deposits( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + durations(overrides?: CallOverrides): Promise; + + liquidate( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + liquidityNode( + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + liquidityNodes( + startTick: PromiseOrValue, + endTick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + loans(receiptHash: PromiseOrValue, overrides?: CallOverrides): Promise; + + multicall( + data: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + onCollateralLiquidated( + encodedLoanReceipt: PromiseOrValue, + proceeds: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + quote( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenIds: PromiseOrValue[], + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + quoteRefinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber]>; + + rates(overrides?: CallOverrides): Promise; + + rebalance( + srcTick: PromiseOrValue, + dstTick: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redeem( + tick: PromiseOrValue, + shares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redemptionAvailable( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { shares: BigNumber; amount: BigNumber }>; + + refinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + repay( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + setAdminFeeRate( + rate: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + supportsInterface(interfaceId: PromiseOrValue, overrides?: CallOverrides): Promise; + + withdraw( + tick: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + withdrawAdminFees( + recipient: PromiseOrValue, + amount: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + callStatic: { + BORROWER_SURPLUS_SPLIT_BASIS_POINTS(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_NAME(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_VERSION(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_NAME(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_VERSION(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_NAME(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_VERSION(overrides?: CallOverrides): Promise; + + TICK_LIMIT_SPACING_BASIS_POINTS(overrides?: CallOverrides): Promise; + + admin(overrides?: CallOverrides): Promise; + + adminFeeBalance(overrides?: CallOverrides): Promise; + + adminFeeRate(overrides?: CallOverrides): Promise; + + borrow( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenId: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + collateralLiquidator(overrides?: CallOverrides): Promise; + + collateralToken(overrides?: CallOverrides): Promise; + + collateralWrappers(overrides?: CallOverrides): Promise; + + currencyToken(overrides?: CallOverrides): Promise; + + decodeLoanReceipt( + loanReceipt: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + delegationRegistry(overrides?: CallOverrides): Promise; + + deposit( + tick: PromiseOrValue, + amount: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + deposits( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + durations(overrides?: CallOverrides): Promise; + + liquidate(encodedLoanReceipt: PromiseOrValue, overrides?: CallOverrides): Promise; + + liquidityNode( + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + liquidityNodes( + startTick: PromiseOrValue, + endTick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + loans(receiptHash: PromiseOrValue, overrides?: CallOverrides): Promise; + + multicall(data: PromiseOrValue[], overrides?: CallOverrides): Promise; + + onCollateralLiquidated( + encodedLoanReceipt: PromiseOrValue, + proceeds: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + quote( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenIds: PromiseOrValue[], + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + quoteRefinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber]>; + + rates(overrides?: CallOverrides): Promise; + + rebalance( + srcTick: PromiseOrValue, + dstTick: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber, BigNumber]>; + + redeem( + tick: PromiseOrValue, + shares: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + redemptionAvailable( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise<[BigNumber, BigNumber] & { shares: BigNumber; amount: BigNumber }>; + + refinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: CallOverrides, + ): Promise; + + repay(encodedLoanReceipt: PromiseOrValue, overrides?: CallOverrides): Promise; + + setAdminFeeRate(rate: PromiseOrValue, overrides?: CallOverrides): Promise; + + supportsInterface(interfaceId: PromiseOrValue, overrides?: CallOverrides): Promise; + + withdraw(tick: PromiseOrValue, overrides?: CallOverrides): Promise<[BigNumber, BigNumber]>; + + withdrawAdminFees( + recipient: PromiseOrValue, + amount: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + }; + + filters: { + 'AdminFeeRateUpdated(uint256)'(rate?: null): AdminFeeRateUpdatedEventFilter; + AdminFeeRateUpdated(rate?: null): AdminFeeRateUpdatedEventFilter; + + 'AdminFeesWithdrawn(address,uint256)'( + account?: PromiseOrValue | null, + amount?: null, + ): AdminFeesWithdrawnEventFilter; + AdminFeesWithdrawn(account?: PromiseOrValue | null, amount?: null): AdminFeesWithdrawnEventFilter; + + 'CollateralLiquidated(bytes32,uint256,uint256)'( + loanReceiptHash?: PromiseOrValue | null, + proceeds?: null, + borrowerProceeds?: null, + ): CollateralLiquidatedEventFilter; + CollateralLiquidated( + loanReceiptHash?: PromiseOrValue | null, + proceeds?: null, + borrowerProceeds?: null, + ): CollateralLiquidatedEventFilter; + + 'Deposited(address,uint128,uint256,uint256)'( + account?: PromiseOrValue | null, + tick?: PromiseOrValue | null, + amount?: null, + shares?: null, + ): DepositedEventFilter; + Deposited( + account?: PromiseOrValue | null, + tick?: PromiseOrValue | null, + amount?: null, + shares?: null, + ): DepositedEventFilter; + + 'LoanLiquidated(bytes32)'(loanReceiptHash?: PromiseOrValue | null): LoanLiquidatedEventFilter; + LoanLiquidated(loanReceiptHash?: PromiseOrValue | null): LoanLiquidatedEventFilter; + + 'LoanOriginated(bytes32,bytes)'( + loanReceiptHash?: PromiseOrValue | null, + loanReceipt?: null, + ): LoanOriginatedEventFilter; + LoanOriginated(loanReceiptHash?: PromiseOrValue | null, loanReceipt?: null): LoanOriginatedEventFilter; + + 'LoanRepaid(bytes32,uint256)'( + loanReceiptHash?: PromiseOrValue | null, + repayment?: null, + ): LoanRepaidEventFilter; + LoanRepaid(loanReceiptHash?: PromiseOrValue | null, repayment?: null): LoanRepaidEventFilter; + + 'Redeemed(address,uint128,uint256)'( + account?: PromiseOrValue | null, + tick?: PromiseOrValue | null, + shares?: null, + ): RedeemedEventFilter; + Redeemed( + account?: PromiseOrValue | null, + tick?: PromiseOrValue | null, + shares?: null, + ): RedeemedEventFilter; + + 'Withdrawn(address,uint128,uint256,uint256)'( + account?: PromiseOrValue | null, + tick?: PromiseOrValue | null, + shares?: null, + amount?: null, + ): WithdrawnEventFilter; + Withdrawn( + account?: PromiseOrValue | null, + tick?: PromiseOrValue | null, + shares?: null, + amount?: null, + ): WithdrawnEventFilter; + }; + + estimateGas: { + BORROWER_SURPLUS_SPLIT_BASIS_POINTS(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_NAME(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_VERSION(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_NAME(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_VERSION(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_NAME(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_VERSION(overrides?: CallOverrides): Promise; + + TICK_LIMIT_SPACING_BASIS_POINTS(overrides?: CallOverrides): Promise; + + admin(overrides?: CallOverrides): Promise; + + adminFeeBalance(overrides?: CallOverrides): Promise; + + adminFeeRate(overrides?: CallOverrides): Promise; + + borrow( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenId: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + collateralLiquidator(overrides?: CallOverrides): Promise; + + collateralToken(overrides?: CallOverrides): Promise; + + collateralWrappers(overrides?: CallOverrides): Promise; + + currencyToken(overrides?: CallOverrides): Promise; + + decodeLoanReceipt(loanReceipt: PromiseOrValue, overrides?: CallOverrides): Promise; + + delegationRegistry(overrides?: CallOverrides): Promise; + + deposit( + tick: PromiseOrValue, + amount: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + deposits( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + durations(overrides?: CallOverrides): Promise; + + liquidate( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + liquidityNode(tick: PromiseOrValue, overrides?: CallOverrides): Promise; + + liquidityNodes( + startTick: PromiseOrValue, + endTick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + loans(receiptHash: PromiseOrValue, overrides?: CallOverrides): Promise; + + multicall( + data: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + onCollateralLiquidated( + encodedLoanReceipt: PromiseOrValue, + proceeds: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + quote( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenIds: PromiseOrValue[], + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + quoteRefinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: CallOverrides, + ): Promise; + + rates(overrides?: CallOverrides): Promise; + + rebalance( + srcTick: PromiseOrValue, + dstTick: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redeem( + tick: PromiseOrValue, + shares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redemptionAvailable( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + refinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + repay( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + setAdminFeeRate( + rate: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + supportsInterface(interfaceId: PromiseOrValue, overrides?: CallOverrides): Promise; + + withdraw( + tick: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + withdrawAdminFees( + recipient: PromiseOrValue, + amount: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + }; + + populateTransaction: { + BORROWER_SURPLUS_SPLIT_BASIS_POINTS(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_NAME(overrides?: CallOverrides): Promise; + + COLLATERAL_FILTER_VERSION(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_NAME(overrides?: CallOverrides): Promise; + + IMPLEMENTATION_VERSION(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_NAME(overrides?: CallOverrides): Promise; + + INTEREST_RATE_MODEL_VERSION(overrides?: CallOverrides): Promise; + + TICK_LIMIT_SPACING_BASIS_POINTS(overrides?: CallOverrides): Promise; + + admin(overrides?: CallOverrides): Promise; + + adminFeeBalance(overrides?: CallOverrides): Promise; + + adminFeeRate(overrides?: CallOverrides): Promise; + + borrow( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenId: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + collateralLiquidator(overrides?: CallOverrides): Promise; + + collateralToken(overrides?: CallOverrides): Promise; + + collateralWrappers(overrides?: CallOverrides): Promise; + + currencyToken(overrides?: CallOverrides): Promise; + + decodeLoanReceipt(loanReceipt: PromiseOrValue, overrides?: CallOverrides): Promise; + + delegationRegistry(overrides?: CallOverrides): Promise; + + deposit( + tick: PromiseOrValue, + amount: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + deposits( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + durations(overrides?: CallOverrides): Promise; + + liquidate( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + liquidityNode(tick: PromiseOrValue, overrides?: CallOverrides): Promise; + + liquidityNodes( + startTick: PromiseOrValue, + endTick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + loans(receiptHash: PromiseOrValue, overrides?: CallOverrides): Promise; + + multicall( + data: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + onCollateralLiquidated( + encodedLoanReceipt: PromiseOrValue, + proceeds: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + quote( + principal: PromiseOrValue, + duration: PromiseOrValue, + collateralToken: PromiseOrValue, + collateralTokenIds: PromiseOrValue[], + ticks: PromiseOrValue[], + options: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + quoteRefinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: CallOverrides, + ): Promise; + + rates(overrides?: CallOverrides): Promise; + + rebalance( + srcTick: PromiseOrValue, + dstTick: PromiseOrValue, + minShares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redeem( + tick: PromiseOrValue, + shares: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + redemptionAvailable( + account: PromiseOrValue, + tick: PromiseOrValue, + overrides?: CallOverrides, + ): Promise; + + refinance( + encodedLoanReceipt: PromiseOrValue, + principal: PromiseOrValue, + duration: PromiseOrValue, + maxRepayment: PromiseOrValue, + ticks: PromiseOrValue[], + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + repay( + encodedLoanReceipt: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + setAdminFeeRate( + rate: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + supportsInterface(interfaceId: PromiseOrValue, overrides?: CallOverrides): Promise; + + withdraw( + tick: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + + withdrawAdminFees( + recipient: PromiseOrValue, + amount: PromiseOrValue, + overrides?: Overrides & { from?: PromiseOrValue }, + ): Promise; + }; +} diff --git a/src/apps/meta-street/contracts/ethers/common.ts b/src/apps/meta-street/contracts/ethers/common.ts new file mode 100644 index 000000000..35f31be99 --- /dev/null +++ b/src/apps/meta-street/contracts/ethers/common.ts @@ -0,0 +1,32 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +import type { Listener } from '@ethersproject/providers'; +import type { Event, EventFilter } from 'ethers'; + +export interface TypedEvent = any, TArgsObject = any> extends Event { + args: TArgsArray & TArgsObject; +} + +export interface TypedEventFilter<_TEvent extends TypedEvent> extends EventFilter {} + +export interface TypedListener { + (...listenerArg: [...__TypechainArgsArray, TEvent]): void; +} + +type __TypechainArgsArray = T extends TypedEvent ? U : never; + +export interface OnEvent { + (eventFilter: TypedEventFilter, listener: TypedListener): TRes; + (eventName: string, listener: Listener): TRes; +} + +export type MinEthersFactory = { + deploy(...a: ARGS[]): Promise; +}; + +export type GetContractTypeFromFactory = F extends MinEthersFactory ? C : never; + +export type GetARGsTypeFromFactory = F extends MinEthersFactory ? Parameters : never; + +export type PromiseOrValue = T | Promise; diff --git a/src/apps/meta-street/contracts/ethers/factories/PoolV2Legacy__factory.ts b/src/apps/meta-street/contracts/ethers/factories/PoolV2Legacy__factory.ts new file mode 100644 index 000000000..d2e6f498e --- /dev/null +++ b/src/apps/meta-street/contracts/ethers/factories/PoolV2Legacy__factory.ts @@ -0,0 +1,1249 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { PoolV2Legacy, PoolV2LegacyInterface } from '../PoolV2Legacy'; + +const _abi = [ + { + inputs: [], + name: 'InactiveLiquidity', + type: 'error', + }, + { + inputs: [], + name: 'InsufficientLiquidity', + type: 'error', + }, + { + inputs: [], + name: 'InsufficientShares', + type: 'error', + }, + { + inputs: [], + name: 'InsufficientTickSpacing', + type: 'error', + }, + { + inputs: [], + name: 'InvalidAddress', + type: 'error', + }, + { + inputs: [], + name: 'InvalidBorrowOptions', + type: 'error', + }, + { + inputs: [], + name: 'InvalidCaller', + type: 'error', + }, + { + inputs: [], + name: 'InvalidLoanReceipt', + type: 'error', + }, + { + inputs: [], + name: 'InvalidReceiptEncoding', + type: 'error', + }, + { + inputs: [], + name: 'InvalidRedemptionStatus', + type: 'error', + }, + { + inputs: [], + name: 'InvalidTick', + type: 'error', + }, + { + inputs: [], + name: 'LoanNotExpired', + type: 'error', + }, + { + inputs: [], + name: 'ParameterOutOfBounds', + type: 'error', + }, + { + inputs: [], + name: 'RepaymentTooHigh', + type: 'error', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'UnsupportedCollateral', + type: 'error', + }, + { + inputs: [], + name: 'UnsupportedLoanDuration', + type: 'error', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'rate', + type: 'uint256', + }, + ], + name: 'AdminFeeRateUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'account', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'AdminFeesWithdrawn', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'loanReceiptHash', + type: 'bytes32', + }, + { + indexed: false, + internalType: 'uint256', + name: 'proceeds', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'borrowerProceeds', + type: 'uint256', + }, + ], + name: 'CollateralLiquidated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'account', + type: 'address', + }, + { + indexed: true, + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'Deposited', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'loanReceiptHash', + type: 'bytes32', + }, + ], + name: 'LoanLiquidated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'loanReceiptHash', + type: 'bytes32', + }, + { + indexed: false, + internalType: 'bytes', + name: 'loanReceipt', + type: 'bytes', + }, + ], + name: 'LoanOriginated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'loanReceiptHash', + type: 'bytes32', + }, + { + indexed: false, + internalType: 'uint256', + name: 'repayment', + type: 'uint256', + }, + ], + name: 'LoanRepaid', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'account', + type: 'address', + }, + { + indexed: true, + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'Redeemed', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'account', + type: 'address', + }, + { + indexed: true, + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'Withdrawn', + type: 'event', + }, + { + inputs: [], + name: 'BORROWER_SURPLUS_SPLIT_BASIS_POINTS', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'COLLATERAL_FILTER_NAME', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'COLLATERAL_FILTER_VERSION', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'IMPLEMENTATION_NAME', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [], + name: 'IMPLEMENTATION_VERSION', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [], + name: 'INTEREST_RATE_MODEL_NAME', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'INTEREST_RATE_MODEL_VERSION', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'TICK_LIMIT_SPACING_BASIS_POINTS', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'admin', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'adminFeeBalance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'adminFeeRate', + outputs: [ + { + internalType: 'uint32', + name: '', + type: 'uint32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'principal', + type: 'uint256', + }, + { + internalType: 'uint64', + name: 'duration', + type: 'uint64', + }, + { + internalType: 'address', + name: 'collateralToken', + type: 'address', + }, + { + internalType: 'uint256', + name: 'collateralTokenId', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'maxRepayment', + type: 'uint256', + }, + { + internalType: 'uint128[]', + name: 'ticks', + type: 'uint128[]', + }, + { + internalType: 'bytes', + name: 'options', + type: 'bytes', + }, + ], + name: 'borrow', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'collateralLiquidator', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'collateralToken', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'collateralWrappers', + outputs: [ + { + internalType: 'address[]', + name: '', + type: 'address[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'currencyToken', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'loanReceipt', + type: 'bytes', + }, + ], + name: 'decodeLoanReceipt', + outputs: [ + { + components: [ + { + internalType: 'uint8', + name: 'version', + type: 'uint8', + }, + { + internalType: 'uint256', + name: 'principal', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'repayment', + type: 'uint256', + }, + { + internalType: 'address', + name: 'borrower', + type: 'address', + }, + { + internalType: 'uint64', + name: 'maturity', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'duration', + type: 'uint64', + }, + { + internalType: 'address', + name: 'collateralToken', + type: 'address', + }, + { + internalType: 'uint256', + name: 'collateralTokenId', + type: 'uint256', + }, + { + internalType: 'uint16', + name: 'collateralWrapperContextLen', + type: 'uint16', + }, + { + internalType: 'bytes', + name: 'collateralWrapperContext', + type: 'bytes', + }, + { + components: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'used', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'pending', + type: 'uint128', + }, + ], + internalType: 'struct LoanReceipt.NodeReceipt[]', + name: 'nodeReceipts', + type: 'tuple[]', + }, + ], + internalType: 'struct LoanReceipt.LoanReceiptV1', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [], + name: 'delegationRegistry', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'minShares', + type: 'uint256', + }, + ], + name: 'deposit', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + ], + name: 'deposits', + outputs: [ + { + components: [ + { + internalType: 'uint128', + name: 'shares', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'redemptionPending', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'redemptionIndex', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'redemptionTarget', + type: 'uint128', + }, + ], + internalType: 'struct Pool.Deposit', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'durations', + outputs: [ + { + internalType: 'uint64[]', + name: '', + type: 'uint64[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'encodedLoanReceipt', + type: 'bytes', + }, + ], + name: 'liquidate', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + ], + name: 'liquidityNode', + outputs: [ + { + components: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'value', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'shares', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'available', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'pending', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'redemptions', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'prev', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'next', + type: 'uint128', + }, + ], + internalType: 'struct ILiquidity.NodeInfo', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: 'startTick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'endTick', + type: 'uint128', + }, + ], + name: 'liquidityNodes', + outputs: [ + { + components: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'value', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'shares', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'available', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'pending', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'redemptions', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'prev', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'next', + type: 'uint128', + }, + ], + internalType: 'struct ILiquidity.NodeInfo[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes32', + name: 'receiptHash', + type: 'bytes32', + }, + ], + name: 'loans', + outputs: [ + { + internalType: 'enum Pool.LoanStatus', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes[]', + name: 'data', + type: 'bytes[]', + }, + ], + name: 'multicall', + outputs: [ + { + internalType: 'bytes[]', + name: 'results', + type: 'bytes[]', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'encodedLoanReceipt', + type: 'bytes', + }, + { + internalType: 'uint256', + name: 'proceeds', + type: 'uint256', + }, + ], + name: 'onCollateralLiquidated', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'principal', + type: 'uint256', + }, + { + internalType: 'uint64', + name: 'duration', + type: 'uint64', + }, + { + internalType: 'address', + name: 'collateralToken', + type: 'address', + }, + { + internalType: 'uint256[]', + name: 'collateralTokenIds', + type: 'uint256[]', + }, + { + internalType: 'uint128[]', + name: 'ticks', + type: 'uint128[]', + }, + { + internalType: 'bytes', + name: 'options', + type: 'bytes', + }, + ], + name: 'quote', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'encodedLoanReceipt', + type: 'bytes', + }, + { + internalType: 'uint256', + name: 'principal', + type: 'uint256', + }, + { + internalType: 'uint64', + name: 'duration', + type: 'uint64', + }, + { + internalType: 'uint128[]', + name: 'ticks', + type: 'uint128[]', + }, + ], + name: 'quoteRefinance', + outputs: [ + { + internalType: 'int256', + name: '', + type: 'int256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'rates', + outputs: [ + { + internalType: 'uint64[]', + name: '', + type: 'uint64[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: 'srcTick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'dstTick', + type: 'uint128', + }, + { + internalType: 'uint256', + name: 'minShares', + type: 'uint256', + }, + ], + name: 'rebalance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'redeem', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + ], + name: 'redemptionAvailable', + outputs: [ + { + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'encodedLoanReceipt', + type: 'bytes', + }, + { + internalType: 'uint256', + name: 'principal', + type: 'uint256', + }, + { + internalType: 'uint64', + name: 'duration', + type: 'uint64', + }, + { + internalType: 'uint256', + name: 'maxRepayment', + type: 'uint256', + }, + { + internalType: 'uint128[]', + name: 'ticks', + type: 'uint128[]', + }, + ], + name: 'refinance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'encodedLoanReceipt', + type: 'bytes', + }, + ], + name: 'repay', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint32', + name: 'rate', + type: 'uint32', + }, + ], + name: 'setAdminFeeRate', + 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: 'uint128', + name: 'tick', + type: 'uint128', + }, + ], + name: 'withdraw', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'withdrawAdminFees', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +]; + +export class PoolV2Legacy__factory { + static readonly abi = _abi; + static createInterface(): PoolV2LegacyInterface { + return new utils.Interface(_abi) as PoolV2LegacyInterface; + } + static connect(address: string, signerOrProvider: Signer | Provider): PoolV2Legacy { + return new Contract(address, _abi, signerOrProvider) as PoolV2Legacy; + } +} diff --git a/src/apps/meta-street/contracts/ethers/factories/PoolV2__factory.ts b/src/apps/meta-street/contracts/ethers/factories/PoolV2__factory.ts new file mode 100644 index 000000000..0e95cf1f1 --- /dev/null +++ b/src/apps/meta-street/contracts/ethers/factories/PoolV2__factory.ts @@ -0,0 +1,1431 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ + +import { Contract, Signer, utils } from 'ethers'; +import type { Provider } from '@ethersproject/providers'; +import type { PoolV2, PoolV2Interface, WeightedInterestRateModel } from '../PoolV2'; + +const _abi = [ + { + inputs: [ + { + internalType: 'address', + name: 'collateralLiquidator', + type: 'address', + }, + { + internalType: 'address', + name: 'delegationRegistry', + type: 'address', + }, + { + internalType: 'address[]', + name: 'collateralWrappers', + type: 'address[]', + }, + { + components: [ + { + internalType: 'uint64', + name: 'tickThreshold', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'tickExponential', + type: 'uint64', + }, + ], + internalType: 'struct WeightedInterestRateModel.Parameters', + name: 'parameters', + type: 'tuple', + }, + ], + stateMutability: 'nonpayable', + type: 'constructor', + }, + { + inputs: [], + name: 'InactiveLiquidity', + type: 'error', + }, + { + inputs: [], + name: 'InsufficientLiquidity', + type: 'error', + }, + { + inputs: [], + name: 'InsufficientShares', + type: 'error', + }, + { + inputs: [], + name: 'InsufficientTickSpacing', + type: 'error', + }, + { + inputs: [], + name: 'InsufficientUtilization', + type: 'error', + }, + { + inputs: [], + name: 'InvalidBorrowOptions', + type: 'error', + }, + { + inputs: [], + name: 'InvalidCaller', + type: 'error', + }, + { + inputs: [], + name: 'InvalidCollateralFilterParameters', + type: 'error', + }, + { + inputs: [], + name: 'InvalidInterestRateModelParameters', + type: 'error', + }, + { + inputs: [], + name: 'InvalidLoanReceipt', + type: 'error', + }, + { + inputs: [], + name: 'InvalidParameters', + type: 'error', + }, + { + inputs: [], + name: 'InvalidReceiptEncoding', + type: 'error', + }, + { + inputs: [], + name: 'InvalidRedemptionStatus', + type: 'error', + }, + { + inputs: [], + name: 'InvalidTick', + type: 'error', + }, + { + inputs: [], + name: 'LoanNotExpired', + type: 'error', + }, + { + inputs: [], + name: 'RepaymentTooHigh', + type: 'error', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'index', + type: 'uint256', + }, + ], + name: 'UnsupportedCollateral', + type: 'error', + }, + { + inputs: [], + name: 'UnsupportedLoanDuration', + type: 'error', + }, + { + anonymous: false, + inputs: [ + { + indexed: false, + internalType: 'uint256', + name: 'rate', + type: 'uint256', + }, + ], + name: 'AdminFeeRateUpdated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'account', + type: 'address', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'AdminFeesWithdrawn', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'loanReceiptHash', + type: 'bytes32', + }, + { + indexed: false, + internalType: 'uint256', + name: 'proceeds', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'borrowerProceeds', + type: 'uint256', + }, + ], + name: 'CollateralLiquidated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'account', + type: 'address', + }, + { + indexed: true, + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'Deposited', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'loanReceiptHash', + type: 'bytes32', + }, + ], + name: 'LoanLiquidated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'loanReceiptHash', + type: 'bytes32', + }, + { + indexed: false, + internalType: 'bytes', + name: 'loanReceipt', + type: 'bytes', + }, + ], + name: 'LoanOriginated', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'bytes32', + name: 'loanReceiptHash', + type: 'bytes32', + }, + { + indexed: false, + internalType: 'uint256', + name: 'repayment', + type: 'uint256', + }, + ], + name: 'LoanRepaid', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'account', + type: 'address', + }, + { + indexed: true, + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + indexed: true, + internalType: 'uint128', + name: 'redemptionId', + type: 'uint128', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'Redeemed', + type: 'event', + }, + { + anonymous: false, + inputs: [ + { + indexed: true, + internalType: 'address', + name: 'account', + type: 'address', + }, + { + indexed: true, + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + indexed: true, + internalType: 'uint128', + name: 'redemptionId', + type: 'uint128', + }, + { + indexed: false, + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + { + indexed: false, + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'Withdrawn', + type: 'event', + }, + { + inputs: [], + name: 'BORROWER_SURPLUS_SPLIT_BASIS_POINTS', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'COLLATERAL_FILTER_NAME', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [], + name: 'COLLATERAL_FILTER_VERSION', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [], + name: 'IMPLEMENTATION_NAME', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [], + name: 'IMPLEMENTATION_VERSION', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [], + name: 'INTEREST_RATE_MODEL_NAME', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [], + name: 'INTEREST_RATE_MODEL_VERSION', + outputs: [ + { + internalType: 'string', + name: '', + type: 'string', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [], + name: 'TICK_LIMIT_SPACING_BASIS_POINTS', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'admin', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'adminFeeBalance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'adminFeeRate', + outputs: [ + { + internalType: 'uint32', + name: '', + type: 'uint32', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'principal', + type: 'uint256', + }, + { + internalType: 'uint64', + name: 'duration', + type: 'uint64', + }, + { + internalType: 'address', + name: 'collateralToken', + type: 'address', + }, + { + internalType: 'uint256', + name: 'collateralTokenId', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'maxRepayment', + type: 'uint256', + }, + { + internalType: 'uint128[]', + name: 'ticks', + type: 'uint128[]', + }, + { + internalType: 'bytes', + name: 'options', + type: 'bytes', + }, + ], + name: 'borrow', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [], + name: 'collateralLiquidator', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'collateralToken', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'collateralWrappers', + outputs: [ + { + internalType: 'address[]', + name: '', + type: 'address[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'currencyToken', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'loanReceipt', + type: 'bytes', + }, + ], + name: 'decodeLoanReceipt', + outputs: [ + { + components: [ + { + internalType: 'uint8', + name: 'version', + type: 'uint8', + }, + { + internalType: 'uint256', + name: 'principal', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'repayment', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'adminFee', + type: 'uint256', + }, + { + internalType: 'address', + name: 'borrower', + type: 'address', + }, + { + internalType: 'uint64', + name: 'maturity', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'duration', + type: 'uint64', + }, + { + internalType: 'address', + name: 'collateralToken', + type: 'address', + }, + { + internalType: 'uint256', + name: 'collateralTokenId', + type: 'uint256', + }, + { + internalType: 'uint16', + name: 'collateralWrapperContextLen', + type: 'uint16', + }, + { + internalType: 'bytes', + name: 'collateralWrapperContext', + type: 'bytes', + }, + { + components: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'used', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'pending', + type: 'uint128', + }, + ], + internalType: 'struct LoanReceipt.NodeReceipt[]', + name: 'nodeReceipts', + type: 'tuple[]', + }, + ], + internalType: 'struct LoanReceipt.LoanReceiptV2', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'pure', + type: 'function', + }, + { + inputs: [], + name: 'delegationRegistry', + outputs: [ + { + internalType: 'address', + name: '', + type: 'address', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'minShares', + type: 'uint256', + }, + ], + name: 'deposit', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + ], + name: 'deposits', + outputs: [ + { + internalType: 'uint128', + name: 'shares', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'redemptionId', + type: 'uint128', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'durations', + outputs: [ + { + internalType: 'uint64[]', + name: '', + type: 'uint64[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'params', + type: 'bytes', + }, + ], + name: 'initialize', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'encodedLoanReceipt', + type: 'bytes', + }, + ], + name: 'liquidate', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + ], + name: 'liquidityNode', + outputs: [ + { + components: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'value', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'shares', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'available', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'pending', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'redemptions', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'prev', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'next', + type: 'uint128', + }, + ], + internalType: 'struct ILiquidity.NodeInfo', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + ], + name: 'liquidityNodeWithAccrual', + outputs: [ + { + components: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'value', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'shares', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'available', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'pending', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'redemptions', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'prev', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'next', + type: 'uint128', + }, + ], + internalType: 'struct ILiquidity.NodeInfo', + name: '', + type: 'tuple', + }, + { + components: [ + { + internalType: 'uint128', + name: 'accrued', + type: 'uint128', + }, + { + internalType: 'uint64', + name: 'rate', + type: 'uint64', + }, + { + internalType: 'uint64', + name: 'timestamp', + type: 'uint64', + }, + ], + internalType: 'struct ILiquidity.AccrualInfo', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: 'startTick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'endTick', + type: 'uint128', + }, + ], + name: 'liquidityNodes', + outputs: [ + { + components: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'value', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'shares', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'available', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'pending', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'redemptions', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'prev', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'next', + type: 'uint128', + }, + ], + internalType: 'struct ILiquidity.NodeInfo[]', + name: '', + type: 'tuple[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes32', + name: 'receiptHash', + type: 'bytes32', + }, + ], + name: 'loans', + outputs: [ + { + internalType: 'enum Pool.LoanStatus', + name: '', + type: 'uint8', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes[]', + name: 'data', + type: 'bytes[]', + }, + ], + name: 'multicall', + outputs: [ + { + internalType: 'bytes[]', + name: 'results', + type: 'bytes[]', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'encodedLoanReceipt', + type: 'bytes', + }, + { + internalType: 'uint256', + name: 'proceeds', + type: 'uint256', + }, + ], + name: 'onCollateralLiquidated', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint256', + name: 'principal', + type: 'uint256', + }, + { + internalType: 'uint64', + name: 'duration', + type: 'uint64', + }, + { + internalType: 'address', + name: 'collateralToken', + type: 'address', + }, + { + internalType: 'uint256[]', + name: 'collateralTokenIds', + type: 'uint256[]', + }, + { + internalType: 'uint256', + name: 'collateralTokenCount', + type: 'uint256', + }, + { + internalType: 'uint128[]', + name: 'ticks', + type: 'uint128[]', + }, + { + internalType: 'bytes', + name: 'options', + type: 'bytes', + }, + ], + name: 'quote', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [], + name: 'rates', + outputs: [ + { + internalType: 'uint64[]', + name: '', + type: 'uint64[]', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: 'srcTick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'dstTick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'redemptionId', + type: 'uint128', + }, + { + internalType: 'uint256', + name: 'minShares', + type: 'uint256', + }, + ], + name: 'rebalance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + ], + name: 'redeem', + outputs: [ + { + internalType: 'uint128', + name: '', + type: 'uint128', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'redemptionId', + type: 'uint128', + }, + ], + name: 'redemptionAvailable', + outputs: [ + { + internalType: 'uint256', + name: 'shares', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + { + internalType: 'uint256', + name: 'sharesAhead', + type: 'uint256', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'account', + type: 'address', + }, + { + internalType: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'redemptionId', + type: 'uint128', + }, + ], + name: 'redemptions', + outputs: [ + { + components: [ + { + internalType: 'uint128', + name: 'pending', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'index', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'target', + type: 'uint128', + }, + ], + internalType: 'struct Pool.Redemption', + name: '', + type: 'tuple', + }, + ], + stateMutability: 'view', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'encodedLoanReceipt', + type: 'bytes', + }, + { + internalType: 'uint256', + name: 'principal', + type: 'uint256', + }, + { + internalType: 'uint64', + name: 'duration', + type: 'uint64', + }, + { + internalType: 'uint256', + name: 'maxRepayment', + type: 'uint256', + }, + { + internalType: 'uint128[]', + name: 'ticks', + type: 'uint128[]', + }, + ], + name: 'refinance', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'bytes', + name: 'encodedLoanReceipt', + type: 'bytes', + }, + ], + name: 'repay', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'uint32', + name: 'rate', + type: 'uint32', + }, + ], + name: 'setAdminFeeRate', + 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: 'uint128', + name: 'tick', + type: 'uint128', + }, + { + internalType: 'uint128', + name: 'redemptionId', + type: 'uint128', + }, + ], + name: 'withdraw', + outputs: [ + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + { + internalType: 'uint256', + name: '', + type: 'uint256', + }, + ], + stateMutability: 'nonpayable', + type: 'function', + }, + { + inputs: [ + { + internalType: 'address', + name: 'recipient', + type: 'address', + }, + { + internalType: 'uint256', + name: 'amount', + type: 'uint256', + }, + ], + name: 'withdrawAdminFees', + outputs: [], + stateMutability: 'nonpayable', + type: 'function', + }, +]; + +export class PoolV2__factory { + static readonly abi = _abi; + static createInterface(): PoolV2Interface { + return new utils.Interface(_abi) as PoolV2Interface; + } + static connect(address: string, signerOrProvider: Signer | Provider): PoolV2 { + return new Contract(address, _abi, signerOrProvider) as PoolV2; + } +} diff --git a/src/apps/meta-street/contracts/ethers/factories/index.ts b/src/apps/meta-street/contracts/ethers/factories/index.ts new file mode 100644 index 000000000..1989c4a18 --- /dev/null +++ b/src/apps/meta-street/contracts/ethers/factories/index.ts @@ -0,0 +1,5 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export { PoolV2__factory } from './PoolV2__factory'; +export { PoolV2Legacy__factory } from './PoolV2Legacy__factory'; diff --git a/src/apps/meta-street/contracts/ethers/index.ts b/src/apps/meta-street/contracts/ethers/index.ts new file mode 100644 index 000000000..78a3b61a2 --- /dev/null +++ b/src/apps/meta-street/contracts/ethers/index.ts @@ -0,0 +1,8 @@ +/* Autogenerated file. Do not edit manually. */ +/* tslint:disable */ +/* eslint-disable */ +export type { PoolV2 } from './PoolV2'; +export type { PoolV2Legacy } from './PoolV2Legacy'; +export * as factories from './factories'; +export { PoolV2Legacy__factory } from './factories/PoolV2Legacy__factory'; +export { PoolV2__factory } from './factories/PoolV2__factory'; diff --git a/src/apps/meta-street/contracts/index.ts b/src/apps/meta-street/contracts/index.ts new file mode 100644 index 000000000..945b63061 --- /dev/null +++ b/src/apps/meta-street/contracts/index.ts @@ -0,0 +1,27 @@ +import { Injectable, Inject } from '@nestjs/common'; + +import { IAppToolkit, APP_TOOLKIT } from '~app-toolkit/app-toolkit.interface'; +import { ContractFactory } from '~contract/contracts'; +import { Network } from '~types/network.interface'; + +import { PoolV2__factory, PoolV2Legacy__factory } from './ethers'; + +// eslint-disable-next-line +type ContractOpts = { address: string; network: Network }; + +@Injectable() +export class MetaStreetContractFactory extends ContractFactory { + constructor(@Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit) { + super((network: Network) => appToolkit.getNetworkProvider(network)); + } + + poolV2({ address, network }: ContractOpts) { + return PoolV2__factory.connect(address, this.appToolkit.getNetworkProvider(network)); + } + poolV2Legacy({ address, network }: ContractOpts) { + return PoolV2Legacy__factory.connect(address, this.appToolkit.getNetworkProvider(network)); + } +} + +export type { PoolV2 } from './ethers'; +export type { PoolV2Legacy } from './ethers'; diff --git a/src/apps/meta-street/ethereum/meta-street.lending-v2-legacy.contract-position-fetcher.ts b/src/apps/meta-street/ethereum/meta-street.lending-v2-legacy.contract-position-fetcher.ts new file mode 100644 index 000000000..279f40fb0 --- /dev/null +++ b/src/apps/meta-street/ethereum/meta-street.lending-v2-legacy.contract-position-fetcher.ts @@ -0,0 +1,233 @@ +import { Inject } from '@nestjs/common'; +import { BigNumberish, BigNumber, constants } from 'ethers'; +import { gql } from 'graphql-request'; + +import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; +import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; +import { gqlFetch } from '~app-toolkit/helpers/the-graph.helper'; + +import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher'; +import { + GetDefinitionsParams, + GetTokenDefinitionsParams, + UnderlyingTokenDefinition, + GetDisplayPropsParams, + GetTokenBalancesParams, + GetDataPropsParams, +} from '~position/template/contract-position.template.types'; +import { MetaType } from '~position/position.interface'; + +import { MetaStreetContractFactory, PoolV2Legacy } from '../contracts'; + +export const GET_POOLS_QUERY = gql` + { + pools(where: { implementationVersionMajor: "1" }) { + id + ticks { + id + limit + duration + rate + raw + } + currencyToken { + symbol + } + collateralToken { + name + } + } + } +`; + +export type GetPoolsResponse = { + pools: { + id: string; + ticks: { + id: string; + limit: BigNumber; + duration: BigNumber; + rate: BigNumber; + raw: BigNumber; + }[]; + currencyToken: string; + collateralToken: string; + }[]; +}; + +export const SUBGRAPH_URL = 'https://api.thegraph.com/subgraphs/name/metastreet-labs/metastreet-v2-beta'; + +/* Block number of the creation of pool factory */ +export const START_BLOCK_NUMBER = 17497132; + +export type ContractPositionDefinition = { + address: string; + tickId: string; + tick: BigNumber; + limit: BigNumber; + duration: BigNumber; + rate: BigNumber; + currencyTokenSymbol: string; + collateralTokenName: string; +}; + +export type DataProps = { + positionKey: string; + tick: BigNumber; // encoded tick +}; + +export type Deposited = { + amount: BigNumber; + shares: BigNumber; +}; + +export type Withdrawn = { + amount: BigNumber; + shares: BigNumber; +}; + +export type Redemption = { + amount: BigNumber; + shares: BigNumber; +}; + +@PositionTemplate() +export class EthereumMetaStreetLendingV2LegacyContractPositionFetcher extends ContractPositionTemplatePositionFetcher { + groupLabel: string = 'Lending V2 Legacy'; + + constructor( + @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, + @Inject(MetaStreetContractFactory) protected readonly MetaStreetContractFactory: MetaStreetContractFactory, + ) { + super(appToolkit); + } + + getContract(_address: string): PoolV2Legacy { + return this.MetaStreetContractFactory.poolV2Legacy({ address: _address, network: this.network }); + } + + async getDefinitions(_params: GetDefinitionsParams): Promise { + const data = await gqlFetch({ + endpoint: SUBGRAPH_URL, + query: GET_POOLS_QUERY, + }); + + return data.pools.flatMap(p => { + return p.ticks.map(t => ({ + address: p.id, + tickId: t.id, + tick: t.raw, + limit: t.limit, + duration: t.duration, + rate: t.rate, + currencyTokenSymbol: p.currencyToken['symbol'], + collateralTokenName: p.collateralToken['name'], + })); + }); + } + + async getTokenDefinitions( + _params: GetTokenDefinitionsParams, + ): Promise { + const currencyTokenAddress: string = await _params.contract.currencyToken(); + return [ + { + metaType: MetaType.SUPPLIED, + address: currencyTokenAddress, + network: this.network, + }, + { + metaType: MetaType.CLAIMABLE, + address: currencyTokenAddress, + network: this.network, + }, + ]; + } + + async getDataProps( + _params: GetDataPropsParams, + ): Promise { + return { + positionKey: _params.definition.tickId, + tick: _params.definition.tick, + }; + } + + async getLabel(_params: GetDisplayPropsParams): Promise { + const collateralTokenName: string = _params.definition.collateralTokenName; // e.g. Wrapped Cryptopunks + const currencyTokenSymbol: string = _params.definition.currencyTokenSymbol; // e.g. WETH + const duration: string = BigNumber.from(_params.definition.duration).lt(86400) + ? '0' + : BigNumber.from(_params.definition.duration).div(86400).mask(17).toString(); // round to closest days + const limit: number = BigNumber.from(_params.definition.limit).lt(1e15) + ? 0 + : BigNumber.from(_params.definition.limit).div(1e15).toNumber() / 1000; + const apr: BigNumber = BigNumber.from(_params.definition.rate).mul(365 * 86400); + const rate: number = Math.round(apr.lt(1e15) ? 0 : apr.div(1e15).toNumber() / 10); + const labelPrefix = + collateralTokenName && currencyTokenSymbol ? `${collateralTokenName} / ${currencyTokenSymbol} - ` : ''; + + // e.g. "Wrapped Cryptopunks / DAI - 30 Day, 10%, 630000 DAI" + return `${labelPrefix}${duration} Day, ${rate}%, ${limit} ${currencyTokenSymbol}`; + } + + async getTokenBalancesPerPosition({ + contract, + contractPosition, + address, + }: GetTokenBalancesParams): Promise { + const tick: BigNumber = contractPosition.dataProps.tick; + + /* Get account's deposit logs and compute deposited amount and received shares */ + const depositLogs = await contract.queryFilter(contract.filters.Deposited(address, tick), START_BLOCK_NUMBER); + const deposited: Deposited = depositLogs.reduce( + (deposited: Deposited, l) => { + if (l.args.tick.eq(tick) && l.args.account.toLowerCase() === address) { + return { amount: deposited.amount.add(l.args.amount), shares: deposited.shares.add(l.args.shares) }; + } else { + return deposited; + } + }, + { amount: constants.Zero, shares: constants.Zero }, + ); + + /* Get account's withdrawal logs and compute withdrawn amount and burned shares */ + let firstDepositBlockNumber: number = depositLogs.length > 0 ? depositLogs[0].blockNumber : START_BLOCK_NUMBER; + const withdrawLogs = await contract.queryFilter(contract.filters.Withdrawn(address, tick), firstDepositBlockNumber); + const withdrawn: Withdrawn = withdrawLogs.reduce( + (withdrawn: Withdrawn, l) => { + if (l.args.tick.eq(tick) && l.args.account.toLowerCase() === address) { + return { amount: withdrawn.amount.add(l.args.amount), shares: withdrawn.shares.add(l.args.shares) }; + } else { + return withdrawn; + } + }, + { amount: constants.Zero, shares: constants.Zero }, + ); + + /* Get redemption available */ + const redemptionAvailable = await contract.redemptionAvailable(address, tick); + + /* Compute active shares in tick */ + const activeShares = deposited.shares.sub(redemptionAvailable.shares).sub(withdrawn.shares); + + /* Compute current position balance from tick data in addition to redeemed amount available */ + const tickData = await contract.liquidityNode(tick); + const currentPosition = tickData.shares.eq(constants.Zero) + ? redemptionAvailable.amount + : activeShares.mul(tickData.value).div(tickData.shares).add(redemptionAvailable.amount); + + /* Compute deposit position (deposit shares * depositor's avg share price - withdrawn amount) */ + const depositPosition = deposited.shares.eq(constants.Zero) + ? constants.Zero + : deposited.shares.mul(deposited.amount).div(deposited.shares).sub(withdrawn.amount); + + /* Compute supplied and claimable balances */ + const suppliedBalance = depositPosition.gt(currentPosition) ? currentPosition : depositPosition; + const claimableBalance = depositPosition.gt(currentPosition) + ? constants.Zero + : currentPosition.sub(depositPosition); + + return [suppliedBalance, claimableBalance]; + } +} diff --git a/src/apps/meta-street/ethereum/meta-street.lending-v2.contract-position-fetcher.ts b/src/apps/meta-street/ethereum/meta-street.lending-v2.contract-position-fetcher.ts new file mode 100644 index 000000000..2aec412d0 --- /dev/null +++ b/src/apps/meta-street/ethereum/meta-street.lending-v2.contract-position-fetcher.ts @@ -0,0 +1,246 @@ +import { Inject } from '@nestjs/common'; +import { BigNumberish, BigNumber, constants } from 'ethers'; +import { gql } from 'graphql-request'; + +import { APP_TOOLKIT, IAppToolkit } from '~app-toolkit/app-toolkit.interface'; +import { PositionTemplate } from '~app-toolkit/decorators/position-template.decorator'; +import { gqlFetch } from '~app-toolkit/helpers/the-graph.helper'; + +import { ContractPositionTemplatePositionFetcher } from '~position/template/contract-position.template.position-fetcher'; +import { + GetDefinitionsParams, + GetTokenDefinitionsParams, + UnderlyingTokenDefinition, + GetDisplayPropsParams, + GetTokenBalancesParams, + GetDataPropsParams, +} from '~position/template/contract-position.template.types'; +import { MetaType } from '~position/position.interface'; + +import { MetaStreetContractFactory, PoolV2 } from '../contracts'; + +export const GET_POOLS_QUERY = gql` + { + pools(where: { implementationVersionMajor_not: "1" }) { + id + ticks { + id + limit + duration + rate + raw + } + currencyToken { + symbol + } + collateralToken { + name + } + } + } +`; + +export type GetPoolsResponse = { + pools: { + id: string; + ticks: { + id: string; + limit: BigNumber; + duration: BigNumber; + rate: BigNumber; + raw: BigNumber; + }[]; + currencyToken: string; + collateralToken: string; + }[]; +}; + +export const SUBGRAPH_URL = 'https://api.thegraph.com/subgraphs/name/metastreet-labs/metastreet-v2-beta'; + +/* Block number of the creation of pool factory */ +export const START_BLOCK_NUMBER = 17497132; + +export type ContractPositionDefinition = { + address: string; + tickId: string; + tick: BigNumber; + limit: BigNumber; + duration: BigNumber; + rate: BigNumber; + currencyTokenSymbol: string; + collateralTokenName: string; +}; + +export type DataProps = { + positionKey: string; + tick: BigNumber; // encoded tick +}; + +export type Deposited = { + amount: BigNumber; + shares: BigNumber; +}; + +export type Withdrawn = { + amount: BigNumber; + shares: BigNumber; +}; + +export type Redemption = { + amount: BigNumber; + shares: BigNumber; +}; + +@PositionTemplate() +export class EthereumMetaStreetLendingV2ContractPositionFetcher extends ContractPositionTemplatePositionFetcher { + groupLabel: string = 'Lending V2'; + + constructor( + @Inject(APP_TOOLKIT) protected readonly appToolkit: IAppToolkit, + @Inject(MetaStreetContractFactory) protected readonly MetaStreetContractFactory: MetaStreetContractFactory, + ) { + super(appToolkit); + } + + getContract(_address: string): PoolV2 { + return this.MetaStreetContractFactory.poolV2({ address: _address, network: this.network }); + } + + async getDefinitions(_params: GetDefinitionsParams): Promise { + const data = await gqlFetch({ + endpoint: SUBGRAPH_URL, + query: GET_POOLS_QUERY, + }); + + return data.pools.flatMap(p => { + return p.ticks.map(t => ({ + address: p.id, + tickId: t.id, + tick: t.raw, + limit: t.limit, + duration: t.duration, + rate: t.rate, + currencyTokenSymbol: p.currencyToken['symbol'], + collateralTokenName: p.collateralToken['name'], + })); + }); + } + + async getTokenDefinitions( + _params: GetTokenDefinitionsParams, + ): Promise { + const currencyTokenAddress: string = await _params.contract.currencyToken(); + return [ + { + metaType: MetaType.SUPPLIED, + address: currencyTokenAddress, + network: this.network, + }, + { + metaType: MetaType.CLAIMABLE, + address: currencyTokenAddress, + network: this.network, + }, + ]; + } + + async getDataProps(_params: GetDataPropsParams): Promise { + return { + positionKey: _params.definition.tickId, + tick: _params.definition.tick, + }; + } + + async getLabel(_params: GetDisplayPropsParams): Promise { + const collateralTokenName: string = _params.definition.collateralTokenName; // e.g. Wrapped Cryptopunks + const currencyTokenSymbol: string = _params.definition.currencyTokenSymbol; // e.g. WETH + const duration: string = BigNumber.from(_params.definition.duration).lt(86400) + ? '0' + : BigNumber.from(_params.definition.duration).div(86400).mask(17).toString(); // round to closest days + const limit: number = BigNumber.from(_params.definition.limit).lt(1e15) + ? 0 + : BigNumber.from(_params.definition.limit).div(1e15).toNumber() / 1000; + const apr: BigNumber = BigNumber.from(_params.definition.rate).mul(365 * 86400); + const rate: number = Math.round(apr.lt(1e15) ? 0 : apr.div(1e15).toNumber() / 10); + const labelPrefix = + collateralTokenName && currencyTokenSymbol ? `${collateralTokenName} / ${currencyTokenSymbol} - ` : ''; + + // e.g. "Wrapped Cryptopunks / DAI - 30 Day, 10%, 630000 DAI" + return `${labelPrefix}${duration} Day, ${rate}%, ${limit} ${currencyTokenSymbol}`; + } + + async getTokenBalancesPerPosition({ + contract, + contractPosition, + address, + multicall, + }: GetTokenBalancesParams): Promise { + const tick: BigNumber = contractPosition.dataProps.tick; + + /* Get account's deposit logs and compute deposited amount and received shares */ + const depositLogs = await contract.queryFilter(contract.filters.Deposited(address, tick), START_BLOCK_NUMBER); + const deposited: Deposited = depositLogs.reduce( + (deposited: Deposited, l) => { + if (l.args.tick.eq(tick) && l.args.account.toLowerCase() === address) { + return { amount: deposited.amount.add(l.args.amount), shares: deposited.shares.add(l.args.shares) }; + } else { + return deposited; + } + }, + { amount: constants.Zero, shares: constants.Zero }, + ); + + /* Get account's withdrawal logs and compute withdrawn amount and burned shares */ + let firstDepositBlockNumber: number = depositLogs.length > 0 ? depositLogs[0].blockNumber : START_BLOCK_NUMBER; + const withdrawLogs = await contract.queryFilter(contract.filters.Withdrawn(address, tick), firstDepositBlockNumber); + const withdrawn: Withdrawn = withdrawLogs.reduce( + (withdrawn: Withdrawn, l) => { + if (l.args.tick.eq(tick) && l.args.account.toLowerCase() === address) { + return { amount: withdrawn.amount.add(l.args.amount), shares: withdrawn.shares.add(l.args.shares) }; + } else { + return withdrawn; + } + }, + { amount: constants.Zero, shares: constants.Zero }, + ); + + /* Get redemption ID from account's deposit */ + const deposit = await contract.deposits(address, tick); + + /* Multicall redemption available and compute total amount and shares */ + const redemptionIds = Array.from({ length: deposit.redemptionId.toNumber() }, (_, index) => index + 1); + const pool = multicall.wrap(contract); + const redemptionsAvailable = await Promise.all( + redemptionIds.map(async id => await pool.redemptionAvailable(address, tick, BigNumber.from(id))), + ); + const redeemed: Redemption = redemptionsAvailable.reduce( + (redemptionAvailable, { amount, shares }) => ({ + amount: redemptionAvailable.amount.add(amount), + shares: redemptionAvailable.shares.add(shares), + }), + { amount: constants.Zero, shares: constants.Zero }, + ); + + /* Compute active shares in tick */ + const activeShares = deposited.shares.sub(redeemed.shares).sub(withdrawn.shares); + + /* Compute current position balance from tick data in addition to redeemed amount available */ + const tickData = await contract.liquidityNode(tick); + const currentPosition = tickData.shares.eq(constants.Zero) + ? redeemed.amount + : activeShares.mul(tickData.value).div(tickData.shares).add(redeemed.amount); + + /* Compute deposit position (deposit shares * depositor's avg share price - withdrawn amount) */ + const depositPosition = deposited.shares.eq(constants.Zero) + ? constants.Zero + : deposited.shares.mul(deposited.amount).div(deposited.shares).sub(withdrawn.amount); + + /* Compute supplied and claimable balances */ + const suppliedBalance = depositPosition.gt(currentPosition) ? currentPosition : depositPosition; + const claimableBalance = depositPosition.gt(currentPosition) + ? constants.Zero + : currentPosition.sub(depositPosition); + + return [suppliedBalance, claimableBalance]; + } +} diff --git a/src/apps/meta-street/meta-street.module.ts b/src/apps/meta-street/meta-street.module.ts new file mode 100644 index 000000000..86ed61fb4 --- /dev/null +++ b/src/apps/meta-street/meta-street.module.ts @@ -0,0 +1,16 @@ +import { Module } from '@nestjs/common'; + +import { AbstractApp } from '~app/app.dynamic-module'; + +import { MetaStreetContractFactory } from './contracts'; +import { EthereumMetaStreetLendingV2ContractPositionFetcher } from './ethereum/meta-street.lending-v2.contract-position-fetcher'; +import { EthereumMetaStreetLendingV2LegacyContractPositionFetcher } from './ethereum/meta-street.lending-v2-legacy.contract-position-fetcher'; + +@Module({ + providers: [ + EthereumMetaStreetLendingV2ContractPositionFetcher, + EthereumMetaStreetLendingV2LegacyContractPositionFetcher, + MetaStreetContractFactory, + ], +}) +export class MetaStreetAppModule extends AbstractApp() {}