@wildcatfi/wildcat-sdk 3.0.67-beta → 3.0.69-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/abi/generated.d.ts +34207 -0
- package/dist/abi/generated.d.ts.map +1 -0
- package/dist/abi/generated.js +43811 -0
- package/dist/abi/generated.js.map +1 -0
- package/dist/abi/index.d.ts +3 -0
- package/dist/abi/index.d.ts.map +1 -0
- package/dist/abi/index.js +19 -0
- package/dist/abi/index.js.map +1 -0
- package/dist/abi/manual.d.ts +354 -0
- package/dist/abi/manual.d.ts.map +1 -0
- package/dist/abi/manual.js +202 -0
- package/dist/abi/manual.js.map +1 -0
- package/dist/access/access-control.d.ts +16 -18
- package/dist/access/access-control.d.ts.map +1 -1
- package/dist/access/access-control.js +101 -101
- package/dist/access/access-control.js.map +1 -1
- package/dist/access/fixed-term.d.ts +16 -18
- package/dist/access/fixed-term.d.ts.map +1 -1
- package/dist/access/fixed-term.js +115 -104
- package/dist/access/fixed-term.js.map +1 -1
- package/dist/access/index.d.ts +3 -3
- package/dist/access/index.d.ts.map +1 -1
- package/dist/access/index.js +47 -13
- package/dist/access/index.js.map +1 -1
- package/dist/access/revolving.d.ts +2 -1
- package/dist/access/revolving.d.ts.map +1 -1
- package/dist/access/revolving.js +6 -6
- package/dist/access/revolving.js.map +1 -1
- package/dist/access/utils.d.ts +2 -1
- package/dist/access/utils.d.ts.map +1 -1
- package/dist/access/utils.js +40 -10
- package/dist/access/utils.js.map +1 -1
- package/dist/access/validation.d.ts +7 -6
- package/dist/access/validation.d.ts.map +1 -1
- package/dist/access/validation.js +1 -0
- package/dist/access/validation.js.map +1 -1
- package/dist/account/index.d.ts +21 -30
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +193 -224
- package/dist/account/index.js.map +1 -1
- package/dist/client.d.ts +22 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +51 -0
- package/dist/client.js.map +1 -0
- package/dist/collateral/collateral-events.d.ts +9 -10
- package/dist/collateral/collateral-events.d.ts.map +1 -1
- package/dist/collateral/collateral-events.js +4 -4
- package/dist/collateral/collateral-events.js.map +1 -1
- package/dist/collateral/index.d.ts +7 -10
- package/dist/collateral/index.d.ts.map +1 -1
- package/dist/collateral/index.js +36 -37
- package/dist/collateral/index.js.map +1 -1
- package/dist/constants.d.ts +72 -16
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +137 -23
- package/dist/constants.js.map +1 -1
- package/dist/controller.d.ts +10 -17
- package/dist/controller.d.ts.map +1 -1
- package/dist/controller.js +66 -67
- package/dist/controller.js.map +1 -1
- package/dist/gql/getActiveLendersByMarket.d.ts +2 -3
- package/dist/gql/getActiveLendersByMarket.d.ts.map +1 -1
- package/dist/gql/getActiveLendersByMarket.js +10 -10
- package/dist/gql/getActiveLendersByMarket.js.map +1 -1
- package/dist/gql/getAllHooksDataForBorrower.d.ts.map +1 -1
- package/dist/gql/getAllHooksDataForBorrower.js +6 -3
- package/dist/gql/getAllHooksDataForBorrower.js.map +1 -1
- package/dist/gql/getAllHooksTemplates.d.ts.map +1 -1
- package/dist/gql/getAllHooksTemplates.js +3 -3
- package/dist/gql/getAllHooksTemplates.js.map +1 -1
- package/dist/gql/graphql.d.ts +532 -10
- package/dist/gql/graphql.d.ts.map +1 -1
- package/dist/gql/graphql.js +182 -4
- package/dist/gql/graphql.js.map +1 -1
- package/dist/index.d.ts +2 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -14
- package/dist/index.js.map +1 -1
- package/dist/internal/arch-controller.d.ts +6 -0
- package/dist/internal/arch-controller.d.ts.map +1 -0
- package/dist/internal/arch-controller.js +36 -0
- package/dist/internal/arch-controller.js.map +1 -0
- package/dist/internal/ethers-signer.d.ts +4 -0
- package/dist/internal/ethers-signer.d.ts.map +1 -0
- package/dist/internal/ethers-signer.js +12 -0
- package/dist/internal/ethers-signer.js.map +1 -0
- package/dist/internal/ethers-viem.d.ts +4 -0
- package/dist/internal/ethers-viem.d.ts.map +1 -0
- package/dist/internal/ethers-viem.js +43 -0
- package/dist/internal/ethers-viem.js.map +1 -0
- package/dist/internal/market-lens.d.ts +26 -0
- package/dist/internal/market-lens.d.ts.map +1 -0
- package/dist/internal/market-lens.js +117 -0
- package/dist/internal/market-lens.js.map +1 -0
- package/dist/internal/viem-read.d.ts +3 -0
- package/dist/internal/viem-read.d.ts.map +1 -0
- package/dist/internal/viem-read.js +13 -0
- package/dist/internal/viem-read.js.map +1 -0
- package/dist/internal/viem-write.d.ts +9 -0
- package/dist/internal/viem-write.d.ts.map +1 -0
- package/dist/internal/viem-write.js +24 -0
- package/dist/internal/viem-write.js.map +1 -0
- package/dist/lens-types.d.ts +283 -0
- package/dist/lens-types.d.ts.map +1 -0
- package/dist/{typechain/ISafe.js → lens-types.js} +1 -1
- package/dist/lens-types.js.map +1 -0
- package/dist/market.d.ts +34 -20
- package/dist/market.d.ts.map +1 -1
- package/dist/market.js +300 -223
- package/dist/market.js.map +1 -1
- package/dist/mockerc20factory.d.ts +4 -15
- package/dist/mockerc20factory.d.ts.map +1 -1
- package/dist/mockerc20factory.js +20 -15
- package/dist/mockerc20factory.js.map +1 -1
- package/dist/token.d.ts +24 -11
- package/dist/token.d.ts.map +1 -1
- package/dist/token.js +78 -61
- package/dist/token.js.map +1 -1
- package/dist/types.d.ts +53 -12
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +6 -15
- package/dist/types.js.map +1 -1
- package/dist/utils/bigint.d.ts +22 -0
- package/dist/utils/bigint.d.ts.map +1 -0
- package/dist/utils/bigint.js +111 -0
- package/dist/utils/bigint.js.map +1 -0
- package/dist/utils/check-registered-borrowers.d.ts.map +1 -1
- package/dist/utils/check-registered-borrowers.js +7 -6
- package/dist/utils/check-registered-borrowers.js.map +1 -1
- package/dist/utils/describe-account.d.ts.map +1 -1
- package/dist/utils/describe-account.js +33 -4
- package/dist/utils/describe-account.js.map +1 -1
- package/dist/utils/describe-signature.d.ts.map +1 -1
- package/dist/utils/describe-signature.js +66 -14
- package/dist/utils/describe-signature.js.map +1 -1
- package/dist/utils/index.d.ts +2 -0
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +2 -0
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/math.d.ts +1 -13
- package/dist/utils/math.d.ts.map +1 -1
- package/dist/utils/math.js +14 -50
- package/dist/utils/math.js.map +1 -1
- package/dist/utils/misc.d.ts +5 -4
- package/dist/utils/misc.d.ts.map +1 -1
- package/dist/utils/misc.js +6 -6
- package/dist/utils/misc.js.map +1 -1
- package/dist/utils/record-types.d.ts +4 -5
- package/dist/utils/record-types.d.ts.map +1 -1
- package/dist/utils/record-types.js +2 -2
- package/dist/utils/record-types.js.map +1 -1
- package/dist/utils/type-parsers.d.ts +9 -3
- package/dist/utils/type-parsers.d.ts.map +1 -1
- package/dist/utils/type-parsers.js +14 -13
- package/dist/utils/type-parsers.js.map +1 -1
- package/dist/utils/viem-encoding.d.ts +15 -0
- package/dist/utils/viem-encoding.d.ts.map +1 -0
- package/dist/utils/viem-encoding.js +33 -0
- package/dist/utils/viem-encoding.js.map +1 -0
- package/dist/withdrawal-batch.d.ts +6 -7
- package/dist/withdrawal-batch.d.ts.map +1 -1
- package/dist/withdrawal-batch.js +29 -30
- package/dist/withdrawal-batch.js.map +1 -1
- package/dist/withdrawal-status.d.ts +5 -5
- package/dist/withdrawal-status.d.ts.map +1 -1
- package/dist/withdrawal-status.js +15 -12
- package/dist/withdrawal-status.js.map +1 -1
- package/dist/wrapper/index.d.ts +14 -31
- package/dist/wrapper/index.d.ts.map +1 -1
- package/dist/wrapper/index.js +80 -83
- package/dist/wrapper/index.js.map +1 -1
- package/package.json +13 -11
- package/dist/typechain/AccountQuery.d.ts +0 -56
- package/dist/typechain/AccountQuery.d.ts.map +0 -1
- package/dist/typechain/AccountQuery.js +0 -3
- package/dist/typechain/AccountQuery.js.map +0 -1
- package/dist/typechain/AccountsQuery.d.ts +0 -56
- package/dist/typechain/AccountsQuery.d.ts.map +0 -1
- package/dist/typechain/AccountsQuery.js +0 -3
- package/dist/typechain/AccountsQuery.js.map +0 -1
- package/dist/typechain/CheckBorrowersRegistered.d.ts +0 -29
- package/dist/typechain/CheckBorrowersRegistered.d.ts.map +0 -1
- package/dist/typechain/CheckBorrowersRegistered.js +0 -3
- package/dist/typechain/CheckBorrowersRegistered.js.map +0 -1
- package/dist/typechain/CheckSafeSignature.d.ts +0 -29
- package/dist/typechain/CheckSafeSignature.d.ts.map +0 -1
- package/dist/typechain/CheckSafeSignature.js +0 -3
- package/dist/typechain/CheckSafeSignature.js.map +0 -1
- package/dist/typechain/CollateralLens.d.ts +0 -220
- package/dist/typechain/CollateralLens.d.ts.map +0 -1
- package/dist/typechain/CollateralLens.js +0 -3
- package/dist/typechain/CollateralLens.js.map +0 -1
- package/dist/typechain/DescribeSignature.d.ts +0 -102
- package/dist/typechain/DescribeSignature.d.ts.map +0 -1
- package/dist/typechain/DescribeSignature.js +0 -3
- package/dist/typechain/DescribeSignature.js.map +0 -1
- package/dist/typechain/HooksFactory.d.ts +0 -593
- package/dist/typechain/HooksFactory.d.ts.map +0 -1
- package/dist/typechain/HooksFactory.js +0 -3
- package/dist/typechain/HooksFactory.js.map +0 -1
- package/dist/typechain/HooksFactoryRevolving.d.ts +0 -603
- package/dist/typechain/HooksFactoryRevolving.d.ts.map +0 -1
- package/dist/typechain/HooksFactoryRevolving.js +0 -3
- package/dist/typechain/HooksFactoryRevolving.js.map +0 -1
- package/dist/typechain/IERC20.d.ts +0 -232
- package/dist/typechain/IERC20.d.ts.map +0 -1
- package/dist/typechain/IERC20.js +0 -3
- package/dist/typechain/IERC20.js.map +0 -1
- package/dist/typechain/IFixedTermHooks.d.ts +0 -1032
- package/dist/typechain/IFixedTermHooks.d.ts.map +0 -1
- package/dist/typechain/IFixedTermHooks.js +0 -3
- package/dist/typechain/IFixedTermHooks.js.map +0 -1
- package/dist/typechain/IOpenTermHooks.d.ts +0 -987
- package/dist/typechain/IOpenTermHooks.d.ts.map +0 -1
- package/dist/typechain/IOpenTermHooks.js +0 -3
- package/dist/typechain/IOpenTermHooks.js.map +0 -1
- package/dist/typechain/ISafe.d.ts +0 -124
- package/dist/typechain/ISafe.d.ts.map +0 -1
- package/dist/typechain/ISafe.js.map +0 -1
- package/dist/typechain/MarketLens.d.ts +0 -611
- package/dist/typechain/MarketLens.d.ts.map +0 -1
- package/dist/typechain/MarketLens.js +0 -3
- package/dist/typechain/MarketLens.js.map +0 -1
- package/dist/typechain/MarketLensV2.d.ts +0 -704
- package/dist/typechain/MarketLensV2.d.ts.map +0 -1
- package/dist/typechain/MarketLensV2.js +0 -3
- package/dist/typechain/MarketLensV2.js.map +0 -1
- package/dist/typechain/MarketLensV2_5.d.ts +0 -996
- package/dist/typechain/MarketLensV2_5.d.ts.map +0 -1
- package/dist/typechain/MarketLensV2_5.js +0 -3
- package/dist/typechain/MarketLensV2_5.js.map +0 -1
- package/dist/typechain/MockArchControllerOwner.d.ts +0 -130
- package/dist/typechain/MockArchControllerOwner.d.ts.map +0 -1
- package/dist/typechain/MockArchControllerOwner.js +0 -3
- package/dist/typechain/MockArchControllerOwner.js.map +0 -1
- package/dist/typechain/MockERC20Factory.d.ts +0 -122
- package/dist/typechain/MockERC20Factory.d.ts.map +0 -1
- package/dist/typechain/MockERC20Factory.js +0 -3
- package/dist/typechain/MockERC20Factory.js.map +0 -1
- package/dist/typechain/SimpleMarketCollateral.d.ts +0 -270
- package/dist/typechain/SimpleMarketCollateral.d.ts.map +0 -1
- package/dist/typechain/SimpleMarketCollateral.js +0 -3
- package/dist/typechain/SimpleMarketCollateral.js.map +0 -1
- package/dist/typechain/Wildcat4626Wrapper.sol/IWildcatMarketToken.d.ts +0 -176
- package/dist/typechain/Wildcat4626Wrapper.sol/IWildcatMarketToken.d.ts.map +0 -1
- package/dist/typechain/Wildcat4626Wrapper.sol/IWildcatMarketToken.js +0 -3
- package/dist/typechain/Wildcat4626Wrapper.sol/IWildcatMarketToken.js.map +0 -1
- package/dist/typechain/Wildcat4626Wrapper.sol/IWildcatSanctionsSentinel.d.ts +0 -44
- package/dist/typechain/Wildcat4626Wrapper.sol/IWildcatSanctionsSentinel.d.ts.map +0 -1
- package/dist/typechain/Wildcat4626Wrapper.sol/IWildcatSanctionsSentinel.js +0 -3
- package/dist/typechain/Wildcat4626Wrapper.sol/IWildcatSanctionsSentinel.js.map +0 -1
- package/dist/typechain/Wildcat4626Wrapper.sol/Wildcat4626Wrapper.d.ts +0 -501
- package/dist/typechain/Wildcat4626Wrapper.sol/Wildcat4626Wrapper.d.ts.map +0 -1
- package/dist/typechain/Wildcat4626Wrapper.sol/Wildcat4626Wrapper.js +0 -3
- package/dist/typechain/Wildcat4626Wrapper.sol/Wildcat4626Wrapper.js.map +0 -1
- package/dist/typechain/Wildcat4626Wrapper.sol/index.d.ts +0 -4
- package/dist/typechain/Wildcat4626Wrapper.sol/index.d.ts.map +0 -1
- package/dist/typechain/Wildcat4626Wrapper.sol/index.js +0 -3
- package/dist/typechain/Wildcat4626Wrapper.sol/index.js.map +0 -1
- package/dist/typechain/Wildcat4626WrapperFactory.d.ts +0 -83
- package/dist/typechain/Wildcat4626WrapperFactory.d.ts.map +0 -1
- package/dist/typechain/Wildcat4626WrapperFactory.js +0 -3
- package/dist/typechain/Wildcat4626WrapperFactory.js.map +0 -1
- package/dist/typechain/WildcatArchController.d.ts +0 -545
- package/dist/typechain/WildcatArchController.d.ts.map +0 -1
- package/dist/typechain/WildcatArchController.js +0 -3
- package/dist/typechain/WildcatArchController.js.map +0 -1
- package/dist/typechain/WildcatCollateralFactory.d.ts +0 -164
- package/dist/typechain/WildcatCollateralFactory.d.ts.map +0 -1
- package/dist/typechain/WildcatCollateralFactory.js +0 -3
- package/dist/typechain/WildcatCollateralFactory.js.map +0 -1
- package/dist/typechain/WildcatMarket.d.ts +0 -1062
- package/dist/typechain/WildcatMarket.d.ts.map +0 -1
- package/dist/typechain/WildcatMarket.js +0 -3
- package/dist/typechain/WildcatMarket.js.map +0 -1
- package/dist/typechain/WildcatMarketController.d.ts +0 -553
- package/dist/typechain/WildcatMarketController.d.ts.map +0 -1
- package/dist/typechain/WildcatMarketController.js +0 -3
- package/dist/typechain/WildcatMarketController.js.map +0 -1
- package/dist/typechain/WildcatMarketControllerFactory.d.ts +0 -344
- package/dist/typechain/WildcatMarketControllerFactory.d.ts.map +0 -1
- package/dist/typechain/WildcatMarketControllerFactory.js +0 -3
- package/dist/typechain/WildcatMarketControllerFactory.js.map +0 -1
- package/dist/typechain/WildcatMarketV2.d.ts +0 -1086
- package/dist/typechain/WildcatMarketV2.d.ts.map +0 -1
- package/dist/typechain/WildcatMarketV2.js +0 -3
- package/dist/typechain/WildcatMarketV2.js.map +0 -1
- package/dist/typechain/common.d.ts +0 -23
- package/dist/typechain/common.d.ts.map +0 -1
- package/dist/typechain/common.js +0 -3
- package/dist/typechain/common.js.map +0 -1
- package/dist/typechain/factories/AccountQuery__factory.d.ts +0 -63
- package/dist/typechain/factories/AccountQuery__factory.d.ts.map +0 -1
- package/dist/typechain/factories/AccountQuery__factory.js +0 -96
- package/dist/typechain/factories/AccountQuery__factory.js.map +0 -1
- package/dist/typechain/factories/AccountsQuery__factory.d.ts +0 -63
- package/dist/typechain/factories/AccountsQuery__factory.d.ts.map +0 -1
- package/dist/typechain/factories/AccountsQuery__factory.js +0 -96
- package/dist/typechain/factories/AccountsQuery__factory.js.map +0 -1
- package/dist/typechain/factories/CheckBorrowersRegistered__factory.d.ts +0 -36
- package/dist/typechain/factories/CheckBorrowersRegistered__factory.d.ts.map +0 -1
- package/dist/typechain/factories/CheckBorrowersRegistered__factory.js +0 -60
- package/dist/typechain/factories/CheckBorrowersRegistered__factory.js.map +0 -1
- package/dist/typechain/factories/CheckSafeSignature__factory.d.ts +0 -40
- package/dist/typechain/factories/CheckSafeSignature__factory.d.ts.map +0 -1
- package/dist/typechain/factories/CheckSafeSignature__factory.js +0 -65
- package/dist/typechain/factories/CheckSafeSignature__factory.js.map +0 -1
- package/dist/typechain/factories/CollateralLens__factory.d.ts +0 -854
- package/dist/typechain/factories/CollateralLens__factory.d.ts.map +0 -1
- package/dist/typechain/factories/CollateralLens__factory.js +0 -1101
- package/dist/typechain/factories/CollateralLens__factory.js.map +0 -1
- package/dist/typechain/factories/DescribeSignature__factory.d.ts +0 -145
- package/dist/typechain/factories/DescribeSignature__factory.d.ts.map +0 -1
- package/dist/typechain/factories/DescribeSignature__factory.js +0 -203
- package/dist/typechain/factories/DescribeSignature__factory.js.map +0 -1
- package/dist/typechain/factories/HooksFactoryRevolving__factory.d.ts +0 -872
- package/dist/typechain/factories/HooksFactoryRevolving__factory.d.ts.map +0 -1
- package/dist/typechain/factories/HooksFactoryRevolving__factory.js +0 -1131
- package/dist/typechain/factories/HooksFactoryRevolving__factory.js.map +0 -1
- package/dist/typechain/factories/HooksFactory__factory.d.ts +0 -902
- package/dist/typechain/factories/HooksFactory__factory.d.ts.map +0 -1
- package/dist/typechain/factories/HooksFactory__factory.js +0 -1168
- package/dist/typechain/factories/HooksFactory__factory.js.map +0 -1
- package/dist/typechain/factories/IERC20__factory.d.ts +0 -235
- package/dist/typechain/factories/IERC20__factory.d.ts.map +0 -1
- package/dist/typechain/factories/IERC20__factory.js +0 -315
- package/dist/typechain/factories/IERC20__factory.js.map +0 -1
- package/dist/typechain/factories/IFixedTermHooks__factory.d.ts +0 -1894
- package/dist/typechain/factories/IFixedTermHooks__factory.d.ts.map +0 -1
- package/dist/typechain/factories/IFixedTermHooks__factory.js +0 -2423
- package/dist/typechain/factories/IFixedTermHooks__factory.js.map +0 -1
- package/dist/typechain/factories/IOpenTermHooks__factory.d.ts +0 -1791
- package/dist/typechain/factories/IOpenTermHooks__factory.d.ts.map +0 -1
- package/dist/typechain/factories/IOpenTermHooks__factory.js +0 -2293
- package/dist/typechain/factories/IOpenTermHooks__factory.js.map +0 -1
- package/dist/typechain/factories/ISafe__factory.d.ts +0 -163
- package/dist/typechain/factories/ISafe__factory.d.ts.map +0 -1
- package/dist/typechain/factories/ISafe__factory.js +0 -225
- package/dist/typechain/factories/ISafe__factory.js.map +0 -1
- package/dist/typechain/factories/MarketLensV2_5__factory.d.ts +0 -14397
- package/dist/typechain/factories/MarketLensV2_5__factory.d.ts.map +0 -1
- package/dist/typechain/factories/MarketLensV2_5__factory.js +0 -18393
- package/dist/typechain/factories/MarketLensV2_5__factory.js.map +0 -1
- package/dist/typechain/factories/MarketLensV2__factory.d.ts +0 -6612
- package/dist/typechain/factories/MarketLensV2__factory.d.ts.map +0 -1
- package/dist/typechain/factories/MarketLensV2__factory.js +0 -8454
- package/dist/typechain/factories/MarketLensV2__factory.js.map +0 -1
- package/dist/typechain/factories/MarketLens__factory.d.ts +0 -3572
- package/dist/typechain/factories/MarketLens__factory.d.ts.map +0 -1
- package/dist/typechain/factories/MarketLens__factory.js +0 -4569
- package/dist/typechain/factories/MarketLens__factory.js.map +0 -1
- package/dist/typechain/factories/MockArchControllerOwner__factory.d.ts +0 -85
- package/dist/typechain/factories/MockArchControllerOwner__factory.d.ts.map +0 -1
- package/dist/typechain/factories/MockArchControllerOwner__factory.js +0 -118
- package/dist/typechain/factories/MockArchControllerOwner__factory.js.map +0 -1
- package/dist/typechain/factories/MockERC20Factory__factory.d.ts +0 -114
- package/dist/typechain/factories/MockERC20Factory__factory.d.ts.map +0 -1
- package/dist/typechain/factories/MockERC20Factory__factory.js +0 -157
- package/dist/typechain/factories/MockERC20Factory__factory.js.map +0 -1
- package/dist/typechain/factories/SimpleMarketCollateral__factory.d.ts +0 -264
- package/dist/typechain/factories/SimpleMarketCollateral__factory.d.ts.map +0 -1
- package/dist/typechain/factories/SimpleMarketCollateral__factory.js +0 -354
- package/dist/typechain/factories/SimpleMarketCollateral__factory.js.map +0 -1
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/IWildcatMarketToken__factory.d.ts +0 -193
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/IWildcatMarketToken__factory.d.ts.map +0 -1
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/IWildcatMarketToken__factory.js +0 -263
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/IWildcatMarketToken__factory.js.map +0 -1
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/IWildcatSanctionsSentinel__factory.d.ts +0 -27
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/IWildcatSanctionsSentinel__factory.d.ts.map +0 -1
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/IWildcatSanctionsSentinel__factory.js +0 -44
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/IWildcatSanctionsSentinel__factory.js.map +0 -1
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/Wildcat4626Wrapper__factory.d.ts +0 -718
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/Wildcat4626Wrapper__factory.d.ts.map +0 -1
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/Wildcat4626Wrapper__factory.js +0 -946
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/Wildcat4626Wrapper__factory.js.map +0 -1
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/index.d.ts +0 -4
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/index.d.ts.map +0 -1
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/index.js +0 -13
- package/dist/typechain/factories/Wildcat4626Wrapper.sol/index.js.map +0 -1
- package/dist/typechain/factories/Wildcat4626WrapperFactory__factory.d.ts +0 -82
- package/dist/typechain/factories/Wildcat4626WrapperFactory__factory.d.ts.map +0 -1
- package/dist/typechain/factories/Wildcat4626WrapperFactory__factory.js +0 -117
- package/dist/typechain/factories/Wildcat4626WrapperFactory__factory.js.map +0 -1
- package/dist/typechain/factories/WildcatArchController__factory.d.ts +0 -554
- package/dist/typechain/factories/WildcatArchController__factory.d.ts.map +0 -1
- package/dist/typechain/factories/WildcatArchController__factory.js +0 -728
- package/dist/typechain/factories/WildcatArchController__factory.js.map +0 -1
- package/dist/typechain/factories/WildcatCollateralFactory__factory.d.ts +0 -160
- package/dist/typechain/factories/WildcatCollateralFactory__factory.d.ts.map +0 -1
- package/dist/typechain/factories/WildcatCollateralFactory__factory.js +0 -223
- package/dist/typechain/factories/WildcatCollateralFactory__factory.js.map +0 -1
- package/dist/typechain/factories/WildcatMarketControllerFactory__factory.d.ts +0 -421
- package/dist/typechain/factories/WildcatMarketControllerFactory__factory.d.ts.map +0 -1
- package/dist/typechain/factories/WildcatMarketControllerFactory__factory.js +0 -549
- package/dist/typechain/factories/WildcatMarketControllerFactory__factory.js.map +0 -1
- package/dist/typechain/factories/WildcatMarketController__factory.d.ts +0 -671
- package/dist/typechain/factories/WildcatMarketController__factory.d.ts.map +0 -1
- package/dist/typechain/factories/WildcatMarketController__factory.js +0 -870
- package/dist/typechain/factories/WildcatMarketController__factory.js.map +0 -1
- package/dist/typechain/factories/WildcatMarketV2__factory.d.ts +0 -1304
- package/dist/typechain/factories/WildcatMarketV2__factory.d.ts.map +0 -1
- package/dist/typechain/factories/WildcatMarketV2__factory.js +0 -1680
- package/dist/typechain/factories/WildcatMarketV2__factory.js.map +0 -1
- package/dist/typechain/factories/WildcatMarket__factory.d.ts +0 -1326
- package/dist/typechain/factories/WildcatMarket__factory.d.ts.map +0 -1
- package/dist/typechain/factories/WildcatMarket__factory.js +0 -1712
- package/dist/typechain/factories/WildcatMarket__factory.js.map +0 -1
- package/dist/typechain/factories/index.d.ts +0 -27
- package/dist/typechain/factories/index.d.ts.map +0 -1
- package/dist/typechain/factories/index.js +0 -81
- package/dist/typechain/factories/index.js.map +0 -1
- package/dist/typechain/index.d.ts +0 -73
- package/dist/typechain/index.d.ts.map +0 -1
- package/dist/typechain/index.js +0 -84
- package/dist/typechain/index.js.map +0 -1
package/dist/market.js
CHANGED
|
@@ -1,26 +1,45 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.Market = void 0;
|
|
4
|
-
const ethers_1 = require("ethers");
|
|
5
|
-
const abstract_signer_1 = require("@ethersproject/abstract-signer");
|
|
6
|
-
const typechain_1 = require("./typechain");
|
|
7
4
|
const constants_1 = require("./constants");
|
|
5
|
+
const arch_controller_1 = require("./internal/arch-controller");
|
|
6
|
+
const market_lens_1 = require("./internal/market-lens");
|
|
8
7
|
const token_1 = require("./token");
|
|
9
8
|
const types_1 = require("./types");
|
|
10
|
-
const utils_1 = require("ethers/lib/utils");
|
|
11
9
|
const account_1 = require("./account");
|
|
12
|
-
const
|
|
10
|
+
const utils_1 = require("./utils");
|
|
13
11
|
const access_1 = require("./access");
|
|
12
|
+
const abi_1 = require("./abi");
|
|
13
|
+
const viem_write_1 = require("./internal/viem-write");
|
|
14
|
+
const ethers_signer_1 = require("./internal/ethers-signer");
|
|
15
|
+
const ethers_viem_1 = require("./internal/ethers-viem");
|
|
16
|
+
const viem_read_1 = require("./internal/viem-read");
|
|
17
|
+
const getAllowForceBuyBacksFromHookedMarket = (hookedMarket, allowForceBuyBacksIndex) => {
|
|
18
|
+
return (hookedMarket.allowForceBuyBacks ??
|
|
19
|
+
Boolean(hookedMarket[allowForceBuyBacksIndex]));
|
|
20
|
+
};
|
|
14
21
|
const hasUnifiedLatestLensForDirectReads = (chainId) => {
|
|
15
22
|
return (0, constants_1.hasDeploymentAddress)(chainId, "MarketLensV2_5");
|
|
16
23
|
};
|
|
24
|
+
const toUnifiedMarketDataV2 = (data) => {
|
|
25
|
+
if ("market" in data) {
|
|
26
|
+
return data;
|
|
27
|
+
}
|
|
28
|
+
return {
|
|
29
|
+
market: data,
|
|
30
|
+
commitmentFeeBips: {
|
|
31
|
+
isPresent: false,
|
|
32
|
+
value: 0n
|
|
33
|
+
},
|
|
34
|
+
drawnAmount: {
|
|
35
|
+
isPresent: false,
|
|
36
|
+
value: 0n
|
|
37
|
+
}
|
|
38
|
+
};
|
|
39
|
+
};
|
|
17
40
|
class Market extends types_1.ContractWrapper {
|
|
18
|
-
get _contractAddress() {
|
|
19
|
-
return this.address;
|
|
20
|
-
}
|
|
21
41
|
constructor({ provider, ...args }) {
|
|
22
42
|
super(provider);
|
|
23
|
-
this.contractFactory = typechain_1.WildcatMarket__factory;
|
|
24
43
|
const { address, name, symbol, decimals } = args.marketToken;
|
|
25
44
|
Object.assign(this, {
|
|
26
45
|
address,
|
|
@@ -29,9 +48,9 @@ class Market extends types_1.ContractWrapper {
|
|
|
29
48
|
decimals
|
|
30
49
|
});
|
|
31
50
|
Object.assign(this, args);
|
|
32
|
-
this.depositRecords = (args.depositRecords ?? []).map((log) => (0,
|
|
33
|
-
this.repaymentRecords = (args.repaymentRecords ?? []).map((log) => (0,
|
|
34
|
-
this.borrowRecords = (args.borrowRecords ?? []).map((log) => (0,
|
|
51
|
+
this.depositRecords = (args.depositRecords ?? []).map((log) => (0, utils_1.parseMarketRecord)(this.underlyingToken, log));
|
|
52
|
+
this.repaymentRecords = (args.repaymentRecords ?? []).map((log) => (0, utils_1.parseMarketRecord)(this.underlyingToken, log));
|
|
53
|
+
this.borrowRecords = (args.borrowRecords ?? []).map((log) => (0, utils_1.parseMarketRecord)(this.underlyingToken, log));
|
|
35
54
|
this.feeCollectionRecords = (args.feeCollectionRecords ?? []).map(({ feesCollected, __typename, ...rest }) => ({
|
|
36
55
|
...rest,
|
|
37
56
|
__typename: "FeesCollected",
|
|
@@ -56,12 +75,50 @@ class Market extends types_1.ContractWrapper {
|
|
|
56
75
|
/** @returns Percentage growth of the market since it was created */
|
|
57
76
|
get allTimeGrowth() {
|
|
58
77
|
// 27 - 2 to convert to percentage
|
|
59
|
-
return +(0, utils_1.
|
|
78
|
+
return +(0, utils_1.formatFixedBigint)(this.scaleFactor, 25, 25);
|
|
60
79
|
}
|
|
61
80
|
/** @returns Maximum amount of underlying token that can be deposited */
|
|
62
81
|
get maximumDeposit() {
|
|
63
82
|
return this.underlyingToken.getAmount(this.maxTotalSupply.satsub(this.totalSupply.raw));
|
|
64
83
|
}
|
|
84
|
+
get currentRevolvingAprMetrics() {
|
|
85
|
+
const commitmentFeeBips = this.commitmentFeeBips;
|
|
86
|
+
const drawnAmount = this.drawnAmount;
|
|
87
|
+
if (commitmentFeeBips == null || drawnAmount == null) {
|
|
88
|
+
return undefined;
|
|
89
|
+
}
|
|
90
|
+
const totalSupply = this.totalSupply.raw;
|
|
91
|
+
const drawnAmountRaw = drawnAmount.raw > totalSupply ? totalSupply : drawnAmount.raw;
|
|
92
|
+
const utilizationBips = totalSupply > 0n ? Number((drawnAmountRaw * utils_1.BIP_BIGINT) / totalSupply) : 0;
|
|
93
|
+
const utilizationAprBips = totalSupply > 0n
|
|
94
|
+
? Number((drawnAmountRaw * BigInt(this.annualInterestBips)) / totalSupply)
|
|
95
|
+
: 0;
|
|
96
|
+
const blendedBaseAprBips = commitmentFeeBips + utilizationAprBips;
|
|
97
|
+
const protocolAprBips = Number((BigInt(blendedBaseAprBips) * BigInt(this.protocolFeeBips)) / utils_1.BIP_BIGINT);
|
|
98
|
+
const penaltyAprBips = this.isIncurringPenalties ? this.delinquencyFeeBips : 0;
|
|
99
|
+
return {
|
|
100
|
+
commitmentFeeBips,
|
|
101
|
+
drawnAmount,
|
|
102
|
+
utilizationBips,
|
|
103
|
+
utilizationAprBips,
|
|
104
|
+
blendedBaseAprBips,
|
|
105
|
+
protocolAprBips,
|
|
106
|
+
penaltyAprBips,
|
|
107
|
+
effectiveLenderAprBips: blendedBaseAprBips + penaltyAprBips
|
|
108
|
+
};
|
|
109
|
+
}
|
|
110
|
+
get currentBaseLenderAprBips() {
|
|
111
|
+
return this.currentRevolvingAprMetrics?.blendedBaseAprBips ?? this.annualInterestBips;
|
|
112
|
+
}
|
|
113
|
+
get currentBaseLenderAPR() {
|
|
114
|
+
return (0, utils_1.bipToRayBigint)(this.currentBaseLenderAprBips);
|
|
115
|
+
}
|
|
116
|
+
get currentPenaltyAPR() {
|
|
117
|
+
return this.isIncurringPenalties ? (0, utils_1.bipToRayBigint)(this.delinquencyFeeBips) : 0n;
|
|
118
|
+
}
|
|
119
|
+
get currentProtocolAPR() {
|
|
120
|
+
return (0, utils_1.bipMulBigint)(this.currentBaseLenderAPR, this.protocolFeeBips);
|
|
121
|
+
}
|
|
65
122
|
/** @returns Whether the borrower is in penalized delinquency */
|
|
66
123
|
get isIncurringPenalties() {
|
|
67
124
|
return this.timeDelinquent > this.delinquencyGracePeriod;
|
|
@@ -107,7 +164,7 @@ class Market extends types_1.ContractWrapper {
|
|
|
107
164
|
const targetRatio = this.reserveRatioBips / 100;
|
|
108
165
|
const actualRatio = this.totalSupply.eq(0)
|
|
109
166
|
? 100
|
|
110
|
-
: +(0, utils_1.
|
|
167
|
+
: +(0, utils_1.formatFixedBigint)((this.totalAssets.raw * utils_1.RAY_BIGINT) / this.totalSupply.raw, 25, 25);
|
|
111
168
|
if (this.temporaryReserveRatio) {
|
|
112
169
|
return {
|
|
113
170
|
targetRatio,
|
|
@@ -120,7 +177,7 @@ class Market extends types_1.ContractWrapper {
|
|
|
120
177
|
return { targetRatio, actualRatio };
|
|
121
178
|
}
|
|
122
179
|
get normalizedPendingWithdrawals() {
|
|
123
|
-
return this.underlyingToken.getAmount((0,
|
|
180
|
+
return this.underlyingToken.getAmount((0, utils_1.rayMulBigint)(this.scaledPendingWithdrawals, this.scaleFactor));
|
|
124
181
|
}
|
|
125
182
|
/** @returns Whether the borrower can change the APR */
|
|
126
183
|
get canReduceAPR() {
|
|
@@ -136,7 +193,7 @@ class Market extends types_1.ContractWrapper {
|
|
|
136
193
|
return this.totalAssets.satsub(unavailableAssets);
|
|
137
194
|
}
|
|
138
195
|
get minimumReserves() {
|
|
139
|
-
return this.
|
|
196
|
+
return this.outstandingTotalSupply.bipMul(this.reserveRatioBips);
|
|
140
197
|
}
|
|
141
198
|
get borrowableAssets() {
|
|
142
199
|
return this.totalAssets.satsub(this.coverageLiquidity);
|
|
@@ -174,63 +231,59 @@ class Market extends types_1.ContractWrapper {
|
|
|
174
231
|
};
|
|
175
232
|
}
|
|
176
233
|
normalizeAmount(amount) {
|
|
177
|
-
return (0,
|
|
234
|
+
return (0, utils_1.rayMulBigint)(amount, this.scaleFactor);
|
|
178
235
|
}
|
|
179
236
|
scaleAmount(amount) {
|
|
180
|
-
return (0,
|
|
237
|
+
return (0, utils_1.rayDivBigint)(amount, this.scaleFactor);
|
|
181
238
|
}
|
|
182
239
|
get secondsBeforeDelinquency() {
|
|
183
240
|
if (this.willBeDelinquent || this.totalDebts.eq(0))
|
|
184
241
|
return 0;
|
|
185
242
|
const scaledBase = this.scaledTotalSupply;
|
|
186
|
-
const basePrincipal = this.underlyingToken.getAmount((0,
|
|
187
|
-
const baseAPRRay =
|
|
188
|
-
const protocolFeeAPRRay =
|
|
189
|
-
const delinquencyFeeAPRRay = this.
|
|
190
|
-
? (0, utils_2.bipToRay)(this.delinquencyFeeBips)
|
|
191
|
-
: ethers_1.BigNumber.from(0);
|
|
243
|
+
const basePrincipal = this.underlyingToken.getAmount((0, utils_1.rayMulBigint)(scaledBase, this.scaleFactor));
|
|
244
|
+
const baseAPRRay = this.currentBaseLenderAPR;
|
|
245
|
+
const protocolFeeAPRRay = this.currentProtocolAPR;
|
|
246
|
+
const delinquencyFeeAPRRay = this.currentPenaltyAPR;
|
|
192
247
|
// lender APR portion
|
|
193
248
|
const lenderRequirementGrowthPerSecond = basePrincipal
|
|
194
|
-
.rayMul(baseAPRRay
|
|
195
|
-
.div(
|
|
249
|
+
.rayMul(baseAPRRay + delinquencyFeeAPRRay)
|
|
250
|
+
.div(utils_1.SECONDS_IN_365_DAYS)
|
|
196
251
|
.bipMul(this.reserveRatioBips);
|
|
197
252
|
// protocol fee portion
|
|
198
253
|
const protocolRequirementGrowthPerSecond = basePrincipal
|
|
199
254
|
.rayMul(protocolFeeAPRRay)
|
|
200
|
-
.div(
|
|
255
|
+
.div(utils_1.SECONDS_IN_365_DAYS);
|
|
201
256
|
const totalRequirementGrowthPerSecond = lenderRequirementGrowthPerSecond.add(protocolRequirementGrowthPerSecond.raw);
|
|
202
257
|
// essentially if apr=0 and rr=0 then bips alone wont move us to delinquency
|
|
203
|
-
if (totalRequirementGrowthPerSecond.raw
|
|
258
|
+
if (totalRequirementGrowthPerSecond.raw === 0n)
|
|
204
259
|
return Number.MAX_SAFE_INTEGER;
|
|
205
260
|
const buffer = this.liquidReserves.sub(this.minimumReserves);
|
|
206
|
-
if (buffer.raw
|
|
261
|
+
if (buffer.raw <= 0n)
|
|
207
262
|
return 0; // we are delinquent
|
|
208
|
-
return buffer.div(totalRequirementGrowthPerSecond, true).raw
|
|
263
|
+
return Number(buffer.div(totalRequirementGrowthPerSecond, true).raw); // seconds until the party
|
|
209
264
|
}
|
|
210
265
|
getSecondsBeforeDelinquencyForBorrowedAmount(borrowAmount) {
|
|
211
266
|
if (this.isDelinquent || this.totalDebts.eq(0))
|
|
212
267
|
return 0;
|
|
213
268
|
const scaledBase = this.scaledTotalSupply;
|
|
214
|
-
const basePrincipal = this.underlyingToken.getAmount((0,
|
|
215
|
-
const baseAPRRay =
|
|
216
|
-
const protocolFeeAPRRay =
|
|
217
|
-
const delinquencyFeeAPRRay = this.
|
|
218
|
-
? (0, utils_2.bipToRay)(this.delinquencyFeeBips)
|
|
219
|
-
: ethers_1.BigNumber.from(0);
|
|
269
|
+
const basePrincipal = this.underlyingToken.getAmount((0, utils_1.rayMulBigint)(scaledBase, this.scaleFactor));
|
|
270
|
+
const baseAPRRay = this.currentBaseLenderAPR;
|
|
271
|
+
const protocolFeeAPRRay = this.currentProtocolAPR;
|
|
272
|
+
const delinquencyFeeAPRRay = this.currentPenaltyAPR;
|
|
220
273
|
const lenderRequirementGrowthPerSecond = basePrincipal
|
|
221
|
-
.rayMul(baseAPRRay
|
|
222
|
-
.div(
|
|
274
|
+
.rayMul(baseAPRRay + delinquencyFeeAPRRay)
|
|
275
|
+
.div(utils_1.SECONDS_IN_365_DAYS)
|
|
223
276
|
.bipMul(this.reserveRatioBips);
|
|
224
277
|
const protocolRequirementGrowthPerSecond = basePrincipal
|
|
225
278
|
.rayMul(protocolFeeAPRRay)
|
|
226
|
-
.div(
|
|
279
|
+
.div(utils_1.SECONDS_IN_365_DAYS);
|
|
227
280
|
const totalRequirementGrowthPerSecond = lenderRequirementGrowthPerSecond.add(protocolRequirementGrowthPerSecond.raw);
|
|
228
|
-
if (totalRequirementGrowthPerSecond.raw
|
|
281
|
+
if (totalRequirementGrowthPerSecond.raw === 0n)
|
|
229
282
|
return Number.MAX_SAFE_INTEGER;
|
|
230
283
|
const postBorrowBuffer = this.liquidReserves.sub(this.minimumReserves).sub(borrowAmount);
|
|
231
|
-
if (postBorrowBuffer.raw
|
|
284
|
+
if (postBorrowBuffer.raw <= 0n)
|
|
232
285
|
return 0;
|
|
233
|
-
return postBorrowBuffer.div(totalRequirementGrowthPerSecond, true).raw
|
|
286
|
+
return Number(postBorrowBuffer.div(totalRequirementGrowthPerSecond, true).raw);
|
|
234
287
|
}
|
|
235
288
|
/**
|
|
236
289
|
* @dev Calculate token amount to be repayed by borrower for a given duration
|
|
@@ -238,22 +291,20 @@ class Market extends types_1.ContractWrapper {
|
|
|
238
291
|
* @return token amount to be repayed
|
|
239
292
|
**/
|
|
240
293
|
repayRequiredForDuration(timeToPayInSeconds) {
|
|
241
|
-
const scaledBase = this.scaledTotalSupply
|
|
242
|
-
if (scaledBase
|
|
294
|
+
const scaledBase = this.scaledTotalSupply - this.scaledPendingWithdrawals;
|
|
295
|
+
if (scaledBase <= 0n)
|
|
243
296
|
return this.underlyingToken.getAmount(0);
|
|
244
|
-
const basePrincipal = this.underlyingToken.getAmount((0,
|
|
245
|
-
const baseAPRRay =
|
|
246
|
-
const protocolFeeAPRRay =
|
|
247
|
-
const delinquencyFeeAPRRay = this.
|
|
248
|
-
? (0, utils_2.bipToRay)(this.delinquencyFeeBips)
|
|
249
|
-
: ethers_1.BigNumber.from(0);
|
|
297
|
+
const basePrincipal = this.underlyingToken.getAmount((0, utils_1.rayMulBigint)(scaledBase, this.scaleFactor));
|
|
298
|
+
const baseAPRRay = this.currentBaseLenderAPR;
|
|
299
|
+
const protocolFeeAPRRay = this.currentProtocolAPR;
|
|
300
|
+
const delinquencyFeeAPRRay = this.currentPenaltyAPR;
|
|
250
301
|
const lenderRequirementGrowthPerSecond = basePrincipal
|
|
251
|
-
.rayMul(baseAPRRay
|
|
252
|
-
.div(
|
|
302
|
+
.rayMul(baseAPRRay + delinquencyFeeAPRRay)
|
|
303
|
+
.div(utils_1.SECONDS_IN_365_DAYS)
|
|
253
304
|
.bipMul(this.reserveRatioBips);
|
|
254
305
|
const protocolRequirementGrowthPerSecond = basePrincipal
|
|
255
306
|
.rayMul(protocolFeeAPRRay)
|
|
256
|
-
.div(
|
|
307
|
+
.div(utils_1.SECONDS_IN_365_DAYS);
|
|
257
308
|
const totalRequirementGrowthPerSecond = lenderRequirementGrowthPerSecond.add(protocolRequirementGrowthPerSecond.raw);
|
|
258
309
|
return totalRequirementGrowthPerSecond.mul(timeToPayInSeconds);
|
|
259
310
|
}
|
|
@@ -265,12 +316,8 @@ class Market extends types_1.ContractWrapper {
|
|
|
265
316
|
* @return apr paid by borrower in ray
|
|
266
317
|
*/
|
|
267
318
|
get effectiveBorrowerAPR() {
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
if (this.timeDelinquent > this.delinquencyGracePeriod) {
|
|
271
|
-
apr = apr.add((0, utils_2.bipToRay)(this.delinquencyFeeBips));
|
|
272
|
-
}
|
|
273
|
-
return apr;
|
|
319
|
+
return ((0, utils_1.bipMulBigint)(this.currentBaseLenderAPR, utils_1.BIP_BIGINT + BigInt(this.protocolFeeBips)) +
|
|
320
|
+
this.currentPenaltyAPR);
|
|
274
321
|
}
|
|
275
322
|
/**
|
|
276
323
|
* @dev Calculate effective interest rate currently earned by lenders.
|
|
@@ -279,35 +326,39 @@ class Market extends types_1.ContractWrapper {
|
|
|
279
326
|
* @return apr earned by lender in ray
|
|
280
327
|
*/
|
|
281
328
|
get effectiveLenderAPR() {
|
|
282
|
-
|
|
283
|
-
if (this.timeDelinquent > this.delinquencyGracePeriod) {
|
|
284
|
-
apr += this.delinquencyFeeBips;
|
|
285
|
-
}
|
|
286
|
-
return (0, utils_2.bipToRay)(apr);
|
|
329
|
+
return this.currentBaseLenderAPR + this.currentPenaltyAPR;
|
|
287
330
|
}
|
|
288
331
|
/* -------------------------------------------------------------------------- */
|
|
289
332
|
/* Withdrawal Execution */
|
|
290
333
|
/* -------------------------------------------------------------------------- */
|
|
291
334
|
async executeWithdrawal({ lender, expiry }) {
|
|
292
|
-
return this.
|
|
335
|
+
return (0, viem_write_1.submitPreparedTransaction)(this.signer, (0, utils_1.prepareTransaction)({
|
|
336
|
+
to: this.address,
|
|
337
|
+
abi: abi_1.wildcatMarketAbi,
|
|
338
|
+
functionName: "executeWithdrawal",
|
|
339
|
+
args: [lender, expiry]
|
|
340
|
+
}));
|
|
293
341
|
}
|
|
294
342
|
async executeWithdrawals(withdrawals) {
|
|
295
343
|
const lenders = withdrawals.map((w) => w.lender);
|
|
296
344
|
const expiries = withdrawals.map((w) => w.expiry);
|
|
297
|
-
return this.
|
|
345
|
+
return (0, viem_write_1.submitPreparedTransaction)(this.signer, (0, utils_1.prepareTransaction)({
|
|
346
|
+
to: this.address,
|
|
347
|
+
abi: abi_1.wildcatMarketAbi,
|
|
348
|
+
functionName: "executeWithdrawals",
|
|
349
|
+
args: [lenders, expiries]
|
|
350
|
+
}));
|
|
298
351
|
}
|
|
299
352
|
populateRepayAndProcessUnpaidWithdrawalBatches(amount, maxBatches = 10) {
|
|
300
|
-
return {
|
|
353
|
+
return (0, utils_1.prepareTransaction)({
|
|
301
354
|
to: this.address,
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
value: "0"
|
|
307
|
-
};
|
|
355
|
+
abi: abi_1.wildcatMarketAbi,
|
|
356
|
+
functionName: "repayAndProcessUnpaidWithdrawalBatches",
|
|
357
|
+
args: [amount.raw, maxBatches]
|
|
358
|
+
});
|
|
308
359
|
}
|
|
309
360
|
async repayAndProcessUnpaidWithdrawalBatches(amount, maxBatches = 10) {
|
|
310
|
-
return this.
|
|
361
|
+
return (0, viem_write_1.submitPreparedTransaction)(this.signer, this.populateRepayAndProcessUnpaidWithdrawalBatches(amount, maxBatches));
|
|
311
362
|
}
|
|
312
363
|
/* -------------------------------------------------------------------------- */
|
|
313
364
|
/* Set APR */
|
|
@@ -323,7 +374,8 @@ class Market extends types_1.ContractWrapper {
|
|
|
323
374
|
if (annualInterestBips < originalAnnualInterestBips) {
|
|
324
375
|
let doubleRelativeDiff;
|
|
325
376
|
if (this.version === types_1.MarketVersion.V2) {
|
|
326
|
-
const relativeDiff = (
|
|
377
|
+
const relativeDiff = Number((10000n * BigInt(originalAnnualInterestBips - annualInterestBips)) /
|
|
378
|
+
BigInt(originalAnnualInterestBips));
|
|
327
379
|
if (relativeDiff <= 2500) {
|
|
328
380
|
// In v2, if the relative diff is 25% or less, the reserve ratio is not changed
|
|
329
381
|
return originalReserveRatioBips;
|
|
@@ -331,7 +383,8 @@ class Market extends types_1.ContractWrapper {
|
|
|
331
383
|
doubleRelativeDiff = 2 * relativeDiff;
|
|
332
384
|
}
|
|
333
385
|
else {
|
|
334
|
-
doubleRelativeDiff = (
|
|
386
|
+
doubleRelativeDiff = Number((20000n * BigInt(originalAnnualInterestBips - annualInterestBips)) /
|
|
387
|
+
BigInt(originalAnnualInterestBips));
|
|
335
388
|
}
|
|
336
389
|
const boundRelativeDiff = Math.min(10000, doubleRelativeDiff);
|
|
337
390
|
return Math.max(boundRelativeDiff, originalReserveRatioBips);
|
|
@@ -343,10 +396,11 @@ class Market extends types_1.ContractWrapper {
|
|
|
343
396
|
return originalReserveRatioBips;
|
|
344
397
|
}
|
|
345
398
|
calculateLiquidityCoverageForReserveRatio(reserveRatio) {
|
|
346
|
-
const scaledRequiredReserves = (0,
|
|
347
|
-
|
|
348
|
-
|
|
349
|
-
|
|
399
|
+
const scaledRequiredReserves = (0, utils_1.bipMulBigint)(this.scaledTotalSupply - this.scaledPendingWithdrawals, reserveRatio) +
|
|
400
|
+
this.scaledPendingWithdrawals;
|
|
401
|
+
return this.underlyingToken.getAmount((0, utils_1.rayMulBigint)(scaledRequiredReserves, this.scaleFactor) +
|
|
402
|
+
this.lastAccruedProtocolFees.raw +
|
|
403
|
+
this.normalizedUnclaimedWithdrawals.raw);
|
|
350
404
|
}
|
|
351
405
|
canChangeAPR(annualInterestBips) {
|
|
352
406
|
const originalAnnualInterestBips = this.temporaryReserveRatio
|
|
@@ -379,7 +433,7 @@ class Market extends types_1.ContractWrapper {
|
|
|
379
433
|
if (this.version === types_1.MarketVersion.V2) {
|
|
380
434
|
if (hasUnifiedLatestLensForDirectReads(this.chainId)) {
|
|
381
435
|
try {
|
|
382
|
-
const market = await (0,
|
|
436
|
+
const market = await (0, market_lens_1.getUnifiedMarketDataV2)(this.chainId, this.provider, this.address);
|
|
383
437
|
this.updateWith(market);
|
|
384
438
|
return;
|
|
385
439
|
}
|
|
@@ -387,69 +441,86 @@ class Market extends types_1.ContractWrapper {
|
|
|
387
441
|
// Fall back to the pre-2.5 V2 lens until unified lens deployment is reliable.
|
|
388
442
|
}
|
|
389
443
|
}
|
|
390
|
-
const market = await (0,
|
|
444
|
+
const market = await (0, market_lens_1.getV2MarketData)(this.chainId, this.provider, this.address);
|
|
391
445
|
this.updateWith(market);
|
|
392
446
|
return;
|
|
393
447
|
}
|
|
394
|
-
const market = await (0,
|
|
448
|
+
const market = await (0, market_lens_1.getLegacyMarketData)(this.chainId, this.provider, this.address);
|
|
395
449
|
this.updateWith(market);
|
|
396
450
|
}
|
|
397
451
|
updateWith(data) {
|
|
452
|
+
const baseData = "market" in data ? data.market : data;
|
|
453
|
+
const nextScaleFactor = (0, token_1.toRawAmount)(baseData.scaleFactor);
|
|
454
|
+
const nextScaledTotalSupply = (0, token_1.toRawAmount)(baseData.scaledTotalSupply);
|
|
455
|
+
const nextScaledPendingWithdrawals = (0, token_1.toRawAmount)(baseData.scaledPendingWithdrawals);
|
|
456
|
+
const nextLastAccruedProtocolFees = (0, token_1.toRawAmount)(baseData.lastAccruedProtocolFees);
|
|
398
457
|
// Note: this adds all the interest accrued to the base interest accrued, since the lens
|
|
399
458
|
// doesn't give us any way to distinguish between base interest and delinquency fees.
|
|
400
|
-
if (this.scaledTotalSupply
|
|
401
|
-
|
|
459
|
+
if (this.scaledTotalSupply === nextScaledTotalSupply &&
|
|
460
|
+
nextScaleFactor > this.scaleFactor &&
|
|
402
461
|
this.totalBaseInterestAccrued) {
|
|
403
|
-
const lastTotalValue = (0,
|
|
404
|
-
const currentTotalValue = (0,
|
|
405
|
-
const baseInterestAccrued = currentTotalValue
|
|
462
|
+
const lastTotalValue = (0, utils_1.rayMulBigint)(this.scaledTotalSupply, this.scaleFactor);
|
|
463
|
+
const currentTotalValue = (0, utils_1.rayMulBigint)(this.scaledTotalSupply, nextScaleFactor);
|
|
464
|
+
const baseInterestAccrued = currentTotalValue - lastTotalValue;
|
|
406
465
|
this.totalBaseInterestAccrued = this.totalBaseInterestAccrued.add(baseInterestAccrued);
|
|
407
466
|
}
|
|
408
|
-
if (
|
|
467
|
+
if (nextLastAccruedProtocolFees > this.lastAccruedProtocolFees.raw &&
|
|
409
468
|
this.totalProtocolFeesAccrued) {
|
|
410
|
-
this.totalProtocolFeesAccrued = this.totalProtocolFeesAccrued.add(
|
|
411
|
-
}
|
|
412
|
-
this.feeRecipient =
|
|
413
|
-
this.protocolFeeBips =
|
|
414
|
-
this.delinquencyFeeBips =
|
|
415
|
-
this.delinquencyGracePeriod =
|
|
416
|
-
this.withdrawalBatchDuration =
|
|
417
|
-
this.reserveRatioBips =
|
|
418
|
-
this.annualInterestBips =
|
|
419
|
-
this.temporaryReserveRatio =
|
|
420
|
-
this.originalAnnualInterestBips =
|
|
421
|
-
this.originalReserveRatioBips =
|
|
422
|
-
this.temporaryReserveRatioExpiry =
|
|
423
|
-
this.isClosed =
|
|
424
|
-
this.scaleFactor =
|
|
425
|
-
this.totalSupply = this.marketToken.getAmount(
|
|
426
|
-
this.maxTotalSupply = this.marketToken.getAmount(
|
|
427
|
-
this.scaledTotalSupply =
|
|
428
|
-
this.totalAssets = this.underlyingToken.getAmount(
|
|
429
|
-
this.lastAccruedProtocolFees = this.underlyingToken.getAmount(
|
|
430
|
-
this.normalizedUnclaimedWithdrawals = this.underlyingToken.getAmount(
|
|
431
|
-
this.scaledPendingWithdrawals =
|
|
432
|
-
this.pendingWithdrawalExpiry =
|
|
433
|
-
this.isDelinquent =
|
|
434
|
-
this.timeDelinquent =
|
|
435
|
-
this.lastInterestAccruedTimestamp =
|
|
436
|
-
this.unpaidWithdrawalBatchExpiries =
|
|
437
|
-
this.coverageLiquidity = this.underlyingToken.getAmount(
|
|
438
|
-
if ("hooksFactory" in
|
|
439
|
-
this.hooksFactory =
|
|
440
|
-
this.marketType = (0, constants_1.getMarketTypeForHooksFactory)(this.chainId,
|
|
441
|
-
}
|
|
442
|
-
if ("hooksConfig" in
|
|
443
|
-
(0,
|
|
469
|
+
this.totalProtocolFeesAccrued = this.totalProtocolFeesAccrued.add(nextLastAccruedProtocolFees - this.lastAccruedProtocolFees.raw);
|
|
470
|
+
}
|
|
471
|
+
this.feeRecipient = baseData.feeRecipient;
|
|
472
|
+
this.protocolFeeBips = (0, utils_1.toNumber)(baseData.protocolFeeBips);
|
|
473
|
+
this.delinquencyFeeBips = (0, utils_1.toNumber)(baseData.delinquencyFeeBips);
|
|
474
|
+
this.delinquencyGracePeriod = (0, utils_1.toNumber)(baseData.delinquencyGracePeriod);
|
|
475
|
+
this.withdrawalBatchDuration = (0, utils_1.toNumber)(baseData.withdrawalBatchDuration);
|
|
476
|
+
this.reserveRatioBips = (0, utils_1.toNumber)(baseData.reserveRatioBips);
|
|
477
|
+
this.annualInterestBips = (0, utils_1.toNumber)(baseData.annualInterestBips);
|
|
478
|
+
this.temporaryReserveRatio = baseData.temporaryReserveRatio;
|
|
479
|
+
this.originalAnnualInterestBips = (0, utils_1.toNumber)(baseData.originalAnnualInterestBips);
|
|
480
|
+
this.originalReserveRatioBips = (0, utils_1.toNumber)(baseData.originalReserveRatioBips);
|
|
481
|
+
this.temporaryReserveRatioExpiry = (0, utils_1.toNumber)(baseData.temporaryReserveRatioExpiry);
|
|
482
|
+
this.isClosed = baseData.isClosed;
|
|
483
|
+
this.scaleFactor = nextScaleFactor;
|
|
484
|
+
this.totalSupply = this.marketToken.getAmount(baseData.totalSupply);
|
|
485
|
+
this.maxTotalSupply = this.marketToken.getAmount(baseData.maxTotalSupply);
|
|
486
|
+
this.scaledTotalSupply = nextScaledTotalSupply;
|
|
487
|
+
this.totalAssets = this.underlyingToken.getAmount(baseData.totalAssets);
|
|
488
|
+
this.lastAccruedProtocolFees = this.underlyingToken.getAmount(baseData.lastAccruedProtocolFees);
|
|
489
|
+
this.normalizedUnclaimedWithdrawals = this.underlyingToken.getAmount(baseData.normalizedUnclaimedWithdrawals);
|
|
490
|
+
this.scaledPendingWithdrawals = nextScaledPendingWithdrawals;
|
|
491
|
+
this.pendingWithdrawalExpiry = (0, utils_1.toNumber)(baseData.pendingWithdrawalExpiry);
|
|
492
|
+
this.isDelinquent = baseData.isDelinquent;
|
|
493
|
+
this.timeDelinquent = (0, utils_1.toNumber)(baseData.timeDelinquent);
|
|
494
|
+
this.lastInterestAccruedTimestamp = (0, utils_1.toNumber)(baseData.lastInterestAccruedTimestamp);
|
|
495
|
+
this.unpaidWithdrawalBatchExpiries = baseData.unpaidWithdrawalBatchExpiries.map(utils_1.toNumber);
|
|
496
|
+
this.coverageLiquidity = this.underlyingToken.getAmount(baseData.coverageLiquidity);
|
|
497
|
+
if ("hooksFactory" in baseData) {
|
|
498
|
+
this.hooksFactory = baseData.hooksFactory;
|
|
499
|
+
this.marketType = (0, constants_1.getMarketTypeForHooksFactory)(this.chainId, baseData.hooksFactory);
|
|
500
|
+
}
|
|
501
|
+
if ("hooksConfig" in baseData) {
|
|
502
|
+
(0, utils_1.assert)(this.version === types_1.MarketVersion.V2, `Can not push V2 lens data to V1 market!`);
|
|
444
503
|
const config = this.hooksConfig;
|
|
445
|
-
(0,
|
|
446
|
-
config.minimumDeposit = this.underlyingToken.getAmount(
|
|
504
|
+
(0, utils_1.assert)(config !== undefined, `V2 market has no hooksConfig!`);
|
|
505
|
+
config.minimumDeposit = this.underlyingToken.getAmount(baseData.hooksConfig.minimumDeposit);
|
|
447
506
|
if (config.kind === types_1.HooksKind.FixedTerm) {
|
|
448
|
-
config.fixedTermEndTime =
|
|
507
|
+
config.fixedTermEndTime = (0, utils_1.toNumber)(baseData.hooksConfig.fixedTermEndTime);
|
|
449
508
|
}
|
|
450
509
|
}
|
|
451
510
|
else {
|
|
452
|
-
(0,
|
|
511
|
+
(0, utils_1.assert)(this.version === types_1.MarketVersion.V1, `Can not push V1 lens data to V2 market!`);
|
|
512
|
+
}
|
|
513
|
+
if ("market" in data) {
|
|
514
|
+
this.commitmentFeeBips = data.commitmentFeeBips.isPresent
|
|
515
|
+
? (0, utils_1.toNumber)(data.commitmentFeeBips.value)
|
|
516
|
+
: undefined;
|
|
517
|
+
this.drawnAmount = data.drawnAmount.isPresent
|
|
518
|
+
? this.underlyingToken.getAmount(data.drawnAmount.value)
|
|
519
|
+
: undefined;
|
|
520
|
+
}
|
|
521
|
+
else {
|
|
522
|
+
this.commitmentFeeBips = undefined;
|
|
523
|
+
this.drawnAmount = undefined;
|
|
453
524
|
}
|
|
454
525
|
}
|
|
455
526
|
/* -------------------------------------------------------------------------- */
|
|
@@ -458,17 +529,18 @@ class Market extends types_1.ContractWrapper {
|
|
|
458
529
|
static fromSubgraphMarketData(chainId, provider, data, signerAddress) {
|
|
459
530
|
const underlyingToken = token_1.Token.fromSubgraphToken(chainId, data._asset, provider);
|
|
460
531
|
const marketToken = token_1.Token.fromSubgraphMarketData(chainId, data, provider);
|
|
461
|
-
const scaledTotalSupply =
|
|
462
|
-
const scaleFactor =
|
|
463
|
-
const scaledWithdrawals =
|
|
464
|
-
const scaledRequiredReserves = (0,
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
.
|
|
532
|
+
const scaledTotalSupply = (0, token_1.toRawAmount)(data.scaledTotalSupply);
|
|
533
|
+
const scaleFactor = (0, token_1.toRawAmount)(data.scaleFactor);
|
|
534
|
+
const scaledWithdrawals = (0, token_1.toRawAmount)(data.scaledPendingWithdrawals);
|
|
535
|
+
const scaledRequiredReserves = (0, utils_1.bipMulBigint)(scaledTotalSupply - scaledWithdrawals, data.reserveRatioBips) +
|
|
536
|
+
scaledWithdrawals;
|
|
537
|
+
const coverageLiquidity = (0, utils_1.rayMulBigint)(scaledRequiredReserves, scaleFactor) +
|
|
538
|
+
(0, token_1.toRawAmount)(data.pendingProtocolFees) +
|
|
539
|
+
(0, token_1.toRawAmount)(data.normalizedUnclaimedWithdrawals);
|
|
468
540
|
let hooksConfig;
|
|
469
541
|
if (data.version === types_1.MarketVersion.V2) {
|
|
470
|
-
(0,
|
|
471
|
-
(0,
|
|
542
|
+
(0, utils_1.assert)(!!data.hooks, `V2 markets require hooks`);
|
|
543
|
+
(0, utils_1.assert)(!!data.hooksConfig, `V2 markets require hooksConfig`);
|
|
472
544
|
const { minimumDeposit: _minimumDeposit, depositRequiresAccess, transferRequiresAccess, queueWithdrawalRequiresAccess, allowClosureBeforeTerm, allowForceBuyBacks, allowTermReduction, fixedTermEndTime, transfersDisabled } = data.hooksConfig;
|
|
473
545
|
const flags = {
|
|
474
546
|
useOnDeposit: data.hooksConfig.useOnDeposit,
|
|
@@ -540,20 +612,22 @@ class Market extends types_1.ContractWrapper {
|
|
|
540
612
|
originalReserveRatioBips: data.originalReserveRatioBips,
|
|
541
613
|
temporaryReserveRatioExpiry: data.temporaryReserveRatioExpiry,
|
|
542
614
|
isClosed: data.isClosed,
|
|
543
|
-
scaleFactor
|
|
544
|
-
totalSupply: marketToken.getAmount((0,
|
|
615
|
+
scaleFactor,
|
|
616
|
+
totalSupply: marketToken.getAmount((0, utils_1.rayMulBigint)(scaledTotalSupply, scaleFactor)),
|
|
545
617
|
maxTotalSupply: marketToken.getAmount(data.maxTotalSupply),
|
|
546
618
|
scaledTotalSupply: scaledTotalSupply,
|
|
547
619
|
totalAssets: underlyingToken.getAmount(0),
|
|
548
620
|
lastAccruedProtocolFees: underlyingToken.getAmount(data.pendingProtocolFees),
|
|
549
621
|
normalizedUnclaimedWithdrawals: underlyingToken.getAmount(data.normalizedUnclaimedWithdrawals),
|
|
550
|
-
scaledPendingWithdrawals:
|
|
622
|
+
scaledPendingWithdrawals: scaledWithdrawals,
|
|
551
623
|
pendingWithdrawalExpiry: +data.pendingWithdrawalExpiry,
|
|
552
624
|
isDelinquent: data.isDelinquent,
|
|
553
625
|
timeDelinquent: data.timeDelinquent,
|
|
554
626
|
lastInterestAccruedTimestamp: data.lastInterestAccruedTimestamp,
|
|
555
627
|
unpaidWithdrawalBatchExpiries: [] /* data.unpaidWithdrawalBatchExpiries */,
|
|
556
628
|
coverageLiquidity: underlyingToken.getAmount(coverageLiquidity),
|
|
629
|
+
commitmentFeeBips: data.commitmentFeeBips != null ? Number(data.commitmentFeeBips) : undefined,
|
|
630
|
+
drawnAmount: data.drawnAmount != null ? underlyingToken.getAmount(data.drawnAmount) : undefined,
|
|
557
631
|
totalBorrowed: underlyingToken.getAmount(data.totalBorrowed),
|
|
558
632
|
totalRepaid: underlyingToken.getAmount(data.totalRepaid),
|
|
559
633
|
totalBaseInterestAccrued: underlyingToken.getAmount(data.totalBaseInterestAccrued),
|
|
@@ -582,30 +656,30 @@ class Market extends types_1.ContractWrapper {
|
|
|
582
656
|
borrower: data.borrower,
|
|
583
657
|
controller: data.controller,
|
|
584
658
|
feeRecipient: data.feeRecipient,
|
|
585
|
-
protocolFeeBips: data.protocolFeeBips
|
|
586
|
-
delinquencyFeeBips: data.delinquencyFeeBips
|
|
587
|
-
delinquencyGracePeriod: data.delinquencyGracePeriod
|
|
588
|
-
withdrawalBatchDuration: data.withdrawalBatchDuration
|
|
589
|
-
reserveRatioBips: data.reserveRatioBips
|
|
590
|
-
annualInterestBips: data.annualInterestBips
|
|
659
|
+
protocolFeeBips: (0, utils_1.toNumber)(data.protocolFeeBips),
|
|
660
|
+
delinquencyFeeBips: (0, utils_1.toNumber)(data.delinquencyFeeBips),
|
|
661
|
+
delinquencyGracePeriod: (0, utils_1.toNumber)(data.delinquencyGracePeriod),
|
|
662
|
+
withdrawalBatchDuration: (0, utils_1.toNumber)(data.withdrawalBatchDuration),
|
|
663
|
+
reserveRatioBips: (0, utils_1.toNumber)(data.reserveRatioBips),
|
|
664
|
+
annualInterestBips: (0, utils_1.toNumber)(data.annualInterestBips),
|
|
591
665
|
temporaryReserveRatio: data.temporaryReserveRatio,
|
|
592
|
-
originalAnnualInterestBips: data.originalAnnualInterestBips
|
|
593
|
-
originalReserveRatioBips: data.originalReserveRatioBips
|
|
594
|
-
temporaryReserveRatioExpiry: data.temporaryReserveRatioExpiry
|
|
666
|
+
originalAnnualInterestBips: (0, utils_1.toNumber)(data.originalAnnualInterestBips),
|
|
667
|
+
originalReserveRatioBips: (0, utils_1.toNumber)(data.originalReserveRatioBips),
|
|
668
|
+
temporaryReserveRatioExpiry: (0, utils_1.toNumber)(data.temporaryReserveRatioExpiry),
|
|
595
669
|
isClosed: data.isClosed,
|
|
596
|
-
scaleFactor: data.scaleFactor,
|
|
670
|
+
scaleFactor: (0, token_1.toRawAmount)(data.scaleFactor),
|
|
597
671
|
totalSupply: marketToken.getAmount(data.totalSupply),
|
|
598
672
|
maxTotalSupply: marketToken.getAmount(data.maxTotalSupply),
|
|
599
|
-
scaledTotalSupply: data.scaledTotalSupply,
|
|
673
|
+
scaledTotalSupply: (0, token_1.toRawAmount)(data.scaledTotalSupply),
|
|
600
674
|
totalAssets: underlyingToken.getAmount(data.totalAssets),
|
|
601
675
|
lastAccruedProtocolFees: underlyingToken.getAmount(data.lastAccruedProtocolFees),
|
|
602
676
|
normalizedUnclaimedWithdrawals: underlyingToken.getAmount(data.normalizedUnclaimedWithdrawals),
|
|
603
|
-
scaledPendingWithdrawals: data.scaledPendingWithdrawals,
|
|
604
|
-
pendingWithdrawalExpiry: data.pendingWithdrawalExpiry
|
|
677
|
+
scaledPendingWithdrawals: (0, token_1.toRawAmount)(data.scaledPendingWithdrawals),
|
|
678
|
+
pendingWithdrawalExpiry: (0, utils_1.toNumber)(data.pendingWithdrawalExpiry),
|
|
605
679
|
isDelinquent: data.isDelinquent,
|
|
606
|
-
timeDelinquent: data.timeDelinquent
|
|
607
|
-
lastInterestAccruedTimestamp: data.lastInterestAccruedTimestamp
|
|
608
|
-
unpaidWithdrawalBatchExpiries: data.unpaidWithdrawalBatchExpiries,
|
|
680
|
+
timeDelinquent: (0, utils_1.toNumber)(data.timeDelinquent),
|
|
681
|
+
lastInterestAccruedTimestamp: (0, utils_1.toNumber)(data.lastInterestAccruedTimestamp),
|
|
682
|
+
unpaidWithdrawalBatchExpiries: data.unpaidWithdrawalBatchExpiries.map(utils_1.toNumber),
|
|
609
683
|
coverageLiquidity: underlyingToken.getAmount(data.coverageLiquidity),
|
|
610
684
|
totalBorrowed: undefined,
|
|
611
685
|
totalRepaid: undefined,
|
|
@@ -627,7 +701,8 @@ class Market extends types_1.ContractWrapper {
|
|
|
627
701
|
const underlyingToken = token_1.Token.fromTokenMetadata(chainId, data.underlyingToken, provider);
|
|
628
702
|
const { hooksAddress } = hooks;
|
|
629
703
|
let hooksConfig;
|
|
630
|
-
|
|
704
|
+
const hooksKind = (0, utils_1.toNumber)(hooksConfigData.kind);
|
|
705
|
+
if (hooksKind === 1) {
|
|
631
706
|
hooksConfig = {
|
|
632
707
|
kind: types_1.HooksKind.OpenTerm,
|
|
633
708
|
hooksAddress: hooksAddress,
|
|
@@ -639,7 +714,7 @@ class Market extends types_1.ContractWrapper {
|
|
|
639
714
|
allowForceBuyBacks: hooksConfigData.allowForceBuyBacks
|
|
640
715
|
};
|
|
641
716
|
}
|
|
642
|
-
else if (
|
|
717
|
+
else if (hooksKind === 2) {
|
|
643
718
|
hooksConfig = {
|
|
644
719
|
kind: types_1.HooksKind.FixedTerm,
|
|
645
720
|
hooksAddress: hooksAddress,
|
|
@@ -648,7 +723,7 @@ class Market extends types_1.ContractWrapper {
|
|
|
648
723
|
transferRequiresAccess: hooksConfigData.transferRequiresAccess,
|
|
649
724
|
transfersDisabled: hooksConfigData.transfersDisabled,
|
|
650
725
|
minimumDeposit: underlyingToken.getAmount(hooksConfigData.minimumDeposit),
|
|
651
|
-
fixedTermEndTime: hooksConfigData.fixedTermEndTime,
|
|
726
|
+
fixedTermEndTime: (0, utils_1.toNumber)(hooksConfigData.fixedTermEndTime),
|
|
652
727
|
queueWithdrawalRequiresAccess: hooksConfigData.withdrawalRequiresAccess,
|
|
653
728
|
allowTermReduction: hooksConfigData.allowTermReduction,
|
|
654
729
|
allowClosureBeforeTerm: hooksConfigData.allowClosureBeforeTerm,
|
|
@@ -656,7 +731,7 @@ class Market extends types_1.ContractWrapper {
|
|
|
656
731
|
};
|
|
657
732
|
}
|
|
658
733
|
else {
|
|
659
|
-
throw Error(`Unknown hooks kind: ${hooks.hooksTemplate.name}, version #${
|
|
734
|
+
throw Error(`Unknown hooks kind: ${hooks.hooksTemplate.name}, version #${hooksKind}`);
|
|
660
735
|
}
|
|
661
736
|
return new Market({
|
|
662
737
|
provider,
|
|
@@ -669,41 +744,43 @@ class Market extends types_1.ContractWrapper {
|
|
|
669
744
|
underlyingToken: underlyingToken,
|
|
670
745
|
borrower: data.borrower,
|
|
671
746
|
feeRecipient: data.feeRecipient,
|
|
672
|
-
protocolFeeBips: data.protocolFeeBips
|
|
673
|
-
delinquencyFeeBips: data.delinquencyFeeBips
|
|
674
|
-
delinquencyGracePeriod: data.delinquencyGracePeriod
|
|
675
|
-
withdrawalBatchDuration: data.withdrawalBatchDuration
|
|
676
|
-
reserveRatioBips: data.reserveRatioBips
|
|
677
|
-
annualInterestBips: data.annualInterestBips
|
|
747
|
+
protocolFeeBips: (0, utils_1.toNumber)(data.protocolFeeBips),
|
|
748
|
+
delinquencyFeeBips: (0, utils_1.toNumber)(data.delinquencyFeeBips),
|
|
749
|
+
delinquencyGracePeriod: (0, utils_1.toNumber)(data.delinquencyGracePeriod),
|
|
750
|
+
withdrawalBatchDuration: (0, utils_1.toNumber)(data.withdrawalBatchDuration),
|
|
751
|
+
reserveRatioBips: (0, utils_1.toNumber)(data.reserveRatioBips),
|
|
752
|
+
annualInterestBips: (0, utils_1.toNumber)(data.annualInterestBips),
|
|
678
753
|
temporaryReserveRatio: data.temporaryReserveRatio,
|
|
679
|
-
originalAnnualInterestBips: data.originalAnnualInterestBips
|
|
680
|
-
originalReserveRatioBips: data.originalReserveRatioBips
|
|
681
|
-
temporaryReserveRatioExpiry: data.temporaryReserveRatioExpiry
|
|
754
|
+
originalAnnualInterestBips: (0, utils_1.toNumber)(data.originalAnnualInterestBips),
|
|
755
|
+
originalReserveRatioBips: (0, utils_1.toNumber)(data.originalReserveRatioBips),
|
|
756
|
+
temporaryReserveRatioExpiry: (0, utils_1.toNumber)(data.temporaryReserveRatioExpiry),
|
|
682
757
|
isClosed: data.isClosed,
|
|
683
|
-
scaleFactor: data.scaleFactor,
|
|
758
|
+
scaleFactor: (0, token_1.toRawAmount)(data.scaleFactor),
|
|
684
759
|
totalSupply: marketToken.getAmount(data.totalSupply),
|
|
685
760
|
maxTotalSupply: marketToken.getAmount(data.maxTotalSupply),
|
|
686
|
-
scaledTotalSupply: data.scaledTotalSupply,
|
|
761
|
+
scaledTotalSupply: (0, token_1.toRawAmount)(data.scaledTotalSupply),
|
|
687
762
|
totalAssets: underlyingToken.getAmount(data.totalAssets),
|
|
688
763
|
lastAccruedProtocolFees: underlyingToken.getAmount(data.lastAccruedProtocolFees),
|
|
689
764
|
normalizedUnclaimedWithdrawals: underlyingToken.getAmount(data.normalizedUnclaimedWithdrawals),
|
|
690
|
-
scaledPendingWithdrawals: data.scaledPendingWithdrawals,
|
|
691
|
-
pendingWithdrawalExpiry: data.pendingWithdrawalExpiry
|
|
765
|
+
scaledPendingWithdrawals: (0, token_1.toRawAmount)(data.scaledPendingWithdrawals),
|
|
766
|
+
pendingWithdrawalExpiry: (0, utils_1.toNumber)(data.pendingWithdrawalExpiry),
|
|
692
767
|
isDelinquent: data.isDelinquent,
|
|
693
|
-
timeDelinquent: data.timeDelinquent
|
|
694
|
-
lastInterestAccruedTimestamp: data.lastInterestAccruedTimestamp
|
|
695
|
-
unpaidWithdrawalBatchExpiries: data.unpaidWithdrawalBatchExpiries,
|
|
768
|
+
timeDelinquent: (0, utils_1.toNumber)(data.timeDelinquent),
|
|
769
|
+
lastInterestAccruedTimestamp: (0, utils_1.toNumber)(data.lastInterestAccruedTimestamp),
|
|
770
|
+
unpaidWithdrawalBatchExpiries: data.unpaidWithdrawalBatchExpiries.map(utils_1.toNumber),
|
|
696
771
|
coverageLiquidity: underlyingToken.getAmount(data.coverageLiquidity),
|
|
697
772
|
signerAddress
|
|
698
773
|
// borrowableAssets: underlyingToken.getAmount(data.borrowableAssets)
|
|
699
774
|
});
|
|
700
775
|
}
|
|
701
|
-
static fromMarketDataV2_5(chainId, provider, {
|
|
776
|
+
static fromMarketDataV2_5(chainId, provider, { market, commitmentFeeBips, drawnAmount }, allowForceBuyBacks, signerAddress) {
|
|
777
|
+
const { hooks, hooksConfig: hooksConfigData, ...data } = market;
|
|
702
778
|
const marketToken = token_1.Token.fromTokenMetadata(chainId, data.marketToken, provider);
|
|
703
779
|
const underlyingToken = token_1.Token.fromTokenMetadata(chainId, data.underlyingToken, provider);
|
|
704
780
|
const { hooksAddress } = hooks;
|
|
705
781
|
let hooksConfig;
|
|
706
|
-
|
|
782
|
+
const hooksKind = (0, utils_1.toNumber)(hooksConfigData.kind);
|
|
783
|
+
if (hooksKind === 1) {
|
|
707
784
|
hooksConfig = {
|
|
708
785
|
kind: types_1.HooksKind.OpenTerm,
|
|
709
786
|
hooksAddress,
|
|
@@ -715,7 +792,7 @@ class Market extends types_1.ContractWrapper {
|
|
|
715
792
|
allowForceBuyBacks
|
|
716
793
|
};
|
|
717
794
|
}
|
|
718
|
-
else if (
|
|
795
|
+
else if (hooksKind === 2) {
|
|
719
796
|
hooksConfig = {
|
|
720
797
|
kind: types_1.HooksKind.FixedTerm,
|
|
721
798
|
hooksAddress,
|
|
@@ -724,7 +801,7 @@ class Market extends types_1.ContractWrapper {
|
|
|
724
801
|
transferRequiresAccess: hooksConfigData.transferRequiresAccess,
|
|
725
802
|
transfersDisabled: hooksConfigData.transfersDisabled,
|
|
726
803
|
minimumDeposit: underlyingToken.getAmount(hooksConfigData.minimumDeposit),
|
|
727
|
-
fixedTermEndTime: hooksConfigData.fixedTermEndTime,
|
|
804
|
+
fixedTermEndTime: (0, utils_1.toNumber)(hooksConfigData.fixedTermEndTime),
|
|
728
805
|
queueWithdrawalRequiresAccess: hooksConfigData.withdrawalRequiresAccess,
|
|
729
806
|
allowTermReduction: hooksConfigData.allowTermReduction,
|
|
730
807
|
allowClosureBeforeTerm: hooksConfigData.allowClosureBeforeTerm,
|
|
@@ -732,7 +809,7 @@ class Market extends types_1.ContractWrapper {
|
|
|
732
809
|
};
|
|
733
810
|
}
|
|
734
811
|
else {
|
|
735
|
-
throw Error(`Unknown hooks kind: ${hooks.hooksTemplate.name}, version #${
|
|
812
|
+
throw Error(`Unknown hooks kind: ${hooks.hooksTemplate.name}, version #${hooksKind}`);
|
|
736
813
|
}
|
|
737
814
|
return new Market({
|
|
738
815
|
provider,
|
|
@@ -745,48 +822,54 @@ class Market extends types_1.ContractWrapper {
|
|
|
745
822
|
underlyingToken,
|
|
746
823
|
borrower: data.borrower,
|
|
747
824
|
feeRecipient: data.feeRecipient,
|
|
748
|
-
protocolFeeBips: data.protocolFeeBips
|
|
749
|
-
delinquencyFeeBips: data.delinquencyFeeBips
|
|
750
|
-
delinquencyGracePeriod: data.delinquencyGracePeriod
|
|
751
|
-
withdrawalBatchDuration: data.withdrawalBatchDuration
|
|
752
|
-
reserveRatioBips: data.reserveRatioBips
|
|
753
|
-
annualInterestBips: data.annualInterestBips
|
|
825
|
+
protocolFeeBips: (0, utils_1.toNumber)(data.protocolFeeBips),
|
|
826
|
+
delinquencyFeeBips: (0, utils_1.toNumber)(data.delinquencyFeeBips),
|
|
827
|
+
delinquencyGracePeriod: (0, utils_1.toNumber)(data.delinquencyGracePeriod),
|
|
828
|
+
withdrawalBatchDuration: (0, utils_1.toNumber)(data.withdrawalBatchDuration),
|
|
829
|
+
reserveRatioBips: (0, utils_1.toNumber)(data.reserveRatioBips),
|
|
830
|
+
annualInterestBips: (0, utils_1.toNumber)(data.annualInterestBips),
|
|
754
831
|
temporaryReserveRatio: data.temporaryReserveRatio,
|
|
755
|
-
originalAnnualInterestBips: data.originalAnnualInterestBips
|
|
756
|
-
originalReserveRatioBips: data.originalReserveRatioBips
|
|
757
|
-
temporaryReserveRatioExpiry: data.temporaryReserveRatioExpiry
|
|
832
|
+
originalAnnualInterestBips: (0, utils_1.toNumber)(data.originalAnnualInterestBips),
|
|
833
|
+
originalReserveRatioBips: (0, utils_1.toNumber)(data.originalReserveRatioBips),
|
|
834
|
+
temporaryReserveRatioExpiry: (0, utils_1.toNumber)(data.temporaryReserveRatioExpiry),
|
|
758
835
|
isClosed: data.isClosed,
|
|
759
|
-
scaleFactor: data.scaleFactor,
|
|
836
|
+
scaleFactor: (0, token_1.toRawAmount)(data.scaleFactor),
|
|
760
837
|
totalSupply: marketToken.getAmount(data.totalSupply),
|
|
761
838
|
maxTotalSupply: marketToken.getAmount(data.maxTotalSupply),
|
|
762
|
-
scaledTotalSupply: data.scaledTotalSupply,
|
|
839
|
+
scaledTotalSupply: (0, token_1.toRawAmount)(data.scaledTotalSupply),
|
|
763
840
|
totalAssets: underlyingToken.getAmount(data.totalAssets),
|
|
764
841
|
lastAccruedProtocolFees: underlyingToken.getAmount(data.lastAccruedProtocolFees),
|
|
765
842
|
normalizedUnclaimedWithdrawals: underlyingToken.getAmount(data.normalizedUnclaimedWithdrawals),
|
|
766
|
-
scaledPendingWithdrawals: data.scaledPendingWithdrawals,
|
|
767
|
-
pendingWithdrawalExpiry: data.pendingWithdrawalExpiry
|
|
843
|
+
scaledPendingWithdrawals: (0, token_1.toRawAmount)(data.scaledPendingWithdrawals),
|
|
844
|
+
pendingWithdrawalExpiry: (0, utils_1.toNumber)(data.pendingWithdrawalExpiry),
|
|
768
845
|
isDelinquent: data.isDelinquent,
|
|
769
|
-
timeDelinquent: data.timeDelinquent
|
|
770
|
-
lastInterestAccruedTimestamp: data.lastInterestAccruedTimestamp
|
|
771
|
-
unpaidWithdrawalBatchExpiries: data.unpaidWithdrawalBatchExpiries,
|
|
846
|
+
timeDelinquent: (0, utils_1.toNumber)(data.timeDelinquent),
|
|
847
|
+
lastInterestAccruedTimestamp: (0, utils_1.toNumber)(data.lastInterestAccruedTimestamp),
|
|
848
|
+
unpaidWithdrawalBatchExpiries: data.unpaidWithdrawalBatchExpiries.map(utils_1.toNumber),
|
|
772
849
|
coverageLiquidity: underlyingToken.getAmount(data.coverageLiquidity),
|
|
850
|
+
commitmentFeeBips: commitmentFeeBips.isPresent
|
|
851
|
+
? (0, utils_1.toNumber)(commitmentFeeBips.value)
|
|
852
|
+
: undefined,
|
|
853
|
+
drawnAmount: drawnAmount.isPresent ? underlyingToken.getAmount(drawnAmount.value) : undefined,
|
|
773
854
|
signerAddress
|
|
774
855
|
});
|
|
775
856
|
}
|
|
776
857
|
static async resolveAllowForceBuyBacks(provider, marketAddress, data) {
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
858
|
+
const marketData = "market" in data ? data.market : data;
|
|
859
|
+
if (marketData.hooksConfig.kind === 1) {
|
|
860
|
+
const hookedMarket = await (0, viem_read_1.readViemContract)((0, ethers_viem_1.getViemPublicClientFromEthers)(provider), marketData.hooksConfig.hooksAddress, abi_1.iOpenTermHooksAbi, "getHookedMarket", [marketAddress]);
|
|
861
|
+
return getAllowForceBuyBacksFromHookedMarket(hookedMarket, 5);
|
|
780
862
|
}
|
|
781
|
-
if (
|
|
782
|
-
const hookedMarket = await
|
|
783
|
-
return hookedMarket
|
|
863
|
+
if (marketData.hooksConfig.kind === 2) {
|
|
864
|
+
const hookedMarket = await (0, viem_read_1.readViemContract)((0, ethers_viem_1.getViemPublicClientFromEthers)(provider), marketData.hooksConfig.hooksAddress, abi_1.iFixedTermHooksAbi, "getHookedMarket", [marketAddress]);
|
|
865
|
+
return getAllowForceBuyBacksFromHookedMarket(hookedMarket, 9);
|
|
784
866
|
}
|
|
785
867
|
return false;
|
|
786
868
|
}
|
|
787
869
|
static async fromUnifiedMarketData(chainId, provider, data, signerAddress) {
|
|
788
|
-
const
|
|
789
|
-
|
|
870
|
+
const marketData = toUnifiedMarketDataV2(data);
|
|
871
|
+
const allowForceBuyBacks = await Market.resolveAllowForceBuyBacks(provider, marketData.market.marketToken.token, marketData);
|
|
872
|
+
return Market.fromMarketDataV2_5(chainId, provider, marketData, allowForceBuyBacks, signerAddress);
|
|
790
873
|
}
|
|
791
874
|
/* -------------------------------------------------------------------------- */
|
|
792
875
|
/* Static Queries */
|
|
@@ -795,62 +878,58 @@ class Market extends types_1.ContractWrapper {
|
|
|
795
878
|
* @returns `Market` instance for `market`
|
|
796
879
|
*/
|
|
797
880
|
static async getMarket(chainId, market, provider) {
|
|
798
|
-
const signerAddress =
|
|
881
|
+
const signerAddress = await (0, ethers_signer_1.getEthersSignerAddress)(provider);
|
|
799
882
|
if (hasUnifiedLatestLensForDirectReads(chainId)) {
|
|
800
883
|
try {
|
|
801
|
-
const data = await (0,
|
|
884
|
+
const data = await (0, market_lens_1.getUnifiedMarketDataV2)(chainId, provider, market);
|
|
802
885
|
return Market.fromUnifiedMarketData(chainId, provider, data, signerAddress);
|
|
803
886
|
}
|
|
804
887
|
catch (_) {
|
|
805
888
|
// Fall back to the legacy lens for V1 markets and pre-unified deployments.
|
|
806
889
|
}
|
|
807
890
|
}
|
|
808
|
-
const
|
|
809
|
-
const data = await lens.getMarketData(market);
|
|
891
|
+
const data = await (0, market_lens_1.getLegacyMarketData)(chainId, provider, market);
|
|
810
892
|
return Market.fromMarketData(chainId, data, provider, signerAddress);
|
|
811
893
|
}
|
|
812
894
|
/**
|
|
813
895
|
* @returns `Market` instance for `market`
|
|
814
896
|
*/
|
|
815
897
|
static async getMarketV2(chainId, market, provider) {
|
|
816
|
-
const signerAddress =
|
|
898
|
+
const signerAddress = await (0, ethers_signer_1.getEthersSignerAddress)(provider);
|
|
817
899
|
if (hasUnifiedLatestLensForDirectReads(chainId)) {
|
|
818
900
|
try {
|
|
819
|
-
const data = await (0,
|
|
901
|
+
const data = await (0, market_lens_1.getUnifiedMarketDataV2)(chainId, provider, market);
|
|
820
902
|
return Market.fromUnifiedMarketData(chainId, provider, data, signerAddress);
|
|
821
903
|
}
|
|
822
904
|
catch (_) {
|
|
823
905
|
// Fall back to the pre-2.5 V2 lens for chains that have not fully migrated.
|
|
824
906
|
}
|
|
825
907
|
}
|
|
826
|
-
const
|
|
827
|
-
const data = await lens.getMarketData(market);
|
|
908
|
+
const data = await (0, market_lens_1.getV2MarketData)(chainId, provider, market);
|
|
828
909
|
return Market.fromMarketDataV2(chainId, provider, data, signerAddress);
|
|
829
910
|
}
|
|
830
911
|
/**
|
|
831
912
|
* @returns `Market` instances for `markets`
|
|
832
913
|
*/
|
|
833
914
|
static async getMarkets(chainId, markets, provider) {
|
|
834
|
-
const signerAddress =
|
|
915
|
+
const signerAddress = await (0, ethers_signer_1.getEthersSignerAddress)(provider);
|
|
835
916
|
if (hasUnifiedLatestLensForDirectReads(chainId)) {
|
|
836
917
|
try {
|
|
837
|
-
const data = await (0,
|
|
918
|
+
const data = await (0, market_lens_1.getUnifiedMarketsDataV2)(chainId, provider, markets);
|
|
838
919
|
return Promise.all(data.map((market) => Market.fromUnifiedMarketData(chainId, provider, market, signerAddress)));
|
|
839
920
|
}
|
|
840
921
|
catch (_) {
|
|
841
922
|
return Promise.all(markets.map((market) => Market.getMarket(chainId, market, provider)));
|
|
842
923
|
}
|
|
843
924
|
}
|
|
844
|
-
const
|
|
845
|
-
const data = await lens.getMarketsData(markets);
|
|
925
|
+
const data = await (0, market_lens_1.getLegacyMarketsData)(chainId, provider, markets);
|
|
846
926
|
return data.map((market) => Market.fromMarketData(chainId, market, provider, signerAddress));
|
|
847
927
|
}
|
|
848
928
|
/**
|
|
849
929
|
* @return All deployed markets
|
|
850
930
|
*/
|
|
851
931
|
static async getAllMarkets(chainId, provider) {
|
|
852
|
-
const
|
|
853
|
-
const markets = await archController["getRegisteredMarkets()"]();
|
|
932
|
+
const markets = await (0, arch_controller_1.getRegisteredMarkets)(chainId, provider);
|
|
854
933
|
if (!markets.length) {
|
|
855
934
|
return [];
|
|
856
935
|
}
|
|
@@ -863,13 +942,12 @@ class Market extends types_1.ContractWrapper {
|
|
|
863
942
|
if (count <= 0) {
|
|
864
943
|
return [];
|
|
865
944
|
}
|
|
866
|
-
const
|
|
867
|
-
const totalMarkets = (await archController.getRegisteredMarketsCount()).toNumber();
|
|
945
|
+
const totalMarkets = await (0, arch_controller_1.getRegisteredMarketsCount)(chainId, provider);
|
|
868
946
|
if (start >= totalMarkets) {
|
|
869
947
|
return [];
|
|
870
948
|
}
|
|
871
949
|
const end = Math.min(start + count, totalMarkets);
|
|
872
|
-
const markets = await
|
|
950
|
+
const markets = await (0, arch_controller_1.getRegisteredMarketsPage)(chainId, provider, start, end);
|
|
873
951
|
if (!markets.length) {
|
|
874
952
|
return [];
|
|
875
953
|
}
|
|
@@ -879,8 +957,7 @@ class Market extends types_1.ContractWrapper {
|
|
|
879
957
|
* @return Total number of deployed markets.
|
|
880
958
|
*/
|
|
881
959
|
static async getMarketsCount(chainId, provider) {
|
|
882
|
-
|
|
883
|
-
return archController.getRegisteredMarketsCount().then((count) => count.toNumber());
|
|
960
|
+
return (0, arch_controller_1.getRegisteredMarketsCount)(chainId, provider);
|
|
884
961
|
}
|
|
885
962
|
}
|
|
886
963
|
exports.Market = Market;
|