@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
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_utils_AddressMap = require("../../../utils/AddressMap.js");
|
|
3
|
-
const require_onchain_utils_AddressSet = require("../../../utils/AddressSet.js");
|
|
4
3
|
require("../../../utils/index.js");
|
|
5
4
|
const require_onchain_base_BaseContract = require("../../../base/BaseContract.js");
|
|
6
5
|
require("../../../base/index.js");
|
|
@@ -12,7 +11,6 @@ let viem = require("viem");
|
|
|
12
11
|
//#region src/onchain/market/rwa/securitize/SecuritizeRWAFactory.ts
|
|
13
12
|
const abi = require_abi_rwa_iSecuritizeRWAFactory.iSecuritizeRWAFactoryAbi;
|
|
14
13
|
var SecuritizeRWAFactory = class extends require_onchain_base_BaseContract.BaseContract {
|
|
15
|
-
#sdk;
|
|
16
14
|
#investorCache = new require_onchain_utils_AddressMap.AddressMap();
|
|
17
15
|
degenNFT;
|
|
18
16
|
owner;
|
|
@@ -24,7 +22,6 @@ var SecuritizeRWAFactory = class extends require_onchain_base_BaseContract.BaseC
|
|
|
24
22
|
name: "SecuritizeRWAFactory",
|
|
25
23
|
abi
|
|
26
24
|
});
|
|
27
|
-
this.#sdk = sdk;
|
|
28
25
|
const decoded = (0, viem.decodeAbiParameters)([
|
|
29
26
|
{
|
|
30
27
|
name: "owner",
|
|
@@ -185,40 +182,6 @@ var SecuritizeRWAFactory = class extends require_onchain_base_BaseContract.BaseC
|
|
|
185
182
|
});
|
|
186
183
|
}
|
|
187
184
|
/**
|
|
188
|
-
* {@inheritDoc IRWAFactory.getOpenAccountRequirements}
|
|
189
|
-
*/
|
|
190
|
-
async getOpenAccountRequirements(investor, props) {
|
|
191
|
-
const [investorData] = await this.#sdk.rwa.getInvestorData(investor, [this.address]);
|
|
192
|
-
const tokensToRegister = new require_onchain_utils_AddressSet.AddressSet([props.tokenOutAddress]);
|
|
193
|
-
const registredTokens = new require_onchain_utils_AddressSet.AddressSet(investorData.registeredTokens);
|
|
194
|
-
const signedTokens = new require_onchain_utils_AddressSet.AddressSet(investorData.cachedSignatures.map((s) => s.token));
|
|
195
|
-
const unsignedTokens = tokensToRegister.difference(signedTokens);
|
|
196
|
-
const securitizeTokensToRegister = tokensToRegister.difference(registredTokens);
|
|
197
|
-
const requiredSignatures = investorData.registerVaultMessages.filter((m) => unsignedTokens.has(m.message.token));
|
|
198
|
-
return {
|
|
199
|
-
type: require_model_rwa.RWA_FACTORY_SECURITIZE,
|
|
200
|
-
securitizeTokensToRegister: Array.from(securitizeTokensToRegister),
|
|
201
|
-
tokensToRegister: Array.from(tokensToRegister),
|
|
202
|
-
requiredSignatures
|
|
203
|
-
};
|
|
204
|
-
}
|
|
205
|
-
/**
|
|
206
|
-
* {@inheritDoc IRWAFactory.getMissingRequirements}
|
|
207
|
-
*
|
|
208
|
-
* A required signature is omitted when `providedArgs.signaturesToCache`
|
|
209
|
-
* already carries a signature for the same token: the transaction caches it
|
|
210
|
-
* on-chain as part of the operation.
|
|
211
|
-
*/
|
|
212
|
-
getMissingRequirements(requirements, providedArgs) {
|
|
213
|
-
const providedTokens = new require_onchain_utils_AddressSet.AddressSet((providedArgs?.signaturesToCache ?? []).map((s) => s.token));
|
|
214
|
-
const requiredSignatures = requirements.requiredSignatures.filter((message) => !providedTokens.has(message.message.token));
|
|
215
|
-
if (requiredSignatures.length === 0) return;
|
|
216
|
-
return {
|
|
217
|
-
type: require_model_rwa.RWA_FACTORY_SECURITIZE,
|
|
218
|
-
requiredSignatures
|
|
219
|
-
};
|
|
220
|
-
}
|
|
221
|
-
/**
|
|
222
185
|
* {@inheritDoc IRWAFactory.openCreditAccount}
|
|
223
186
|
*/
|
|
224
187
|
openCreditAccount(creditManager, calls, args) {
|
|
@@ -38,12 +38,18 @@ var MultichainOpportunitiesService = class extends require_onchain_base_Multicha
|
|
|
38
38
|
*
|
|
39
39
|
* See {@link MultichainOpportunitiesService.getPool}.
|
|
40
40
|
**/
|
|
41
|
-
async getStrategy(key
|
|
41
|
+
async getStrategy(key) {
|
|
42
42
|
return this.queryChain({
|
|
43
43
|
network: key.chainId,
|
|
44
|
-
run: (sdk) => sdk.opportunities.getStrategy(key
|
|
44
|
+
run: (sdk) => sdk.opportunities.getStrategy(key)
|
|
45
45
|
});
|
|
46
46
|
}
|
|
47
|
+
/**
|
|
48
|
+
* {@inheritDoc OpportunitiesService.isEligibleForStrategy}
|
|
49
|
+
**/
|
|
50
|
+
async isEligibleForStrategy(key, wallet) {
|
|
51
|
+
return this.sdk.chain(key.chainId).opportunities.isEligibleForStrategy(key, wallet);
|
|
52
|
+
}
|
|
47
53
|
};
|
|
48
54
|
//#endregion
|
|
49
55
|
exports.MultichainOpportunitiesService = MultichainOpportunitiesService;
|
|
@@ -37,22 +37,34 @@ var OpportunitiesService = class extends require_onchain_base_SDKConstruct.SDKCo
|
|
|
37
37
|
* A single strategy opportunity plus the rate curve of the pool it borrows
|
|
38
38
|
* from and the price feeds its liquidation price depends on.
|
|
39
39
|
*
|
|
40
|
-
*
|
|
41
|
-
* with the strategy's KYC provider first; `null` otherwise.
|
|
40
|
+
* `kyc` is the strategy's KYC gate, independent of any wallet.
|
|
42
41
|
*
|
|
43
42
|
* @throws If the credit manager is unknown, or does not currently offer a
|
|
44
43
|
* strategy.
|
|
45
44
|
**/
|
|
46
|
-
async getStrategy(key
|
|
45
|
+
async getStrategy(key) {
|
|
47
46
|
const suite = this.sdk.marketRegister.findCreditManager(key.creditManager);
|
|
48
47
|
const detail = suite.strategyOpportunityDetail();
|
|
49
48
|
if (!detail) throw new Error(`credit manager ${key.creditManager} does not currently offer a strategy`);
|
|
50
|
-
const kyc =
|
|
49
|
+
const kyc = await suite.kycRequirement(detail.targetCollateral.address);
|
|
51
50
|
return {
|
|
52
51
|
...detail,
|
|
53
52
|
kyc
|
|
54
53
|
};
|
|
55
54
|
}
|
|
55
|
+
/**
|
|
56
|
+
* Whether `wallet` may open this strategy today: `true` when it is not
|
|
57
|
+
* KYC-gated or the wallet already passed the gate.
|
|
58
|
+
*
|
|
59
|
+
* @throws If the credit manager is unknown, or does not currently offer a
|
|
60
|
+
* strategy.
|
|
61
|
+
**/
|
|
62
|
+
async isEligibleForStrategy(key, wallet) {
|
|
63
|
+
const suite = this.sdk.marketRegister.findCreditManager(key.creditManager);
|
|
64
|
+
const opportunity = suite.strategyOpportunity();
|
|
65
|
+
if (!opportunity) throw new Error(`credit manager ${key.creditManager} does not currently offer a strategy`);
|
|
66
|
+
return suite.isEligibleForStrategy(wallet, opportunity.targetCollateral.address);
|
|
67
|
+
}
|
|
56
68
|
};
|
|
57
69
|
//#endregion
|
|
58
70
|
exports.OpportunitiesService = OpportunitiesService;
|
|
@@ -155,7 +155,7 @@ var PoolService = class extends require_onchain_base_SDKConstruct.SDKConstruct {
|
|
|
155
155
|
tokenIn: toTokenAmount(tokenIn, pool.pool.underlyingToShares(amount * require_onchain_constants_math.PERCENTAGE_FACTOR / (require_onchain_constants_math.PERCENTAGE_FACTOR - pool.pool.withdrawFee), true)),
|
|
156
156
|
tokenOut: toTokenAmount(tokenOut, amount),
|
|
157
157
|
zapper: zapper?.baseParams.addr,
|
|
158
|
-
availableLiquidity: this
|
|
158
|
+
availableLiquidity: this.withdrawableLiquidity(poolAddr)
|
|
159
159
|
};
|
|
160
160
|
}
|
|
161
161
|
/**
|
|
@@ -177,7 +177,7 @@ var PoolService = class extends require_onchain_base_SDKConstruct.SDKConstruct {
|
|
|
177
177
|
tokenIn: toTokenAmount(tokenIn, amount),
|
|
178
178
|
tokenOut: toTokenAmount(tokenOut, pool.pool.sharesToUnderlying(amount) * (require_onchain_constants_math.PERCENTAGE_FACTOR - pool.pool.withdrawFee) / require_onchain_constants_math.PERCENTAGE_FACTOR),
|
|
179
179
|
zapper: zapper?.baseParams.addr,
|
|
180
|
-
availableLiquidity: this
|
|
180
|
+
availableLiquidity: this.withdrawableLiquidity(poolAddr)
|
|
181
181
|
};
|
|
182
182
|
}
|
|
183
183
|
/**
|
|
@@ -406,12 +406,11 @@ var PoolService = class extends require_onchain_base_SDKConstruct.SDKConstruct {
|
|
|
406
406
|
};
|
|
407
407
|
}
|
|
408
408
|
/**
|
|
409
|
-
*
|
|
410
|
-
|
|
411
|
-
|
|
412
|
-
|
|
413
|
-
|
|
414
|
-
return market.priceOracle.toAmount(pool.underlying, pool.pool.availableLiquidity * 99999n / 100000n);
|
|
409
|
+
* {@inheritDoc IPoolsService.withdrawableLiquidity}
|
|
410
|
+
*/
|
|
411
|
+
withdrawableLiquidity(pool) {
|
|
412
|
+
const market = this.sdk.marketRegister.findByPool(pool);
|
|
413
|
+
return market.priceOracle.toAmount(market.pool.underlying, market.pool.pool.availableLiquidity * 99999n / 100000n);
|
|
415
414
|
}
|
|
416
415
|
};
|
|
417
416
|
//#endregion
|
|
@@ -36,7 +36,7 @@ function calcHealthFactor(props) {
|
|
|
36
36
|
const scale = 10n ** BigInt(decimalsByToken.get(token) ?? 18);
|
|
37
37
|
return amount * price / scale;
|
|
38
38
|
};
|
|
39
|
-
const
|
|
39
|
+
const assetValue = snapshot.assets.reduce((acc, { token, balance }) => {
|
|
40
40
|
if (balance <= 10n) return acc;
|
|
41
41
|
const lt = BigInt(lts.get(token) ?? 0);
|
|
42
42
|
const tokenLtWeighted = (convertToUSD(token, balance, true) ?? 0n) * lt;
|
|
@@ -45,8 +45,8 @@ function calcHealthFactor(props) {
|
|
|
45
45
|
const quotaWeighted = (convertToUSD(underlying, quotaBalance) ?? 0n) * require_onchain_constants_math.PERCENTAGE_FACTOR;
|
|
46
46
|
return acc + (quota ? require_onchain_utils_bigint_math.BigIntMath.min(quotaWeighted, tokenLtWeighted) : tokenLtWeighted);
|
|
47
47
|
}, 0n);
|
|
48
|
-
const
|
|
49
|
-
const hf =
|
|
48
|
+
const borrowedValue = convertToUSD(underlying, snapshot.totalDebt) ?? 0n;
|
|
49
|
+
const hf = borrowedValue > 0n ? assetValue / borrowedValue : 0n;
|
|
50
50
|
return Number(hf);
|
|
51
51
|
}
|
|
52
52
|
//#endregion
|
|
@@ -12,6 +12,7 @@ const require_onchain_preview_preview_detectCloseOrRepay = require("./preview/de
|
|
|
12
12
|
const require_onchain_preview_preview_detectDelayedClaim = require("./preview/detectDelayedClaim.js");
|
|
13
13
|
const require_onchain_preview_preview_detectDelayedOperation = require("./preview/detectDelayedOperation.js");
|
|
14
14
|
const require_onchain_preview_preview_estimateClaimableAt = require("./preview/estimateClaimableAt.js");
|
|
15
|
+
const require_onchain_preview_preview_midasGreenlistsAccount = require("./preview/midasGreenlistsAccount.js");
|
|
15
16
|
const require_onchain_preview_preview_previewAdjustStrategyPosition = require("./preview/previewAdjustStrategyPosition.js");
|
|
16
17
|
const require_onchain_preview_preview_previewExitOrRepayStrategyPosition = require("./preview/previewExitOrRepayStrategyPosition.js");
|
|
17
18
|
const require_onchain_preview_preview_replayInnerOperations = require("./preview/replayInnerOperations.js");
|
|
@@ -29,6 +30,7 @@ exports.isCloseOrRepay = require_onchain_preview_preview_detectCloseOrRepay.isCl
|
|
|
29
30
|
exports.isPoolOperation = require_onchain_preview_parse_types.isPoolOperation;
|
|
30
31
|
exports.isRWAOperation = require_onchain_preview_parse_types.isRWAOperation;
|
|
31
32
|
exports.makeReplayState = require_onchain_preview_preview_replayInnerOperations.makeReplayState;
|
|
33
|
+
exports.midasGreenlistsAccount = require_onchain_preview_preview_midasGreenlistsAccount.midasGreenlistsAccount;
|
|
32
34
|
exports.parseFacadeOperationCalldata = require_onchain_preview_parse_parseFacadeOperationCalldata.parseFacadeOperationCalldata;
|
|
33
35
|
exports.parseOperationCalldata = require_onchain_preview_parse_parseOperationCalldata.parseOperationCalldata;
|
|
34
36
|
exports.parsePoolOperationCalldata = require_onchain_preview_parse_parsePoolOperationCalldata.parsePoolOperationCalldata;
|
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
const require_onchain_utils_hex = require("../../utils/hex.js");
|
|
3
3
|
const require_onchain_market_adapters_contracts_AbstractAdapter = require("../../market/adapters/contracts/AbstractAdapter.js");
|
|
4
4
|
const require_onchain_market_credit_CreditFacadeV310Contract = require("../../market/credit/CreditFacadeV310Contract.js");
|
|
5
|
-
|
|
5
|
+
require("../../../model/rwa.js");
|
|
6
6
|
require("../../../model/index.js");
|
|
7
7
|
const require_onchain_market_rwa_types = require("../../market/rwa/types.js");
|
|
8
8
|
const require_onchain_preview_parse_classifyInnerOperations = require("./classifyInnerOperations.js");
|
|
@@ -33,7 +33,7 @@ function parseSecuritizeOperationCalldata(sdk, factory, calldata) {
|
|
|
33
33
|
const { rawArgs } = parsed;
|
|
34
34
|
const innerCalls = rawArgs.calls ?? [];
|
|
35
35
|
const args = {
|
|
36
|
-
|
|
36
|
+
protocol: "securitize",
|
|
37
37
|
tokensToRegister: [...rawArgs.tokensToRegister ?? []],
|
|
38
38
|
signaturesToCache: [...rawArgs.signaturesToCache ?? []]
|
|
39
39
|
};
|
|
@@ -5,6 +5,7 @@ const require_onchain_preview_preview_detectCloseOrRepay = require("./detectClos
|
|
|
5
5
|
const require_onchain_preview_preview_detectDelayedClaim = require("./detectDelayedClaim.js");
|
|
6
6
|
const require_onchain_preview_preview_detectDelayedOperation = require("./detectDelayedOperation.js");
|
|
7
7
|
const require_onchain_preview_preview_estimateClaimableAt = require("./estimateClaimableAt.js");
|
|
8
|
+
const require_onchain_preview_preview_midasGreenlistsAccount = require("./midasGreenlistsAccount.js");
|
|
8
9
|
const require_onchain_preview_preview_previewAdjustStrategyPosition = require("./previewAdjustStrategyPosition.js");
|
|
9
10
|
const require_onchain_preview_preview_previewExitOrRepayStrategyPosition = require("./previewExitOrRepayStrategyPosition.js");
|
|
10
11
|
const require_onchain_preview_preview_replayInnerOperations = require("./replayInnerOperations.js");
|
|
@@ -18,6 +19,7 @@ exports.detectDelayedOperation = require_onchain_preview_preview_detectDelayedOp
|
|
|
18
19
|
exports.estimateClaimableAt = require_onchain_preview_preview_estimateClaimableAt.estimateClaimableAt;
|
|
19
20
|
exports.isCloseOrRepay = require_onchain_preview_preview_detectCloseOrRepay.isCloseOrRepay;
|
|
20
21
|
exports.makeReplayState = require_onchain_preview_preview_replayInnerOperations.makeReplayState;
|
|
22
|
+
exports.midasGreenlistsAccount = require_onchain_preview_preview_midasGreenlistsAccount.midasGreenlistsAccount;
|
|
21
23
|
exports.previewAdjustStrategyPosition = require_onchain_preview_preview_previewAdjustStrategyPosition.previewAdjustStrategyPosition;
|
|
22
24
|
exports.previewExitOrRepayStrategyPosition = require_onchain_preview_preview_previewExitOrRepayStrategyPosition.previewExitOrRepayStrategyPosition;
|
|
23
25
|
exports.previewOperation = require_onchain_preview_preview_previewOperation.previewOperation;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_onchain_market_adapters_contracts_MidasGatewayAdapterContract = require("../../market/adapters/contracts/MidasGatewayAdapterContract.js");
|
|
3
|
+
//#region src/onchain/preview/preview/midasGreenlistsAccount.ts
|
|
4
|
+
/**
|
|
5
|
+
* Whether the multicall grants the Midas greenlisted role to the credit
|
|
6
|
+
* account via `receiveGreenlist()`.
|
|
7
|
+
*/
|
|
8
|
+
function midasGreenlistsAccount(sdk, multicall) {
|
|
9
|
+
for (const op of multicall) {
|
|
10
|
+
if (op.operation !== "Execute") continue;
|
|
11
|
+
const adapter = sdk.getContract(op.adapter);
|
|
12
|
+
if (adapter instanceof require_onchain_market_adapters_contracts_MidasGatewayAdapterContract.MidasGatewayAdapterContract && adapter.isReceiveGreenlist(op.calldata)) return true;
|
|
13
|
+
}
|
|
14
|
+
return false;
|
|
15
|
+
}
|
|
16
|
+
//#endregion
|
|
17
|
+
exports.midasGreenlistsAccount = midasGreenlistsAccount;
|
|
@@ -3,25 +3,23 @@ const require_onchain_constants_address_provider = require("../../constants/addr
|
|
|
3
3
|
const require_model_previews = require("../../../model/previews.js");
|
|
4
4
|
const require_model_result = require("../../../model/result.js");
|
|
5
5
|
require("../../../model/index.js");
|
|
6
|
-
const
|
|
6
|
+
const require_onchain_preview_preview_midasGreenlistsAccount = require("./midasGreenlistsAccount.js");
|
|
7
7
|
const require_onchain_preview_preview_unwrapNativeCollateral = require("./unwrapNativeCollateral.js");
|
|
8
|
-
const require_onchain_preview_preview_replayInnerOperations = require("./replayInnerOperations.js");
|
|
9
8
|
//#region src/onchain/preview/preview/previewOpenStrategyPosition.ts
|
|
10
|
-
function previewOpenStrategyPosition(sdk, input, operation) {
|
|
9
|
+
function previewOpenStrategyPosition(sdk, input, operation, replay) {
|
|
11
10
|
const { value = 0n } = input;
|
|
12
11
|
const market = sdk.marketRegister.findByCreditManager(operation.creditManager);
|
|
13
12
|
const oracle = market.priceOracle;
|
|
14
|
-
const
|
|
15
|
-
const
|
|
16
|
-
if (replayError) return require_model_result.sdkErr(replayError);
|
|
17
|
-
const account = state.account;
|
|
13
|
+
const { before, after } = replay;
|
|
14
|
+
const account = after.account;
|
|
18
15
|
let warning;
|
|
19
|
-
const
|
|
16
|
+
const price = (token, balance) => {
|
|
20
17
|
const priced = oracle.safeConvert(token, market.underlying, balance);
|
|
21
18
|
warning ??= priced.error;
|
|
22
19
|
return priced.value;
|
|
23
|
-
}
|
|
24
|
-
const
|
|
20
|
+
};
|
|
21
|
+
const netValue = before.balances.sum(price) + after.collateralAdded.sum(price) - after.collateralWithdrawn.sum(price);
|
|
22
|
+
const unwrapped = require_onchain_preview_preview_unwrapNativeCollateral.unwrapNativeCollateral(after.collateralAdded.toAssets(), value, sdk.addressProvider.getAddress(require_onchain_constants_address_provider.AP_WETH_TOKEN, 0));
|
|
25
23
|
if (!unwrapped.ok) return unwrapped;
|
|
26
24
|
const collateral = unwrapped.data;
|
|
27
25
|
const snap = account.toSnapshot(netValue + account.totalDebt);
|
|
@@ -30,16 +28,15 @@ function previewOpenStrategyPosition(sdk, input, operation) {
|
|
|
30
28
|
...require_model_previews.asEstimated(sdk.positions.projection(snap, { availableLiquidityChange: -account.totalDebt })),
|
|
31
29
|
targetCollateral: targetAsset ? oracle.toTokenAmount(targetAsset.token, targetAsset.balance) : void 0,
|
|
32
30
|
collateralAdded: collateral.map((a) => oracle.toTokenAmount(a.token, a.balance)),
|
|
31
|
+
collateralWithdrawn: after.collateralWithdrawn.toAssets().map((a) => oracle.toTokenAmount(a.token, a.balance)),
|
|
33
32
|
warning
|
|
34
33
|
};
|
|
35
|
-
if (operation.operation === "RWAOpenCreditAccount") return require_model_result.sdkOk({
|
|
36
|
-
...projection,
|
|
37
|
-
operation: "RWAOpenCreditAccount",
|
|
38
|
-
rwaArgs: operation.args
|
|
39
|
-
});
|
|
40
34
|
return require_model_result.sdkOk({
|
|
41
35
|
...projection,
|
|
42
|
-
operation: "OpenCreditAccount"
|
|
36
|
+
operation: "OpenCreditAccount",
|
|
37
|
+
...operation.operation === "MultiCall" || operation.operation === "BotMulticall" || operation.operation === "RWAMulticall" ? { creditAccount: operation.creditAccount } : {},
|
|
38
|
+
..."args" in operation ? { rwaArgs: operation.args } : {},
|
|
39
|
+
midasGreenlistsAccount: require_onchain_preview_preview_midasGreenlistsAccount.midasGreenlistsAccount(sdk, operation.multicall)
|
|
43
40
|
});
|
|
44
41
|
}
|
|
45
42
|
/**
|
|
@@ -34,9 +34,13 @@ async function previewOperation(sdk, input, options, creditAccount) {
|
|
|
34
34
|
if (!parsed.ok) return parsed;
|
|
35
35
|
const operation = parsed.data;
|
|
36
36
|
if (require_onchain_preview_parse_types.isPoolOperation(operation)) return require_onchain_preview_preview_previewPoolPositionOperation.previewPoolPositionOperation(sdk, operation, options);
|
|
37
|
-
if (operation.operation === "OpenCreditAccount" || operation.operation === "RWAOpenCreditAccount")
|
|
37
|
+
if (operation.operation === "OpenCreditAccount" || operation.operation === "RWAOpenCreditAccount") {
|
|
38
|
+
const replayed = require_onchain_preview_preview_replayMulticall.replayMulticall(sdk, operation);
|
|
39
|
+
if (!replayed.ok) return replayed;
|
|
40
|
+
return require_onchain_preview_preview_previewOpenStrategyPosition.previewOpenStrategyPosition(sdk, input, operation, replayed.data);
|
|
41
|
+
}
|
|
38
42
|
if (operation.operation === "CloseCreditAccount") {
|
|
39
|
-
const resolved = await resolveCreditAccount(sdk, operation, options, creditAccount);
|
|
43
|
+
const resolved = await resolveCreditAccount(sdk, operation.creditAccount, options, creditAccount);
|
|
40
44
|
if (!resolved.ok) return resolved;
|
|
41
45
|
const replayed = require_onchain_preview_preview_replayMulticall.replayMulticall(sdk, operation, resolved.data);
|
|
42
46
|
if (!replayed.ok) return replayed;
|
|
@@ -48,7 +52,7 @@ async function previewOperation(sdk, input, options, creditAccount) {
|
|
|
48
52
|
return preview;
|
|
49
53
|
}
|
|
50
54
|
if (operation.operation === "MultiCall" || operation.operation === "BotMulticall" || operation.operation === "RWAMulticall") {
|
|
51
|
-
const resolved = await resolveCreditAccount(sdk, operation, options, creditAccount);
|
|
55
|
+
const resolved = await resolveCreditAccount(sdk, operation.creditAccount, options, creditAccount);
|
|
52
56
|
if (!resolved.ok) return resolved;
|
|
53
57
|
const replayed = require_onchain_preview_preview_replayMulticall.replayMulticall(sdk, operation, resolved.data);
|
|
54
58
|
if (!replayed.ok) return replayed;
|
|
@@ -65,20 +69,24 @@ async function previewOperation(sdk, input, options, creditAccount) {
|
|
|
65
69
|
* injected state when present, otherwise fetches it from the credit account
|
|
66
70
|
* compressor.
|
|
67
71
|
*/
|
|
68
|
-
async function resolveCreditAccount(sdk,
|
|
69
|
-
let resolved =
|
|
70
|
-
if (!resolved) resolved = await sdk.accounts.getCreditAccountData(
|
|
71
|
-
if (!resolved) return require_model_result.sdkErr(require_model_errors_prepare_errors.creditAccountNotFound(
|
|
72
|
+
async function resolveCreditAccount(sdk, address, options, data) {
|
|
73
|
+
let resolved = data;
|
|
74
|
+
if (!resolved) resolved = await sdk.accounts.getCreditAccountData(address, options?.blockNumber);
|
|
75
|
+
if (!resolved) return require_model_result.sdkErr(require_model_errors_prepare_errors.creditAccountNotFound(address));
|
|
72
76
|
return require_model_result.sdkOk(resolved);
|
|
73
77
|
}
|
|
74
78
|
/**
|
|
75
79
|
* Previews a plain/bot/RWA multicall: classifies the instant preview
|
|
76
|
-
* (zero-debt closure/repay
|
|
77
|
-
* delayed withdrawal, wraps the instant
|
|
78
|
-
* `DelayedCreditAccountOperation` together with the
|
|
79
|
-
* the state after the withdrawal is claimed.
|
|
80
|
+
* (reopening a zero-debt account, zero-debt closure/repay, or adjustment)
|
|
81
|
+
* and, when the multicall requests a delayed withdrawal, wraps the instant
|
|
82
|
+
* preview into a `DelayedCreditAccountOperation` together with the
|
|
83
|
+
* best-effort preview of the state after the withdrawal is claimed.
|
|
84
|
+
*
|
|
85
|
+
* A reopening is reported as `OpenCreditAccount` and never as a delayed
|
|
86
|
+
* withdrawal: an opening requests no redemption.
|
|
80
87
|
*/
|
|
81
88
|
async function previewMulticallOperation(sdk, input, operation, replay, blockNumber) {
|
|
89
|
+
if (replay.before.totalDebt === 0n && replay.before.quotas.toAssets(0n).length === 0 && replay.after.account.totalDebt > 0n) return require_onchain_preview_preview_previewOpenStrategyPosition.previewOpenStrategyPosition(sdk, input, operation, replay);
|
|
82
90
|
let instantPreview;
|
|
83
91
|
if (require_onchain_preview_preview_detectCloseOrRepay.isCloseOrRepay(operation.multicall)) {
|
|
84
92
|
const instant = require_onchain_preview_preview_previewExitOrRepayStrategyPosition.previewExitOrRepayStrategyPosition(sdk, input, operation, false, replay);
|
|
@@ -5,11 +5,12 @@ const require_onchain_preview_preview_CreditAccountState = require("./CreditAcco
|
|
|
5
5
|
const require_onchain_preview_preview_replayInnerOperations = require("./replayInnerOperations.js");
|
|
6
6
|
//#region src/onchain/preview/preview/replayMulticall.ts
|
|
7
7
|
/**
|
|
8
|
-
* Replays the operation's multicall
|
|
9
|
-
*
|
|
8
|
+
* Replays the operation's multicall via {@link replayInnerOperations}.
|
|
9
|
+
* When `creditAccount` is omitted, the seed is
|
|
10
|
+
* {@link CreditAccountState.beforeOpen} (a fresh opening).
|
|
10
11
|
*/
|
|
11
12
|
function replayMulticall(sdk, operation, creditAccount) {
|
|
12
|
-
const before = require_onchain_preview_preview_CreditAccountState.CreditAccountState.fromCreditAccountData(creditAccount);
|
|
13
|
+
const before = creditAccount ? require_onchain_preview_preview_CreditAccountState.CreditAccountState.fromCreditAccountData(creditAccount) : require_onchain_preview_preview_CreditAccountState.CreditAccountState.beforeOpen(operation.creditManager, sdk.marketRegister.findByCreditManager(operation.creditManager).underlying);
|
|
13
14
|
const after = require_onchain_preview_preview_replayInnerOperations.makeReplayState(before.clone());
|
|
14
15
|
const error = require_onchain_preview_preview_replayInnerOperations.replayInnerOperations(sdk, operation.multicall, after);
|
|
15
16
|
if (error) return require_model_result.sdkErr(error);
|
|
@@ -23,13 +23,13 @@ async function checkCollateralFunding(input) {
|
|
|
23
23
|
if (held.size === 0) return [];
|
|
24
24
|
let spender;
|
|
25
25
|
try {
|
|
26
|
-
if (preview.
|
|
26
|
+
if (preview.creditAccount) spender = await sdk.accounts.getApprovalAddress({
|
|
27
27
|
creditManager: preview.creditManager,
|
|
28
|
-
|
|
28
|
+
creditAccount: preview.creditAccount
|
|
29
29
|
});
|
|
30
30
|
else spender = await sdk.accounts.getApprovalAddress({
|
|
31
31
|
creditManager: preview.creditManager,
|
|
32
|
-
|
|
32
|
+
borrower: sender
|
|
33
33
|
});
|
|
34
34
|
} catch (cause) {
|
|
35
35
|
return [require_model_errors_prepare_errors.unexpectedFailure(cause, "resolve the approval address")];
|
|
@@ -5,11 +5,11 @@ const require_onchain_validation_checks_checkDebtLimits = require("../checks/che
|
|
|
5
5
|
require("../checks/index.js");
|
|
6
6
|
const require_onchain_validation_bundles_checkAccountQuotas = require("./checkAccountQuotas.js");
|
|
7
7
|
const require_onchain_validation_bundles_checkCollateralFunding = require("./checkCollateralFunding.js");
|
|
8
|
-
const require_onchain_validation_bundles_checkDraw = require("./checkDraw.js");
|
|
9
8
|
const require_onchain_validation_bundles_checkHealthFactors = require("./checkHealthFactors.js");
|
|
9
|
+
const require_onchain_validation_bundles_checkIncreaseDebt = require("./checkIncreaseDebt.js");
|
|
10
|
+
const require_onchain_validation_bundles_checkIncreaseQuota = require("./checkIncreaseQuota.js");
|
|
10
11
|
const require_onchain_validation_bundles_checkMarket = require("./checkMarket.js");
|
|
11
12
|
const require_onchain_validation_bundles_checkObtained = require("./checkObtained.js");
|
|
12
|
-
const require_onchain_validation_bundles_checkQuotasAsked = require("./checkQuotasAsked.js");
|
|
13
13
|
const require_onchain_validation_bundles_checkRWAOpening = require("./checkRWAOpening.js");
|
|
14
14
|
//#region src/onchain/validation/bundles/checkCreditOperation.ts
|
|
15
15
|
/**
|
|
@@ -17,15 +17,17 @@ const require_onchain_validation_bundles_checkRWAOpening = require("./checkRWAOp
|
|
|
17
17
|
* has to hold, approve or sign.
|
|
18
18
|
*
|
|
19
19
|
* The array is in check order, most fundamental first: the market's own state,
|
|
20
|
-
* then what the facade would revert on, then what the operation
|
|
21
|
-
*
|
|
20
|
+
* then what the facade would revert on, then what the operation borrows and the
|
|
21
|
+
* quota it increases, then the account it leaves behind, and last the wallet's
|
|
22
|
+
* side.
|
|
22
23
|
*/
|
|
23
24
|
async function checkCreditOperation(args) {
|
|
24
25
|
const { sdk, preview, sender, blockNumber, ...thresholds } = args;
|
|
25
26
|
const suite = sdk.marketRegister.findCreditManager(preview.creditManager);
|
|
26
27
|
const market = suite.market;
|
|
27
28
|
const underlying = require_onchain_validation_helpers_token.toToken(sdk, market.pool.underlying);
|
|
28
|
-
const isOpening = preview.operation === "OpenCreditAccount"
|
|
29
|
+
const isOpening = preview.operation === "OpenCreditAccount";
|
|
30
|
+
const isEmptyOpening = preview.operation === "OpenCreditAccount" && preview.totalDebt.value === 0n && preview.collateralAdded.length === 0 && preview.quotas.length === 0;
|
|
29
31
|
const protocol = [
|
|
30
32
|
...require_onchain_validation_bundles_checkMarket.checkMarket(suite),
|
|
31
33
|
...require_onchain_validation_checks_checkDebtLimits.checkDebtLimits({
|
|
@@ -33,13 +35,13 @@ async function checkCreditOperation(args) {
|
|
|
33
35
|
minDebt: suite.creditFacade.minDebt,
|
|
34
36
|
maxDebt: suite.creditFacade.maxDebt,
|
|
35
37
|
underlying,
|
|
36
|
-
allowZero: !isOpening,
|
|
38
|
+
allowZero: !isOpening || isEmptyOpening,
|
|
37
39
|
maxBorrowAmount: suite.maxBorrowAmount()
|
|
38
40
|
}),
|
|
39
|
-
...
|
|
41
|
+
...require_onchain_validation_bundles_checkIncreaseDebt.checkIncreaseDebt(suite, preview, underlying),
|
|
40
42
|
...require_onchain_validation_bundles_checkObtained.checkObtained(suite, preview),
|
|
41
43
|
...require_onchain_validation_bundles_checkAccountQuotas.checkAccountQuotas(suite, preview),
|
|
42
|
-
...
|
|
44
|
+
...require_onchain_validation_bundles_checkIncreaseQuota.checkIncreaseQuota(market, preview, underlying),
|
|
43
45
|
...require_onchain_validation_bundles_checkHealthFactors.checkHealthFactors({
|
|
44
46
|
totalDebt: preview.totalDebt,
|
|
45
47
|
healthFactor: preview.estHealthFactor,
|
|
@@ -51,7 +53,7 @@ async function checkCreditOperation(args) {
|
|
|
51
53
|
preview,
|
|
52
54
|
sender,
|
|
53
55
|
blockNumber
|
|
54
|
-
}),
|
|
56
|
+
}), isOpening ? require_onchain_validation_bundles_checkRWAOpening.checkRWAOpening({
|
|
55
57
|
sdk,
|
|
56
58
|
preview,
|
|
57
59
|
sender
|
|
@@ -1,28 +1,28 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_validation_checks_checkBorrowLimit = require("../checks/checkBorrowLimit.js");
|
|
3
3
|
require("../checks/index.js");
|
|
4
|
-
//#region src/onchain/validation/bundles/
|
|
4
|
+
//#region src/onchain/validation/bundles/checkIncreaseDebt.ts
|
|
5
5
|
/**
|
|
6
|
-
* What the transaction
|
|
6
|
+
* What the transaction borrows, against what the market can lend right now.
|
|
7
7
|
*
|
|
8
|
-
* Only a
|
|
9
|
-
*
|
|
10
|
-
* `totalDebtChange`.
|
|
8
|
+
* Only a debt increase is weighed: repaying, or leaving the debt alone, can
|
|
9
|
+
* never exceed the borrow limit. Opening borrows the whole debt; adjusting
|
|
10
|
+
* borrows `totalDebtChange`.
|
|
11
11
|
*
|
|
12
12
|
* The engine holds every simulation to this already (`assertCanBorrow`), so
|
|
13
13
|
* this is here for the transactions it never saw — a pasted calldata reaches
|
|
14
14
|
* the confirm screen with nothing else standing between it and a revert.
|
|
15
15
|
*/
|
|
16
|
-
function
|
|
17
|
-
const
|
|
18
|
-
if (
|
|
16
|
+
function checkIncreaseDebt(suite, preview, underlying) {
|
|
17
|
+
const debtIncrease = preview.operation === "AdjustCreditAccount" ? preview.totalDebtChange.value : preview.totalDebt.value;
|
|
18
|
+
if (debtIncrease <= 0n) return [];
|
|
19
19
|
const maxBorrowAmount = suite.maxBorrowAmount();
|
|
20
20
|
return require_onchain_validation_checks_checkBorrowLimit.checkBorrowLimit({
|
|
21
|
-
requested:
|
|
21
|
+
requested: debtIncrease,
|
|
22
22
|
available: maxBorrowAmount.amount.value,
|
|
23
23
|
limit: maxBorrowAmount.limit,
|
|
24
24
|
underlying
|
|
25
25
|
});
|
|
26
26
|
}
|
|
27
27
|
//#endregion
|
|
28
|
-
exports.
|
|
28
|
+
exports.checkIncreaseDebt = checkIncreaseDebt;
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
2
|
const require_onchain_validation_checks_checkQuotaLimit = require("../checks/checkQuotaLimit.js");
|
|
3
3
|
require("../checks/index.js");
|
|
4
|
-
//#region src/onchain/validation/bundles/
|
|
4
|
+
//#region src/onchain/validation/bundles/checkIncreaseQuota.ts
|
|
5
5
|
/** Every quota the operation raises, against the room the keeper has left. */
|
|
6
|
-
function
|
|
6
|
+
function checkIncreaseQuota(market, preview, underlying) {
|
|
7
7
|
const increases = preview.operation === "AdjustCreditAccount" ? preview.quotasChange : preview.quotas;
|
|
8
8
|
const { pqk } = market.pool;
|
|
9
9
|
return increases.filter((q) => q.value > 0n).flatMap((q) => {
|
|
@@ -17,4 +17,4 @@ function checkQuotasAsked(market, preview, underlying) {
|
|
|
17
17
|
});
|
|
18
18
|
}
|
|
19
19
|
//#endregion
|
|
20
|
-
exports.
|
|
20
|
+
exports.checkIncreaseQuota = checkIncreaseQuota;
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_model_errors_operation_errors = require("../../../model/errors/operation-errors.js");
|
|
3
|
+
const require_model_errors_prepare_errors = require("../../../model/errors/prepare-errors.js");
|
|
4
|
+
require("../../../model/index.js");
|
|
5
|
+
const require_onchain_validation_helpers_token = require("../helpers/token.js");
|
|
6
|
+
require("../helpers/index.js");
|
|
7
|
+
//#region src/onchain/validation/bundles/checkMidasAccountGreenlist.ts
|
|
8
|
+
/**
|
|
9
|
+
* Whether the credit account already holds the Midas greenlisted role
|
|
10
|
+
* this permissioned mToken requires of its holder.
|
|
11
|
+
*/
|
|
12
|
+
async function checkMidasAccountGreenlist(input) {
|
|
13
|
+
const { sdk, preview, nft, tokens } = input;
|
|
14
|
+
if (nft.protocol !== "midas") return [];
|
|
15
|
+
if (tokens.length === 0) return [];
|
|
16
|
+
const account = preview.creditAccount;
|
|
17
|
+
if (!account) return tokens.map((token) => require_model_errors_operation_errors.accountNotMidasGreenlisted({
|
|
18
|
+
token: require_onchain_validation_helpers_token.toToken(sdk, token),
|
|
19
|
+
creditManager: preview.creditManager
|
|
20
|
+
}));
|
|
21
|
+
return (await Promise.all(tokens.map((token) => checkAccountRole({
|
|
22
|
+
sdk,
|
|
23
|
+
nft,
|
|
24
|
+
account,
|
|
25
|
+
token,
|
|
26
|
+
preview
|
|
27
|
+
})))).flat();
|
|
28
|
+
}
|
|
29
|
+
async function checkAccountRole(input) {
|
|
30
|
+
const { sdk, nft, account, token, preview } = input;
|
|
31
|
+
try {
|
|
32
|
+
const requirements = await nft.getOpenAccountRequirements(account, { tokenOutAddress: token });
|
|
33
|
+
if (nft.isRegistered(requirements)) return [];
|
|
34
|
+
return [require_model_errors_operation_errors.accountNotMidasGreenlisted({
|
|
35
|
+
token: require_onchain_validation_helpers_token.toToken(sdk, token),
|
|
36
|
+
creditManager: preview.creditManager,
|
|
37
|
+
creditAccount: account
|
|
38
|
+
})];
|
|
39
|
+
} catch (cause) {
|
|
40
|
+
return [require_model_errors_prepare_errors.unexpectedFailure(cause, "read the Midas account greenlist")];
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
//#endregion
|
|
44
|
+
exports.checkMidasAccountGreenlist = checkMidasAccountGreenlist;
|
|
@@ -4,13 +4,7 @@ const require_onchain_validation_checks_checkPoolPaused = require("../checks/che
|
|
|
4
4
|
const require_onchain_validation_checks_checkPoolSunset = require("../checks/checkPoolSunset.js");
|
|
5
5
|
require("../checks/index.js");
|
|
6
6
|
//#region src/onchain/validation/bundles/checkPoolOperation.ts
|
|
7
|
-
/**
|
|
8
|
-
* What the pool's own state stops, whichever side of it the wallet is on.
|
|
9
|
-
*
|
|
10
|
-
* The liquidity read is the market's rather than the trimmed figure a
|
|
11
|
-
* simulation carries: a withdrawal sized against that figure has to pass the
|
|
12
|
-
* check that follows it.
|
|
13
|
-
*/
|
|
7
|
+
/** What the pool's own state stops, whichever side of it the wallet is on. */
|
|
14
8
|
function checkPoolOperation(args) {
|
|
15
9
|
const { sdk, pool, isDeposit, tokenOut } = args;
|
|
16
10
|
const market = sdk.marketRegister.findByPool(pool);
|
|
@@ -26,7 +20,7 @@ function checkPoolOperation(args) {
|
|
|
26
20
|
}),
|
|
27
21
|
...isDeposit ? [] : require_onchain_validation_checks_checkPoolLiquidity.checkPoolLiquidity({
|
|
28
22
|
requested: tokenOut.value,
|
|
29
|
-
available:
|
|
23
|
+
available: sdk.pools.withdrawableLiquidity(pool).value,
|
|
30
24
|
underlying: tokenOut.token
|
|
31
25
|
})
|
|
32
26
|
];
|
|
@@ -6,24 +6,24 @@ const require_onchain_validation_helpers_token = require("../helpers/token.js");
|
|
|
6
6
|
require("../helpers/index.js");
|
|
7
7
|
//#region src/onchain/validation/bundles/checkRWAOpenRequirements.ts
|
|
8
8
|
/**
|
|
9
|
-
* The
|
|
9
|
+
* The degen NFT is satisfied that `wallet` may open on `token` with the
|
|
10
10
|
* registration args already on the transaction.
|
|
11
11
|
*/
|
|
12
12
|
async function checkRWAOpenRequirements(input) {
|
|
13
13
|
const { sdk, wallet, creditManager, token, providedArgs } = input;
|
|
14
14
|
try {
|
|
15
|
-
const
|
|
16
|
-
if (!
|
|
17
|
-
const
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
if (!missing && requirements.securitizeTokensToRegister.length === 0) return [];
|
|
15
|
+
const nft = await sdk.marketRegister.findCreditManager(creditManager).degenNFT();
|
|
16
|
+
if (!nft) return [];
|
|
17
|
+
const requirements = await nft.getOpenAccountRequirements(wallet, { tokenOutAddress: token });
|
|
18
|
+
const missing = nft.getMissingRequirements(requirements, providedArgs);
|
|
19
|
+
if (!missing && nft.isRegistered(requirements)) return [];
|
|
21
20
|
return [require_model_errors_operation_errors.rwaOpenRequirementsNotMet({
|
|
22
21
|
token: require_onchain_validation_helpers_token.toToken(sdk, token),
|
|
23
22
|
creditManager,
|
|
24
|
-
|
|
23
|
+
protocol: nft.protocol,
|
|
24
|
+
registrationLink: nft.registrationLink,
|
|
25
25
|
requirements,
|
|
26
|
-
|
|
26
|
+
missing
|
|
27
27
|
})];
|
|
28
28
|
} catch (cause) {
|
|
29
29
|
return [require_model_errors_prepare_errors.unexpectedFailure(cause, "read the RWA opening requirements")];
|