@gearbox-protocol/sdk 17.0.0-next.4 → 17.0.0
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/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/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/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/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 +1 -1
- 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/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/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/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/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 +1 -1
- 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/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/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/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 -1
- 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,8 +1,9 @@
|
|
|
1
1
|
import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, noStrategyTargetCollateral, unexpectedFailure } from "../../model/errors/prepare-errors.js";
|
|
2
2
|
import "../../model/index.js";
|
|
3
|
+
import { ExecutionCost, OperationState, PathLossRate, RouteErrors, WithdrawCeilings } from "../../onchain/accounts/intents/types.js";
|
|
4
|
+
import { BorrowState } from "../../onchain/accounts/intents/borrow.js";
|
|
3
5
|
import { LeverageBand } from "../../onchain/accounts/intents/leverage-band.js";
|
|
4
|
-
import { OperationState, PathLossRate, RouteErrors, WithdrawCeilings } from "../../onchain/accounts/intents/types.js";
|
|
5
6
|
import { PoolOperationError } from "../../onchain/validation/bundles/checkPoolOperation.js";
|
|
6
|
-
import { AccountFlowError, AddCollateralParams, AdjustLeverageParams, DelayedStrategyResult, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState,
|
|
7
|
+
import { AccountFlowError, AddCollateralParams, AdjustLeverageParams, BorrowParams, BorrowResult, DelayedStrategyResult, DepositStrategyParams, EmptyCreditAccountResult, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, LpParams, LpRedeemParams, LpResult, LpState, MaxBorrowParams, OpenFlowError, OpenStrategyParams, OpenStrategyResult, PoolInput, PositionInput, PrepareOptions, RepayStrategyParams, StrategyInput, StrategyResult, StrategyRoutesResult, WithRouteErrors, WithdrawCollateralParams, WithdrawStrategyParams } from "./types.js";
|
|
7
8
|
import { ChainOf, PrepareApi } from "./PrepareApi.js";
|
|
8
|
-
export { AccountFlowError, AddCollateralParams, AdjustLeverageParams, ChainOf, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DelayedStrategyResult, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, type LeverageBand, LpParams, LpRedeemParams, LpResult, LpState, type MultipleDelayedWithdrawalsError, type NoDelayedRouteError, type NoRecordedIntentError, type NoStrategyTargetCollateralError, OpenFlowError,
|
|
9
|
+
export { AccountFlowError, AddCollateralParams, AdjustLeverageParams, BorrowParams, BorrowResult, type BorrowState, ChainOf, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DelayedStrategyResult, DepositStrategyParams, EmptyCreditAccountResult, type ExecutionCost, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, type LeverageBand, LpParams, LpRedeemParams, LpResult, LpState, MaxBorrowParams, type MultipleDelayedWithdrawalsError, type NoDelayedRouteError, type NoRecordedIntentError, type NoStrategyTargetCollateralError, OpenFlowError, OpenStrategyParams, OpenStrategyResult, type OperationState, type PathLossRate, PoolInput, type PoolOperationError, PositionInput, PrepareApi, PrepareOptions, RepayStrategyParams, type RouteErrors, StrategyInput, StrategyResult, StrategyRoutesResult, type UnexpectedFailureError, type UnsupportedCollateralTokenError, type UnsupportedTokenPairError, WithRouteErrors, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, type WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, noStrategyTargetCollateral, unexpectedFailure };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { Bps, Timestamp, TokenAmount } from "../../model/primitives.js";
|
|
2
2
|
import { Curator } from "../../model/curators.js";
|
|
3
|
-
import { CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, QuotaLimitReachedError } from "../../model/errors/operation-errors.js";
|
|
3
|
+
import { CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, QuotaLimitReachedError, ReservePriceLimitedError } from "../../model/errors/operation-errors.js";
|
|
4
4
|
import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError } from "../../model/errors/prepare-errors.js";
|
|
5
5
|
import { PoolOpportunityKey, StrategyOpportunityKey } from "../../model/opportunities.js";
|
|
6
6
|
import { PositionCollateral, StrategyPosition, StrategyPositionKey } from "../../model/positions.js";
|
|
@@ -10,9 +10,10 @@ import "../../model/index.js";
|
|
|
10
10
|
import { Asset } from "../../onchain/base/types.js";
|
|
11
11
|
import { MultiCall } from "../../onchain/types/transactions.js";
|
|
12
12
|
import { PoolSimulation } from "../../onchain/pools/types.js";
|
|
13
|
-
import { LeverageBand } from "../../onchain/accounts/intents/leverage-band.js";
|
|
14
13
|
import { AccountCalculatorOperation } from "../../onchain/accounts/intents/operations.js";
|
|
15
|
-
import { ClaimRemainder, DelayedStart, OperationState, PathLossRate, ResumableIntent, RouteErrors, WithdrawCeilings } from "../../onchain/accounts/intents/types.js";
|
|
14
|
+
import { ClaimRemainder, DelayedStart, ExecutionCost, OperationState, PathLossRate, ResumableIntent, RouteErrors, WithdrawCeilings } from "../../onchain/accounts/intents/types.js";
|
|
15
|
+
import { BorrowState } from "../../onchain/accounts/intents/borrow.js";
|
|
16
|
+
import { LeverageBand } from "../../onchain/accounts/intents/leverage-band.js";
|
|
16
17
|
import { OpenStrategyState } from "../../onchain/accounts/intents/open-strategy.js";
|
|
17
18
|
import { PoolOperationError } from "../../onchain/validation/bundles/checkPoolOperation.js";
|
|
18
19
|
import "../../onchain/index.js";
|
|
@@ -22,7 +23,7 @@ import { Address } from "viem";
|
|
|
22
23
|
* What any operation on an existing account can answer with: the engine's
|
|
23
24
|
* shared guards, the missing account, and a wrapped crash.
|
|
24
25
|
**/
|
|
25
|
-
type AccountFlowError = CreditManagerPausedError | MarketExpiredError | ForbiddenTokenError | QuotaLimitReachedError | InsufficientCollateralError | InsufficientBalanceError | CreditAccountNotFoundError | UnexpectedFailureError;
|
|
26
|
+
type AccountFlowError = CreditManagerPausedError | MarketExpiredError | ForbiddenTokenError | QuotaLimitReachedError | InsufficientCollateralError | ReservePriceLimitedError | InsufficientBalanceError | CreditAccountNotFoundError | UnexpectedFailureError;
|
|
26
27
|
/** Same guards for the account-less open flow. */
|
|
27
28
|
type OpenFlowError = CreditManagerPausedError | MarketExpiredError | ForbiddenTokenError | QuotaLimitReachedError | InsufficientCollateralError | InsufficientBalanceError | UnexpectedFailureError;
|
|
28
29
|
/**
|
|
@@ -227,6 +228,41 @@ interface OpenStrategyResult {
|
|
|
227
228
|
/** Unix seconds of {@link blockNumber}. */
|
|
228
229
|
timestamp: Timestamp;
|
|
229
230
|
}
|
|
231
|
+
/**
|
|
232
|
+
* What taking a loan against collateral comes to.
|
|
233
|
+
*
|
|
234
|
+
* Shaped like {@link OpenStrategyResult} — a borrow opens its account too, so
|
|
235
|
+
* there is no chain of steps to report — with the whole projection on the
|
|
236
|
+
* state rather than two branches of balances, see {@link BorrowState}.
|
|
237
|
+
**/
|
|
238
|
+
interface BorrowResult {
|
|
239
|
+
/**
|
|
240
|
+
* Everything the loan arrives at: the collateral and the debt it backs, the
|
|
241
|
+
* payout expected and its floor, the position metrics a screen shows beside
|
|
242
|
+
* them, and the router path `openCA` is handed.
|
|
243
|
+
**/
|
|
244
|
+
state: BorrowState;
|
|
245
|
+
/** Block of the chain state this result was computed from. */
|
|
246
|
+
blockNumber: number;
|
|
247
|
+
/** Unix seconds of {@link blockNumber}. */
|
|
248
|
+
timestamp: Timestamp;
|
|
249
|
+
}
|
|
250
|
+
/**
|
|
251
|
+
* What opening an account that holds nothing comes to: the block it was
|
|
252
|
+
* cleared at, and nothing else.
|
|
253
|
+
*
|
|
254
|
+
* The one prepared operation with no state to report. Every other result
|
|
255
|
+
* describes where the account lands, but this one lands it holding nothing and
|
|
256
|
+
* owing nothing — there is no collateral to value, no debt to weigh and no
|
|
257
|
+
* health factor to read. What the preparation is for is the refusal it can
|
|
258
|
+
* answer with instead: a market that takes no multicall.
|
|
259
|
+
**/
|
|
260
|
+
interface EmptyCreditAccountResult {
|
|
261
|
+
/** Block of the chain state this result was computed from. */
|
|
262
|
+
blockNumber: number;
|
|
263
|
+
/** Unix seconds of {@link blockNumber}. */
|
|
264
|
+
timestamp: Timestamp;
|
|
265
|
+
}
|
|
230
266
|
/**
|
|
231
267
|
* Shared knobs. Both default to the SDK's own defaults when omitted.
|
|
232
268
|
**/
|
|
@@ -338,15 +374,7 @@ interface WithdrawCollateralParams extends PrepareOptions {
|
|
|
338
374
|
/** Wallet receiving the tokens. */
|
|
339
375
|
to: Address;
|
|
340
376
|
}
|
|
341
|
-
|
|
342
|
-
* Opening a position, in one of the two shapes an opening comes in.
|
|
343
|
-
*
|
|
344
|
-
* The union is the check: an empty opening names nothing to open with, so
|
|
345
|
-
* collateral it meant to spend or an account it meant to reuse cannot be
|
|
346
|
-
* silently dropped — those arguments do not typecheck against `empty: true`.
|
|
347
|
-
**/
|
|
348
|
-
type OpenStrategyParams = OpenStrategyFundedParams | OpenStrategyEmptyParams;
|
|
349
|
-
interface OpenStrategyFundedParams extends PrepareOptions {
|
|
377
|
+
interface OpenStrategyParams extends PrepareOptions {
|
|
350
378
|
/** Collateral coming from the wallet, in their own tokens. */
|
|
351
379
|
collateral: Asset[];
|
|
352
380
|
/**
|
|
@@ -363,43 +391,80 @@ interface OpenStrategyFundedParams extends PrepareOptions {
|
|
|
363
391
|
/**
|
|
364
392
|
* Existing credit account to open the position on, instead of creating one.
|
|
365
393
|
*
|
|
366
|
-
*
|
|
367
|
-
*
|
|
368
|
-
*
|
|
369
|
-
*
|
|
370
|
-
|
|
394
|
+
* Any account of `strategy.creditManager` that carries no debt and no
|
|
395
|
+
* quotas qualifies. The projection is identical either way; only the
|
|
396
|
+
* transaction differs, and `execute.buildTx` reads which one to build off
|
|
397
|
+
* the result's own `state.creditAccount`.
|
|
398
|
+
**/
|
|
399
|
+
creditAccount?: Address;
|
|
400
|
+
}
|
|
401
|
+
interface BorrowParams extends PrepareOptions {
|
|
402
|
+
/**
|
|
403
|
+
* Token the wallet puts up as collateral. Must be a collateral token of the
|
|
404
|
+
* market, and cannot be {@link borrowToken} — the payout is swept off the
|
|
405
|
+
* account, and a sweep takes the whole balance of the token it names.
|
|
406
|
+
**/
|
|
407
|
+
collateralToken: Address;
|
|
408
|
+
/** Amount of {@link collateralToken} that leaves the wallet. */
|
|
409
|
+
collateralAmount: bigint;
|
|
410
|
+
/**
|
|
411
|
+
* Token the wallet is paid the loan in. The market underlying is handed over
|
|
412
|
+
* as it is borrowed; anything else the router has a path to is bought with
|
|
413
|
+
* the borrowed underlying first, and then {@link BorrowResult} reports both
|
|
414
|
+
* what that trade is expected to return and its floor.
|
|
415
|
+
*
|
|
416
|
+
* An RWA market is paid in the asset its underlying wraps — `USDC`, not the
|
|
417
|
+
* `dcUSDC` the pool lends — because the wrapper cannot leave the account.
|
|
418
|
+
* The two convert one for one through the market's vault, so that payout is
|
|
419
|
+
* exact like the underlying's. Naming the wrapper is refused with
|
|
420
|
+
* `unsupportedCollateralToken`.
|
|
421
|
+
**/
|
|
422
|
+
borrowToken: Address;
|
|
423
|
+
/**
|
|
424
|
+
* Amount of {@link borrowToken} the wallet asks for. It is the debt exactly
|
|
425
|
+
* when `borrowToken` is the market underlying, and the same amount in the
|
|
426
|
+
* underlying's own decimals when it is the asset an RWA market unwraps into;
|
|
427
|
+
* otherwise the debt is what the oracle prices that much of it at, and what
|
|
428
|
+
* actually arrives is the router's answer.
|
|
429
|
+
**/
|
|
430
|
+
borrowAmount: bigint;
|
|
431
|
+
/**
|
|
432
|
+
* Existing credit account to draw the loan on, instead of opening one.
|
|
433
|
+
*
|
|
434
|
+
* Any account of `strategy.creditManager` that carries no debt and no
|
|
435
|
+
* quotas qualifies. Only the transaction differs; `execute.buildTx` reads
|
|
436
|
+
* which one to build off the result's own `state.creditAccount`.
|
|
437
|
+
*
|
|
438
|
+
* Balances already sitting on it are left where they are and are **not**
|
|
439
|
+
* counted towards the health factor, so the loan this allows is the one the
|
|
440
|
+
* named collateral alone carries. The exception is a balance in
|
|
441
|
+
* {@link borrowToken}: the payout sweep takes the whole balance of the token
|
|
442
|
+
* it names, so that one leaves with the loan.
|
|
371
443
|
**/
|
|
372
444
|
creditAccount?: Address;
|
|
373
|
-
empty?: false;
|
|
374
445
|
}
|
|
375
446
|
/**
|
|
376
|
-
*
|
|
377
|
-
*
|
|
378
|
-
* an opening that names it as
|
|
379
|
-
* {@link OpenStrategyFundedParams.creditAccount}.
|
|
380
|
-
*
|
|
381
|
-
* The market is the whole request. There is nothing else to say: with no
|
|
382
|
-
* collateral the debt is zero at any leverage, and there is nothing to route
|
|
383
|
-
* anywhere — so leverage and a target token are not merely ignored here, they
|
|
384
|
-
* cannot be named.
|
|
447
|
+
* What a borrow form knows before it knows the amount: everything
|
|
448
|
+
* {@link BorrowParams} carries except the loan itself, which is the answer.
|
|
385
449
|
**/
|
|
386
|
-
interface
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
*
|
|
395
|
-
*
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
450
|
+
interface MaxBorrowParams {
|
|
451
|
+
/** Token the wallet would put up, as in {@link BorrowParams}. */
|
|
452
|
+
collateralToken: Address;
|
|
453
|
+
/** Amount of {@link collateralToken} that would leave the wallet. */
|
|
454
|
+
collateralAmount: bigint;
|
|
455
|
+
/** Token the loan would be paid in; the ceiling comes back in its units. */
|
|
456
|
+
borrowToken: Address;
|
|
457
|
+
/**
|
|
458
|
+
* Health factor the loan should leave the account at, in basis points.
|
|
459
|
+
* Omitted, the SDK holds it to the threshold a form would.
|
|
460
|
+
**/
|
|
461
|
+
targetHF?: bigint;
|
|
462
|
+
/**
|
|
463
|
+
* Extra quota headroom in PERCENTAGE_FORMAT. Pass what the borrow itself
|
|
464
|
+
* will pass: a quota short of the collateral's weighted value is what caps
|
|
465
|
+
* the loan, so a different reserve here answers about a different loan.
|
|
466
|
+
**/
|
|
467
|
+
quotaReserve?: number;
|
|
403
468
|
}
|
|
404
469
|
interface LpParams {
|
|
405
470
|
/**
|
|
@@ -472,11 +537,11 @@ interface FinalizeParams extends PrepareOptions {
|
|
|
472
537
|
* throws: a chain that cannot be reached or a crash on the way arrives as
|
|
473
538
|
* `unexpectedFailure` with the cause attached.
|
|
474
539
|
*
|
|
475
|
-
* The bare readers stay outside the envelope
|
|
476
|
-
* number and throw on an account or chain the SDK does not hold
|
|
477
|
-
* synchronous
|
|
478
|
-
* weigh state already loaded and say "nothing available"
|
|
479
|
-
* an empty list
|
|
540
|
+
* The bare readers stay outside the envelope. The ones that read an account
|
|
541
|
+
* answer their number and throw on an account or chain the SDK does not hold;
|
|
542
|
+
* the synchronous ones ({@link leverageBand}, {@link withdrawableCollaterals},
|
|
543
|
+
* {@link maxBorrow}) weigh state already loaded and say "nothing available"
|
|
544
|
+
* with `undefined`, an empty list or `0n`.
|
|
480
545
|
**/
|
|
481
546
|
interface IOpportunitiesPrepare {
|
|
482
547
|
/**
|
|
@@ -503,10 +568,41 @@ interface IOpportunitiesPrepare {
|
|
|
503
568
|
/**
|
|
504
569
|
* Opening a leveraged position from wallet collateral.
|
|
505
570
|
*
|
|
506
|
-
*
|
|
571
|
+
* There is no account to walk yet, so the result carries no operation list —
|
|
507
572
|
* it feeds `sdk.accounts.openCA` instead.
|
|
573
|
+
*
|
|
574
|
+
* `creditAccount` puts the position on an account the wallet already holds
|
|
575
|
+
* rather than creating one.
|
|
508
576
|
**/
|
|
509
577
|
openNewStrategy(strategy: StrategyInput, params: OpenStrategyParams): Promise<SDKReturn<OpenStrategyResult, OpenFlowError | DebtOutOfRangeError | LeverageOutOfRangeError | UnsupportedTokenPairError | InsufficientPoolLiquidityError | NoStrategyTargetCollateralError | CreditAccountNotFoundError | CreditAccountNotEmptyError>>;
|
|
578
|
+
/**
|
|
579
|
+
* Handing a wallet an account that holds nothing: no collateral, no debt, no
|
|
580
|
+
* quotas and no route quoted. It exists so a wallet can hold an account
|
|
581
|
+
* ahead of having a use for one, and so the two flows that put something on
|
|
582
|
+
* an account have one to name as their `creditAccount`.
|
|
583
|
+
*
|
|
584
|
+
* The market is the whole request, and the only thing that can refuse it is
|
|
585
|
+
* the market itself: a facade that is paused or past its expiration takes no
|
|
586
|
+
* multicall, so an account cannot be opened there either.
|
|
587
|
+
**/
|
|
588
|
+
openEmptyCreditAccount(strategy: StrategyInput): Promise<SDKReturn<EmptyCreditAccountResult, CreditManagerPausedError | MarketExpiredError | UnexpectedFailureError>>;
|
|
589
|
+
/**
|
|
590
|
+
* Borrowing against collateral: one transaction opens an account, puts the
|
|
591
|
+
* collateral on it, draws the loan and pays it out to the wallet.
|
|
592
|
+
*
|
|
593
|
+
* The account is left holding the collateral and owing the debt, and nothing
|
|
594
|
+
* else — which is what tells this apart from {@link openNewStrategy}, where
|
|
595
|
+
* the borrowed funds stay on the account as part of the position. There is
|
|
596
|
+
* no leverage to name for the same reason: the loan is the amount asked for.
|
|
597
|
+
*
|
|
598
|
+
* The payout leaves the account, so the market weighs what is left at safe
|
|
599
|
+
* prices, and a loan the remaining collateral cannot carry there comes back
|
|
600
|
+
* as `insufficientCollateral` rather than reverting on arrival.
|
|
601
|
+
*
|
|
602
|
+
* `creditAccount` draws the loan on an account the wallet already holds
|
|
603
|
+
* instead of opening another, as {@link openNewStrategy} does.
|
|
604
|
+
**/
|
|
605
|
+
borrow(strategy: StrategyInput, params: BorrowParams): Promise<SDKReturn<BorrowResult, OpenFlowError | DebtOutOfRangeError | UnsupportedCollateralTokenError | UnsupportedTokenPairError | InsufficientPoolLiquidityError | CreditAccountNotFoundError | CreditAccountNotEmptyError>>;
|
|
510
606
|
/**
|
|
511
607
|
* Growing a position: collateral in, debt drawn on top, both converted into
|
|
512
608
|
* the position token.
|
|
@@ -541,26 +637,33 @@ interface IOpportunitiesPrepare {
|
|
|
541
637
|
**/
|
|
542
638
|
withdrawStrategy(position: PositionInput, params: WithdrawStrategyParams): Promise<SDKReturn<StrategyRoutesResult, (AccountFlowError | DebtOutOfRangeError | UnsupportedTokenPairError | NoDelayedRouteError | MultipleDelayedWithdrawalsError | WithdrawalInProgressError) & WithRouteErrors>>;
|
|
543
639
|
/**
|
|
544
|
-
* How much {@link withdrawStrategy} can take out,
|
|
545
|
-
* underlying units: `
|
|
546
|
-
*
|
|
547
|
-
* value leaving entirely hands over.
|
|
548
|
-
*
|
|
549
|
-
*
|
|
550
|
-
*
|
|
551
|
-
* sit below the floor. A form driving a slider off
|
|
552
|
-
* button off `exit` describes what the account can
|
|
553
|
-
* either alone will misstate one of them — see
|
|
554
|
-
* which spells out how far apart they can be
|
|
555
|
-
*
|
|
556
|
-
*
|
|
640
|
+
* How much {@link withdrawStrategy} can take out, every end of it, in
|
|
641
|
+
* underlying units: `safePartial` is the largest partial withdrawal the flow
|
|
642
|
+
* accepts, `partial` the same figure before the safe-price collateral check
|
|
643
|
+
* has had its say, and `exit` the net value leaving entirely hands over.
|
|
644
|
+
*
|
|
645
|
+
* More than one number because the range has a hole in it: between the
|
|
646
|
+
* largest partial and `exit` the flow refuses with `debtOutOfRange`, since
|
|
647
|
+
* the leftover loan would sit below the floor. A form driving a slider off
|
|
648
|
+
* `safePartial` and a Max button off `exit` describes what the account can
|
|
649
|
+
* actually do; a form using either alone will misstate one of them — see
|
|
650
|
+
* {@link WithdrawCeilings}, which spells out how far apart they can be and
|
|
651
|
+
* why the two partial figures differ.
|
|
652
|
+
*
|
|
653
|
+
* `sourceToken` is the collateral the withdrawal would be funded from, the
|
|
654
|
+
* same argument {@link withdrawStrategy} takes. It matters because selling
|
|
655
|
+
* one collateral and selling another cost the safe-price check different
|
|
656
|
+
* amounts; omitted, both this and the flow itself reach for the account's
|
|
657
|
+
* largest non-phantom balance.
|
|
658
|
+
*
|
|
659
|
+
* Taking everything out needs none of the figures: send `MAX_UINT256` to
|
|
557
660
|
* {@link withdrawStrategy} and the exit is what runs, named rather than
|
|
558
661
|
* priced.
|
|
559
662
|
*
|
|
560
663
|
* A bare read: it answers its numbers, and throws on an account or a chain
|
|
561
664
|
* the SDK does not hold.
|
|
562
665
|
**/
|
|
563
|
-
maxWithdraw(position: PositionInput): Promise<WithdrawCeilings>;
|
|
666
|
+
maxWithdraw(position: PositionInput, sourceToken?: Address): Promise<WithdrawCeilings>;
|
|
564
667
|
/**
|
|
565
668
|
* Paying debt down with funds from the wallet: collateral stays where it is,
|
|
566
669
|
* so net value grows by what was repaid, leverage falls and the health factor
|
|
@@ -663,6 +766,37 @@ interface IOpportunitiesPrepare {
|
|
|
663
766
|
* the SDK does not hold.
|
|
664
767
|
**/
|
|
665
768
|
maxWithdrawCollateral(position: PositionInput, token: Address, targetHF?: bigint): Promise<bigint>;
|
|
769
|
+
/**
|
|
770
|
+
* Largest loan {@link borrow} can draw against a given collateral while the
|
|
771
|
+
* account stays safely collateralised, in the payout token's units — the
|
|
772
|
+
* ceiling a borrow form should offer.
|
|
773
|
+
*
|
|
774
|
+
* The loan leaves the account, so the collateral alone backs the debt and
|
|
775
|
+
* the market weighs it at safe prices, under its liquidation threshold and
|
|
776
|
+
* capped by the quota the borrow buys for it. The answer is then held to
|
|
777
|
+
* what the market will actually lend: the pool's free liquidity, the
|
|
778
|
+
* manager's own allowance and the facade's `maxDebt`.
|
|
779
|
+
*
|
|
780
|
+
* `targetHF` names the health factor to land at, in basis points; omitted,
|
|
781
|
+
* the SDK holds it to the threshold a form would.
|
|
782
|
+
*
|
|
783
|
+
* Synchronous, like {@link leverageBand} and for the same reason: the
|
|
784
|
+
* account does not exist yet, so there is nothing to read and a form can ask
|
|
785
|
+
* on every keystroke.
|
|
786
|
+
*
|
|
787
|
+
* It is a ceiling and not a verdict: the facade's `minDebt` is a floor, and
|
|
788
|
+
* holding the answer to it would tell a form `0` for collateral that does
|
|
789
|
+
* carry a loan, only a smaller one than this market lends. So a Max offered
|
|
790
|
+
* from here can still be refused by {@link borrow} with `debtOutOfRange`,
|
|
791
|
+
* which names the floor the amount fell short of.
|
|
792
|
+
*
|
|
793
|
+
* `0n` where this market funds no loan of this shape at any size — a
|
|
794
|
+
* collateral worth nothing at safe prices, a payout token equal to the
|
|
795
|
+
* collateral, a market with nothing left to lend, or a manager the SDK does
|
|
796
|
+
* not hold. Not the same as "any amount works", and a caller must not offer
|
|
797
|
+
* a Max for it.
|
|
798
|
+
**/
|
|
799
|
+
maxBorrow(strategy: StrategyInput, params: MaxBorrowParams): bigint;
|
|
666
800
|
/**
|
|
667
801
|
* The tail of a delayed route: claim the matured withdrawal, then whatever the
|
|
668
802
|
* operation that requested it still owes — repaying debt and paying the wallet
|
|
@@ -688,4 +822,4 @@ interface IOpportunitiesPrepare {
|
|
|
688
822
|
finalize(position: PositionInput, params: FinalizeParams): Promise<SDKReturn<FinalizeResult, AccountFlowError | NoRecordedIntentError | NoDelayedRouteError | WithdrawalInProgressError | UnsupportedTokenPairError>>;
|
|
689
823
|
}
|
|
690
824
|
//#endregion
|
|
691
|
-
export { AccountFlowError, AddCollateralParams, AdjustLeverageParams, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DelayedStrategyResult, DepositStrategyParams, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, type LeverageBand, LpParams, LpRedeemParams, LpResult, LpState, type MultipleDelayedWithdrawalsError, type NoDelayedRouteError, type NoRecordedIntentError, type NoStrategyTargetCollateralError, OpenFlowError,
|
|
825
|
+
export { AccountFlowError, AddCollateralParams, AdjustLeverageParams, BorrowParams, BorrowResult, type BorrowState, type CreditAccountNotEmptyError, type CreditAccountNotFoundError, DelayedStrategyResult, DepositStrategyParams, EmptyCreditAccountResult, type ExecutionCost, FinalizeParams, FinalizeResult, IOpportunitiesPrepare, type LeverageBand, LpParams, LpRedeemParams, LpResult, LpState, MaxBorrowParams, type MultipleDelayedWithdrawalsError, type NoDelayedRouteError, type NoRecordedIntentError, type NoStrategyTargetCollateralError, OpenFlowError, OpenStrategyParams, OpenStrategyResult, type OperationState, type PathLossRate, PoolInput, type PoolOperationError, PositionInput, PrepareOptions, RepayStrategyParams, type RouteErrors, StrategyInput, StrategyResult, StrategyRoutesResult, type UnexpectedFailureError, type UnsupportedCollateralTokenError, type UnsupportedTokenPairError, WithRouteErrors, type WithdrawCeilings, WithdrawCollateralParams, WithdrawStrategyParams, type WithdrawalInProgressError };
|
package/package.json
CHANGED
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_onchain_utils_AddressMap = require("../../utils/AddressMap.js");
|
|
3
|
-
let viem = require("viem");
|
|
4
|
-
//#region src/onchain/accounts/utils/midasUtils.ts
|
|
5
|
-
const ADAPTER_MIDAS_GATEWAY = "ADAPTER::MIDAS_GATEWAY";
|
|
6
|
-
const ADAPTER_MIDAS_ISSUANCE_VAULT = "ADAPTER::MIDAS_ISSUANCE_VAULT";
|
|
7
|
-
/**
|
|
8
|
-
* Permissionless gateways have no greenlist and reject `receiveGreenlist`,
|
|
9
|
-
* see MidasMode in integrations-v3
|
|
10
|
-
*/
|
|
11
|
-
const MIDAS_MODE_PERMISSIONLESS = 0;
|
|
12
|
-
const iMidasGatewayAdapterExtAbi = (0, viem.parseAbi)(["function receiveGreenlist() external returns (bool)"]);
|
|
13
|
-
const iMidasGatewayModeAbi = (0, viem.parseAbi)(["function mode() external view returns (uint8)"]);
|
|
14
|
-
const receiveGreenlistCallData = (0, viem.encodeFunctionData)({
|
|
15
|
-
abi: iMidasGatewayAdapterExtAbi,
|
|
16
|
-
functionName: "receiveGreenlist"
|
|
17
|
-
});
|
|
18
|
-
/**
|
|
19
|
-
* Prepends `MidasGatewayAdapter.receiveGreenlist()` to a credit facade
|
|
20
|
-
* multicall that mints an mToken through a Midas issuance vault.
|
|
21
|
-
*
|
|
22
|
-
* Permissioned and restricted-interface mTokens can only be held by greenlisted
|
|
23
|
-
* accounts, and a freshly opened credit account is never greenlisted, so the
|
|
24
|
-
* mint reverts with `WMAC: hasnt role` unless the account asks the gateway for
|
|
25
|
-
* the greenlist first. Greenlisting the borrower is not enough — the role is
|
|
26
|
-
* checked on the token holder, which is the credit account.
|
|
27
|
-
*
|
|
28
|
-
* Returns `calls` unchanged when nothing has to be greenlisted: no issuance
|
|
29
|
-
* vault is called, its mToken has no gateway adapter on this credit manager,
|
|
30
|
-
* the gateway is permissionless, or the call is already there.
|
|
31
|
-
*/
|
|
32
|
-
async function prependMidasReceiveGreenlist(props) {
|
|
33
|
-
const { cm, client, calls, logger } = props;
|
|
34
|
-
const adapters = Array.from(cm.creditManager.adapters.values());
|
|
35
|
-
const gatewayByMToken = require_onchain_utils_AddressMap.AddressMap.fromMappedArray(adapters.filter((a) => a.contractType === ADAPTER_MIDAS_GATEWAY), (a) => a.mToken);
|
|
36
|
-
const calledVaults = adapters.filter((a) => a.contractType === ADAPTER_MIDAS_ISSUANCE_VAULT).filter((vault) => calls.some((call) => (0, viem.isAddressEqual)(call.target, vault.address)));
|
|
37
|
-
if (gatewayByMToken.size === 0 || calledVaults.length === 0) return calls;
|
|
38
|
-
const gateways = new require_onchain_utils_AddressMap.AddressMap();
|
|
39
|
-
for (const vault of calledVaults) {
|
|
40
|
-
const gateway = gatewayByMToken.get(vault.mToken);
|
|
41
|
-
if (!gateway) logger?.debug(`midas: no gateway adapter for mToken ${vault.mToken} minted by ${vault.address} on ${cm.name}, cannot greenlist the credit account`);
|
|
42
|
-
else if (calls.some((call) => (0, viem.isAddressEqual)(call.target, gateway.address) && call.callData === receiveGreenlistCallData)) logger?.debug(`midas: gateway adapter ${gateway.address} already receives the greenlist`);
|
|
43
|
-
else gateways.upsert(gateway.address, gateway);
|
|
44
|
-
}
|
|
45
|
-
if (gateways.size === 0) return calls;
|
|
46
|
-
const uniqueGateways = gateways.values();
|
|
47
|
-
const modes = await client.multicall({
|
|
48
|
-
allowFailure: false,
|
|
49
|
-
contracts: uniqueGateways.map(({ targetContract }) => ({
|
|
50
|
-
address: targetContract,
|
|
51
|
-
abi: iMidasGatewayModeAbi,
|
|
52
|
-
functionName: "mode"
|
|
53
|
-
}))
|
|
54
|
-
});
|
|
55
|
-
const prepended = [];
|
|
56
|
-
for (const [i, gateway] of uniqueGateways.entries()) {
|
|
57
|
-
if (modes[i] === MIDAS_MODE_PERMISSIONLESS) {
|
|
58
|
-
logger?.debug(`midas: gateway ${gateway.targetContract} is permissionless, nothing to greenlist`);
|
|
59
|
-
continue;
|
|
60
|
-
}
|
|
61
|
-
logger?.debug(`midas: greenlisting the credit account via gateway adapter ${gateway.address}`);
|
|
62
|
-
prepended.push({
|
|
63
|
-
target: gateway.address,
|
|
64
|
-
callData: receiveGreenlistCallData
|
|
65
|
-
});
|
|
66
|
-
}
|
|
67
|
-
return prepended.length > 0 ? [...prepended, ...calls] : calls;
|
|
68
|
-
}
|
|
69
|
-
//#endregion
|
|
70
|
-
exports.prependMidasReceiveGreenlist = prependMidasReceiveGreenlist;
|