@gearbox-protocol/sdk 17.0.0-next.4 → 17.1.0-next.1
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/dist/cjs/dev/abi.js +14 -15
- package/dist/cjs/dev/claimFromFaucet.js +4 -8
- package/dist/cjs/dev/createAnvilClient.js +35 -17
- package/dist/cjs/dev/index.js +7 -2
- package/dist/cjs/dev/kycUtils.js +66 -58
- package/dist/cjs/dev/midasUtils.js +113 -16
- package/dist/cjs/dev/securitizeUtils.js +82 -42
- package/dist/cjs/dev/withdrawalUtils.js +3 -6
- package/dist/cjs/model/errors/index.js +2 -0
- package/dist/cjs/model/errors/operation-errors.js +19 -1
- package/dist/cjs/model/index.js +4 -2
- package/dist/cjs/model/rwa.js +4 -4
- package/dist/cjs/model/rwa.schema.js +4 -4
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/cjs/onchain/OnchainSDK.js +3 -3
- package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +2 -17
- package/dist/cjs/onchain/accounts/intents/borrow.js +140 -0
- package/dist/cjs/onchain/accounts/intents/collateral-valuation.js +41 -0
- package/dist/cjs/onchain/accounts/intents/guards.js +15 -3
- package/dist/cjs/onchain/accounts/intents/index.js +107 -20
- package/dist/cjs/onchain/accounts/intents/leverage-band.js +2 -12
- package/dist/cjs/onchain/accounts/intents/math.js +12 -3
- package/dist/cjs/onchain/accounts/intents/maxBorrow.js +89 -0
- package/dist/cjs/onchain/accounts/intents/maxWithdrawCollateral.js +15 -41
- package/dist/cjs/onchain/accounts/intents/open-strategy.js +8 -46
- package/dist/cjs/onchain/accounts/intents/operations.js +0 -1
- package/dist/cjs/onchain/accounts/intents/plan.js +1 -8
- package/dist/cjs/onchain/accounts/intents/realize.js +61 -4
- package/dist/cjs/onchain/accounts/intents/tail.js +1 -1
- package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/cjs/onchain/accounts/intents/utils/common.js +19 -0
- package/dist/cjs/onchain/accounts/intents/utils/credit-account-slice.js +21 -0
- package/dist/cjs/onchain/accounts/intents/utils/index.js +2 -0
- package/dist/cjs/onchain/accounts/intents/utils/price-impact.js +12 -9
- package/dist/cjs/onchain/accounts/intents/utils/router-path.js +4 -5
- package/dist/cjs/onchain/accounts/intents/withdraw-limits.js +97 -0
- package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/cjs/onchain/constants/address-provider.js +0 -2
- package/dist/cjs/onchain/constants/index.js +0 -1
- package/dist/cjs/onchain/core/createAddressProvider.js +2 -5
- package/dist/cjs/onchain/index.js +60 -43
- package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +2 -2
- package/dist/cjs/onchain/market/adapters/contracts/AbstractAdapter.js +6 -0
- package/dist/cjs/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +49 -5
- package/dist/cjs/onchain/market/credit/CreditSuite.js +26 -9
- package/dist/cjs/onchain/market/index.js +50 -38
- package/dist/cjs/onchain/market/oracle/PriceOracleBaseContract.js +3 -3
- package/dist/cjs/onchain/market/pricefeeds/AbstractPriceFeed.js +0 -5
- package/dist/cjs/onchain/market/pricefeeds/PriceFeedRegistry.js +127 -0
- package/dist/cjs/onchain/market/pricefeeds/{BalancerStablePriceFeed.js → feeds/BalancerStablePriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.js → feeds/BalancerWeightedPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{BoundedPriceFeed.js → feeds/BoundedPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{CompositePriceFeed.js → feeds/CompositePriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{ConstantPriceFeed.js → feeds/ConstantPriceFeed.js} +3 -3
- package/dist/cjs/onchain/market/pricefeeds/{CurveCryptoPriceFeed.js → feeds/CurveCryptoPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{CurveStablePriceFeed.js → feeds/CurveStablePriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{CurveUSDPriceFeed.js → feeds/CurveUSDPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{Erc4626PriceFeed.js → feeds/Erc4626PriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{ExternalPriceFeed.js → feeds/ExternalPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{MellowLRTPriceFeed.js → feeds/MellowLRTPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.js → feeds/PendleTWAPPTPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{PythPriceFeed.js → feeds/PythPriceFeed.js} +3 -3
- package/dist/cjs/onchain/market/pricefeeds/{RedstonePriceFeed.js → feeds/RedstonePriceFeed.js} +6 -6
- package/dist/cjs/onchain/market/pricefeeds/{WstETHPriceFeed.js → feeds/WstETHPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{YearnPriceFeed.js → feeds/YearnPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{ZeroPriceFeed.js → feeds/ZeroPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/feeds/index.js +35 -0
- package/dist/cjs/onchain/market/pricefeeds/index.js +51 -39
- package/dist/cjs/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.js +189 -0
- package/dist/cjs/onchain/market/pricefeeds/{getRawPriceUpdates.js → updates/getRawPriceUpdates.js} +2 -2
- package/dist/cjs/onchain/market/pricefeeds/updates/index.js +8 -0
- package/dist/cjs/onchain/market/pricefeeds/{isUpdatablePriceFeed.js → updates/isUpdatablePriceFeed.js} +1 -1
- package/dist/cjs/onchain/market/pricefeeds/updates/updatableDependencies.js +14 -0
- package/dist/cjs/onchain/market/rwa/RWARegistry.js +4 -7
- package/dist/cjs/onchain/market/rwa/index.js +1 -0
- package/dist/cjs/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +56 -12
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
- package/dist/cjs/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
- package/dist/cjs/onchain/opportunities/OpportunitiesService.js +16 -4
- package/dist/cjs/onchain/pools/PoolService.js +7 -8
- package/dist/cjs/onchain/positions/calcHealthFactor.js +3 -3
- package/dist/cjs/onchain/preview/index.js +2 -0
- package/dist/cjs/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
- package/dist/cjs/onchain/preview/preview/index.js +2 -0
- package/dist/cjs/onchain/preview/preview/midasGreenlistsAccount.js +17 -0
- package/dist/cjs/onchain/preview/preview/previewOpenStrategyPosition.js +13 -16
- package/dist/cjs/onchain/preview/preview/previewOperation.js +19 -11
- package/dist/cjs/onchain/preview/preview/replayMulticall.js +4 -3
- package/dist/cjs/onchain/validation/bundles/checkCollateralFunding.js +3 -3
- package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +11 -9
- package/dist/cjs/onchain/validation/bundles/{checkDraw.js → checkIncreaseDebt.js} +10 -10
- package/dist/cjs/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
- package/dist/cjs/onchain/validation/bundles/checkMidasAccountGreenlist.js +44 -0
- package/dist/cjs/onchain/validation/bundles/checkPoolOperation.js +2 -8
- package/dist/cjs/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
- package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +18 -8
- package/dist/cjs/onchain/validation/bundles/index.js +6 -4
- package/dist/cjs/onchain/validation/checkOperation.js +0 -1
- package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +1 -1
- package/dist/cjs/onchain/validation/checks/checkPoolLiquidity.js +2 -9
- package/dist/cjs/onchain/validation/checks/checkReservePriceLimited.js +30 -0
- package/dist/cjs/onchain/validation/checks/index.js +2 -0
- package/dist/cjs/onchain/validation/index.js +8 -4
- package/dist/cjs/permissionless/utils/price-update/get-price-update-tx.js +2 -2
- package/dist/cjs/permissionless/utils/price-update/get-updatable-feeds.js +2 -2
- package/dist/cjs/sdk/execute/ExecuteApi.js +67 -7
- package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +9 -3
- package/dist/cjs/sdk/prepare/PrepareApi.js +89 -14
- package/dist/esm/dev/abi.js +14 -15
- package/dist/esm/dev/claimFromFaucet.js +4 -8
- package/dist/esm/dev/createAnvilClient.js +36 -19
- package/dist/esm/dev/index.js +4 -4
- package/dist/esm/dev/kycUtils.js +66 -59
- package/dist/esm/dev/midasUtils.js +112 -18
- package/dist/esm/dev/securitizeUtils.js +84 -44
- package/dist/esm/dev/withdrawalUtils.js +3 -6
- package/dist/esm/model/errors/index.js +2 -2
- package/dist/esm/model/errors/operation-errors.js +18 -2
- package/dist/esm/model/index.js +4 -4
- package/dist/esm/model/rwa.js +4 -4
- package/dist/esm/model/rwa.schema.js +5 -5
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/esm/onchain/OnchainSDK.js +3 -3
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -17
- package/dist/esm/onchain/accounts/intents/borrow.js +138 -0
- package/dist/esm/onchain/accounts/intents/collateral-valuation.js +40 -0
- package/dist/esm/onchain/accounts/intents/guards.js +15 -3
- package/dist/esm/onchain/accounts/intents/index.js +107 -20
- package/dist/esm/onchain/accounts/intents/leverage-band.js +2 -12
- package/dist/esm/onchain/accounts/intents/math.js +13 -5
- package/dist/esm/onchain/accounts/intents/maxBorrow.js +87 -0
- package/dist/esm/onchain/accounts/intents/maxWithdrawCollateral.js +15 -41
- package/dist/esm/onchain/accounts/intents/open-strategy.js +8 -46
- package/dist/esm/onchain/accounts/intents/operations.js +0 -1
- package/dist/esm/onchain/accounts/intents/plan.js +1 -8
- package/dist/esm/onchain/accounts/intents/realize.js +61 -4
- package/dist/esm/onchain/accounts/intents/tail.js +1 -1
- package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/esm/onchain/accounts/intents/utils/common.js +19 -1
- package/dist/esm/onchain/accounts/intents/utils/credit-account-slice.js +21 -1
- package/dist/esm/onchain/accounts/intents/utils/index.js +3 -3
- package/dist/esm/onchain/accounts/intents/utils/price-impact.js +12 -9
- package/dist/esm/onchain/accounts/intents/utils/router-path.js +4 -5
- package/dist/esm/onchain/accounts/intents/withdraw-limits.js +95 -0
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/constants/address-provider.js +1 -2
- package/dist/esm/onchain/constants/index.js +2 -2
- package/dist/esm/onchain/core/createAddressProvider.js +2 -5
- package/dist/esm/onchain/index.js +32 -24
- package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +2 -2
- package/dist/esm/onchain/market/adapters/contracts/AbstractAdapter.js +6 -0
- package/dist/esm/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +50 -6
- package/dist/esm/onchain/market/credit/CreditSuite.js +26 -9
- package/dist/esm/onchain/market/index.js +26 -21
- package/dist/esm/onchain/market/oracle/PriceOracleBaseContract.js +1 -1
- package/dist/esm/onchain/market/pricefeeds/AbstractPriceFeed.js +0 -5
- package/dist/esm/onchain/market/pricefeeds/PriceFeedRegistry.js +126 -0
- package/dist/esm/onchain/market/pricefeeds/{BalancerStablePriceFeed.js → feeds/BalancerStablePriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.js → feeds/BalancerWeightedPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{BoundedPriceFeed.js → feeds/BoundedPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{CompositePriceFeed.js → feeds/CompositePriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{ConstantPriceFeed.js → feeds/ConstantPriceFeed.js} +3 -3
- package/dist/esm/onchain/market/pricefeeds/{CurveCryptoPriceFeed.js → feeds/CurveCryptoPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{CurveStablePriceFeed.js → feeds/CurveStablePriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{CurveUSDPriceFeed.js → feeds/CurveUSDPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{Erc4626PriceFeed.js → feeds/Erc4626PriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{ExternalPriceFeed.js → feeds/ExternalPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{MellowLRTPriceFeed.js → feeds/MellowLRTPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.js → feeds/PendleTWAPPTPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{PythPriceFeed.js → feeds/PythPriceFeed.js} +3 -3
- package/dist/esm/onchain/market/pricefeeds/{RedstonePriceFeed.js → feeds/RedstonePriceFeed.js} +6 -6
- package/dist/esm/onchain/market/pricefeeds/{WstETHPriceFeed.js → feeds/WstETHPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{YearnPriceFeed.js → feeds/YearnPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{ZeroPriceFeed.js → feeds/ZeroPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/feeds/index.js +18 -0
- package/dist/esm/onchain/market/pricefeeds/index.js +27 -21
- package/dist/esm/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.js +188 -0
- package/dist/esm/onchain/market/pricefeeds/{getRawPriceUpdates.js → updates/getRawPriceUpdates.js} +2 -2
- package/dist/esm/onchain/market/pricefeeds/updates/index.js +5 -1
- package/dist/esm/onchain/market/pricefeeds/{isUpdatablePriceFeed.js → updates/isUpdatablePriceFeed.js} +1 -1
- package/dist/esm/onchain/market/pricefeeds/updates/updatableDependencies.js +13 -0
- package/dist/esm/onchain/market/rwa/RWARegistry.js +4 -8
- package/dist/esm/onchain/market/rwa/index.js +2 -2
- package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +55 -10
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
- package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
- package/dist/esm/onchain/opportunities/OpportunitiesService.js +16 -4
- package/dist/esm/onchain/pools/PoolService.js +7 -8
- package/dist/esm/onchain/positions/calcHealthFactor.js +3 -3
- package/dist/esm/onchain/preview/index.js +2 -1
- package/dist/esm/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
- package/dist/esm/onchain/preview/preview/index.js +2 -1
- package/dist/esm/onchain/preview/preview/midasGreenlistsAccount.js +16 -0
- package/dist/esm/onchain/preview/preview/previewOpenStrategyPosition.js +14 -17
- package/dist/esm/onchain/preview/preview/previewOperation.js +19 -11
- package/dist/esm/onchain/preview/preview/replayMulticall.js +4 -3
- package/dist/esm/onchain/validation/bundles/checkCollateralFunding.js +3 -3
- package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +11 -9
- package/dist/esm/onchain/validation/bundles/checkIncreaseDebt.js +27 -0
- package/dist/esm/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
- package/dist/esm/onchain/validation/bundles/checkMidasAccountGreenlist.js +43 -0
- package/dist/esm/onchain/validation/bundles/checkPoolOperation.js +2 -8
- package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
- package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +18 -8
- package/dist/esm/onchain/validation/bundles/index.js +4 -3
- package/dist/esm/onchain/validation/checkOperation.js +0 -1
- package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +1 -1
- package/dist/esm/onchain/validation/checks/checkPoolLiquidity.js +2 -9
- package/dist/esm/onchain/validation/checks/checkReservePriceLimited.js +29 -0
- package/dist/esm/onchain/validation/checks/index.js +2 -1
- package/dist/esm/onchain/validation/index.js +5 -3
- package/dist/esm/permissionless/utils/price-update/get-price-update-tx.js +1 -1
- package/dist/esm/permissionless/utils/price-update/get-updatable-feeds.js +1 -1
- package/dist/esm/sdk/execute/ExecuteApi.js +67 -7
- package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +9 -3
- package/dist/esm/sdk/prepare/PrepareApi.js +94 -19
- package/dist/types/dev/abi.d.ts +13 -15
- package/dist/types/dev/claimFromFaucet.d.ts +0 -1
- package/dist/types/dev/createAnvilClient.d.ts +10 -3
- package/dist/types/dev/index.d.ts +4 -4
- package/dist/types/dev/kycUtils.d.ts +15 -24
- package/dist/types/dev/midasUtils.d.ts +35 -4
- package/dist/types/dev/securitizeUtils.d.ts +3 -9
- package/dist/types/model/errors/index.d.ts +2 -2
- package/dist/types/model/errors/operation-errors.d.ts +62 -7
- package/dist/types/model/index.d.ts +5 -5
- package/dist/types/model/opportunities.d.ts +6 -7
- package/dist/types/model/previews.d.ts +25 -19
- package/dist/types/model/rwa.d.ts +47 -27
- package/dist/types/model/rwa.schema.d.ts +3 -3
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -2
- package/dist/types/offchain/opportunities/types.d.ts +1 -4
- package/dist/types/onchain/OnchainSDK.d.ts +2 -2
- package/dist/types/onchain/accounts/index.d.ts +5 -4
- package/dist/types/onchain/accounts/intents/borrow.d.ts +141 -0
- package/dist/types/onchain/accounts/intents/collateral-valuation.d.ts +42 -0
- package/dist/types/onchain/accounts/intents/guards.d.ts +18 -2
- package/dist/types/onchain/accounts/intents/index.d.ts +103 -15
- package/dist/types/onchain/accounts/intents/math.d.ts +11 -3
- package/dist/types/onchain/accounts/intents/maxBorrow.d.ts +54 -0
- package/dist/types/onchain/accounts/intents/maxWithdrawCollateral.d.ts +3 -8
- package/dist/types/onchain/accounts/intents/open-strategy.d.ts +3 -17
- package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +2 -0
- package/dist/types/onchain/accounts/intents/tests/open-strategy.fixtures.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/types.d.ts +51 -6
- package/dist/types/onchain/accounts/intents/utils/common.d.ts +15 -1
- package/dist/types/onchain/accounts/intents/utils/credit-account-slice.d.ts +14 -1
- package/dist/types/onchain/accounts/intents/utils/index.d.ts +3 -3
- package/dist/types/onchain/accounts/intents/utils/price-impact.d.ts +4 -1
- package/dist/types/onchain/accounts/intents/utils/router-path.d.ts +2 -5
- package/dist/types/onchain/accounts/intents/withdraw-limits.d.ts +80 -0
- package/dist/types/onchain/accounts/types.d.ts +4 -2
- package/dist/types/onchain/constants/address-provider.d.ts +1 -2
- package/dist/types/onchain/constants/index.d.ts +2 -2
- package/dist/types/onchain/index.d.ts +40 -31
- package/dist/types/onchain/market/adapters/contracts/AbstractAdapter.d.ts +6 -0
- package/dist/types/onchain/market/adapters/contracts/MidasGatewayAdapterContract.d.ts +20 -4
- package/dist/types/onchain/market/adapters/types.d.ts +8 -0
- package/dist/types/onchain/market/credit/CreditSuite.d.ts +13 -3
- package/dist/types/onchain/market/index.d.ts +29 -24
- package/dist/types/onchain/market/oracle/PriceOracleBaseContract.d.ts +2 -1
- package/dist/types/onchain/market/oracle/types.d.ts +2 -1
- package/dist/types/onchain/market/pool/types.d.ts +1 -1
- package/dist/types/onchain/market/pricefeeds/AbstractPriceFeed.d.ts +1 -2
- package/dist/types/onchain/market/pricefeeds/PriceFeedRegistry.d.ts +60 -0
- package/dist/types/onchain/market/pricefeeds/feeds/BalancerStablePriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.d.ts → feeds/BalancerWeightedPriceFeed.d.ts} +7 -7
- package/dist/types/onchain/market/pricefeeds/feeds/BoundedPriceFeed.d.ts +15 -0
- package/dist/types/onchain/market/pricefeeds/{CompositePriceFeed.d.ts → feeds/CompositePriceFeed.d.ts} +6 -6
- package/dist/types/onchain/market/pricefeeds/{ConstantPriceFeed.d.ts → feeds/ConstantPriceFeed.d.ts} +6 -6
- package/dist/types/onchain/market/pricefeeds/feeds/CurveCryptoPriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/feeds/CurveStablePriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/feeds/CurveUSDPriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/feeds/Erc4626PriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/feeds/ExternalPriceFeed.d.ts +11 -0
- package/dist/types/onchain/market/pricefeeds/feeds/MellowLRTPriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.d.ts → feeds/PendleTWAPPTPriceFeed.d.ts} +3 -3
- package/dist/types/onchain/market/pricefeeds/{PythPriceFeed.d.ts → feeds/PythPriceFeed.d.ts} +3 -3
- package/dist/types/onchain/market/pricefeeds/{RedstonePriceFeed.d.ts → feeds/RedstonePriceFeed.d.ts} +9 -9
- package/dist/types/onchain/market/pricefeeds/feeds/WstETHPriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/feeds/YearnPriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/feeds/ZeroPriceFeed.d.ts +11 -0
- package/dist/types/onchain/market/pricefeeds/feeds/index.d.ts +18 -0
- package/dist/types/onchain/market/pricefeeds/index.d.ts +28 -22
- package/dist/types/onchain/market/pricefeeds/types.d.ts +1 -31
- package/dist/types/onchain/market/pricefeeds/updates/RedstoneUpdater.d.ts +1 -1
- package/dist/types/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.d.ts +106 -0
- package/dist/types/onchain/market/pricefeeds/updates/getRawPriceUpdates.d.ts +6 -0
- package/dist/types/onchain/market/pricefeeds/updates/index.d.ts +7 -3
- package/dist/types/onchain/market/pricefeeds/updates/isUpdatablePriceFeed.d.ts +6 -0
- package/dist/types/onchain/market/pricefeeds/updates/types.d.ts +56 -2
- package/dist/types/onchain/market/pricefeeds/updates/updatableDependencies.d.ts +10 -0
- package/dist/types/onchain/market/rwa/RWARegistry.d.ts +2 -1
- package/dist/types/onchain/market/rwa/index.d.ts +3 -3
- package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +19 -4
- package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +24 -4
- package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +2 -14
- package/dist/types/onchain/market/rwa/types.d.ts +39 -37
- package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +5 -1
- package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +10 -3
- package/dist/types/onchain/opportunities/types.d.ts +6 -1
- package/dist/types/onchain/pools/PoolService.d.ts +5 -0
- package/dist/types/onchain/pools/types.d.ts +9 -2
- package/dist/types/onchain/preview/index.d.ts +2 -1
- package/dist/types/onchain/preview/preview/index.d.ts +2 -1
- package/dist/types/onchain/preview/preview/midasGreenlistsAccount.d.ts +13 -0
- package/dist/types/onchain/preview/preview/previewOpenStrategyPosition.d.ts +5 -3
- package/dist/types/onchain/preview/preview/replayMulticall.d.ts +8 -7
- package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +5 -4
- package/dist/types/onchain/validation/bundles/{checkDraw.d.ts → checkIncreaseDebt.d.ts} +7 -7
- package/dist/types/onchain/validation/bundles/{checkQuotasAsked.d.ts → checkIncreaseQuota.d.ts} +3 -3
- package/dist/types/onchain/validation/bundles/checkMidasAccountGreenlist.d.ts +22 -0
- package/dist/types/onchain/validation/bundles/checkPoolOperation.d.ts +1 -7
- package/dist/types/onchain/validation/bundles/checkRWAOpenRequirements.d.ts +2 -2
- package/dist/types/onchain/validation/bundles/checkRWAOpening.d.ts +9 -7
- package/dist/types/onchain/validation/bundles/index.d.ts +5 -4
- package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +1 -1
- package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +2 -2
- package/dist/types/onchain/validation/checks/checkPoolLiquidity.d.ts +1 -8
- package/dist/types/onchain/validation/checks/checkReservePriceLimited.d.ts +31 -0
- package/dist/types/onchain/validation/checks/index.d.ts +2 -1
- package/dist/types/onchain/validation/index.d.ts +6 -4
- package/dist/types/onchain/validation/raise.d.ts +2 -2
- package/dist/types/sdk/execute/index.d.ts +2 -2
- package/dist/types/sdk/execute/types.d.ts +48 -6
- package/dist/types/sdk/index.d.ts +5 -4
- package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +5 -1
- package/dist/types/sdk/opportunities/types.d.ts +9 -3
- package/dist/types/sdk/prepare/PrepareApi.d.ts +16 -4
- package/dist/types/sdk/prepare/index.d.ts +4 -3
- package/dist/types/sdk/prepare/types.d.ts +200 -66
- package/package.json +1 -1
- package/dist/cjs/onchain/accounts/utils/midasUtils.js +0 -70
- package/dist/cjs/onchain/market/pricefeeds/PriceFeedsRegister.js +0 -301
- package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -61
- package/dist/cjs/plugins/degen-distributors/index.js +0 -4
- package/dist/cjs/plugins/degen-distributors/package.json +0 -1
- package/dist/cjs/plugins/degen-distributors/types.js +0 -1
- package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -114
- package/dist/cjs/plugins/delayed-withdrawal/index.js +0 -4
- package/dist/cjs/plugins/delayed-withdrawal/package.json +0 -1
- package/dist/cjs/plugins/delayed-withdrawal/types.js +0 -1
- package/dist/esm/onchain/accounts/utils/midasUtils.js +0 -69
- package/dist/esm/onchain/market/pricefeeds/PriceFeedsRegister.js +0 -300
- package/dist/esm/onchain/validation/bundles/checkDraw.js +0 -27
- package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -60
- package/dist/esm/plugins/degen-distributors/index.js +0 -3
- package/dist/esm/plugins/degen-distributors/package.json +0 -1
- package/dist/esm/plugins/degen-distributors/types.js +0 -1
- package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -113
- package/dist/esm/plugins/delayed-withdrawal/index.js +0 -3
- package/dist/esm/plugins/delayed-withdrawal/package.json +0 -1
- package/dist/esm/plugins/delayed-withdrawal/types.js +0 -1
- package/dist/types/onchain/accounts/utils/midasUtils.d.ts +0 -38
- package/dist/types/onchain/market/pricefeeds/BalancerStablePriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/BoundedPriceFeed.d.ts +0 -15
- package/dist/types/onchain/market/pricefeeds/CurveCryptoPriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/CurveStablePriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/CurveUSDPriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/Erc4626PriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/ExternalPriceFeed.d.ts +0 -11
- package/dist/types/onchain/market/pricefeeds/MellowLRTPriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/PriceFeedsRegister.d.ts +0 -180
- package/dist/types/onchain/market/pricefeeds/WstETHPriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/YearnPriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/ZeroPriceFeed.d.ts +0 -11
- package/dist/types/onchain/market/pricefeeds/getRawPriceUpdates.d.ts +0 -5
- package/dist/types/onchain/market/pricefeeds/isUpdatablePriceFeed.d.ts +0 -5
- package/dist/types/plugins/degen-distributors/DegenDistributorsPlugin.d.ts +0 -25
- package/dist/types/plugins/degen-distributors/index.d.ts +0 -3
- package/dist/types/plugins/degen-distributors/types.d.ts +0 -8
- package/dist/types/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.d.ts +0 -25
- package/dist/types/plugins/delayed-withdrawal/index.d.ts +0 -3
- package/dist/types/plugins/delayed-withdrawal/types.d.ts +0 -10
|
@@ -37,12 +37,18 @@ var MultichainOpportunitiesService = class extends MultichainConstruct {
|
|
|
37
37
|
*
|
|
38
38
|
* See {@link MultichainOpportunitiesService.getPool}.
|
|
39
39
|
**/
|
|
40
|
-
async getStrategy(key
|
|
40
|
+
async getStrategy(key) {
|
|
41
41
|
return this.queryChain({
|
|
42
42
|
network: key.chainId,
|
|
43
|
-
run: (sdk) => sdk.opportunities.getStrategy(key
|
|
43
|
+
run: (sdk) => sdk.opportunities.getStrategy(key)
|
|
44
44
|
});
|
|
45
45
|
}
|
|
46
|
+
/**
|
|
47
|
+
* {@inheritDoc OpportunitiesService.isEligibleForStrategy}
|
|
48
|
+
**/
|
|
49
|
+
async isEligibleForStrategy(key, wallet) {
|
|
50
|
+
return this.sdk.chain(key.chainId).opportunities.isEligibleForStrategy(key, wallet);
|
|
51
|
+
}
|
|
46
52
|
};
|
|
47
53
|
//#endregion
|
|
48
54
|
export { MultichainOpportunitiesService };
|
|
@@ -36,22 +36,34 @@ var OpportunitiesService = class extends SDKConstruct {
|
|
|
36
36
|
* A single strategy opportunity plus the rate curve of the pool it borrows
|
|
37
37
|
* from and the price feeds its liquidation price depends on.
|
|
38
38
|
*
|
|
39
|
-
*
|
|
40
|
-
* with the strategy's KYC provider first; `null` otherwise.
|
|
39
|
+
* `kyc` is the strategy's KYC gate, independent of any wallet.
|
|
41
40
|
*
|
|
42
41
|
* @throws If the credit manager is unknown, or does not currently offer a
|
|
43
42
|
* strategy.
|
|
44
43
|
**/
|
|
45
|
-
async getStrategy(key
|
|
44
|
+
async getStrategy(key) {
|
|
46
45
|
const suite = this.sdk.marketRegister.findCreditManager(key.creditManager);
|
|
47
46
|
const detail = suite.strategyOpportunityDetail();
|
|
48
47
|
if (!detail) throw new Error(`credit manager ${key.creditManager} does not currently offer a strategy`);
|
|
49
|
-
const kyc =
|
|
48
|
+
const kyc = await suite.kycRequirement(detail.targetCollateral.address);
|
|
50
49
|
return {
|
|
51
50
|
...detail,
|
|
52
51
|
kyc
|
|
53
52
|
};
|
|
54
53
|
}
|
|
54
|
+
/**
|
|
55
|
+
* Whether `wallet` may open this strategy today: `true` when it is not
|
|
56
|
+
* KYC-gated or the wallet already passed the gate.
|
|
57
|
+
*
|
|
58
|
+
* @throws If the credit manager is unknown, or does not currently offer a
|
|
59
|
+
* strategy.
|
|
60
|
+
**/
|
|
61
|
+
async isEligibleForStrategy(key, wallet) {
|
|
62
|
+
const suite = this.sdk.marketRegister.findCreditManager(key.creditManager);
|
|
63
|
+
const opportunity = suite.strategyOpportunity();
|
|
64
|
+
if (!opportunity) throw new Error(`credit manager ${key.creditManager} does not currently offer a strategy`);
|
|
65
|
+
return suite.isEligibleForStrategy(wallet, opportunity.targetCollateral.address);
|
|
66
|
+
}
|
|
55
67
|
};
|
|
56
68
|
//#endregion
|
|
57
69
|
export { OpportunitiesService };
|
|
@@ -154,7 +154,7 @@ var PoolService = class extends SDKConstruct {
|
|
|
154
154
|
tokenIn: toTokenAmount(tokenIn, pool.pool.underlyingToShares(amount * PERCENTAGE_FACTOR / (PERCENTAGE_FACTOR - pool.pool.withdrawFee), true)),
|
|
155
155
|
tokenOut: toTokenAmount(tokenOut, amount),
|
|
156
156
|
zapper: zapper?.baseParams.addr,
|
|
157
|
-
availableLiquidity: this
|
|
157
|
+
availableLiquidity: this.withdrawableLiquidity(poolAddr)
|
|
158
158
|
};
|
|
159
159
|
}
|
|
160
160
|
/**
|
|
@@ -176,7 +176,7 @@ var PoolService = class extends SDKConstruct {
|
|
|
176
176
|
tokenIn: toTokenAmount(tokenIn, amount),
|
|
177
177
|
tokenOut: toTokenAmount(tokenOut, pool.pool.sharesToUnderlying(amount) * (PERCENTAGE_FACTOR - pool.pool.withdrawFee) / PERCENTAGE_FACTOR),
|
|
178
178
|
zapper: zapper?.baseParams.addr,
|
|
179
|
-
availableLiquidity: this
|
|
179
|
+
availableLiquidity: this.withdrawableLiquidity(poolAddr)
|
|
180
180
|
};
|
|
181
181
|
}
|
|
182
182
|
/**
|
|
@@ -405,12 +405,11 @@ var PoolService = class extends SDKConstruct {
|
|
|
405
405
|
};
|
|
406
406
|
}
|
|
407
407
|
/**
|
|
408
|
-
*
|
|
409
|
-
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
return market.priceOracle.toAmount(pool.underlying, pool.pool.availableLiquidity * 99999n / 100000n);
|
|
408
|
+
* {@inheritDoc IPoolsService.withdrawableLiquidity}
|
|
409
|
+
*/
|
|
410
|
+
withdrawableLiquidity(pool) {
|
|
411
|
+
const market = this.sdk.marketRegister.findByPool(pool);
|
|
412
|
+
return market.priceOracle.toAmount(market.pool.underlying, market.pool.pool.availableLiquidity * 99999n / 100000n);
|
|
414
413
|
}
|
|
415
414
|
};
|
|
416
415
|
//#endregion
|
|
@@ -35,7 +35,7 @@ function calcHealthFactor(props) {
|
|
|
35
35
|
const scale = 10n ** BigInt(decimalsByToken.get(token) ?? 18);
|
|
36
36
|
return amount * price / scale;
|
|
37
37
|
};
|
|
38
|
-
const
|
|
38
|
+
const assetValue = snapshot.assets.reduce((acc, { token, balance }) => {
|
|
39
39
|
if (balance <= 10n) return acc;
|
|
40
40
|
const lt = BigInt(lts.get(token) ?? 0);
|
|
41
41
|
const tokenLtWeighted = (convertToUSD(token, balance, true) ?? 0n) * lt;
|
|
@@ -44,8 +44,8 @@ function calcHealthFactor(props) {
|
|
|
44
44
|
const quotaWeighted = (convertToUSD(underlying, quotaBalance) ?? 0n) * PERCENTAGE_FACTOR;
|
|
45
45
|
return acc + (quota ? BigIntMath.min(quotaWeighted, tokenLtWeighted) : tokenLtWeighted);
|
|
46
46
|
}, 0n);
|
|
47
|
-
const
|
|
48
|
-
const hf =
|
|
47
|
+
const borrowedValue = convertToUSD(underlying, snapshot.totalDebt) ?? 0n;
|
|
48
|
+
const hf = borrowedValue > 0n ? assetValue / borrowedValue : 0n;
|
|
49
49
|
return Number(hf);
|
|
50
50
|
}
|
|
51
51
|
//#endregion
|
|
@@ -11,10 +11,11 @@ import { classifyCloseOrRepay, isCloseOrRepay } from "./preview/detectCloseOrRep
|
|
|
11
11
|
import { detectDelayedClaim, resolveDelayedClaimIntent } from "./preview/detectDelayedClaim.js";
|
|
12
12
|
import { detectDelayedOperation } from "./preview/detectDelayedOperation.js";
|
|
13
13
|
import { estimateClaimableAt } from "./preview/estimateClaimableAt.js";
|
|
14
|
+
import { midasGreenlistsAccount } from "./preview/midasGreenlistsAccount.js";
|
|
14
15
|
import { previewAdjustStrategyPosition } from "./preview/previewAdjustStrategyPosition.js";
|
|
15
16
|
import { previewExitOrRepayStrategyPosition } from "./preview/previewExitOrRepayStrategyPosition.js";
|
|
16
17
|
import { makeReplayState, replayInnerOperations } from "./preview/replayInnerOperations.js";
|
|
17
18
|
import { replayMulticall } from "./preview/replayMulticall.js";
|
|
18
19
|
import { previewOperation } from "./preview/previewOperation.js";
|
|
19
20
|
import "./preview/index.js";
|
|
20
|
-
export { CreditAccountState, buildDelayedStrategyPositionOperationPreview, classifyCloseOrRepay, classifyInnerOperations, detectDelayedClaim, detectDelayedOperation, estimateClaimableAt, isCloseOrRepay, isPoolOperation, isRWAOperation, makeReplayState, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parseRWAFactoryOperationCalldata, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
|
|
21
|
+
export { CreditAccountState, buildDelayedStrategyPositionOperationPreview, classifyCloseOrRepay, classifyInnerOperations, detectDelayedClaim, detectDelayedOperation, estimateClaimableAt, isCloseOrRepay, isPoolOperation, isRWAOperation, makeReplayState, midasGreenlistsAccount, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parseRWAFactoryOperationCalldata, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { hexEq } from "../../utils/hex.js";
|
|
2
2
|
import { AbstractAdapterContract } from "../../market/adapters/contracts/AbstractAdapter.js";
|
|
3
3
|
import { CreditFacadeV310Contract } from "../../market/credit/CreditFacadeV310Contract.js";
|
|
4
|
-
import
|
|
4
|
+
import "../../../model/rwa.js";
|
|
5
5
|
import "../../../model/index.js";
|
|
6
6
|
import { isRWAFactory } from "../../market/rwa/types.js";
|
|
7
7
|
import { classifyInnerOperations } from "./classifyInnerOperations.js";
|
|
@@ -32,7 +32,7 @@ function parseSecuritizeOperationCalldata(sdk, factory, calldata) {
|
|
|
32
32
|
const { rawArgs } = parsed;
|
|
33
33
|
const innerCalls = rawArgs.calls ?? [];
|
|
34
34
|
const args = {
|
|
35
|
-
|
|
35
|
+
protocol: "securitize",
|
|
36
36
|
tokensToRegister: [...rawArgs.tokensToRegister ?? []],
|
|
37
37
|
signaturesToCache: [...rawArgs.signaturesToCache ?? []]
|
|
38
38
|
};
|
|
@@ -4,9 +4,10 @@ import { classifyCloseOrRepay, isCloseOrRepay } from "./detectCloseOrRepay.js";
|
|
|
4
4
|
import { detectDelayedClaim, resolveDelayedClaimIntent } from "./detectDelayedClaim.js";
|
|
5
5
|
import { detectDelayedOperation } from "./detectDelayedOperation.js";
|
|
6
6
|
import { estimateClaimableAt } from "./estimateClaimableAt.js";
|
|
7
|
+
import { midasGreenlistsAccount } from "./midasGreenlistsAccount.js";
|
|
7
8
|
import { previewAdjustStrategyPosition } from "./previewAdjustStrategyPosition.js";
|
|
8
9
|
import { previewExitOrRepayStrategyPosition } from "./previewExitOrRepayStrategyPosition.js";
|
|
9
10
|
import { makeReplayState, replayInnerOperations } from "./replayInnerOperations.js";
|
|
10
11
|
import { replayMulticall } from "./replayMulticall.js";
|
|
11
12
|
import { previewOperation } from "./previewOperation.js";
|
|
12
|
-
export { CreditAccountState, buildDelayedStrategyPositionOperationPreview, classifyCloseOrRepay, detectDelayedClaim, detectDelayedOperation, estimateClaimableAt, isCloseOrRepay, makeReplayState, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
|
|
13
|
+
export { CreditAccountState, buildDelayedStrategyPositionOperationPreview, classifyCloseOrRepay, detectDelayedClaim, detectDelayedOperation, estimateClaimableAt, isCloseOrRepay, makeReplayState, midasGreenlistsAccount, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent };
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import { MidasGatewayAdapterContract } from "../../market/adapters/contracts/MidasGatewayAdapterContract.js";
|
|
2
|
+
//#region src/onchain/preview/preview/midasGreenlistsAccount.ts
|
|
3
|
+
/**
|
|
4
|
+
* Whether the multicall grants the Midas greenlisted role to the credit
|
|
5
|
+
* account via `receiveGreenlist()`.
|
|
6
|
+
*/
|
|
7
|
+
function midasGreenlistsAccount(sdk, multicall) {
|
|
8
|
+
for (const op of multicall) {
|
|
9
|
+
if (op.operation !== "Execute") continue;
|
|
10
|
+
const adapter = sdk.getContract(op.adapter);
|
|
11
|
+
if (adapter instanceof MidasGatewayAdapterContract && adapter.isReceiveGreenlist(op.calldata)) return true;
|
|
12
|
+
}
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
//#endregion
|
|
16
|
+
export { midasGreenlistsAccount };
|
|
@@ -1,26 +1,24 @@
|
|
|
1
1
|
import { AP_WETH_TOKEN } from "../../constants/address-provider.js";
|
|
2
2
|
import { asEstimated } from "../../../model/previews.js";
|
|
3
|
-
import {
|
|
3
|
+
import { sdkOk } from "../../../model/result.js";
|
|
4
4
|
import "../../../model/index.js";
|
|
5
|
-
import {
|
|
5
|
+
import { midasGreenlistsAccount } from "./midasGreenlistsAccount.js";
|
|
6
6
|
import { unwrapNativeCollateral } from "./unwrapNativeCollateral.js";
|
|
7
|
-
import { makeReplayState, replayInnerOperations } from "./replayInnerOperations.js";
|
|
8
7
|
//#region src/onchain/preview/preview/previewOpenStrategyPosition.ts
|
|
9
|
-
function previewOpenStrategyPosition(sdk, input, operation) {
|
|
8
|
+
function previewOpenStrategyPosition(sdk, input, operation, replay) {
|
|
10
9
|
const { value = 0n } = input;
|
|
11
10
|
const market = sdk.marketRegister.findByCreditManager(operation.creditManager);
|
|
12
11
|
const oracle = market.priceOracle;
|
|
13
|
-
const
|
|
14
|
-
const
|
|
15
|
-
if (replayError) return sdkErr(replayError);
|
|
16
|
-
const account = state.account;
|
|
12
|
+
const { before, after } = replay;
|
|
13
|
+
const account = after.account;
|
|
17
14
|
let warning;
|
|
18
|
-
const
|
|
15
|
+
const price = (token, balance) => {
|
|
19
16
|
const priced = oracle.safeConvert(token, market.underlying, balance);
|
|
20
17
|
warning ??= priced.error;
|
|
21
18
|
return priced.value;
|
|
22
|
-
}
|
|
23
|
-
const
|
|
19
|
+
};
|
|
20
|
+
const netValue = before.balances.sum(price) + after.collateralAdded.sum(price) - after.collateralWithdrawn.sum(price);
|
|
21
|
+
const unwrapped = unwrapNativeCollateral(after.collateralAdded.toAssets(), value, sdk.addressProvider.getAddress(AP_WETH_TOKEN, 0));
|
|
24
22
|
if (!unwrapped.ok) return unwrapped;
|
|
25
23
|
const collateral = unwrapped.data;
|
|
26
24
|
const snap = account.toSnapshot(netValue + account.totalDebt);
|
|
@@ -29,16 +27,15 @@ function previewOpenStrategyPosition(sdk, input, operation) {
|
|
|
29
27
|
...asEstimated(sdk.positions.projection(snap, { availableLiquidityChange: -account.totalDebt })),
|
|
30
28
|
targetCollateral: targetAsset ? oracle.toTokenAmount(targetAsset.token, targetAsset.balance) : void 0,
|
|
31
29
|
collateralAdded: collateral.map((a) => oracle.toTokenAmount(a.token, a.balance)),
|
|
30
|
+
collateralWithdrawn: after.collateralWithdrawn.toAssets().map((a) => oracle.toTokenAmount(a.token, a.balance)),
|
|
32
31
|
warning
|
|
33
32
|
};
|
|
34
|
-
if (operation.operation === "RWAOpenCreditAccount") return sdkOk({
|
|
35
|
-
...projection,
|
|
36
|
-
operation: "RWAOpenCreditAccount",
|
|
37
|
-
rwaArgs: operation.args
|
|
38
|
-
});
|
|
39
33
|
return sdkOk({
|
|
40
34
|
...projection,
|
|
41
|
-
operation: "OpenCreditAccount"
|
|
35
|
+
operation: "OpenCreditAccount",
|
|
36
|
+
...operation.operation === "MultiCall" || operation.operation === "BotMulticall" || operation.operation === "RWAMulticall" ? { creditAccount: operation.creditAccount } : {},
|
|
37
|
+
..."args" in operation ? { rwaArgs: operation.args } : {},
|
|
38
|
+
midasGreenlistsAccount: midasGreenlistsAccount(sdk, operation.multicall)
|
|
42
39
|
});
|
|
43
40
|
}
|
|
44
41
|
/**
|
|
@@ -33,9 +33,13 @@ async function previewOperation(sdk, input, options, creditAccount) {
|
|
|
33
33
|
if (!parsed.ok) return parsed;
|
|
34
34
|
const operation = parsed.data;
|
|
35
35
|
if (isPoolOperation(operation)) return previewPoolPositionOperation(sdk, operation, options);
|
|
36
|
-
if (operation.operation === "OpenCreditAccount" || operation.operation === "RWAOpenCreditAccount")
|
|
36
|
+
if (operation.operation === "OpenCreditAccount" || operation.operation === "RWAOpenCreditAccount") {
|
|
37
|
+
const replayed = replayMulticall(sdk, operation);
|
|
38
|
+
if (!replayed.ok) return replayed;
|
|
39
|
+
return previewOpenStrategyPosition(sdk, input, operation, replayed.data);
|
|
40
|
+
}
|
|
37
41
|
if (operation.operation === "CloseCreditAccount") {
|
|
38
|
-
const resolved = await resolveCreditAccount(sdk, operation, options, creditAccount);
|
|
42
|
+
const resolved = await resolveCreditAccount(sdk, operation.creditAccount, options, creditAccount);
|
|
39
43
|
if (!resolved.ok) return resolved;
|
|
40
44
|
const replayed = replayMulticall(sdk, operation, resolved.data);
|
|
41
45
|
if (!replayed.ok) return replayed;
|
|
@@ -47,7 +51,7 @@ async function previewOperation(sdk, input, options, creditAccount) {
|
|
|
47
51
|
return preview;
|
|
48
52
|
}
|
|
49
53
|
if (operation.operation === "MultiCall" || operation.operation === "BotMulticall" || operation.operation === "RWAMulticall") {
|
|
50
|
-
const resolved = await resolveCreditAccount(sdk, operation, options, creditAccount);
|
|
54
|
+
const resolved = await resolveCreditAccount(sdk, operation.creditAccount, options, creditAccount);
|
|
51
55
|
if (!resolved.ok) return resolved;
|
|
52
56
|
const replayed = replayMulticall(sdk, operation, resolved.data);
|
|
53
57
|
if (!replayed.ok) return replayed;
|
|
@@ -64,20 +68,24 @@ async function previewOperation(sdk, input, options, creditAccount) {
|
|
|
64
68
|
* injected state when present, otherwise fetches it from the credit account
|
|
65
69
|
* compressor.
|
|
66
70
|
*/
|
|
67
|
-
async function resolveCreditAccount(sdk,
|
|
68
|
-
let resolved =
|
|
69
|
-
if (!resolved) resolved = await sdk.accounts.getCreditAccountData(
|
|
70
|
-
if (!resolved) return sdkErr(creditAccountNotFound(
|
|
71
|
+
async function resolveCreditAccount(sdk, address, options, data) {
|
|
72
|
+
let resolved = data;
|
|
73
|
+
if (!resolved) resolved = await sdk.accounts.getCreditAccountData(address, options?.blockNumber);
|
|
74
|
+
if (!resolved) return sdkErr(creditAccountNotFound(address));
|
|
71
75
|
return sdkOk(resolved);
|
|
72
76
|
}
|
|
73
77
|
/**
|
|
74
78
|
* Previews a plain/bot/RWA multicall: classifies the instant preview
|
|
75
|
-
* (zero-debt closure/repay
|
|
76
|
-
* delayed withdrawal, wraps the instant
|
|
77
|
-
* `DelayedCreditAccountOperation` together with the
|
|
78
|
-
* the state after the withdrawal is claimed.
|
|
79
|
+
* (reopening a zero-debt account, zero-debt closure/repay, or adjustment)
|
|
80
|
+
* and, when the multicall requests a delayed withdrawal, wraps the instant
|
|
81
|
+
* preview into a `DelayedCreditAccountOperation` together with the
|
|
82
|
+
* best-effort preview of the state after the withdrawal is claimed.
|
|
83
|
+
*
|
|
84
|
+
* A reopening is reported as `OpenCreditAccount` and never as a delayed
|
|
85
|
+
* withdrawal: an opening requests no redemption.
|
|
79
86
|
*/
|
|
80
87
|
async function previewMulticallOperation(sdk, input, operation, replay, blockNumber) {
|
|
88
|
+
if (replay.before.totalDebt === 0n && replay.before.quotas.toAssets(0n).length === 0 && replay.after.account.totalDebt > 0n) return previewOpenStrategyPosition(sdk, input, operation, replay);
|
|
81
89
|
let instantPreview;
|
|
82
90
|
if (isCloseOrRepay(operation.multicall)) {
|
|
83
91
|
const instant = previewExitOrRepayStrategyPosition(sdk, input, operation, false, replay);
|
|
@@ -4,11 +4,12 @@ import { CreditAccountState } from "./CreditAccountState.js";
|
|
|
4
4
|
import { makeReplayState, replayInnerOperations } from "./replayInnerOperations.js";
|
|
5
5
|
//#region src/onchain/preview/preview/replayMulticall.ts
|
|
6
6
|
/**
|
|
7
|
-
* Replays the operation's multicall
|
|
8
|
-
*
|
|
7
|
+
* Replays the operation's multicall via {@link replayInnerOperations}.
|
|
8
|
+
* When `creditAccount` is omitted, the seed is
|
|
9
|
+
* {@link CreditAccountState.beforeOpen} (a fresh opening).
|
|
9
10
|
*/
|
|
10
11
|
function replayMulticall(sdk, operation, creditAccount) {
|
|
11
|
-
const before = CreditAccountState.fromCreditAccountData(creditAccount);
|
|
12
|
+
const before = creditAccount ? CreditAccountState.fromCreditAccountData(creditAccount) : CreditAccountState.beforeOpen(operation.creditManager, sdk.marketRegister.findByCreditManager(operation.creditManager).underlying);
|
|
12
13
|
const after = makeReplayState(before.clone());
|
|
13
14
|
const error = replayInnerOperations(sdk, operation.multicall, after);
|
|
14
15
|
if (error) return sdkErr(error);
|
|
@@ -22,13 +22,13 @@ async function checkCollateralFunding(input) {
|
|
|
22
22
|
if (held.size === 0) return [];
|
|
23
23
|
let spender;
|
|
24
24
|
try {
|
|
25
|
-
if (preview.
|
|
25
|
+
if (preview.creditAccount) spender = await sdk.accounts.getApprovalAddress({
|
|
26
26
|
creditManager: preview.creditManager,
|
|
27
|
-
|
|
27
|
+
creditAccount: preview.creditAccount
|
|
28
28
|
});
|
|
29
29
|
else spender = await sdk.accounts.getApprovalAddress({
|
|
30
30
|
creditManager: preview.creditManager,
|
|
31
|
-
|
|
31
|
+
borrower: sender
|
|
32
32
|
});
|
|
33
33
|
} catch (cause) {
|
|
34
34
|
return [unexpectedFailure(cause, "resolve the approval address")];
|
|
@@ -4,11 +4,11 @@ import { checkDebtLimits } from "../checks/checkDebtLimits.js";
|
|
|
4
4
|
import "../checks/index.js";
|
|
5
5
|
import { checkAccountQuotas } from "./checkAccountQuotas.js";
|
|
6
6
|
import { checkCollateralFunding } from "./checkCollateralFunding.js";
|
|
7
|
-
import { checkDraw } from "./checkDraw.js";
|
|
8
7
|
import { checkHealthFactors } from "./checkHealthFactors.js";
|
|
8
|
+
import { checkIncreaseDebt } from "./checkIncreaseDebt.js";
|
|
9
|
+
import { checkIncreaseQuota } from "./checkIncreaseQuota.js";
|
|
9
10
|
import { checkMarket } from "./checkMarket.js";
|
|
10
11
|
import { checkObtained } from "./checkObtained.js";
|
|
11
|
-
import { checkQuotasAsked } from "./checkQuotasAsked.js";
|
|
12
12
|
import { checkRWAOpening } from "./checkRWAOpening.js";
|
|
13
13
|
//#region src/onchain/validation/bundles/checkCreditOperation.ts
|
|
14
14
|
/**
|
|
@@ -16,15 +16,17 @@ import { checkRWAOpening } from "./checkRWAOpening.js";
|
|
|
16
16
|
* has to hold, approve or sign.
|
|
17
17
|
*
|
|
18
18
|
* The array is in check order, most fundamental first: the market's own state,
|
|
19
|
-
* then what the facade would revert on, then what the operation
|
|
20
|
-
*
|
|
19
|
+
* then what the facade would revert on, then what the operation borrows and the
|
|
20
|
+
* quota it increases, then the account it leaves behind, and last the wallet's
|
|
21
|
+
* side.
|
|
21
22
|
*/
|
|
22
23
|
async function checkCreditOperation(args) {
|
|
23
24
|
const { sdk, preview, sender, blockNumber, ...thresholds } = args;
|
|
24
25
|
const suite = sdk.marketRegister.findCreditManager(preview.creditManager);
|
|
25
26
|
const market = suite.market;
|
|
26
27
|
const underlying = toToken(sdk, market.pool.underlying);
|
|
27
|
-
const isOpening = preview.operation === "OpenCreditAccount"
|
|
28
|
+
const isOpening = preview.operation === "OpenCreditAccount";
|
|
29
|
+
const isEmptyOpening = preview.operation === "OpenCreditAccount" && preview.totalDebt.value === 0n && preview.collateralAdded.length === 0 && preview.quotas.length === 0;
|
|
28
30
|
const protocol = [
|
|
29
31
|
...checkMarket(suite),
|
|
30
32
|
...checkDebtLimits({
|
|
@@ -32,13 +34,13 @@ async function checkCreditOperation(args) {
|
|
|
32
34
|
minDebt: suite.creditFacade.minDebt,
|
|
33
35
|
maxDebt: suite.creditFacade.maxDebt,
|
|
34
36
|
underlying,
|
|
35
|
-
allowZero: !isOpening,
|
|
37
|
+
allowZero: !isOpening || isEmptyOpening,
|
|
36
38
|
maxBorrowAmount: suite.maxBorrowAmount()
|
|
37
39
|
}),
|
|
38
|
-
...
|
|
40
|
+
...checkIncreaseDebt(suite, preview, underlying),
|
|
39
41
|
...checkObtained(suite, preview),
|
|
40
42
|
...checkAccountQuotas(suite, preview),
|
|
41
|
-
...
|
|
43
|
+
...checkIncreaseQuota(market, preview, underlying),
|
|
42
44
|
...checkHealthFactors({
|
|
43
45
|
totalDebt: preview.totalDebt,
|
|
44
46
|
healthFactor: preview.estHealthFactor,
|
|
@@ -50,7 +52,7 @@ async function checkCreditOperation(args) {
|
|
|
50
52
|
preview,
|
|
51
53
|
sender,
|
|
52
54
|
blockNumber
|
|
53
|
-
}),
|
|
55
|
+
}), isOpening ? checkRWAOpening({
|
|
54
56
|
sdk,
|
|
55
57
|
preview,
|
|
56
58
|
sender
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { checkBorrowLimit } from "../checks/checkBorrowLimit.js";
|
|
2
|
+
import "../checks/index.js";
|
|
3
|
+
//#region src/onchain/validation/bundles/checkIncreaseDebt.ts
|
|
4
|
+
/**
|
|
5
|
+
* What the transaction borrows, against what the market can lend right now.
|
|
6
|
+
*
|
|
7
|
+
* Only a debt increase is weighed: repaying, or leaving the debt alone, can
|
|
8
|
+
* never exceed the borrow limit. Opening borrows the whole debt; adjusting
|
|
9
|
+
* borrows `totalDebtChange`.
|
|
10
|
+
*
|
|
11
|
+
* The engine holds every simulation to this already (`assertCanBorrow`), so
|
|
12
|
+
* this is here for the transactions it never saw — a pasted calldata reaches
|
|
13
|
+
* the confirm screen with nothing else standing between it and a revert.
|
|
14
|
+
*/
|
|
15
|
+
function checkIncreaseDebt(suite, preview, underlying) {
|
|
16
|
+
const debtIncrease = preview.operation === "AdjustCreditAccount" ? preview.totalDebtChange.value : preview.totalDebt.value;
|
|
17
|
+
if (debtIncrease <= 0n) return [];
|
|
18
|
+
const maxBorrowAmount = suite.maxBorrowAmount();
|
|
19
|
+
return checkBorrowLimit({
|
|
20
|
+
requested: debtIncrease,
|
|
21
|
+
available: maxBorrowAmount.amount.value,
|
|
22
|
+
limit: maxBorrowAmount.limit,
|
|
23
|
+
underlying
|
|
24
|
+
});
|
|
25
|
+
}
|
|
26
|
+
//#endregion
|
|
27
|
+
export { checkIncreaseDebt };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { checkQuotaLimit } from "../checks/checkQuotaLimit.js";
|
|
2
2
|
import "../checks/index.js";
|
|
3
|
-
//#region src/onchain/validation/bundles/
|
|
3
|
+
//#region src/onchain/validation/bundles/checkIncreaseQuota.ts
|
|
4
4
|
/** Every quota the operation raises, against the room the keeper has left. */
|
|
5
|
-
function
|
|
5
|
+
function checkIncreaseQuota(market, preview, underlying) {
|
|
6
6
|
const increases = preview.operation === "AdjustCreditAccount" ? preview.quotasChange : preview.quotas;
|
|
7
7
|
const { pqk } = market.pool;
|
|
8
8
|
return increases.filter((q) => q.value > 0n).flatMap((q) => {
|
|
@@ -16,4 +16,4 @@ function checkQuotasAsked(market, preview, underlying) {
|
|
|
16
16
|
});
|
|
17
17
|
}
|
|
18
18
|
//#endregion
|
|
19
|
-
export {
|
|
19
|
+
export { checkIncreaseQuota };
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import { accountNotMidasGreenlisted } from "../../../model/errors/operation-errors.js";
|
|
2
|
+
import { unexpectedFailure } from "../../../model/errors/prepare-errors.js";
|
|
3
|
+
import "../../../model/index.js";
|
|
4
|
+
import { toToken } from "../helpers/token.js";
|
|
5
|
+
import "../helpers/index.js";
|
|
6
|
+
//#region src/onchain/validation/bundles/checkMidasAccountGreenlist.ts
|
|
7
|
+
/**
|
|
8
|
+
* Whether the credit account already holds the Midas greenlisted role
|
|
9
|
+
* this permissioned mToken requires of its holder.
|
|
10
|
+
*/
|
|
11
|
+
async function checkMidasAccountGreenlist(input) {
|
|
12
|
+
const { sdk, preview, nft, tokens } = input;
|
|
13
|
+
if (nft.protocol !== "midas") return [];
|
|
14
|
+
if (tokens.length === 0) return [];
|
|
15
|
+
const account = preview.creditAccount;
|
|
16
|
+
if (!account) return tokens.map((token) => accountNotMidasGreenlisted({
|
|
17
|
+
token: toToken(sdk, token),
|
|
18
|
+
creditManager: preview.creditManager
|
|
19
|
+
}));
|
|
20
|
+
return (await Promise.all(tokens.map((token) => checkAccountRole({
|
|
21
|
+
sdk,
|
|
22
|
+
nft,
|
|
23
|
+
account,
|
|
24
|
+
token,
|
|
25
|
+
preview
|
|
26
|
+
})))).flat();
|
|
27
|
+
}
|
|
28
|
+
async function checkAccountRole(input) {
|
|
29
|
+
const { sdk, nft, account, token, preview } = input;
|
|
30
|
+
try {
|
|
31
|
+
const requirements = await nft.getOpenAccountRequirements(account, { tokenOutAddress: token });
|
|
32
|
+
if (nft.isRegistered(requirements)) return [];
|
|
33
|
+
return [accountNotMidasGreenlisted({
|
|
34
|
+
token: toToken(sdk, token),
|
|
35
|
+
creditManager: preview.creditManager,
|
|
36
|
+
creditAccount: account
|
|
37
|
+
})];
|
|
38
|
+
} catch (cause) {
|
|
39
|
+
return [unexpectedFailure(cause, "read the Midas account greenlist")];
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
//#endregion
|
|
43
|
+
export { checkMidasAccountGreenlist };
|
|
@@ -3,13 +3,7 @@ import { checkPoolPaused } from "../checks/checkPoolPaused.js";
|
|
|
3
3
|
import { checkPoolSunset } from "../checks/checkPoolSunset.js";
|
|
4
4
|
import "../checks/index.js";
|
|
5
5
|
//#region src/onchain/validation/bundles/checkPoolOperation.ts
|
|
6
|
-
/**
|
|
7
|
-
* What the pool's own state stops, whichever side of it the wallet is on.
|
|
8
|
-
*
|
|
9
|
-
* The liquidity read is the market's rather than the trimmed figure a
|
|
10
|
-
* simulation carries: a withdrawal sized against that figure has to pass the
|
|
11
|
-
* check that follows it.
|
|
12
|
-
*/
|
|
6
|
+
/** What the pool's own state stops, whichever side of it the wallet is on. */
|
|
13
7
|
function checkPoolOperation(args) {
|
|
14
8
|
const { sdk, pool, isDeposit, tokenOut } = args;
|
|
15
9
|
const market = sdk.marketRegister.findByPool(pool);
|
|
@@ -25,7 +19,7 @@ function checkPoolOperation(args) {
|
|
|
25
19
|
}),
|
|
26
20
|
...isDeposit ? [] : checkPoolLiquidity({
|
|
27
21
|
requested: tokenOut.value,
|
|
28
|
-
available:
|
|
22
|
+
available: sdk.pools.withdrawableLiquidity(pool).value,
|
|
29
23
|
underlying: tokenOut.token
|
|
30
24
|
})
|
|
31
25
|
];
|
|
@@ -5,24 +5,24 @@ import { toToken } from "../helpers/token.js";
|
|
|
5
5
|
import "../helpers/index.js";
|
|
6
6
|
//#region src/onchain/validation/bundles/checkRWAOpenRequirements.ts
|
|
7
7
|
/**
|
|
8
|
-
* The
|
|
8
|
+
* The degen NFT is satisfied that `wallet` may open on `token` with the
|
|
9
9
|
* registration args already on the transaction.
|
|
10
10
|
*/
|
|
11
11
|
async function checkRWAOpenRequirements(input) {
|
|
12
12
|
const { sdk, wallet, creditManager, token, providedArgs } = input;
|
|
13
13
|
try {
|
|
14
|
-
const
|
|
15
|
-
if (!
|
|
16
|
-
const
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
if (!missing && requirements.securitizeTokensToRegister.length === 0) return [];
|
|
14
|
+
const nft = await sdk.marketRegister.findCreditManager(creditManager).degenNFT();
|
|
15
|
+
if (!nft) return [];
|
|
16
|
+
const requirements = await nft.getOpenAccountRequirements(wallet, { tokenOutAddress: token });
|
|
17
|
+
const missing = nft.getMissingRequirements(requirements, providedArgs);
|
|
18
|
+
if (!missing && nft.isRegistered(requirements)) return [];
|
|
20
19
|
return [rwaOpenRequirementsNotMet({
|
|
21
20
|
token: toToken(sdk, token),
|
|
22
21
|
creditManager,
|
|
23
|
-
|
|
22
|
+
protocol: nft.protocol,
|
|
23
|
+
registrationLink: nft.registrationLink,
|
|
24
24
|
requirements,
|
|
25
|
-
|
|
25
|
+
missing
|
|
26
26
|
})];
|
|
27
27
|
} catch (cause) {
|
|
28
28
|
return [unexpectedFailure(cause, "read the RWA opening requirements")];
|
|
@@ -1,23 +1,33 @@
|
|
|
1
1
|
import { AddressSet } from "../../utils/AddressSet.js";
|
|
2
|
+
import { checkMidasAccountGreenlist } from "./checkMidasAccountGreenlist.js";
|
|
2
3
|
import { checkRWAOpenRequirements } from "./checkRWAOpenRequirements.js";
|
|
3
4
|
//#region src/onchain/validation/bundles/checkRWAOpening.ts
|
|
4
5
|
/**
|
|
5
|
-
* Per
|
|
6
|
-
* borrower still has to register or sign before this opening can land
|
|
6
|
+
* Per KYC-gated token among `collateralAdded ∪ quotas`, whether the
|
|
7
|
+
* borrower still has to register or sign before this opening can land,
|
|
8
|
+
* and whether a Midas credit account may hold the mToken.
|
|
7
9
|
*/
|
|
8
10
|
async function checkRWAOpening(input) {
|
|
9
11
|
const { sdk, preview, sender } = input;
|
|
10
|
-
const
|
|
11
|
-
if (!
|
|
12
|
-
const
|
|
13
|
-
|
|
14
|
-
|
|
12
|
+
const nft = await sdk.marketRegister.findCreditManager(preview.creditManager).degenNFT();
|
|
13
|
+
if (!nft) return [];
|
|
14
|
+
const nftTokens = new AddressSet(await nft.getTokens());
|
|
15
|
+
let candidates = new AddressSet([...preview.collateralAdded.map((a) => a.token.address), ...preview.quotas.map((q) => q.token.address)]).asArray();
|
|
16
|
+
candidates = candidates.filter((token) => nftTokens.has(token));
|
|
17
|
+
let tokensToCheck = candidates;
|
|
18
|
+
if (tokensToCheck.length === 0 && !preview.creditAccount && nft.protocol === "midas") tokensToCheck = nftTokens.asArray();
|
|
19
|
+
return (await Promise.all([...tokensToCheck.map((token) => checkRWAOpenRequirements({
|
|
15
20
|
sdk,
|
|
16
21
|
wallet: sender,
|
|
17
22
|
creditManager: preview.creditManager,
|
|
18
23
|
token,
|
|
19
24
|
providedArgs: preview.rwaArgs
|
|
20
|
-
}))
|
|
25
|
+
})), checkMidasAccountGreenlist({
|
|
26
|
+
sdk,
|
|
27
|
+
preview,
|
|
28
|
+
nft,
|
|
29
|
+
tokens: candidates
|
|
30
|
+
})])).flat();
|
|
21
31
|
}
|
|
22
32
|
//#endregion
|
|
23
33
|
export { checkRWAOpening };
|
|
@@ -2,11 +2,12 @@ import { checkAccountQuotas } from "./checkAccountQuotas.js";
|
|
|
2
2
|
import { checkWalletAllowance } from "./checkWalletAllowance.js";
|
|
3
3
|
import { checkWalletBalance } from "./checkWalletBalance.js";
|
|
4
4
|
import { checkCollateralFunding } from "./checkCollateralFunding.js";
|
|
5
|
-
import { checkDraw } from "./checkDraw.js";
|
|
6
5
|
import { checkHealthFactors } from "./checkHealthFactors.js";
|
|
6
|
+
import { checkIncreaseDebt } from "./checkIncreaseDebt.js";
|
|
7
|
+
import { checkIncreaseQuota } from "./checkIncreaseQuota.js";
|
|
7
8
|
import { checkMarket } from "./checkMarket.js";
|
|
8
9
|
import { checkObtained } from "./checkObtained.js";
|
|
9
|
-
import {
|
|
10
|
+
import { checkMidasAccountGreenlist } from "./checkMidasAccountGreenlist.js";
|
|
10
11
|
import { checkRWAOpenRequirements } from "./checkRWAOpenRequirements.js";
|
|
11
12
|
import { checkRWAOpening } from "./checkRWAOpening.js";
|
|
12
13
|
import { checkCreditOperation } from "./checkCreditOperation.js";
|
|
@@ -15,4 +16,4 @@ import { checkLiquidationFunding } from "./checkLiquidationFunding.js";
|
|
|
15
16
|
import { checkWallet } from "./checkWallet.js";
|
|
16
17
|
import { checkPoolFunding } from "./checkPoolFunding.js";
|
|
17
18
|
import { checkPoolOperation } from "./checkPoolOperation.js";
|
|
18
|
-
export { checkAccountQuotas, checkCollateralFunding, checkCreditOperation,
|
|
19
|
+
export { checkAccountQuotas, checkCollateralFunding, checkCreditOperation, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLiquidationEligibility, checkLiquidationFunding, checkMarket, checkMidasAccountGreenlist, checkObtained, checkPoolFunding, checkPoolOperation, checkRWAOpenRequirements, checkRWAOpening, checkWallet, checkWalletAllowance, checkWalletBalance };
|
|
@@ -4,7 +4,7 @@ import { amountOf } from "../helpers/amount.js";
|
|
|
4
4
|
import "../helpers/index.js";
|
|
5
5
|
//#region src/onchain/validation/checks/checkBorrowLimit.ts
|
|
6
6
|
/**
|
|
7
|
-
* What the pool will hand over, against
|
|
7
|
+
* What the pool will hand over, against the amount requested.
|
|
8
8
|
*
|
|
9
9
|
* `available` and `limit` are the caller's reading of which limit is in the
|
|
10
10
|
* way; this check only compares. `maxBorrowAmount` is the largest debt still
|