@wildcatfi/wildcat-sdk 3.0.76-beta → 3.1.1-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/access/access-control.d.ts +23 -36
- package/dist/access/access-control.d.ts.map +1 -1
- package/dist/access/access-control.js +104 -142
- package/dist/access/access-control.js.map +1 -1
- package/dist/access/fixed-term.d.ts +23 -36
- package/dist/access/fixed-term.d.ts.map +1 -1
- package/dist/access/fixed-term.js +115 -154
- package/dist/access/fixed-term.js.map +1 -1
- package/dist/access/index.d.ts +9 -15
- package/dist/access/index.d.ts.map +1 -1
- package/dist/access/index.js +21 -59
- package/dist/access/index.js.map +1 -1
- package/dist/access/periodic-term.d.ts +84 -0
- package/dist/access/periodic-term.d.ts.map +1 -0
- package/dist/access/periodic-term.js +298 -0
- package/dist/access/periodic-term.js.map +1 -0
- package/dist/access/utils.d.ts +1 -11
- package/dist/access/utils.d.ts.map +1 -1
- package/dist/access/utils.js +11 -87
- package/dist/access/utils.js.map +1 -1
- package/dist/access/validation.d.ts +8 -32
- package/dist/access/validation.d.ts.map +1 -1
- package/dist/access/validation.js +1 -18
- package/dist/access/validation.js.map +1 -1
- package/dist/account/index.d.ts +39 -35
- package/dist/account/index.d.ts.map +1 -1
- package/dist/account/index.js +301 -315
- package/dist/account/index.js.map +1 -1
- package/dist/account/validation.d.ts +19 -3
- package/dist/account/validation.d.ts.map +1 -1
- package/dist/account/validation.js +16 -2
- package/dist/account/validation.js.map +1 -1
- package/dist/collateral/collateral-events.d.ts +10 -9
- 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 +10 -7
- package/dist/collateral/index.d.ts.map +1 -1
- package/dist/collateral/index.js +37 -36
- package/dist/collateral/index.js.map +1 -1
- package/dist/constants.d.ts +13 -100
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +27 -290
- package/dist/constants.js.map +1 -1
- package/dist/controller.d.ts +17 -10
- package/dist/controller.d.ts.map +1 -1
- package/dist/controller.js +67 -67
- package/dist/controller.js.map +1 -1
- package/dist/gql/getActiveLendersByMarket.d.ts +4 -5
- package/dist/gql/getActiveLendersByMarket.d.ts.map +1 -1
- package/dist/gql/getActiveLendersByMarket.js +10 -11
- package/dist/gql/getActiveLendersByMarket.js.map +1 -1
- package/dist/gql/getAllHooksDataForBorrower.d.ts.map +1 -1
- package/dist/gql/getAllHooksDataForBorrower.js +8 -11
- package/dist/gql/getAllHooksDataForBorrower.js.map +1 -1
- package/dist/gql/getAllHooksTemplates.d.ts.map +1 -1
- package/dist/gql/getAllHooksTemplates.js +4 -6
- package/dist/gql/getAllHooksTemplates.js.map +1 -1
- package/dist/gql/getLenderAccountsForAllMarkets.d.ts +1 -8
- package/dist/gql/getLenderAccountsForAllMarkets.d.ts.map +1 -1
- package/dist/gql/getLenderAccountsForAllMarkets.js +11 -26
- package/dist/gql/getLenderAccountsForAllMarkets.js.map +1 -1
- package/dist/gql/getMarketRecords.d.ts +2 -2
- package/dist/gql/getMarketRecords.d.ts.map +1 -1
- package/dist/gql/getMarketRecords.js +6 -2
- package/dist/gql/getMarketRecords.js.map +1 -1
- package/dist/gql/getMarketsForBorrower.d.ts.map +1 -1
- package/dist/gql/getMarketsForBorrower.js +2 -32
- package/dist/gql/getMarketsForBorrower.js.map +1 -1
- package/dist/gql/getMarketsWithEvents.d.ts.map +1 -1
- package/dist/gql/getMarketsWithEvents.js +0 -28
- package/dist/gql/getMarketsWithEvents.js.map +1 -1
- package/dist/gql/graphql.d.ts +678 -1480
- package/dist/gql/graphql.d.ts.map +1 -1
- package/dist/gql/graphql.js +243 -591
- package/dist/gql/graphql.js.map +1 -1
- package/dist/gql/index.d.ts +0 -2
- package/dist/gql/index.d.ts.map +1 -1
- package/dist/gql/index.js +0 -2
- package/dist/gql/index.js.map +1 -1
- package/dist/index.d.ts +4 -6
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +17 -8
- package/dist/index.js.map +1 -1
- package/dist/market.d.ts +22 -73
- package/dist/market.d.ts.map +1 -1
- package/dist/market.js +284 -582
- package/dist/market.js.map +1 -1
- package/dist/mockerc20factory.d.ts +11 -4
- package/dist/mockerc20factory.d.ts.map +1 -1
- package/dist/mockerc20factory.js +15 -20
- package/dist/mockerc20factory.js.map +1 -1
- package/dist/token.d.ts +12 -54
- package/dist/token.d.ts.map +1 -1
- package/dist/token.js +57 -148
- package/dist/token.js.map +1 -1
- package/dist/typechain/AccountQuery.d.ts +54 -0
- package/dist/typechain/AccountQuery.d.ts.map +1 -0
- package/dist/typechain/AccountQuery.js +3 -0
- package/dist/typechain/AccountQuery.js.map +1 -0
- package/dist/typechain/AccountsQuery.d.ts +54 -0
- package/dist/typechain/AccountsQuery.d.ts.map +1 -0
- package/dist/typechain/AccountsQuery.js +3 -0
- package/dist/typechain/AccountsQuery.js.map +1 -0
- package/dist/typechain/CheckBorrowersRegistered.d.ts +29 -0
- package/dist/typechain/CheckBorrowersRegistered.d.ts.map +1 -0
- package/dist/typechain/CheckBorrowersRegistered.js +3 -0
- package/dist/typechain/CheckBorrowersRegistered.js.map +1 -0
- package/dist/typechain/CheckSafeSignature.d.ts +29 -0
- package/dist/typechain/CheckSafeSignature.d.ts.map +1 -0
- package/dist/typechain/CheckSafeSignature.js +3 -0
- package/dist/typechain/CheckSafeSignature.js.map +1 -0
- package/dist/typechain/CollateralLens.d.ts +220 -0
- package/dist/typechain/CollateralLens.d.ts.map +1 -0
- package/dist/typechain/CollateralLens.js +3 -0
- package/dist/typechain/CollateralLens.js.map +1 -0
- package/dist/typechain/DescribeSignature.d.ts +100 -0
- package/dist/typechain/DescribeSignature.d.ts.map +1 -0
- package/dist/typechain/DescribeSignature.js +3 -0
- package/dist/typechain/DescribeSignature.js.map +1 -0
- package/dist/typechain/HooksFactory.d.ts +591 -16
- package/dist/typechain/HooksFactory.d.ts.map +1 -1
- package/dist/typechain/IERC20.d.ts +232 -0
- package/dist/typechain/IERC20.d.ts.map +1 -0
- package/dist/{lens-types.js → typechain/IERC20.js} +1 -1
- package/dist/typechain/IERC20.js.map +1 -0
- package/dist/typechain/IFixedTermHooks.d.ts +1032 -0
- package/dist/typechain/IFixedTermHooks.d.ts.map +1 -0
- package/dist/typechain/IFixedTermHooks.js +3 -0
- package/dist/typechain/IFixedTermHooks.js.map +1 -0
- package/dist/typechain/IOpenTermHooks.d.ts +987 -0
- package/dist/typechain/IOpenTermHooks.d.ts.map +1 -0
- package/dist/typechain/IOpenTermHooks.js +3 -0
- package/dist/typechain/IOpenTermHooks.js.map +1 -0
- package/dist/typechain/IPeriodicTermHooks.d.ts +663 -0
- package/dist/typechain/IPeriodicTermHooks.d.ts.map +1 -0
- package/dist/typechain/IPeriodicTermHooks.js +3 -0
- package/dist/typechain/IPeriodicTermHooks.js.map +1 -0
- package/dist/typechain/ISafe.d.ts +124 -0
- package/dist/typechain/ISafe.d.ts.map +1 -0
- package/dist/typechain/ISafe.js +3 -0
- package/dist/typechain/ISafe.js.map +1 -0
- package/dist/typechain/MarketLens.d.ts +611 -0
- package/dist/typechain/MarketLens.d.ts.map +1 -0
- package/dist/typechain/MarketLens.js +3 -0
- package/dist/typechain/MarketLens.js.map +1 -0
- package/dist/typechain/MarketLensV2.d.ts +710 -0
- package/dist/typechain/MarketLensV2.d.ts.map +1 -0
- package/dist/typechain/MarketLensV2.js +3 -0
- package/dist/typechain/MarketLensV2.js.map +1 -0
- package/dist/typechain/MockArchControllerOwner.d.ts +130 -0
- package/dist/typechain/MockArchControllerOwner.d.ts.map +1 -0
- package/dist/typechain/MockArchControllerOwner.js +3 -0
- package/dist/typechain/MockArchControllerOwner.js.map +1 -0
- package/dist/typechain/MockERC20Factory.d.ts +122 -0
- package/dist/typechain/MockERC20Factory.d.ts.map +1 -0
- package/dist/typechain/MockERC20Factory.js +3 -0
- package/dist/typechain/MockERC20Factory.js.map +1 -0
- package/dist/typechain/SimpleMarketCollateral.d.ts +270 -0
- package/dist/typechain/SimpleMarketCollateral.d.ts.map +1 -0
- package/dist/typechain/SimpleMarketCollateral.js +3 -0
- package/dist/typechain/SimpleMarketCollateral.js.map +1 -0
- package/dist/typechain/WildcatArchController.d.ts +545 -0
- package/dist/typechain/WildcatArchController.d.ts.map +1 -0
- package/dist/typechain/WildcatArchController.js +3 -0
- package/dist/typechain/WildcatArchController.js.map +1 -0
- package/dist/typechain/WildcatCollateralFactory.d.ts +164 -0
- package/dist/typechain/WildcatCollateralFactory.d.ts.map +1 -0
- package/dist/typechain/WildcatCollateralFactory.js +3 -0
- package/dist/typechain/WildcatCollateralFactory.js.map +1 -0
- package/dist/typechain/WildcatMarket.d.ts +1062 -0
- package/dist/typechain/WildcatMarket.d.ts.map +1 -0
- package/dist/typechain/WildcatMarket.js +3 -0
- package/dist/typechain/WildcatMarket.js.map +1 -0
- package/dist/typechain/WildcatMarketController.d.ts +553 -0
- package/dist/typechain/WildcatMarketController.d.ts.map +1 -0
- package/dist/typechain/WildcatMarketController.js +3 -0
- package/dist/typechain/WildcatMarketController.js.map +1 -0
- package/dist/typechain/WildcatMarketControllerFactory.d.ts +344 -0
- package/dist/typechain/WildcatMarketControllerFactory.d.ts.map +1 -0
- package/dist/typechain/WildcatMarketControllerFactory.js +3 -0
- package/dist/typechain/WildcatMarketControllerFactory.js.map +1 -0
- package/dist/typechain/WildcatMarketV2.d.ts +1086 -0
- package/dist/typechain/WildcatMarketV2.d.ts.map +1 -0
- package/dist/typechain/WildcatMarketV2.js +3 -0
- package/dist/typechain/WildcatMarketV2.js.map +1 -0
- package/dist/typechain/common.d.ts +23 -0
- package/dist/typechain/common.d.ts.map +1 -0
- package/dist/typechain/common.js +3 -0
- package/dist/typechain/common.js.map +1 -0
- package/dist/typechain/factories/AccountQuery__factory.d.ts +59 -0
- package/dist/typechain/factories/AccountQuery__factory.d.ts.map +1 -0
- package/dist/typechain/factories/AccountQuery__factory.js +91 -0
- package/dist/typechain/factories/AccountQuery__factory.js.map +1 -0
- package/dist/typechain/factories/AccountsQuery__factory.d.ts +59 -0
- package/dist/typechain/factories/AccountsQuery__factory.d.ts.map +1 -0
- package/dist/typechain/factories/AccountsQuery__factory.js +91 -0
- package/dist/typechain/factories/AccountsQuery__factory.js.map +1 -0
- package/dist/typechain/factories/CheckBorrowersRegistered__factory.d.ts +36 -0
- package/dist/typechain/factories/CheckBorrowersRegistered__factory.d.ts.map +1 -0
- package/dist/typechain/factories/CheckBorrowersRegistered__factory.js +60 -0
- package/dist/typechain/factories/CheckBorrowersRegistered__factory.js.map +1 -0
- package/dist/typechain/factories/CheckSafeSignature__factory.d.ts +40 -0
- package/dist/typechain/factories/CheckSafeSignature__factory.d.ts.map +1 -0
- package/dist/typechain/factories/CheckSafeSignature__factory.js +65 -0
- package/dist/typechain/factories/CheckSafeSignature__factory.js.map +1 -0
- package/dist/typechain/factories/CollateralLens__factory.d.ts +854 -0
- package/dist/typechain/factories/CollateralLens__factory.d.ts.map +1 -0
- package/dist/typechain/factories/CollateralLens__factory.js +1101 -0
- package/dist/typechain/factories/CollateralLens__factory.js.map +1 -0
- package/dist/typechain/factories/DescribeSignature__factory.d.ts +141 -0
- package/dist/typechain/factories/DescribeSignature__factory.d.ts.map +1 -0
- package/dist/typechain/factories/DescribeSignature__factory.js +198 -0
- package/dist/typechain/factories/DescribeSignature__factory.js.map +1 -0
- package/dist/typechain/factories/HooksFactory__factory.d.ts +902 -0
- package/dist/typechain/factories/HooksFactory__factory.d.ts.map +1 -0
- package/dist/typechain/factories/HooksFactory__factory.js +1168 -0
- package/dist/typechain/factories/HooksFactory__factory.js.map +1 -0
- package/dist/typechain/factories/IERC20__factory.d.ts +235 -0
- package/dist/typechain/factories/IERC20__factory.d.ts.map +1 -0
- package/dist/typechain/factories/IERC20__factory.js +315 -0
- package/dist/typechain/factories/IERC20__factory.js.map +1 -0
- package/dist/typechain/factories/IFixedTermHooks__factory.d.ts +1894 -0
- package/dist/typechain/factories/IFixedTermHooks__factory.d.ts.map +1 -0
- package/dist/typechain/factories/IFixedTermHooks__factory.js +2423 -0
- package/dist/typechain/factories/IFixedTermHooks__factory.js.map +1 -0
- package/dist/typechain/factories/IOpenTermHooks__factory.d.ts +1791 -0
- package/dist/typechain/factories/IOpenTermHooks__factory.d.ts.map +1 -0
- package/dist/typechain/factories/IOpenTermHooks__factory.js +2293 -0
- package/dist/typechain/factories/IOpenTermHooks__factory.js.map +1 -0
- package/dist/typechain/factories/IPeriodicTermHooks__factory.d.ts +750 -0
- package/dist/typechain/factories/IPeriodicTermHooks__factory.d.ts.map +1 -0
- package/dist/typechain/factories/IPeriodicTermHooks__factory.js +975 -0
- package/dist/typechain/factories/IPeriodicTermHooks__factory.js.map +1 -0
- package/dist/typechain/factories/ISafe__factory.d.ts +163 -0
- package/dist/typechain/factories/ISafe__factory.d.ts.map +1 -0
- package/dist/typechain/factories/ISafe__factory.js +225 -0
- package/dist/typechain/factories/ISafe__factory.js.map +1 -0
- package/dist/typechain/factories/MarketLensV2__factory.d.ts +6708 -0
- package/dist/typechain/factories/MarketLensV2__factory.d.ts.map +1 -0
- package/dist/typechain/factories/MarketLensV2__factory.js +8574 -0
- package/dist/typechain/factories/MarketLensV2__factory.js.map +1 -0
- package/dist/typechain/factories/MarketLens__factory.d.ts +3572 -0
- package/dist/typechain/factories/MarketLens__factory.d.ts.map +1 -0
- package/dist/typechain/factories/MarketLens__factory.js +4569 -0
- package/dist/typechain/factories/MarketLens__factory.js.map +1 -0
- package/dist/typechain/factories/MockArchControllerOwner__factory.d.ts +85 -0
- package/dist/typechain/factories/MockArchControllerOwner__factory.d.ts.map +1 -0
- package/dist/typechain/factories/MockArchControllerOwner__factory.js +118 -0
- package/dist/typechain/factories/MockArchControllerOwner__factory.js.map +1 -0
- package/dist/typechain/factories/MockERC20Factory__factory.d.ts +114 -0
- package/dist/typechain/factories/MockERC20Factory__factory.d.ts.map +1 -0
- package/dist/typechain/factories/MockERC20Factory__factory.js +157 -0
- package/dist/typechain/factories/MockERC20Factory__factory.js.map +1 -0
- package/dist/typechain/factories/SimpleMarketCollateral__factory.d.ts +264 -0
- package/dist/typechain/factories/SimpleMarketCollateral__factory.d.ts.map +1 -0
- package/dist/typechain/factories/SimpleMarketCollateral__factory.js +354 -0
- package/dist/typechain/factories/SimpleMarketCollateral__factory.js.map +1 -0
- package/dist/typechain/factories/WildcatArchController__factory.d.ts +554 -0
- package/dist/typechain/factories/WildcatArchController__factory.d.ts.map +1 -0
- package/dist/typechain/factories/WildcatArchController__factory.js +728 -0
- package/dist/typechain/factories/WildcatArchController__factory.js.map +1 -0
- package/dist/typechain/factories/WildcatCollateralFactory__factory.d.ts +160 -0
- package/dist/typechain/factories/WildcatCollateralFactory__factory.d.ts.map +1 -0
- package/dist/typechain/factories/WildcatCollateralFactory__factory.js +223 -0
- package/dist/typechain/factories/WildcatCollateralFactory__factory.js.map +1 -0
- package/dist/typechain/factories/WildcatMarketControllerFactory__factory.d.ts +421 -0
- package/dist/typechain/factories/WildcatMarketControllerFactory__factory.d.ts.map +1 -0
- package/dist/typechain/factories/WildcatMarketControllerFactory__factory.js +549 -0
- package/dist/typechain/factories/WildcatMarketControllerFactory__factory.js.map +1 -0
- package/dist/typechain/factories/WildcatMarketController__factory.d.ts +671 -0
- package/dist/typechain/factories/WildcatMarketController__factory.d.ts.map +1 -0
- package/dist/typechain/factories/WildcatMarketController__factory.js +870 -0
- package/dist/typechain/factories/WildcatMarketController__factory.js.map +1 -0
- package/dist/typechain/factories/WildcatMarketV2__factory.d.ts +1304 -0
- package/dist/typechain/factories/WildcatMarketV2__factory.d.ts.map +1 -0
- package/dist/typechain/factories/WildcatMarketV2__factory.js +1680 -0
- package/dist/typechain/factories/WildcatMarketV2__factory.js.map +1 -0
- package/dist/typechain/factories/WildcatMarket__factory.d.ts +1326 -0
- package/dist/typechain/factories/WildcatMarket__factory.d.ts.map +1 -0
- package/dist/typechain/factories/WildcatMarket__factory.js +1712 -0
- package/dist/typechain/factories/WildcatMarket__factory.js.map +1 -0
- package/dist/typechain/factories/index.d.ts +24 -0
- package/dist/typechain/factories/index.d.ts.map +1 -0
- package/dist/typechain/factories/index.js +53 -0
- package/dist/typechain/factories/index.js.map +1 -0
- package/dist/typechain/index.d.ts +60 -84
- package/dist/typechain/index.d.ts.map +1 -1
- package/dist/typechain/index.js +71 -120
- package/dist/typechain/index.js.map +1 -1
- package/dist/types.d.ts +34 -75
- package/dist/types.d.ts.map +1 -1
- package/dist/types.js +16 -21
- package/dist/types.js.map +1 -1
- package/dist/utils/check-registered-borrowers.d.ts.map +1 -1
- package/dist/utils/check-registered-borrowers.js +6 -7
- package/dist/utils/check-registered-borrowers.js.map +1 -1
- package/dist/utils/describe-account.d.ts +2 -5
- package/dist/utils/describe-account.d.ts.map +1 -1
- package/dist/utils/describe-account.js +8 -38
- package/dist/utils/describe-account.js.map +1 -1
- package/dist/utils/describe-signature.d.ts +1 -1
- package/dist/utils/describe-signature.d.ts.map +1 -1
- package/dist/utils/describe-signature.js +25 -80
- package/dist/utils/describe-signature.js.map +1 -1
- package/dist/utils/index.d.ts +0 -2
- package/dist/utils/index.d.ts.map +1 -1
- package/dist/utils/index.js +0 -2
- package/dist/utils/index.js.map +1 -1
- package/dist/utils/logger.d.ts.map +1 -1
- package/dist/utils/logger.js +1 -0
- package/dist/utils/logger.js.map +1 -1
- package/dist/utils/math.d.ts +13 -1
- package/dist/utils/math.d.ts.map +1 -1
- package/dist/utils/math.js +50 -14
- package/dist/utils/math.js.map +1 -1
- package/dist/utils/misc.d.ts +4 -5
- 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 +10 -7
- 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 +3 -9
- package/dist/utils/type-parsers.d.ts.map +1 -1
- package/dist/utils/type-parsers.js +13 -12
- package/dist/utils/type-parsers.js.map +1 -1
- package/dist/withdrawal-batch.d.ts +9 -12
- package/dist/withdrawal-batch.d.ts.map +1 -1
- package/dist/withdrawal-batch.js +30 -46
- package/dist/withdrawal-batch.js.map +1 -1
- package/dist/withdrawal-status.d.ts +7 -12
- package/dist/withdrawal-status.d.ts.map +1 -1
- package/dist/withdrawal-status.js +12 -29
- package/dist/withdrawal-status.js.map +1 -1
- package/package.json +12 -20
- package/dist/abi/generated.d.ts +0 -34504
- package/dist/abi/generated.d.ts.map +0 -1
- package/dist/abi/generated.js +0 -44192
- package/dist/abi/generated.js.map +0 -1
- package/dist/abi/index.d.ts +0 -3
- package/dist/abi/index.d.ts.map +0 -1
- package/dist/abi/index.js +0 -19
- package/dist/abi/index.js.map +0 -1
- package/dist/abi/manual.d.ts +0 -354
- package/dist/abi/manual.d.ts.map +0 -1
- package/dist/abi/manual.js +0 -202
- package/dist/abi/manual.js.map +0 -1
- package/dist/access/revolving.d.ts +0 -8
- package/dist/access/revolving.d.ts.map +0 -1
- package/dist/access/revolving.js +0 -15
- package/dist/access/revolving.js.map +0 -1
- package/dist/access/subgraph-template.d.ts +0 -14
- package/dist/access/subgraph-template.d.ts.map +0 -1
- package/dist/access/subgraph-template.js +0 -20
- package/dist/access/subgraph-template.js.map +0 -1
- package/dist/client.d.ts +0 -22
- package/dist/client.d.ts.map +0 -1
- package/dist/client.js +0 -51
- package/dist/client.js.map +0 -1
- package/dist/gql/getMarketChartsData.d.ts +0 -35
- package/dist/gql/getMarketChartsData.d.ts.map +0 -1
- package/dist/gql/getMarketChartsData.js +0 -56
- package/dist/gql/getMarketChartsData.js.map +0 -1
- package/dist/gql/getMarketList.d.ts +0 -16
- package/dist/gql/getMarketList.d.ts.map +0 -1
- package/dist/gql/getMarketList.js +0 -23
- package/dist/gql/getMarketList.js.map +0 -1
- package/dist/internal/arch-controller.d.ts +0 -6
- package/dist/internal/arch-controller.d.ts.map +0 -1
- package/dist/internal/arch-controller.js +0 -36
- package/dist/internal/arch-controller.js.map +0 -1
- package/dist/internal/ethers-signer.d.ts +0 -4
- package/dist/internal/ethers-signer.d.ts.map +0 -1
- package/dist/internal/ethers-signer.js +0 -12
- package/dist/internal/ethers-signer.js.map +0 -1
- package/dist/internal/ethers-viem.d.ts +0 -4
- package/dist/internal/ethers-viem.d.ts.map +0 -1
- package/dist/internal/ethers-viem.js +0 -43
- package/dist/internal/ethers-viem.js.map +0 -1
- package/dist/internal/market-lens.d.ts +0 -28
- package/dist/internal/market-lens.d.ts.map +0 -1
- package/dist/internal/market-lens.js +0 -125
- package/dist/internal/market-lens.js.map +0 -1
- package/dist/internal/viem-read.d.ts +0 -3
- package/dist/internal/viem-read.d.ts.map +0 -1
- package/dist/internal/viem-read.js +0 -13
- package/dist/internal/viem-read.js.map +0 -1
- package/dist/internal/viem-write.d.ts +0 -10
- package/dist/internal/viem-write.d.ts.map +0 -1
- package/dist/internal/viem-write.js +0 -51
- package/dist/internal/viem-write.js.map +0 -1
- package/dist/lens-types.d.ts +0 -309
- package/dist/lens-types.d.ts.map +0 -1
- package/dist/lens-types.js.map +0 -1
- package/dist/utils/bigint.d.ts +0 -22
- package/dist/utils/bigint.d.ts.map +0 -1
- package/dist/utils/bigint.js +0 -111
- package/dist/utils/bigint.js.map +0 -1
- package/dist/utils/viem-encoding.d.ts +0 -15
- package/dist/utils/viem-encoding.d.ts.map +0 -1
- package/dist/utils/viem-encoding.js +0 -33
- package/dist/utils/viem-encoding.js.map +0 -1
- package/dist/wrapper/index.d.ts +0 -94
- package/dist/wrapper/index.d.ts.map +0 -1
- package/dist/wrapper/index.js +0 -296
- package/dist/wrapper/index.js.map +0 -1
package/dist/account/index.js
CHANGED
|
@@ -15,18 +15,15 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
17
|
exports.MarketAccount = exports.LenderRole = void 0;
|
|
18
|
+
const ethers_1 = require("ethers");
|
|
18
19
|
const token_1 = require("../token");
|
|
19
20
|
const market_1 = require("../market");
|
|
21
|
+
const typechain_1 = require("../typechain");
|
|
20
22
|
const utils_1 = require("../utils");
|
|
21
23
|
const constants_1 = require("../constants");
|
|
22
|
-
const arch_controller_1 = require("../internal/arch-controller");
|
|
23
|
-
const market_lens_1 = require("../internal/market-lens");
|
|
24
24
|
const types_1 = require("../types");
|
|
25
25
|
const withdrawal_status_1 = require("../withdrawal-status");
|
|
26
26
|
const validation_1 = require("./validation");
|
|
27
|
-
const abi_1 = require("../abi");
|
|
28
|
-
const viem_write_1 = require("../internal/viem-write");
|
|
29
|
-
const viem_1 = require("viem");
|
|
30
27
|
__exportStar(require("./validation"), exports);
|
|
31
28
|
var LenderRole;
|
|
32
29
|
(function (LenderRole) {
|
|
@@ -35,18 +32,7 @@ var LenderRole;
|
|
|
35
32
|
LenderRole[LenderRole["WithdrawOnly"] = 2] = "WithdrawOnly";
|
|
36
33
|
LenderRole[LenderRole["DepositAndWithdraw"] = 3] = "DepositAndWithdraw";
|
|
37
34
|
})(LenderRole = exports.LenderRole || (exports.LenderRole = {}));
|
|
38
|
-
const NullProviderIndex = 2
|
|
39
|
-
const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
40
|
-
const hasUnifiedLatestLensForAccountReads = (chainId) => {
|
|
41
|
-
return (0, constants_1.hasDeploymentAddress)(chainId, "MarketLensV2_5");
|
|
42
|
-
};
|
|
43
|
-
const zeroLenderBalances = (info) => ({
|
|
44
|
-
...info,
|
|
45
|
-
scaledBalance: 0n,
|
|
46
|
-
normalizedBalance: 0n,
|
|
47
|
-
underlyingBalance: 0n,
|
|
48
|
-
underlyingApproval: 0n
|
|
49
|
-
});
|
|
35
|
+
const NullProviderIndex = ethers_1.BigNumber.from(2).pow(24).sub(1).toNumber();
|
|
50
36
|
/**
|
|
51
37
|
* Class to provide information about a market user's account
|
|
52
38
|
* and to wrap interactions.
|
|
@@ -150,6 +136,9 @@ class MarketAccount {
|
|
|
150
136
|
// Can not withdraw if market in fixed term
|
|
151
137
|
if (this.market.isInFixedTerm)
|
|
152
138
|
return validation_1.QueueWithdrawalStatus.MarketInClosedTerm;
|
|
139
|
+
if (config.kind === types_1.HooksKind.PeriodicTerm && !this.market.isPeriodicWithdrawalWindowOpen) {
|
|
140
|
+
return validation_1.QueueWithdrawalStatus.OutsideWithdrawalWindow;
|
|
141
|
+
}
|
|
153
142
|
// Can not withdraw if market requires access and lender has no credential and is not a known lender
|
|
154
143
|
if (config.flags.useOnQueueWithdrawal &&
|
|
155
144
|
(config.kind === types_1.HooksKind.OpenTerm || config.queueWithdrawalRequiresAccess) &&
|
|
@@ -215,6 +204,27 @@ class MarketAccount {
|
|
|
215
204
|
return { status: validation_1.SetAprStatus.NotBorrower };
|
|
216
205
|
if (!(apr > 0 && apr <= 10000))
|
|
217
206
|
return { status: validation_1.SetAprStatus.InvalidApr };
|
|
207
|
+
if (this.market.version === types_1.MarketVersion.V2 &&
|
|
208
|
+
this.market.hooksConfig?.kind === types_1.HooksKind.PeriodicTerm &&
|
|
209
|
+
apr < this.market.annualInterestBips) {
|
|
210
|
+
const config = this.market.hooksConfig;
|
|
211
|
+
if (config.pendingAnnualInterestProposalTimestamp === 0) {
|
|
212
|
+
return { status: validation_1.SetAprStatus.NoPendingAprChange };
|
|
213
|
+
}
|
|
214
|
+
if (config.pendingAnnualInterestBips !== apr) {
|
|
215
|
+
return { status: validation_1.SetAprStatus.AprChangeDoesNotMatchProposal };
|
|
216
|
+
}
|
|
217
|
+
if (Math.floor(Date.now() / 1000) < config.pendingAnnualInterestResponseWindowEnd) {
|
|
218
|
+
return { status: validation_1.SetAprStatus.AprChangeNotReady };
|
|
219
|
+
}
|
|
220
|
+
if (!this.market.scaledPendingWithdrawals.isZero()) {
|
|
221
|
+
return { status: validation_1.SetAprStatus.UnpaidWithdrawalsExist };
|
|
222
|
+
}
|
|
223
|
+
return {
|
|
224
|
+
status: validation_1.SetAprStatus.Ready,
|
|
225
|
+
willChangeReserveRatio: false
|
|
226
|
+
};
|
|
227
|
+
}
|
|
218
228
|
const [originalReserveRatioBips, originalAnnualInterestBips] = this.market.originalReserveRatioAndAnnualInterestBips;
|
|
219
229
|
const newReserveRatioBips = this.market.getReserveRatioForNewAPR(apr);
|
|
220
230
|
const willChangeReserveRatio = newReserveRatioBips !== this.market.reserveRatioBips;
|
|
@@ -267,6 +277,26 @@ class MarketAccount {
|
|
|
267
277
|
return { status: validation_1.SetMinimumDepositStatus.NotBorrower };
|
|
268
278
|
return { status: validation_1.SetMinimumDepositStatus.Ready };
|
|
269
279
|
}
|
|
280
|
+
previewProposeAnnualInterestBips(apr) {
|
|
281
|
+
if (this.market.version !== types_1.MarketVersion.V2) {
|
|
282
|
+
return { status: validation_1.ProposeAnnualInterestBipsStatus.NotV2Market };
|
|
283
|
+
}
|
|
284
|
+
if (!this.isBorrower)
|
|
285
|
+
return { status: validation_1.ProposeAnnualInterestBipsStatus.NotBorrower };
|
|
286
|
+
if (this.market.hooksConfig?.kind !== types_1.HooksKind.PeriodicTerm) {
|
|
287
|
+
return { status: validation_1.ProposeAnnualInterestBipsStatus.NotPeriodicTermMarket };
|
|
288
|
+
}
|
|
289
|
+
if (!(apr > 0 && apr <= 10000)) {
|
|
290
|
+
return { status: validation_1.ProposeAnnualInterestBipsStatus.InvalidApr };
|
|
291
|
+
}
|
|
292
|
+
if (apr >= this.market.annualInterestBips) {
|
|
293
|
+
return { status: validation_1.ProposeAnnualInterestBipsStatus.NotReduction };
|
|
294
|
+
}
|
|
295
|
+
if (this.market.isPeriodicWithdrawalWindowOpen) {
|
|
296
|
+
return { status: validation_1.ProposeAnnualInterestBipsStatus.WithdrawalWindowOpen };
|
|
297
|
+
}
|
|
298
|
+
return { status: validation_1.ProposeAnnualInterestBipsStatus.Ready };
|
|
299
|
+
}
|
|
270
300
|
previewSetFixedTermEndTime(endTime) {
|
|
271
301
|
if (this.market.version !== types_1.MarketVersion.V2)
|
|
272
302
|
return { status: validation_1.SetFixedTermEndTimeStatus.NotV2Market };
|
|
@@ -291,101 +321,130 @@ class MarketAccount {
|
|
|
291
321
|
(0, utils_1.assert)(status === validation_1.SetMinimumDepositStatus.Ready, `Cannot set minimum deposit: ${status}`);
|
|
292
322
|
const config = this.market.hooksConfig;
|
|
293
323
|
(0, utils_1.assert)(config !== undefined, `V2 market missing hooksConfig`);
|
|
294
|
-
|
|
324
|
+
const iface = typechain_1.IOpenTermHooks__factory.createInterface();
|
|
325
|
+
return {
|
|
295
326
|
to: config.hooksAddress,
|
|
296
|
-
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
327
|
+
data: iface.encodeFunctionData("setMinimumDeposit", [this.market.address, amount.raw]),
|
|
328
|
+
value: "0"
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
async populateProposeAnnualInterestBips(apr) {
|
|
332
|
+
const { status } = this.previewProposeAnnualInterestBips(apr);
|
|
333
|
+
(0, utils_1.assert)(status === validation_1.ProposeAnnualInterestBipsStatus.Ready, `Cannot propose APR reduction: ${status}`);
|
|
334
|
+
const config = this.market.hooksConfig;
|
|
335
|
+
(0, utils_1.assert)(config !== undefined, `V2 market missing hooksConfig`);
|
|
336
|
+
const iface = typechain_1.IPeriodicTermHooks__factory.createInterface();
|
|
337
|
+
return {
|
|
338
|
+
to: config.hooksAddress,
|
|
339
|
+
data: iface.encodeFunctionData("proposeAnnualInterestBips", [this.market.address, apr]),
|
|
340
|
+
value: "0"
|
|
341
|
+
};
|
|
300
342
|
}
|
|
301
343
|
async populateSetFixedTermEndTime(endTime) {
|
|
302
344
|
const { status } = this.previewSetFixedTermEndTime(endTime);
|
|
303
345
|
(0, utils_1.assert)(status === validation_1.SetFixedTermEndTimeStatus.Ready, `Cannot set fixed term end time: ${status}`);
|
|
304
346
|
const config = this.market.hooksConfig;
|
|
305
347
|
(0, utils_1.assert)(config !== undefined, `V2 market missing hooksConfig`);
|
|
306
|
-
|
|
348
|
+
const iface = typechain_1.IFixedTermHooks__factory.createInterface();
|
|
349
|
+
return {
|
|
307
350
|
to: config.hooksAddress,
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
});
|
|
351
|
+
data: iface.encodeFunctionData("setFixedTermEndTime", [this.market.address, endTime]),
|
|
352
|
+
value: "0"
|
|
353
|
+
};
|
|
312
354
|
}
|
|
313
355
|
async setMinimumDeposit(amount) {
|
|
314
|
-
|
|
356
|
+
const { status } = this.previewSetMinimumDeposit(amount);
|
|
357
|
+
(0, utils_1.assert)(status === validation_1.SetMinimumDepositStatus.Ready, `Cannot set minimum deposit: ${status}`);
|
|
358
|
+
const config = this.market.hooksConfig;
|
|
359
|
+
(0, utils_1.assert)(config !== undefined, `V2 market missing hooksConfig`);
|
|
360
|
+
const contract = typechain_1.IOpenTermHooks__factory.connect(config.hooksAddress, this.market.signer);
|
|
361
|
+
return contract.setMinimumDeposit(this.market.address, amount.raw);
|
|
362
|
+
}
|
|
363
|
+
async proposeAnnualInterestBips(apr) {
|
|
364
|
+
const { status } = this.previewProposeAnnualInterestBips(apr);
|
|
365
|
+
(0, utils_1.assert)(status === validation_1.ProposeAnnualInterestBipsStatus.Ready, `Cannot propose APR reduction: ${status}`);
|
|
366
|
+
const config = this.market.hooksConfig;
|
|
367
|
+
(0, utils_1.assert)(config !== undefined, `V2 market missing hooksConfig`);
|
|
368
|
+
const contract = typechain_1.IPeriodicTermHooks__factory.connect(config.hooksAddress, this.market.signer);
|
|
369
|
+
return contract.proposeAnnualInterestBips(this.market.address, apr);
|
|
315
370
|
}
|
|
316
371
|
async setFixedTermEndTime(endTime) {
|
|
317
|
-
|
|
372
|
+
const { status } = this.previewSetFixedTermEndTime(endTime);
|
|
373
|
+
(0, utils_1.assert)(status === validation_1.SetFixedTermEndTimeStatus.Ready, `Cannot set fixed term end time: ${status}`);
|
|
374
|
+
const config = this.market.hooksConfig;
|
|
375
|
+
(0, utils_1.assert)(config !== undefined, `V2 market missing hooksConfig`);
|
|
376
|
+
const contract = typechain_1.IFixedTermHooks__factory.connect(config.hooksAddress, this.market.signer);
|
|
377
|
+
return contract.setFixedTermEndTime(this.market.address, endTime);
|
|
318
378
|
}
|
|
319
379
|
/* -------------------------------------------------------------------------- */
|
|
320
380
|
/* Management Actions */
|
|
321
381
|
/* -------------------------------------------------------------------------- */
|
|
322
382
|
async closeMarket() {
|
|
323
|
-
|
|
383
|
+
const { status } = this.previewCloseMarket();
|
|
384
|
+
(0, utils_1.assert)(status === validation_1.CloseMarketStatus.Ready, `Cannot close market: ${status}`);
|
|
385
|
+
if (this.market.version === types_1.MarketVersion.V1) {
|
|
386
|
+
(0, utils_1.assert)(this.market.controller !== undefined, "Controller address is required for V1 markets");
|
|
387
|
+
const controller = (0, constants_1.getControllerContract)(this.market.signer, this.market.controller);
|
|
388
|
+
return controller.closeMarket(this.market.address);
|
|
389
|
+
}
|
|
390
|
+
return this.market.contract.closeMarket();
|
|
324
391
|
}
|
|
325
392
|
populateCloseMarket() {
|
|
326
393
|
const { status } = this.previewCloseMarket();
|
|
327
394
|
(0, utils_1.assert)(status === validation_1.CloseMarketStatus.Ready, `Cannot close market: ${status}`);
|
|
328
395
|
if (this.market.version === types_1.MarketVersion.V1) {
|
|
329
396
|
(0, utils_1.assert)(this.market.controller !== undefined, "Controller address is required for V1 markets");
|
|
330
|
-
|
|
331
|
-
|
|
332
|
-
|
|
333
|
-
|
|
334
|
-
|
|
335
|
-
}
|
|
336
|
-
}
|
|
337
|
-
return
|
|
397
|
+
const controller = (0, constants_1.getControllerContract)(this.market.signer, this.market.controller);
|
|
398
|
+
return {
|
|
399
|
+
to: controller.address,
|
|
400
|
+
data: controller.interface.encodeFunctionData("closeMarket", [this.market.address]),
|
|
401
|
+
value: "0"
|
|
402
|
+
};
|
|
403
|
+
}
|
|
404
|
+
return {
|
|
338
405
|
to: this.market.address,
|
|
339
|
-
|
|
340
|
-
|
|
341
|
-
}
|
|
406
|
+
data: this.market.contract.interface.encodeFunctionData("closeMarket"),
|
|
407
|
+
value: "0"
|
|
408
|
+
};
|
|
342
409
|
}
|
|
343
410
|
async setMaxTotalSupply(amount) {
|
|
344
411
|
const { status } = this.previewSetMaxTotalSupply(amount);
|
|
345
412
|
(0, utils_1.assert)(status === validation_1.SetMaxTotalSupplyStatus.Ready, `Cannot close market: ${status}`);
|
|
346
413
|
if (this.market.version === types_1.MarketVersion.V1) {
|
|
347
414
|
(0, utils_1.assert)(this.market.controller !== undefined, "Controller address is required for V1 markets");
|
|
348
|
-
|
|
349
|
-
|
|
350
|
-
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
}
|
|
355
|
-
return (0, viem_write_1.submitPreparedTransaction)(this.market.signer, (0, utils_1.prepareTransaction)({
|
|
356
|
-
to: this.market.address,
|
|
357
|
-
abi: abi_1.wildcatMarketV2Abi,
|
|
358
|
-
functionName: "setMaxTotalSupply",
|
|
359
|
-
args: [amount.raw]
|
|
360
|
-
}));
|
|
415
|
+
const controller = (0, constants_1.getControllerContract)(this.market.signer, this.market.controller);
|
|
416
|
+
return controller.setMaxTotalSupply(this.market.address, amount.raw);
|
|
417
|
+
}
|
|
418
|
+
else {
|
|
419
|
+
return this.market.contract.setMaxTotalSupply(amount.raw);
|
|
420
|
+
}
|
|
361
421
|
}
|
|
362
422
|
async setAnnualInterestBips(newAprBips) {
|
|
363
423
|
const { status } = this.previewSetAPR(newAprBips);
|
|
364
424
|
(0, utils_1.assert)(status === validation_1.SetAprStatus.Ready, `Cannot set new APR of ${newAprBips / 10000}%: ${status}`);
|
|
365
425
|
if (this.market.version === types_1.MarketVersion.V1) {
|
|
366
426
|
(0, utils_1.assert)(this.market.controller !== undefined, "Controller address is required for V1 markets");
|
|
367
|
-
|
|
368
|
-
|
|
369
|
-
|
|
370
|
-
|
|
371
|
-
|
|
372
|
-
|
|
373
|
-
}
|
|
374
|
-
return (0, viem_write_1.submitPreparedTransaction)(this.market.signer, (0, utils_1.prepareTransaction)({
|
|
375
|
-
to: this.market.address,
|
|
376
|
-
abi: abi_1.wildcatMarketV2Abi,
|
|
377
|
-
functionName: "setAnnualInterestAndReserveRatioBips",
|
|
378
|
-
args: [newAprBips, this.market.reserveRatioBips]
|
|
379
|
-
}));
|
|
427
|
+
const controller = (0, constants_1.getControllerContract)(this.market.provider, this.market.controller);
|
|
428
|
+
return controller.setAnnualInterestBips(this.market.address, newAprBips);
|
|
429
|
+
}
|
|
430
|
+
else {
|
|
431
|
+
const contract = typechain_1.WildcatMarketV2__factory.connect(this.market.address, this.market.signer);
|
|
432
|
+
return contract.setAnnualInterestAndReserveRatioBips(newAprBips, this.market.reserveRatioBips);
|
|
433
|
+
}
|
|
380
434
|
}
|
|
381
435
|
/* -------------------------------------------------------------------------- */
|
|
382
436
|
/* Approval */
|
|
383
437
|
/* -------------------------------------------------------------------------- */
|
|
384
438
|
isApprovedFor(amount) {
|
|
385
|
-
return this.underlyingApproval
|
|
439
|
+
return this.underlyingApproval.gte(amount.raw);
|
|
386
440
|
}
|
|
387
441
|
async approveMarket(amount) {
|
|
388
|
-
|
|
442
|
+
const token = this.market.underlyingToken;
|
|
443
|
+
const signer = await token.signer.getAddress();
|
|
444
|
+
if (signer.toLowerCase() !== this.account.toLowerCase()) {
|
|
445
|
+
throw Error(`MarketAccount signer ${signer} does not match ${this.account}`);
|
|
446
|
+
}
|
|
447
|
+
return token.contract.approve(this.market.address, amount.raw);
|
|
389
448
|
}
|
|
390
449
|
async populateApproveMarket(amount) {
|
|
391
450
|
const token = this.market.underlyingToken;
|
|
@@ -393,12 +452,14 @@ class MarketAccount {
|
|
|
393
452
|
if (signer.toLowerCase() !== this.account.toLowerCase()) {
|
|
394
453
|
throw Error(`MarketAccount signer ${signer} does not match ${this.account}`);
|
|
395
454
|
}
|
|
396
|
-
return
|
|
455
|
+
return {
|
|
397
456
|
to: token.address,
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
457
|
+
data: token.contract.interface.encodeFunctionData("approve", [
|
|
458
|
+
this.market.address,
|
|
459
|
+
amount.raw
|
|
460
|
+
]),
|
|
461
|
+
value: "0"
|
|
462
|
+
};
|
|
402
463
|
}
|
|
403
464
|
/* -------------------------------------------------------------------------- */
|
|
404
465
|
/* ForceBuyBack */
|
|
@@ -412,9 +473,6 @@ class MarketAccount {
|
|
|
412
473
|
if (this.market.chainId !== constants_1.SupportedChainId.Sepolia) {
|
|
413
474
|
return { status: validation_1.ForceBuyBackStatus.MainnetNotSupported };
|
|
414
475
|
}
|
|
415
|
-
if (!this.market.hooksConfig?.allowForceBuyBacks) {
|
|
416
|
-
return { status: validation_1.ForceBuyBackStatus.HooksNotSupported };
|
|
417
|
-
}
|
|
418
476
|
if (amount.gt(this.underlyingBalance)) {
|
|
419
477
|
return { status: validation_1.ForceBuyBackStatus.InsufficientBalance };
|
|
420
478
|
}
|
|
@@ -429,17 +487,20 @@ class MarketAccount {
|
|
|
429
487
|
};
|
|
430
488
|
}
|
|
431
489
|
async forceBuyBack(lender, amount) {
|
|
432
|
-
|
|
490
|
+
const { status } = this.previewForceBuyBack(lender, amount);
|
|
491
|
+
(0, utils_1.assert)(status === validation_1.ForceBuyBackStatus.Ready, `Cannot force buy back: ${status}`);
|
|
492
|
+
const contract = typechain_1.WildcatMarketV2__factory.connect(this.market.address, this.market.signer);
|
|
493
|
+
return await contract.forceBuyBack(lender, amount.raw);
|
|
433
494
|
}
|
|
434
495
|
populateForceBuyBack(lender, amount) {
|
|
435
496
|
const { status } = this.previewForceBuyBack(lender, amount);
|
|
436
497
|
(0, utils_1.assert)(status === validation_1.ForceBuyBackStatus.Ready, `Cannot force buy back: ${status}`);
|
|
437
|
-
|
|
498
|
+
const contract = typechain_1.WildcatMarketV2__factory.connect(this.market.address, this.market.signer);
|
|
499
|
+
return {
|
|
438
500
|
to: this.market.address,
|
|
439
|
-
|
|
440
|
-
|
|
441
|
-
|
|
442
|
-
});
|
|
501
|
+
data: contract.interface.encodeFunctionData("forceBuyBack", [lender, amount.raw]),
|
|
502
|
+
value: "0"
|
|
503
|
+
};
|
|
443
504
|
}
|
|
444
505
|
/* -------------------------------------------------------------------------- */
|
|
445
506
|
/* Deposits */
|
|
@@ -485,15 +546,20 @@ class MarketAccount {
|
|
|
485
546
|
if (signer.toLowerCase() !== this.account.toLowerCase()) {
|
|
486
547
|
throw Error(`MarketAccount signer ${signer} does not match ${this.account}`);
|
|
487
548
|
}
|
|
488
|
-
return
|
|
549
|
+
return {
|
|
489
550
|
to: this.market.address,
|
|
490
|
-
|
|
491
|
-
|
|
492
|
-
|
|
493
|
-
});
|
|
551
|
+
data: this.market.contract.interface.encodeFunctionData("deposit", [amount.raw]),
|
|
552
|
+
value: "0"
|
|
553
|
+
};
|
|
494
554
|
}
|
|
495
555
|
async deposit(amount) {
|
|
496
|
-
|
|
556
|
+
const { status } = this.previewDeposit(amount);
|
|
557
|
+
(0, utils_1.assert)(status === validation_1.DepositStatus.Ready, `Cannot deposit: ${status}`);
|
|
558
|
+
const signer = await this.market.signer.getAddress();
|
|
559
|
+
if (signer.toLowerCase() !== this.account.toLowerCase()) {
|
|
560
|
+
throw Error(`MarketAccount signer ${signer} does not match ${this.account}`);
|
|
561
|
+
}
|
|
562
|
+
return this.market.contract.deposit(amount.raw);
|
|
497
563
|
}
|
|
498
564
|
/* ------ Withdrawals ------ */
|
|
499
565
|
previewQueueWithdrawal(amount) {
|
|
@@ -512,19 +578,17 @@ class MarketAccount {
|
|
|
512
578
|
if (signer.toLowerCase() !== this.account.toLowerCase()) {
|
|
513
579
|
throw Error(`MarketAccount signer ${signer} does not match ${this.account}`);
|
|
514
580
|
}
|
|
515
|
-
const
|
|
516
|
-
|
|
517
|
-
|
|
518
|
-
|
|
519
|
-
|
|
520
|
-
|
|
521
|
-
const queuedWithdrawalTransaction = toQueueWithdrawalTransaction(this.market.underlyingToken, receipt, this.market.address);
|
|
581
|
+
const transaction = await this.market.contract.queueWithdrawal(amount.raw);
|
|
582
|
+
const receipt = await transaction.wait();
|
|
583
|
+
const queuedWithdrawalTopic = this.market.contract.interface.getEventTopic("WithdrawalQueued");
|
|
584
|
+
const queuedWithdrawalTransaction = toQueueWithdrawalTransaction(this.market.underlyingToken, receipt.events.find((e) => e.topics[0] === queuedWithdrawalTopic));
|
|
585
|
+
if (!queuedWithdrawalTransaction)
|
|
586
|
+
throw Error("No queued withdrawal event found");
|
|
522
587
|
const withdrawal = await withdrawal_status_1.LenderWithdrawalStatus.getWithdrawalForLender(this.market, queuedWithdrawalTransaction.expiry, this.account);
|
|
523
588
|
return {
|
|
524
|
-
|
|
525
|
-
receipt,
|
|
589
|
+
withdrawal,
|
|
526
590
|
transaction,
|
|
527
|
-
|
|
591
|
+
receipt
|
|
528
592
|
};
|
|
529
593
|
}
|
|
530
594
|
async queueFullWithdrawal() {
|
|
@@ -534,25 +598,24 @@ class MarketAccount {
|
|
|
534
598
|
if (signer.toLowerCase() !== this.account.toLowerCase()) {
|
|
535
599
|
throw Error(`MarketAccount signer ${signer} does not match ${this.account}`);
|
|
536
600
|
}
|
|
537
|
-
|
|
538
|
-
|
|
539
|
-
|
|
540
|
-
|
|
541
|
-
|
|
542
|
-
|
|
543
|
-
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
601
|
+
let transaction;
|
|
602
|
+
if (this.market.version === types_1.MarketVersion.V2) {
|
|
603
|
+
const contract = typechain_1.WildcatMarketV2__factory.connect(this.market.address, this.market.signer);
|
|
604
|
+
transaction = await contract.queueFullWithdrawal();
|
|
605
|
+
}
|
|
606
|
+
else {
|
|
607
|
+
transaction = await this.market.contract.queueWithdrawal(this.marketBalance.raw);
|
|
608
|
+
}
|
|
609
|
+
const receipt = await transaction.wait();
|
|
610
|
+
const queuedWithdrawalTopic = this.market.contract.interface.getEventTopic("WithdrawalQueued");
|
|
611
|
+
const queuedWithdrawalTransaction = toQueueWithdrawalTransaction(this.market.underlyingToken, receipt.events.find((e) => e.topics[0] === queuedWithdrawalTopic));
|
|
612
|
+
if (!queuedWithdrawalTransaction)
|
|
613
|
+
throw Error("No queued withdrawal event found");
|
|
550
614
|
const withdrawal = await withdrawal_status_1.LenderWithdrawalStatus.getWithdrawalForLender(this.market, queuedWithdrawalTransaction.expiry, this.account);
|
|
551
615
|
return {
|
|
552
|
-
|
|
553
|
-
receipt,
|
|
616
|
+
withdrawal,
|
|
554
617
|
transaction,
|
|
555
|
-
|
|
618
|
+
receipt
|
|
556
619
|
};
|
|
557
620
|
}
|
|
558
621
|
/* -------------------------------------------------------------------------- */
|
|
@@ -589,7 +652,13 @@ class MarketAccount {
|
|
|
589
652
|
return { status: validation_1.RepayStatus.Ready };
|
|
590
653
|
}
|
|
591
654
|
async repay(amount) {
|
|
592
|
-
|
|
655
|
+
const signer = await this.market.signer.getAddress();
|
|
656
|
+
if (signer.toLowerCase() !== this.account.toLowerCase()) {
|
|
657
|
+
throw Error(`MarketAccount signer ${signer} does not match ${this.account}`);
|
|
658
|
+
}
|
|
659
|
+
if (!this.isBorrower)
|
|
660
|
+
throw Error("Only borrower can repay");
|
|
661
|
+
return this.market.contract.repay(amount);
|
|
593
662
|
}
|
|
594
663
|
async populateRepay(amount) {
|
|
595
664
|
const signer = await this.market.signer.getAddress();
|
|
@@ -598,15 +667,23 @@ class MarketAccount {
|
|
|
598
667
|
}
|
|
599
668
|
if (!this.isBorrower)
|
|
600
669
|
throw Error("Only borrower can repay");
|
|
601
|
-
return
|
|
670
|
+
return {
|
|
602
671
|
to: this.market.address,
|
|
603
|
-
|
|
604
|
-
|
|
605
|
-
|
|
606
|
-
});
|
|
672
|
+
data: this.market.contract.interface.encodeFunctionData("repay", [amount]),
|
|
673
|
+
value: "0"
|
|
674
|
+
};
|
|
607
675
|
}
|
|
608
676
|
async repayOutstandingDebt() {
|
|
609
|
-
|
|
677
|
+
if (this.market.version !== types_1.MarketVersion.V1) {
|
|
678
|
+
throw Error(`Only V1 supports repayOutstandingDebt`);
|
|
679
|
+
}
|
|
680
|
+
if (!this.isBorrower)
|
|
681
|
+
throw Error("Only borrower can repay");
|
|
682
|
+
const signer = await this.market.signer.getAddress();
|
|
683
|
+
if (signer.toLowerCase() !== this.account.toLowerCase()) {
|
|
684
|
+
throw Error(`MarketAccount signer ${signer} does not match ${this.account}`);
|
|
685
|
+
}
|
|
686
|
+
return this.market.contract.repayOutstandingDebt();
|
|
610
687
|
}
|
|
611
688
|
async populateRepayOutstandingDebt() {
|
|
612
689
|
if (this.market.version !== types_1.MarketVersion.V1) {
|
|
@@ -618,14 +695,23 @@ class MarketAccount {
|
|
|
618
695
|
if (signer.toLowerCase() !== this.account.toLowerCase()) {
|
|
619
696
|
throw Error(`MarketAccount signer ${signer} does not match ${this.account}`);
|
|
620
697
|
}
|
|
621
|
-
return
|
|
698
|
+
return {
|
|
622
699
|
to: this.market.address,
|
|
623
|
-
|
|
624
|
-
|
|
625
|
-
}
|
|
700
|
+
data: this.market.contract.interface.encodeFunctionData("repayOutstandingDebt"),
|
|
701
|
+
value: "0"
|
|
702
|
+
};
|
|
626
703
|
}
|
|
627
704
|
async repayDelinquentDebt() {
|
|
628
|
-
|
|
705
|
+
if (this.market.version !== types_1.MarketVersion.V1) {
|
|
706
|
+
throw Error(`Only V1 supports repayDelinquentDebt`);
|
|
707
|
+
}
|
|
708
|
+
if (!this.isBorrower)
|
|
709
|
+
throw Error("Only borrower can repay");
|
|
710
|
+
const signer = await this.market.signer.getAddress();
|
|
711
|
+
if (signer.toLowerCase() !== this.account.toLowerCase()) {
|
|
712
|
+
throw Error(`MarketAccount signer ${signer} does not match ${this.account}`);
|
|
713
|
+
}
|
|
714
|
+
return this.market.contract.repayDelinquentDebt();
|
|
629
715
|
}
|
|
630
716
|
async populateRepayDelinquentDebt() {
|
|
631
717
|
if (this.market.version !== types_1.MarketVersion.V1) {
|
|
@@ -637,11 +723,11 @@ class MarketAccount {
|
|
|
637
723
|
if (signer.toLowerCase() !== this.account.toLowerCase()) {
|
|
638
724
|
throw Error(`MarketAccount signer ${signer} does not match ${this.account}`);
|
|
639
725
|
}
|
|
640
|
-
return
|
|
726
|
+
return {
|
|
641
727
|
to: this.market.address,
|
|
642
|
-
|
|
643
|
-
|
|
644
|
-
}
|
|
728
|
+
data: this.market.contract.interface.encodeFunctionData("repayDelinquentDebt"),
|
|
729
|
+
value: "0"
|
|
730
|
+
};
|
|
645
731
|
}
|
|
646
732
|
/* -------------------------------------------------------------------------- */
|
|
647
733
|
/* Borrow */
|
|
@@ -662,69 +748,59 @@ class MarketAccount {
|
|
|
662
748
|
if (amount.gt(this.market.borrowableAssets)) {
|
|
663
749
|
throw Error("Insufficient borrowable assets");
|
|
664
750
|
}
|
|
665
|
-
return
|
|
666
|
-
to: this.market.address,
|
|
667
|
-
abi: abi_1.wildcatMarketAbi,
|
|
668
|
-
functionName: "borrow",
|
|
669
|
-
args: [amount.raw]
|
|
670
|
-
}));
|
|
751
|
+
return this.market.contract.borrow(amount.raw);
|
|
671
752
|
}
|
|
672
753
|
/* -------------------------------------------------------------------------- */
|
|
673
754
|
/* Updates */
|
|
674
755
|
/* -------------------------------------------------------------------------- */
|
|
675
756
|
async update() {
|
|
676
|
-
|
|
677
|
-
|
|
678
|
-
this.updateWith(acccountMarketInfo);
|
|
679
|
-
return;
|
|
680
|
-
}
|
|
681
|
-
const accountMarketInfo = await (0, market_lens_1.getLatestLenderAccountData)(this.chainId, this.market.provider, this.account, this.market.address);
|
|
682
|
-
this.updateWith(accountMarketInfo);
|
|
757
|
+
const acccountMarketInfo = await (0, constants_1.getLensContract)(this.chainId, this.market.provider).getMarketLenderStatus(this.account, this.market.address);
|
|
758
|
+
this.updateWith(acccountMarketInfo);
|
|
683
759
|
}
|
|
684
760
|
updateWith(info) {
|
|
685
761
|
if ("isAuthorizedOnController" in info) {
|
|
686
762
|
(0, utils_1.assert)(this.market.version === types_1.MarketVersion.V1, "V2 market can not be updated with V1 lens data");
|
|
687
763
|
this.isAuthorizedOnController = info.isAuthorizedOnController;
|
|
688
|
-
this.role =
|
|
764
|
+
this.role = info.role;
|
|
689
765
|
}
|
|
690
766
|
else {
|
|
691
767
|
(0, utils_1.assert)(this.market.version === types_1.MarketVersion.V2, "V1 market can not be updated with V2 lens data");
|
|
692
768
|
this.credential = {
|
|
693
769
|
canRefresh: info.canRefresh,
|
|
694
770
|
isBlockedFromDeposits: info.isBlockedFromDeposits,
|
|
695
|
-
lastApprovalTimestamp:
|
|
771
|
+
lastApprovalTimestamp: info.lastApprovalTimestamp,
|
|
696
772
|
lastProvider: {
|
|
697
773
|
isApproved: true,
|
|
698
774
|
providerAddress: info.lastProvider.providerAddress,
|
|
699
|
-
isPullProvider:
|
|
700
|
-
isPushProvider:
|
|
701
|
-
pullProviderIndex:
|
|
702
|
-
pushProviderIndex:
|
|
703
|
-
timeToLive:
|
|
775
|
+
isPullProvider: info.lastProvider.pullProviderIndex !== NullProviderIndex,
|
|
776
|
+
isPushProvider: info.lastProvider.pushProviderIndex !== NullProviderIndex,
|
|
777
|
+
pullProviderIndex: info.lastProvider.pullProviderIndex,
|
|
778
|
+
pushProviderIndex: info.lastProvider.pushProviderIndex,
|
|
779
|
+
timeToLive: info.lastProvider.timeToLive
|
|
704
780
|
}
|
|
705
781
|
};
|
|
706
782
|
this.isKnownLender = info.isKnownLender;
|
|
707
783
|
}
|
|
708
|
-
this.scaledMarketBalance =
|
|
784
|
+
this.scaledMarketBalance = info.scaledBalance;
|
|
709
785
|
this.marketBalance = this.market.marketToken.getAmount(info.normalizedBalance);
|
|
710
786
|
this.underlyingBalance = this.market.underlyingToken.getAmount(info.underlyingBalance);
|
|
711
|
-
this.underlyingApproval =
|
|
787
|
+
this.underlyingApproval = info.underlyingApproval;
|
|
712
788
|
this.processInterestAccrued();
|
|
713
789
|
}
|
|
714
790
|
calculateInterestEarned() {
|
|
715
791
|
if (!this.lastScaleFactor)
|
|
716
|
-
return
|
|
717
|
-
if (this.scaledMarketBalance
|
|
718
|
-
return
|
|
792
|
+
return ethers_1.BigNumber.from(0);
|
|
793
|
+
if (this.scaledMarketBalance.eq(0) || this.lastScaleFactor?.eq(this.market.scaleFactor)) {
|
|
794
|
+
return ethers_1.BigNumber.from(0);
|
|
719
795
|
}
|
|
720
|
-
const lastBalance = (0, utils_1.
|
|
721
|
-
const currentBalance = (0, utils_1.
|
|
722
|
-
return currentBalance
|
|
796
|
+
const lastBalance = (0, utils_1.rayMul)(this.scaledMarketBalance, this.lastScaleFactor);
|
|
797
|
+
const currentBalance = (0, utils_1.rayMul)(this.scaledMarketBalance, this.market.scaleFactor);
|
|
798
|
+
return currentBalance.sub(lastBalance);
|
|
723
799
|
}
|
|
724
800
|
processInterestAccrued() {
|
|
725
801
|
if (!this.lastScaleFactor || !this.totalInterestEarned)
|
|
726
802
|
return;
|
|
727
|
-
if (this.lastScaleFactor
|
|
803
|
+
if (!this.lastScaleFactor.eq(this.market.scaleFactor)) {
|
|
728
804
|
const interestEarned = this.calculateInterestEarned();
|
|
729
805
|
this.lastScaleFactor = this.market.scaleFactor;
|
|
730
806
|
this.totalInterestEarned = this.totalInterestEarned.add(interestEarned);
|
|
@@ -737,19 +813,19 @@ class MarketAccount {
|
|
|
737
813
|
/* Builders / Getters */
|
|
738
814
|
/* -------------------------------------------------------------------------- */
|
|
739
815
|
static fromSubgraphAccountData(market, data) {
|
|
740
|
-
const scaledBalance =
|
|
816
|
+
const scaledBalance = ethers_1.BigNumber.from(data.scaledBalance);
|
|
741
817
|
const account = new MarketAccount({
|
|
742
818
|
account: data.address,
|
|
743
819
|
isAuthorizedOnController: data.controllerAuthorization?.authorized ?? false,
|
|
744
820
|
role: (0, utils_1.parseSubgraphLenderStatus)(data.role),
|
|
745
821
|
scaledMarketBalance: scaledBalance,
|
|
746
|
-
marketBalance: market.marketToken.getAmount((0, utils_1.
|
|
822
|
+
marketBalance: market.marketToken.getAmount((0, utils_1.rayMul)(scaledBalance, market.scaleFactor)),
|
|
747
823
|
underlyingBalance: market.underlyingToken.getAmount(0),
|
|
748
|
-
underlyingApproval:
|
|
824
|
+
underlyingApproval: ethers_1.BigNumber.from(0),
|
|
749
825
|
market,
|
|
750
|
-
deposits:
|
|
826
|
+
deposits: data.deposits,
|
|
751
827
|
totalDeposited: market.underlyingToken.getAmount(data.totalDeposited),
|
|
752
|
-
lastScaleFactor:
|
|
828
|
+
lastScaleFactor: ethers_1.BigNumber.from(data.lastScaleFactor),
|
|
753
829
|
lastUpdatedTimestamp: data.lastUpdatedTimestamp,
|
|
754
830
|
totalInterestEarned: market.underlyingToken.getAmount(data.totalInterestEarned),
|
|
755
831
|
numPendingWithdrawalBatches: data.numPendingWithdrawalBatches,
|
|
@@ -765,10 +841,10 @@ class MarketAccount {
|
|
|
765
841
|
account,
|
|
766
842
|
isAuthorizedOnController: info.isAuthorizedOnController,
|
|
767
843
|
role: info.role,
|
|
768
|
-
scaledMarketBalance:
|
|
844
|
+
scaledMarketBalance: info.scaledBalance,
|
|
769
845
|
marketBalance: market.marketToken.getAmount(info.normalizedBalance),
|
|
770
846
|
underlyingBalance: market.underlyingToken.getAmount(info.underlyingBalance),
|
|
771
|
-
underlyingApproval:
|
|
847
|
+
underlyingApproval: info.underlyingApproval,
|
|
772
848
|
market
|
|
773
849
|
});
|
|
774
850
|
}
|
|
@@ -778,52 +854,46 @@ class MarketAccount {
|
|
|
778
854
|
market,
|
|
779
855
|
role: LenderRole.Null,
|
|
780
856
|
marketBalance: market.marketToken.getAmount(data.normalizedBalance),
|
|
781
|
-
scaledMarketBalance:
|
|
782
|
-
underlyingApproval:
|
|
857
|
+
scaledMarketBalance: data.scaledBalance,
|
|
858
|
+
underlyingApproval: data.underlyingApproval,
|
|
783
859
|
underlyingBalance: market.underlyingToken.getAmount(data.underlyingBalance),
|
|
784
860
|
isAuthorizedOnController: false,
|
|
785
861
|
isKnownLender: data.isKnownLender,
|
|
786
862
|
credential: {
|
|
787
863
|
canRefresh: data.canRefresh,
|
|
788
864
|
isBlockedFromDeposits: data.isBlockedFromDeposits,
|
|
789
|
-
lastApprovalTimestamp:
|
|
865
|
+
lastApprovalTimestamp: data.lastApprovalTimestamp,
|
|
790
866
|
lastProvider: {
|
|
791
867
|
isApproved: true,
|
|
792
868
|
providerAddress: data.lastProvider.providerAddress,
|
|
793
|
-
isPullProvider:
|
|
794
|
-
pullProviderIndex:
|
|
795
|
-
isPushProvider:
|
|
796
|
-
pushProviderIndex:
|
|
797
|
-
timeToLive:
|
|
869
|
+
isPullProvider: data.lastProvider.pullProviderIndex !== NullProviderIndex,
|
|
870
|
+
pullProviderIndex: data.lastProvider.pullProviderIndex,
|
|
871
|
+
isPushProvider: data.lastProvider.pushProviderIndex !== NullProviderIndex,
|
|
872
|
+
pushProviderIndex: data.lastProvider.pushProviderIndex,
|
|
873
|
+
timeToLive: data.lastProvider.timeToLive
|
|
798
874
|
}
|
|
799
875
|
}
|
|
800
876
|
});
|
|
801
877
|
}
|
|
802
|
-
static
|
|
878
|
+
static fromMarketDataWithLenderStatus(chainId, provider, account, info) {
|
|
803
879
|
if ("controller" in info.market) {
|
|
804
880
|
info = info;
|
|
805
881
|
return MarketAccount.fromMarketLenderStatus(account, info.lenderStatus, market_1.Market.fromMarketData(chainId, info.market, provider));
|
|
806
882
|
}
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
return MarketAccount.fromLenderAccountData(market_1.Market.fromMarketDataV2(chainId, provider,
|
|
883
|
+
else {
|
|
884
|
+
info = info;
|
|
885
|
+
return MarketAccount.fromLenderAccountData(market_1.Market.fromMarketDataV2(chainId, provider, info.market), info.lenderStatus);
|
|
810
886
|
}
|
|
811
|
-
const infoV2_5 = info;
|
|
812
|
-
const market = await market_1.Market.fromUnifiedMarketData(chainId, provider, infoV2_5.market);
|
|
813
|
-
return MarketAccount.fromLenderAccountData(market, infoV2_5.lenderStatus);
|
|
814
|
-
}
|
|
815
|
-
static async hydrateMarketAccounts(chainId, provider, account, infos) {
|
|
816
|
-
return Promise.all(infos.map((info) => MarketAccount.fromMarketDataWithLenderStatus(chainId, provider, account, info)));
|
|
817
887
|
}
|
|
818
888
|
static fromMarketDataOnly(market, account, isAuthorizedOnController) {
|
|
819
889
|
return new MarketAccount({
|
|
820
890
|
account,
|
|
821
891
|
isAuthorizedOnController,
|
|
822
892
|
role: LenderRole.Null,
|
|
823
|
-
scaledMarketBalance:
|
|
893
|
+
scaledMarketBalance: ethers_1.BigNumber.from(0),
|
|
824
894
|
marketBalance: market.marketToken.getAmount(0),
|
|
825
895
|
underlyingBalance: market.underlyingToken.getAmount(0),
|
|
826
|
-
underlyingApproval:
|
|
896
|
+
underlyingApproval: ethers_1.BigNumber.from(0),
|
|
827
897
|
market
|
|
828
898
|
});
|
|
829
899
|
}
|
|
@@ -832,19 +902,16 @@ class MarketAccount {
|
|
|
832
902
|
* If `market` is a string, the market data will be fetched in the same call as the account data.
|
|
833
903
|
*/
|
|
834
904
|
static async getMarketAccount(chainId, provider, account, market) {
|
|
905
|
+
const lens = (0, constants_1.getLensContract)(chainId, provider);
|
|
835
906
|
if (market instanceof market_1.Market) {
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
return (0, market_lens_1.getLatestLenderAccountData)(chainId, provider, account, market.address).then((info) => MarketAccount.fromLenderAccountData(market, info));
|
|
840
|
-
}
|
|
841
|
-
try {
|
|
842
|
-
const info = await (0, market_lens_1.getLatestMarketDataWithLenderStatus)(chainId, provider, account, market);
|
|
843
|
-
return MarketAccount.fromMarketDataWithLenderStatus(chainId, provider, account, info);
|
|
907
|
+
return lens
|
|
908
|
+
.getMarketLenderStatus(account, market.address)
|
|
909
|
+
.then((info) => MarketAccount.fromMarketLenderStatus(account, info, market));
|
|
844
910
|
}
|
|
845
|
-
|
|
846
|
-
|
|
847
|
-
|
|
911
|
+
else {
|
|
912
|
+
return lens
|
|
913
|
+
.getMarketDataWithLenderStatus(account, market)
|
|
914
|
+
.then((info) => MarketAccount.fromMarketDataWithLenderStatus(chainId, provider, account, info));
|
|
848
915
|
}
|
|
849
916
|
}
|
|
850
917
|
/**
|
|
@@ -852,10 +919,17 @@ class MarketAccount {
|
|
|
852
919
|
* If `market` is a string, the market data will be fetched in the same call as the account data.
|
|
853
920
|
*/
|
|
854
921
|
static async getMarketAccountV2(chainId, provider, account, market) {
|
|
922
|
+
const lens = (0, constants_1.getLensV2Contract)(chainId, provider);
|
|
855
923
|
if (market instanceof market_1.Market) {
|
|
856
|
-
return
|
|
924
|
+
return lens
|
|
925
|
+
.getMarketDataWithLenderStatus(account, market.address)
|
|
926
|
+
.then((info) => MarketAccount.fromMarketDataWithLenderStatus(chainId, provider, account, info));
|
|
927
|
+
}
|
|
928
|
+
else {
|
|
929
|
+
return lens
|
|
930
|
+
.getMarketDataWithLenderStatus(account, market)
|
|
931
|
+
.then((info) => MarketAccount.fromMarketDataWithLenderStatus(chainId, provider, account, info));
|
|
857
932
|
}
|
|
858
|
-
return (0, market_lens_1.getLatestMarketDataWithLenderStatus)(chainId, provider, account, market).then((info) => MarketAccount.fromMarketDataWithLenderStatus(chainId, provider, account, info));
|
|
859
933
|
}
|
|
860
934
|
/**
|
|
861
935
|
* Get multiple `MarketAccount`s given an account and existing list of `Market`
|
|
@@ -863,139 +937,51 @@ class MarketAccount {
|
|
|
863
937
|
* data will be fetched in the same call as the account data.
|
|
864
938
|
*/
|
|
865
939
|
static async getMarketAccountsForLender(chainId, provider, account, markets) {
|
|
940
|
+
const lens = (0, constants_1.getLensContract)(chainId, provider);
|
|
866
941
|
if (markets.length === 0) {
|
|
867
942
|
return [];
|
|
868
943
|
}
|
|
869
944
|
if ((0, validation_1.isMarketInstanceArray)(markets)) {
|
|
870
|
-
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
markets.forEach((market, index) => {
|
|
874
|
-
if (market.version === types_1.MarketVersion.V1) {
|
|
875
|
-
legacyIndexes.push(index);
|
|
876
|
-
}
|
|
877
|
-
else {
|
|
878
|
-
latestIndexes.push(index);
|
|
879
|
-
}
|
|
880
|
-
});
|
|
881
|
-
if (legacyIndexes.length > 0) {
|
|
882
|
-
const legacyMarkets = legacyIndexes.map((index) => markets[index]);
|
|
883
|
-
const infos = await (0, market_lens_1.getLegacyMarketsLenderStatus)(chainId, provider, account, legacyMarkets.map((market) => market.address));
|
|
884
|
-
infos.forEach((info, i) => {
|
|
885
|
-
results[legacyIndexes[i]] = MarketAccount.fromMarketLenderStatus(account, info, legacyMarkets[i]);
|
|
886
|
-
});
|
|
887
|
-
}
|
|
888
|
-
if (latestIndexes.length > 0) {
|
|
889
|
-
const latestMarkets = latestIndexes.map((index) => markets[index]);
|
|
890
|
-
const infos = await (0, market_lens_1.getLatestLenderAccountsData)(chainId, provider, account, latestMarkets.map((market) => market.address));
|
|
891
|
-
infos.forEach((info, i) => {
|
|
892
|
-
results[latestIndexes[i]] = MarketAccount.fromLenderAccountData(latestMarkets[i], info);
|
|
893
|
-
});
|
|
894
|
-
}
|
|
895
|
-
return results;
|
|
896
|
-
}
|
|
897
|
-
try {
|
|
898
|
-
const infos = await (0, market_lens_1.getLatestMarketsDataWithLenderStatus)(chainId, provider, account, markets);
|
|
899
|
-
return MarketAccount.hydrateMarketAccounts(chainId, provider, account, infos);
|
|
945
|
+
return lens
|
|
946
|
+
.getMarketsLenderStatus(account, markets.map((v) => v.address))
|
|
947
|
+
.then((infos) => infos.map((info, i) => MarketAccount.fromMarketLenderStatus(account, info, markets[i])));
|
|
900
948
|
}
|
|
901
|
-
|
|
902
|
-
|
|
903
|
-
|
|
949
|
+
else {
|
|
950
|
+
return lens
|
|
951
|
+
.getMarketsDataWithLenderStatus(account, markets)
|
|
952
|
+
.then((infos) => infos.map((info) => MarketAccount.fromMarketDataWithLenderStatus(chainId, provider, account, info)));
|
|
904
953
|
}
|
|
905
954
|
}
|
|
906
|
-
/**
|
|
907
|
-
* Refresh existing V2 lender market accounts using the focused live lens surface when available.
|
|
908
|
-
* Falls back to existing broad V2 market reads plus lender-account reads.
|
|
909
|
-
*/
|
|
910
|
-
static async refreshMarketAccountsV2LiveData(chainId, provider, account, marketAccounts) {
|
|
911
|
-
if (marketAccounts.length === 0) {
|
|
912
|
-
return marketAccounts;
|
|
913
|
-
}
|
|
914
|
-
const lender = account ?? ZERO_ADDRESS;
|
|
915
|
-
const shouldZeroBalances = !account;
|
|
916
|
-
const marketAddresses = marketAccounts.map((marketAccount) => marketAccount.market.address);
|
|
917
|
-
if (hasUnifiedLatestLensForAccountReads(chainId)) {
|
|
918
|
-
try {
|
|
919
|
-
const updates = await (0, market_lens_1.getUnifiedMarketsLiveDataWithLenderStatusV2)(chainId, provider, lender, marketAddresses);
|
|
920
|
-
updates.forEach((update, i) => {
|
|
921
|
-
marketAccounts[i].market.updateWithLiveData(update.market);
|
|
922
|
-
marketAccounts[i].updateWith(shouldZeroBalances ? zeroLenderBalances(update.lenderStatus) : update.lenderStatus);
|
|
923
|
-
});
|
|
924
|
-
return marketAccounts;
|
|
925
|
-
}
|
|
926
|
-
catch (_) {
|
|
927
|
-
// Fall back to existing reads for older unified lens deployments.
|
|
928
|
-
}
|
|
929
|
-
}
|
|
930
|
-
const [refreshedMarkets, lenderStatuses] = await Promise.all([
|
|
931
|
-
market_1.Market.getMarketsV2(chainId, marketAddresses, provider),
|
|
932
|
-
(0, market_lens_1.getLatestLenderAccountsData)(chainId, provider, lender, marketAddresses)
|
|
933
|
-
]);
|
|
934
|
-
marketAccounts.forEach((marketAccount, i) => {
|
|
935
|
-
Object.assign(marketAccount.market, refreshedMarkets[i]);
|
|
936
|
-
marketAccount.updateWith(shouldZeroBalances ? zeroLenderBalances(lenderStatuses[i]) : lenderStatuses[i]);
|
|
937
|
-
});
|
|
938
|
-
return marketAccounts;
|
|
939
|
-
}
|
|
940
955
|
/**
|
|
941
956
|
* Get all `MarketAccount`s for a given account.
|
|
942
957
|
* Fetches the market data in the same call as the account data.
|
|
943
958
|
*/
|
|
944
|
-
static
|
|
945
|
-
|
|
946
|
-
|
|
947
|
-
|
|
948
|
-
|
|
949
|
-
}
|
|
950
|
-
const infos = await (0, market_lens_1.getLatestMarketsDataWithLenderStatus)(chainId, provider, account, markets);
|
|
951
|
-
return MarketAccount.hydrateMarketAccounts(chainId, provider, account, infos);
|
|
952
|
-
}
|
|
953
|
-
const infos = await (0, market_lens_1.getLegacyAllMarketsDataWithLenderStatus)(chainId, provider, account);
|
|
954
|
-
return MarketAccount.hydrateMarketAccounts(chainId, provider, account, infos);
|
|
959
|
+
static getAllMarketAccountsForLender(chainId, provider, account) {
|
|
960
|
+
const lens = (0, constants_1.getLensContract)(chainId, provider);
|
|
961
|
+
return lens
|
|
962
|
+
.getAllMarketsDataWithLenderStatus(account)
|
|
963
|
+
.then((infos) => infos.map((info) => MarketAccount.fromMarketDataWithLenderStatus(chainId, provider, account, info)));
|
|
955
964
|
}
|
|
956
965
|
/**
|
|
957
966
|
* Get paginated `MarketAccount`s for a given account.
|
|
958
967
|
* Fetches the market data in the same call as the account data.
|
|
959
968
|
* @note Throws an error if `start + count` exceeds the number of markets.
|
|
960
969
|
*/
|
|
961
|
-
static
|
|
962
|
-
|
|
963
|
-
|
|
964
|
-
|
|
965
|
-
|
|
966
|
-
const totalMarkets = await (0, arch_controller_1.getRegisteredMarketsCount)(chainId, provider);
|
|
967
|
-
if (start >= totalMarkets) {
|
|
968
|
-
return [];
|
|
969
|
-
}
|
|
970
|
-
const end = Math.min(start + count, totalMarkets);
|
|
971
|
-
const markets = await (0, arch_controller_1.getRegisteredMarketsPage)(chainId, provider, start, end);
|
|
972
|
-
if (markets.length === 0) {
|
|
973
|
-
return [];
|
|
974
|
-
}
|
|
975
|
-
const infos = await (0, market_lens_1.getLatestMarketsDataWithLenderStatus)(chainId, provider, account, markets);
|
|
976
|
-
return MarketAccount.hydrateMarketAccounts(chainId, provider, account, infos);
|
|
977
|
-
}
|
|
978
|
-
const infos = await (0, market_lens_1.getLegacyPaginatedMarketsDataWithLenderStatus)(chainId, provider, account, start, count);
|
|
979
|
-
return MarketAccount.hydrateMarketAccounts(chainId, provider, account, infos);
|
|
970
|
+
static getPaginatedMarketAccounts(chainId, provider, account, start = 0, count) {
|
|
971
|
+
const lens = (0, constants_1.getLensContract)(chainId, provider);
|
|
972
|
+
return lens
|
|
973
|
+
.getPaginatedMarketsDataWithLenderStatus(account, start, count)
|
|
974
|
+
.then((infos) => infos.map((info) => MarketAccount.fromMarketDataWithLenderStatus(chainId, provider, account, info)));
|
|
980
975
|
}
|
|
981
976
|
}
|
|
982
977
|
exports.MarketAccount = MarketAccount;
|
|
983
|
-
const toQueueWithdrawalTransaction = (underlyingToken,
|
|
984
|
-
|
|
985
|
-
|
|
986
|
-
|
|
987
|
-
|
|
988
|
-
|
|
989
|
-
|
|
990
|
-
|
|
991
|
-
|
|
992
|
-
transactionHash: receipt.transactionHash,
|
|
993
|
-
blockNumber: Number(receipt.blockNumber),
|
|
994
|
-
expiry: Number(event.args.expiry),
|
|
995
|
-
lender: event.args.account,
|
|
996
|
-
market: marketAddress,
|
|
997
|
-
scaledAmount: (0, token_1.toRawAmount)(event.args.scaledAmount),
|
|
998
|
-
originalAmount: underlyingToken.getAmount(event.args.normalizedAmount)
|
|
999
|
-
};
|
|
1000
|
-
};
|
|
978
|
+
const toQueueWithdrawalTransaction = (underlyingToken, log) => ({
|
|
979
|
+
transactionHash: log.transactionHash,
|
|
980
|
+
blockNumber: log.blockNumber,
|
|
981
|
+
expiry: log.args.expiry.toNumber(),
|
|
982
|
+
lender: log.args.account,
|
|
983
|
+
market: log.address,
|
|
984
|
+
scaledAmount: log.args.scaledAmount,
|
|
985
|
+
originalAmount: underlyingToken.getAmount(log.args.normalizedAmount)
|
|
986
|
+
});
|
|
1001
987
|
//# sourceMappingURL=index.js.map
|