@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
|
@@ -16,6 +16,8 @@ var ExecuteApi = class {
|
|
|
16
16
|
switch (request.kind) {
|
|
17
17
|
case "pool": return poolTx(sdk, request);
|
|
18
18
|
case "open": return openTx(sdk, request);
|
|
19
|
+
case "openEmpty": return openEmptyTx(sdk, request);
|
|
20
|
+
case "borrow": return borrowTx(sdk, request);
|
|
19
21
|
case "account": return accountTx(sdk, request);
|
|
20
22
|
}
|
|
21
23
|
}
|
|
@@ -62,20 +64,78 @@ async function openTx(sdk, request) {
|
|
|
62
64
|
reopenCreditAccount: state.creditAccount,
|
|
63
65
|
permits: {},
|
|
64
66
|
referralCode: 0n,
|
|
65
|
-
rwaOptions: await openRwaOptions(sdk, request)
|
|
67
|
+
rwaOptions: await openRwaOptions(sdk, request, request.targetToken)
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* The opening with nothing in it: no debt to draw, no collateral to take, no
|
|
72
|
+
* path to run and no quota to buy, so `openCA` is left with the price updates
|
|
73
|
+
* the market demands and the facade's own `openCreditAccount`.
|
|
74
|
+
*
|
|
75
|
+
* Nothing is read off the preparation because there is nothing on it. The
|
|
76
|
+
* account holds no token, so an RWA market has none to gate on either.
|
|
77
|
+
**/
|
|
78
|
+
function openEmptyTx(sdk, request) {
|
|
79
|
+
return sdk.accounts.openCA({
|
|
80
|
+
creditManager: request.creditManager,
|
|
81
|
+
to: request.wallet,
|
|
82
|
+
collateral: [],
|
|
83
|
+
ethAmount: 0n,
|
|
84
|
+
debt: 0n,
|
|
85
|
+
calls: [],
|
|
86
|
+
averageQuota: [],
|
|
87
|
+
minQuota: [],
|
|
88
|
+
permits: {},
|
|
89
|
+
referralCode: 0n
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
/**
|
|
93
|
+
* A loan is an opening whose debt leaves again, so it is the same `openCA`
|
|
94
|
+
* with `withdrawToken` set: the facade draws the debt, takes the collateral,
|
|
95
|
+
* runs whatever path buys the payout, and sweeps that payout to the wallet.
|
|
96
|
+
*
|
|
97
|
+
* Both quota branches are the one the state carries. An opening has two
|
|
98
|
+
* because the balances it lands on are a router quote; here the account is
|
|
99
|
+
* left holding the collateral the caller named, and a named amount has no
|
|
100
|
+
* floor to differ from.
|
|
101
|
+
**/
|
|
102
|
+
async function borrowTx(sdk, request) {
|
|
103
|
+
const { creditManager, wallet, ethAmount, sim } = request;
|
|
104
|
+
const { state } = sim.data;
|
|
105
|
+
const collateral = {
|
|
106
|
+
token: state.collateral.token.address,
|
|
107
|
+
balance: state.collateral.value
|
|
108
|
+
};
|
|
109
|
+
return sdk.accounts.openCA({
|
|
110
|
+
creditManager,
|
|
111
|
+
to: wallet,
|
|
112
|
+
collateral: [collateral],
|
|
113
|
+
ethAmount,
|
|
114
|
+
debt: state.totalDebt.value,
|
|
115
|
+
calls: state.calls,
|
|
116
|
+
withdrawToken: state.borrowed.token.address,
|
|
117
|
+
averageQuota: state.quotaIncrease,
|
|
118
|
+
minQuota: state.quotaIncrease,
|
|
119
|
+
reopenCreditAccount: state.creditAccount,
|
|
120
|
+
permits: {},
|
|
121
|
+
referralCode: 0n,
|
|
122
|
+
rwaOptions: await openRwaOptions(sdk, request, collateral.token)
|
|
66
123
|
});
|
|
67
124
|
}
|
|
68
125
|
/**
|
|
69
126
|
* The documented `openCA` contract: ask the market for its open requirements
|
|
70
127
|
* and hand them back as operation args, with the caller's cached signatures
|
|
71
|
-
* attached. `undefined` on non-RWA markets and when no
|
|
128
|
+
* attached. `undefined` on non-RWA markets and when no token is named.
|
|
129
|
+
*
|
|
130
|
+
* `token` is the one the account ends up holding, which is what an RWA market
|
|
131
|
+
* gates on: the opening's target, and the borrow's collateral.
|
|
72
132
|
**/
|
|
73
|
-
async function openRwaOptions(sdk, request) {
|
|
74
|
-
if (!
|
|
75
|
-
const requirements = await sdk.accounts.getOpenAccountRequirements(request.wallet, request.creditManager, { tokenOutAddress:
|
|
76
|
-
if (
|
|
133
|
+
async function openRwaOptions(sdk, request, token) {
|
|
134
|
+
if (!token) return;
|
|
135
|
+
const requirements = await sdk.accounts.getOpenAccountRequirements(request.wallet, request.creditManager, { tokenOutAddress: token });
|
|
136
|
+
if (requirements?.protocol !== "securitize") return;
|
|
77
137
|
return {
|
|
78
|
-
|
|
138
|
+
protocol: "securitize",
|
|
79
139
|
tokensToRegister: requirements.tokensToRegister,
|
|
80
140
|
signaturesToCache: request.signaturesToCache ?? []
|
|
81
141
|
};
|
|
@@ -70,15 +70,21 @@ var OpportunitiesNamespace = class extends AbstractNamespace {
|
|
|
70
70
|
/**
|
|
71
71
|
* {@inheritDoc IOpportunitiesBase.getStrategy}
|
|
72
72
|
**/
|
|
73
|
-
async getStrategy(key
|
|
73
|
+
async getStrategy(key) {
|
|
74
74
|
return this.merged("get strategy opportunity", {
|
|
75
75
|
chainIds: [key.chainId],
|
|
76
|
-
fromChain: (source) => source.getStrategy(key
|
|
77
|
-
fromBackend: (source) => source.getStrategy(key
|
|
76
|
+
fromChain: (source) => source.getStrategy(key),
|
|
77
|
+
fromBackend: (source) => source.getStrategy(key),
|
|
78
78
|
merge: this.merge.strategy
|
|
79
79
|
});
|
|
80
80
|
}
|
|
81
81
|
/**
|
|
82
|
+
* {@inheritDoc IOpportunitiesOnchainOnly.isEligibleForStrategy}
|
|
83
|
+
**/
|
|
84
|
+
async isEligibleForStrategy(key, wallet) {
|
|
85
|
+
return this.onchain.isEligibleForStrategy(key, wallet);
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
82
88
|
* {@inheritDoc IOpportunitiesBase.filter}
|
|
83
89
|
**/
|
|
84
90
|
filter(response, filter) {
|
|
@@ -55,7 +55,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
55
55
|
const at = stateBlock(sdk);
|
|
56
56
|
const intent = resumable(params.intent ?? params.claimable.intent);
|
|
57
57
|
if (!intent) return sdkErr(noRecordedIntent());
|
|
58
|
-
const creditAccount = await slice(sdk, position.creditAccount);
|
|
58
|
+
const creditAccount = await slice$1(sdk, position.creditAccount);
|
|
59
59
|
if (!creditAccount) return sdkErr(creditAccountNotFound(position.creditAccount));
|
|
60
60
|
return finalized(await service(sdk).finishIntent({
|
|
61
61
|
intent,
|
|
@@ -195,26 +195,33 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
195
195
|
}
|
|
196
196
|
}
|
|
197
197
|
/**
|
|
198
|
+
* {@inheritDoc IOpportunitiesPrepare.openEmptyCreditAccount}
|
|
199
|
+
**/
|
|
200
|
+
async openEmptyCreditAccount(strategy) {
|
|
201
|
+
try {
|
|
202
|
+
const sdk = await this.#chain(strategy.chainId);
|
|
203
|
+
const at = stateBlock(sdk);
|
|
204
|
+
const result = await service(sdk).openEmptyAccountIntent({
|
|
205
|
+
sdk,
|
|
206
|
+
creditManager: strategy.creditManager
|
|
207
|
+
});
|
|
208
|
+
return result.ok ? sdkOk(at) : methodError(result);
|
|
209
|
+
} catch (e) {
|
|
210
|
+
return sdkErr(unexpectedFailure(e));
|
|
211
|
+
}
|
|
212
|
+
}
|
|
213
|
+
/**
|
|
198
214
|
* {@inheritDoc IOpportunitiesPrepare.openNewStrategy}
|
|
199
215
|
**/
|
|
200
216
|
async openNewStrategy(strategy, params) {
|
|
201
217
|
try {
|
|
202
218
|
const sdk = await this.#chain(strategy.chainId);
|
|
203
219
|
const at = stateBlock(sdk);
|
|
204
|
-
if (params.empty) return opened(await service(sdk).openStrategyIntent({
|
|
205
|
-
sdk,
|
|
206
|
-
creditManager: strategy.creditManager,
|
|
207
|
-
empty: true
|
|
208
|
-
}), at);
|
|
209
220
|
const targetToken = params.targetToken ?? sdk.marketRegister.findCreditManager(strategy.creditManager).strategyTargetCollateral;
|
|
210
221
|
if (!targetToken) return sdkErr(noStrategyTargetCollateral(strategy.creditManager));
|
|
211
|
-
|
|
212
|
-
if (
|
|
213
|
-
|
|
214
|
-
if (!reused || !isAddressEqual(reused.creditManager, strategy.creditManager)) return sdkErr(creditAccountNotFound(params.creditAccount));
|
|
215
|
-
if (reused.totalDebt > 0n || reused.tokens.some((t) => t.quota > 0n)) return sdkErr(creditAccountNotEmpty(params.creditAccount));
|
|
216
|
-
creditAccount = reused;
|
|
217
|
-
}
|
|
222
|
+
const reused = await reusable(sdk, strategy, params.creditAccount);
|
|
223
|
+
if (reused && "error" in reused) return reused;
|
|
224
|
+
const creditAccount = reused?.account;
|
|
218
225
|
return opened(await service(sdk).openStrategyIntent({
|
|
219
226
|
sdk,
|
|
220
227
|
creditManager: strategy.creditManager,
|
|
@@ -231,6 +238,30 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
231
238
|
}
|
|
232
239
|
}
|
|
233
240
|
/**
|
|
241
|
+
* {@inheritDoc IOpportunitiesPrepare.borrow}
|
|
242
|
+
**/
|
|
243
|
+
async borrow(strategy, params) {
|
|
244
|
+
try {
|
|
245
|
+
const sdk = await this.#chain(strategy.chainId);
|
|
246
|
+
const at = stateBlock(sdk);
|
|
247
|
+
const reused = await reusable(sdk, strategy, params.creditAccount);
|
|
248
|
+
if (reused && "error" in reused) return reused;
|
|
249
|
+
return borrowed(await service(sdk).borrowIntent({
|
|
250
|
+
sdk,
|
|
251
|
+
creditManager: strategy.creditManager,
|
|
252
|
+
collateralToken: params.collateralToken,
|
|
253
|
+
collateralAmount: params.collateralAmount,
|
|
254
|
+
borrowToken: params.borrowToken,
|
|
255
|
+
borrowAmount: params.borrowAmount,
|
|
256
|
+
slippage: params.slippage,
|
|
257
|
+
quotaReserve: params.quotaReserve,
|
|
258
|
+
creditAccount: reused?.account
|
|
259
|
+
}), at);
|
|
260
|
+
} catch (e) {
|
|
261
|
+
return sdkErr(unexpectedFailure(e));
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
/**
|
|
234
265
|
* {@inheritDoc IOpportunitiesPrepare.depositStrategy}
|
|
235
266
|
**/
|
|
236
267
|
async depositStrategy(position, params) {
|
|
@@ -258,12 +289,13 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
258
289
|
/**
|
|
259
290
|
* {@inheritDoc IOpportunitiesPrepare.maxWithdraw}
|
|
260
291
|
**/
|
|
261
|
-
async maxWithdraw(position) {
|
|
292
|
+
async maxWithdraw(position, sourceToken) {
|
|
262
293
|
const sdk = await this.#chain(position.chainId);
|
|
263
294
|
const creditAccount = await this.#account(sdk, position);
|
|
264
295
|
return service(sdk).maxWithdraw({
|
|
265
296
|
creditAccount,
|
|
266
|
-
sdk
|
|
297
|
+
sdk,
|
|
298
|
+
sourceToken
|
|
267
299
|
});
|
|
268
300
|
}
|
|
269
301
|
/**
|
|
@@ -352,12 +384,27 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
352
384
|
});
|
|
353
385
|
}
|
|
354
386
|
/**
|
|
387
|
+
* {@inheritDoc IOpportunitiesPrepare.maxBorrow}
|
|
388
|
+
**/
|
|
389
|
+
maxBorrow(strategy, params) {
|
|
390
|
+
const sdk = this.sdk.chain(strategy.chainId);
|
|
391
|
+
return service(sdk).maxBorrow({
|
|
392
|
+
sdk,
|
|
393
|
+
creditManager: strategy.creditManager,
|
|
394
|
+
collateralToken: params.collateralToken,
|
|
395
|
+
collateralAmount: params.collateralAmount,
|
|
396
|
+
borrowToken: params.borrowToken,
|
|
397
|
+
targetHF: params.targetHF,
|
|
398
|
+
quotaReserve: params.quotaReserve
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
/**
|
|
355
402
|
* The account a bare `max*` read weighs. These reads answer a number, not
|
|
356
403
|
* an envelope, so an account the markets do not hold is thrown rather than
|
|
357
404
|
* described, see {@link IOpportunitiesPrepare.maxWithdraw}.
|
|
358
405
|
**/
|
|
359
406
|
async #account(sdk, position) {
|
|
360
|
-
const creditAccount = await slice(sdk, position.creditAccount);
|
|
407
|
+
const creditAccount = await slice$1(sdk, position.creditAccount);
|
|
361
408
|
if (!creditAccount) throw new Error(creditAccountNotFound(position.creditAccount).message);
|
|
362
409
|
return creditAccount;
|
|
363
410
|
}
|
|
@@ -374,7 +421,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
374
421
|
try {
|
|
375
422
|
const sdk = await this.#chain(position.chainId);
|
|
376
423
|
const at = stateBlock(sdk);
|
|
377
|
-
const creditAccount = await slice(sdk, position.creditAccount);
|
|
424
|
+
const creditAccount = await slice$1(sdk, position.creditAccount);
|
|
378
425
|
if (!creditAccount) return neitherRoute(creditAccountNotFound(position.creditAccount));
|
|
379
426
|
return routed(await service(sdk).intentRoutes({
|
|
380
427
|
intent,
|
|
@@ -400,7 +447,7 @@ var PrepareApi = class extends MultichainConstruct {
|
|
|
400
447
|
try {
|
|
401
448
|
const sdk = await this.#chain(position.chainId);
|
|
402
449
|
const at = stateBlock(sdk);
|
|
403
|
-
const creditAccount = await slice(sdk, position.creditAccount);
|
|
450
|
+
const creditAccount = await slice$1(sdk, position.creditAccount);
|
|
404
451
|
if (!creditAccount) return sdkErr(creditAccountNotFound(position.creditAccount));
|
|
405
452
|
return planned(await service(sdk).startIntent({
|
|
406
453
|
intent,
|
|
@@ -432,11 +479,30 @@ function stateBlock(sdk) {
|
|
|
432
479
|
* connected to hold no such account — closed since it was listed, or named on
|
|
433
480
|
* the wrong chain. Read rather than thrown, so the caller gets a code for it.
|
|
434
481
|
**/
|
|
435
|
-
async function slice(sdk, creditAccount) {
|
|
482
|
+
async function slice$1(sdk, creditAccount) {
|
|
436
483
|
const data = await sdk.accounts.getCreditAccountData(creditAccount);
|
|
437
484
|
return data && toCreditAccountSlice(data);
|
|
438
485
|
}
|
|
439
486
|
/**
|
|
487
|
+
* The pre-opened account a request asks to be run on, held to what "pre-opened"
|
|
488
|
+
* means: this manager's, owing nothing and holding no quota.
|
|
489
|
+
*
|
|
490
|
+
* Shared by the two flows that put something on a fresh account — an opening
|
|
491
|
+
* and a borrow — so both hold a reused one to the same terms. Whatever
|
|
492
|
+
* balances sit on it are left to the flow: an opening routes them, a borrow
|
|
493
|
+
* leaves them where they are.
|
|
494
|
+
*
|
|
495
|
+
* @returns Nothing when the request named no account, the refusal to answer
|
|
496
|
+
* with when it named one that does not qualify, and the slice otherwise
|
|
497
|
+
**/
|
|
498
|
+
async function reusable(sdk, strategy, creditAccount) {
|
|
499
|
+
if (!creditAccount) return;
|
|
500
|
+
const account = await slice$1(sdk, creditAccount);
|
|
501
|
+
if (!account || !isAddressEqual(account.creditManager, strategy.creditManager)) return sdkErr(creditAccountNotFound(creditAccount));
|
|
502
|
+
if (account.totalDebt > 0n || account.tokens.some((t) => t.quota > 0n)) return sdkErr(creditAccountNotEmpty(creditAccount));
|
|
503
|
+
return { account };
|
|
504
|
+
}
|
|
505
|
+
/**
|
|
440
506
|
* The operation a claim resumes, or `undefined` when there is none to resume:
|
|
441
507
|
* a withdrawal requested without an intent, or one read through a compressor
|
|
442
508
|
* too old to report it. Every intent the engine records can be finished,
|
|
@@ -536,6 +602,15 @@ function opened(result, at) {
|
|
|
536
602
|
}
|
|
537
603
|
/**
|
|
538
604
|
* {@inheritDoc planned}
|
|
605
|
+
**/
|
|
606
|
+
function borrowed(result, at) {
|
|
607
|
+
return result.ok ? sdkOk({
|
|
608
|
+
state: result.state,
|
|
609
|
+
...at
|
|
610
|
+
}) : methodError(result);
|
|
611
|
+
}
|
|
612
|
+
/**
|
|
613
|
+
* {@inheritDoc planned}
|
|
539
614
|
*
|
|
540
615
|
* Both routes are payload, error and all: `errors` says why a missing one is
|
|
541
616
|
* missing, and it stays on the error when neither route answered, since that is
|
package/dist/types/dev/abi.d.ts
CHANGED
|
@@ -108,11 +108,7 @@ declare const iFaucetAbi: readonly [{
|
|
|
108
108
|
readonly internalType: "uint256";
|
|
109
109
|
}];
|
|
110
110
|
}];
|
|
111
|
-
readonly outputs: readonly [
|
|
112
|
-
readonly name: "";
|
|
113
|
-
readonly type: "bool";
|
|
114
|
-
readonly internalType: "bool";
|
|
115
|
-
}];
|
|
111
|
+
readonly outputs: readonly [];
|
|
116
112
|
readonly stateMutability: "nonpayable";
|
|
117
113
|
}, {
|
|
118
114
|
readonly type: "function";
|
|
@@ -126,11 +122,7 @@ declare const iFaucetAbi: readonly [{
|
|
|
126
122
|
readonly type: "uint256";
|
|
127
123
|
readonly internalType: "uint256";
|
|
128
124
|
}];
|
|
129
|
-
readonly outputs: readonly [
|
|
130
|
-
readonly name: "";
|
|
131
|
-
readonly type: "bool";
|
|
132
|
-
readonly internalType: "bool";
|
|
133
|
-
}];
|
|
125
|
+
readonly outputs: readonly [];
|
|
134
126
|
readonly stateMutability: "nonpayable";
|
|
135
127
|
}, {
|
|
136
128
|
readonly type: "function";
|
|
@@ -140,11 +132,7 @@ declare const iFaucetAbi: readonly [{
|
|
|
140
132
|
readonly type: "address";
|
|
141
133
|
readonly internalType: "address";
|
|
142
134
|
}];
|
|
143
|
-
readonly outputs: readonly [
|
|
144
|
-
readonly name: "";
|
|
145
|
-
readonly type: "bool";
|
|
146
|
-
readonly internalType: "bool";
|
|
147
|
-
}];
|
|
135
|
+
readonly outputs: readonly [];
|
|
148
136
|
readonly stateMutability: "nonpayable";
|
|
149
137
|
}, {
|
|
150
138
|
readonly type: "function";
|
|
@@ -207,6 +195,16 @@ declare const iFaucetAbi: readonly [{
|
|
|
207
195
|
readonly internalType: "uint256";
|
|
208
196
|
}];
|
|
209
197
|
readonly stateMutability: "view";
|
|
198
|
+
}, {
|
|
199
|
+
readonly type: "function";
|
|
200
|
+
readonly name: "owner";
|
|
201
|
+
readonly inputs: readonly [];
|
|
202
|
+
readonly outputs: readonly [{
|
|
203
|
+
readonly name: "";
|
|
204
|
+
readonly type: "address";
|
|
205
|
+
readonly internalType: "address";
|
|
206
|
+
}];
|
|
207
|
+
readonly stateMutability: "view";
|
|
210
208
|
}, {
|
|
211
209
|
readonly type: "function";
|
|
212
210
|
readonly name: "prices";
|
|
@@ -24,7 +24,6 @@ interface ClaimFromFaucetOptions {
|
|
|
24
24
|
amount?: TokenClaim[] | bigint | ((minAmountUSD: bigint) => bigint);
|
|
25
25
|
gasMultiplier?: bigint;
|
|
26
26
|
logger?: ILogger;
|
|
27
|
-
sync?: boolean;
|
|
28
27
|
}
|
|
29
28
|
declare function claimFromFaucet(opts: ClaimFromFaucetOptions): Promise<void>;
|
|
30
29
|
//#endregion
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Account, Address, Block, Chain, Client, Hex, Prettify, PublicClient, TestActions, TestRpcSchema, Transport, WalletClient } from "viem";
|
|
1
|
+
import { Abi, Account, Address, Block, Chain, Client, ContractFunctionArgs, ContractFunctionName, Hex, Prettify, PublicClient, TestActions, TestRpcSchema, Transport, WalletClient, WriteContractSyncParameters, WriteContractSyncReturnType } from "viem";
|
|
2
2
|
//#region src/dev/createAnvilClient.d.ts
|
|
3
3
|
interface AnvilNodeInfo {
|
|
4
4
|
currentBlockNumber: string;
|
|
@@ -67,7 +67,7 @@ interface AnvilClientConfig<transport extends Transport = Transport, chain exten
|
|
|
67
67
|
/**
|
|
68
68
|
* Extends an arbitrary viem `PublicClient` with anvil + wallet actions plus
|
|
69
69
|
* the SDK's bonus actions (`anvilNodeInfo`, `isAnvil`, `evmMineDetailed`,
|
|
70
|
-
* `deal`).
|
|
70
|
+
* `deal`, `writeContractSync`).
|
|
71
71
|
*
|
|
72
72
|
* Used to lift `sdk.client` into an `AnvilClient` shape on the fly when test
|
|
73
73
|
* RPCs (impersonateAccount, setBalance, setStorageAt, ...) are needed.
|
|
@@ -93,5 +93,12 @@ declare function anvilNodeInfo(client: Client<any, any, any, AnvilRPCSchema, any
|
|
|
93
93
|
* @returns
|
|
94
94
|
*/
|
|
95
95
|
declare function evmMineDetailed(client: Client<any, any, any, AnvilRPCSchema, any>, timestamp: bigint | number): Promise<Block<Hex> | undefined>;
|
|
96
|
+
/**
|
|
97
|
+
* Anvil-compatible `writeContractSync`: send via `writeContract` (Anvil
|
|
98
|
+
* supports `eth_sendTransaction` / `eth_sendRawTransaction`) then wait for
|
|
99
|
+
* the receipt. Viem's own action uses `eth_sendRawTransactionSync`, which
|
|
100
|
+
* Anvil does not implement.
|
|
101
|
+
*/
|
|
102
|
+
declare function writeContractSync<chain extends Chain | undefined, account extends Account | undefined, const abi extends Abi | readonly unknown[], functionName extends ContractFunctionName<abi, "nonpayable" | "payable">, args extends ContractFunctionArgs<abi, "nonpayable" | "payable", functionName>, chainOverride extends Chain | undefined>(client: Client<Transport, chain, account>, parameters: WriteContractSyncParameters<abi, functionName, args, chain, account, chainOverride>): Promise<WriteContractSyncReturnType<chain>>;
|
|
96
103
|
//#endregion
|
|
97
|
-
export { AnvilActions, AnvilClient, AnvilClientConfig, AnvilDealParameters, AnvilNodeInfo, AnvilRPCSchema, anvilNodeInfo, createAnvilClient, evmMineDetailed, extendAnvilClient, isAnvil };
|
|
104
|
+
export { AnvilActions, AnvilClient, AnvilClientConfig, AnvilDealParameters, AnvilNodeInfo, AnvilRPCSchema, anvilNodeInfo, createAnvilClient, evmMineDetailed, extendAnvilClient, isAnvil, writeContractSync };
|
|
@@ -6,15 +6,15 @@ import { iDegenNftv2Abi, iFaucetAbi, iOnchainExecutionIdAbi, iOwnableAbi, iaclTr
|
|
|
6
6
|
import { calcLiquidatableLTs } from "./calcLiquidatableLTs.js";
|
|
7
7
|
import { claimFromFaucet } from "./claimFromFaucet.js";
|
|
8
8
|
import { Create2Deployer, Create2Parameters, DEFAULT_CREATE2_SALT, EnsureExistsUsingPublicCreate2ReturnType, GetCreate2AddressParameters, PUBLIC_CREATE2_FACTORY, deployUsingPublicCreate2, getPublicCreate2Address, isDeployedUsingPublicCreate2 } from "./create2.js";
|
|
9
|
-
import { AnvilActions, AnvilClient, AnvilClientConfig, AnvilDealParameters, AnvilNodeInfo, AnvilRPCSchema, anvilNodeInfo, createAnvilClient, evmMineDetailed, extendAnvilClient, isAnvil } from "./createAnvilClient.js";
|
|
9
|
+
import { AnvilActions, AnvilClient, AnvilClientConfig, AnvilDealParameters, AnvilNodeInfo, AnvilRPCSchema, anvilNodeInfo, createAnvilClient, evmMineDetailed, extendAnvilClient, isAnvil, writeContractSync } from "./createAnvilClient.js";
|
|
10
10
|
import { detectChain } from "./detectChain.js";
|
|
11
11
|
import { isOutOfSyncError } from "./isOutOfSyncError.js";
|
|
12
12
|
import { isRateLimitError } from "./isRateLimitError.js";
|
|
13
13
|
import { isTransientError } from "./isTransientError.js";
|
|
14
|
-
import { GreenlistMidasGatewayProps, RWAKycFailure, RegisterMidasInvestorProps, RegisterRWAInvestorProps, RegisterRWAInvestorResult, RegisterSecuritizeInvestorProps, greenlistMidasGateway, registerMidasInvestor, registerRWAInvestor, registerSecuritizeInvestor
|
|
14
|
+
import { DEFAULT_MIDAS_ADMIN, GreenlistMidasGatewayProps, RWAKycFailure, RegisterMidasInvestorProps, RegisterRWAInvestorProps, RegisterRWAInvestorResult, RegisterSecuritizeInvestorProps, getSecuritizeAdmin, greenlistMidasGateway, registerMidasInvestor, registerRWAInvestor, registerSecuritizeInvestor } from "./kycUtils.js";
|
|
15
15
|
import { LogSplitterTransportOptions, isRangeError, logSplitterTransport } from "./logSplitterTransport.js";
|
|
16
16
|
import { setLTZero, setLTs } from "./ltUtils.js";
|
|
17
|
-
import { RestoreMidasIssuanceVaultPause, UnpauseMidasIssuanceVaultProps, unpauseMidasIssuanceVault } from "./midasUtils.js";
|
|
17
|
+
import { MidasCreditSuite, RestoreMidasIssuanceVaultPause, UnpauseMidasIssuanceVaultProps, discoverMidasCreditSuites, discoverMidasGateways, discoverMidasMTokens, unpauseMidasIssuanceVault } from "./midasUtils.js";
|
|
18
18
|
import { migrateFaucet } from "./migrateFaucet.js";
|
|
19
19
|
import { IMinter } from "./mint/types.js";
|
|
20
20
|
import { createMinter } from "./mint/factory.js";
|
|
@@ -26,4 +26,4 @@ import { EnableDSTokenBackDatingProps, RestoreDSTokenBackDating, claimDSToken, c
|
|
|
26
26
|
import { httpTransportOptionsSchema } from "./transports.js";
|
|
27
27
|
import { ONCHAIN_EXECUTION_ID_ADDRESS, VerifyTestnetParams, verifyTestnet } from "./verifyTestnet.js";
|
|
28
28
|
import { MakePendingWithdrawalsClaimableOptions, makePendingWithdrawalsClaimable } from "./withdrawalUtils.js";
|
|
29
|
-
export { AccountOpener, AccountOpenerOptions, AnvilActions, AnvilClient, AnvilClientConfig, AnvilDealParameters, AnvilNodeInfo, AnvilRPCSchema, CheckMulticallFn, Create2Deployer, Create2Parameters, DEFAULT_CREATE2_SALT, DetectedCall, EnableDSTokenBackDatingProps, EnsureExistsUsingPublicCreate2ReturnType, EthCallMethod, EthCallRequest, EthCallSpy, GetCreate2AddressParameters, GreenlistMidasGatewayProps, IMinter, type LogSplitterTransportOptions, MakePendingWithdrawalsClaimableOptions, NoAvailableTransportsError, ONCHAIN_EXECUTION_ID_ADDRESS, OpenAccountHumanizedPreview, OpenAccountResult, OpenAccountsResult, OpenTxRevertedError, PUBLIC_CREATE2_FACTORY, PoolDepositResult, ProviderConfig, ProviderStatus, RWAKycFailure, RegisterMidasInvestorProps, RegisterRWAInvestorProps, RegisterRWAInvestorResult, RegisterSecuritizeInvestorProps, ReplaceStorageParams, ResilientTransportOptions, RestoreDSTokenBackDating, RestoreMidasIssuanceVaultPause, RevolverTransport, RevolverTransportConfig, RevolverTransportValue, RpcErrorResult, RpcProvider, RpcResponse, RpcSuccessResult, SUPPORTED_RPC_PROVIDERS, SelectionStrategy, TargetAccount, UnpauseMidasIssuanceVaultProps, VerifyTestnetParams, anvilNodeInfo, calcLiquidatableLTs, claimDSToken, claimDSTokens, claimFromFaucet, createAnvilClient, createMinter, deployUsingPublicCreate2, detectChain, enableDSTokenBackDating, evmMineDetailed, extendAnvilClient, getAlchemyUrl, getAnkrUrl, getDrpcUrl, getErpcKey, getPublicCreate2Address, getRpcProviderUrl, getThirdWebUrl, greenlistMidasGateway, httpTransportOptionsSchema, iDegenNftv2Abi, iFaucetAbi, iOnchainExecutionIdAbi, iOwnableAbi, iaclTraitAbi, isAnvil, isDeployedUsingPublicCreate2, isOutOfSyncError, isRangeError, isRateLimitError, isTransientError, logSplitterTransport, makePendingWithdrawalsClaimable, migrateFaucet, providerConfigSchema, registerMidasInvestor, registerRWAInvestor, registerSecuritizeInvestor, replaceStorage, resilientTransport, resilientTransportOptionsSchema, revolverTransportConfigBaseSchema, revolverTransportConfigSchema, rpcProvidersSchema, setLTZero, setLTs, unpauseMidasIssuanceVault, verifyTestnet,
|
|
29
|
+
export { AccountOpener, AccountOpenerOptions, AnvilActions, AnvilClient, AnvilClientConfig, AnvilDealParameters, AnvilNodeInfo, AnvilRPCSchema, CheckMulticallFn, Create2Deployer, Create2Parameters, DEFAULT_CREATE2_SALT, DEFAULT_MIDAS_ADMIN, DetectedCall, EnableDSTokenBackDatingProps, EnsureExistsUsingPublicCreate2ReturnType, EthCallMethod, EthCallRequest, EthCallSpy, GetCreate2AddressParameters, GreenlistMidasGatewayProps, IMinter, type LogSplitterTransportOptions, MakePendingWithdrawalsClaimableOptions, MidasCreditSuite, NoAvailableTransportsError, ONCHAIN_EXECUTION_ID_ADDRESS, OpenAccountHumanizedPreview, OpenAccountResult, OpenAccountsResult, OpenTxRevertedError, PUBLIC_CREATE2_FACTORY, PoolDepositResult, ProviderConfig, ProviderStatus, RWAKycFailure, RegisterMidasInvestorProps, RegisterRWAInvestorProps, RegisterRWAInvestorResult, RegisterSecuritizeInvestorProps, ReplaceStorageParams, ResilientTransportOptions, RestoreDSTokenBackDating, RestoreMidasIssuanceVaultPause, RevolverTransport, RevolverTransportConfig, RevolverTransportValue, RpcErrorResult, RpcProvider, RpcResponse, RpcSuccessResult, SUPPORTED_RPC_PROVIDERS, SelectionStrategy, TargetAccount, UnpauseMidasIssuanceVaultProps, VerifyTestnetParams, anvilNodeInfo, calcLiquidatableLTs, claimDSToken, claimDSTokens, claimFromFaucet, createAnvilClient, createMinter, deployUsingPublicCreate2, detectChain, discoverMidasCreditSuites, discoverMidasGateways, discoverMidasMTokens, enableDSTokenBackDating, evmMineDetailed, extendAnvilClient, getAlchemyUrl, getAnkrUrl, getDrpcUrl, getErpcKey, getPublicCreate2Address, getRpcProviderUrl, getSecuritizeAdmin, getThirdWebUrl, greenlistMidasGateway, httpTransportOptionsSchema, iDegenNftv2Abi, iFaucetAbi, iOnchainExecutionIdAbi, iOwnableAbi, iaclTraitAbi, isAnvil, isDeployedUsingPublicCreate2, isOutOfSyncError, isRangeError, isRateLimitError, isTransientError, logSplitterTransport, makePendingWithdrawalsClaimable, migrateFaucet, providerConfigSchema, registerMidasInvestor, registerRWAInvestor, registerSecuritizeInvestor, replaceStorage, resilientTransport, resilientTransportOptionsSchema, revolverTransportConfigBaseSchema, revolverTransportConfigSchema, rpcProvidersSchema, setLTZero, setLTs, unpauseMidasIssuanceVault, verifyTestnet, writeContractSync };
|
|
@@ -2,32 +2,26 @@ import { ILogger } from "../onchain/types/logger.js";
|
|
|
2
2
|
import { OnchainSDK } from "../onchain/OnchainSDK.js";
|
|
3
3
|
import "../onchain/index.js";
|
|
4
4
|
import { AnvilClient } from "./createAnvilClient.js";
|
|
5
|
-
import { Address
|
|
5
|
+
import { Address } from "viem";
|
|
6
6
|
//#region src/dev/kycUtils.d.ts
|
|
7
|
-
/**
|
|
8
|
-
* Writes to a contract, mines a block and waits for the receipt
|
|
9
|
-
*/
|
|
10
|
-
declare function writeAndWait(anvil: AnvilClient, params: Parameters<AnvilClient["writeContract"]>[0]): Promise<Hex>;
|
|
11
7
|
interface RegisterSecuritizeInvestorProps {
|
|
12
8
|
anvil: AnvilClient;
|
|
13
9
|
/**
|
|
14
10
|
* Wallet to register in the Securitize DS registry
|
|
15
11
|
*/
|
|
16
12
|
investor: Address;
|
|
17
|
-
/**
|
|
18
|
-
* Private key of the DS registry admin, signs the registry writes
|
|
19
|
-
*/
|
|
20
|
-
adminPrivateKey?: Hex;
|
|
21
|
-
/**
|
|
22
|
-
* DS registry admin, impersonated on the fork when no private key is given
|
|
23
|
-
*/
|
|
24
|
-
admin?: Address;
|
|
25
13
|
/**
|
|
26
14
|
* DSToken address
|
|
27
15
|
*/
|
|
28
16
|
token: Address;
|
|
29
17
|
logger?: ILogger;
|
|
30
18
|
}
|
|
19
|
+
/**
|
|
20
|
+
* DS trust-service master of `token`: Ownable owner at storage slot 0 of the
|
|
21
|
+
* trust service, same as periphery-v3 SecuritizeAttachHelper. MockDSToken
|
|
22
|
+
* returns itself as the trust service, so `admin()` is used instead.
|
|
23
|
+
*/
|
|
24
|
+
declare function getSecuritizeAdmin(anvil: AnvilClient, token: Address, logger?: ILogger): Promise<Address>;
|
|
31
25
|
/**
|
|
32
26
|
* Registers a wallet as a Securitize investor (fake KYC) in the DS registry
|
|
33
27
|
* service of a DSToken.
|
|
@@ -86,6 +80,11 @@ interface GreenlistMidasGatewayProps {
|
|
|
86
80
|
* Greenlists an investor in the access control of a single Midas gateway
|
|
87
81
|
*/
|
|
88
82
|
declare function greenlistMidasGateway(props: GreenlistMidasGatewayProps): Promise<void>;
|
|
83
|
+
/**
|
|
84
|
+
* Midas access control admin on mainnet. Holds the admin role of the greenlist
|
|
85
|
+
* operator role.
|
|
86
|
+
*/
|
|
87
|
+
declare const DEFAULT_MIDAS_ADMIN: Address;
|
|
89
88
|
interface RegisterRWAInvestorProps {
|
|
90
89
|
anvil: AnvilClient;
|
|
91
90
|
/**
|
|
@@ -97,16 +96,8 @@ interface RegisterRWAInvestorProps {
|
|
|
97
96
|
*/
|
|
98
97
|
investor: Address;
|
|
99
98
|
/**
|
|
100
|
-
*
|
|
101
|
-
*
|
|
102
|
-
*/
|
|
103
|
-
adminPrivateKey?: Hex;
|
|
104
|
-
/**
|
|
105
|
-
* Securitize registry admin, impersonated on the fork
|
|
106
|
-
*/
|
|
107
|
-
securitizeAdmin?: Address;
|
|
108
|
-
/**
|
|
109
|
-
* Override midas access control admin address
|
|
99
|
+
* Midas access control admin, impersonated on the fork.
|
|
100
|
+
* Defaults to {@link DEFAULT_MIDAS_ADMIN}.
|
|
110
101
|
*/
|
|
111
102
|
midasAdmin?: Address;
|
|
112
103
|
logger?: ILogger;
|
|
@@ -138,4 +129,4 @@ interface RegisterRWAInvestorResult {
|
|
|
138
129
|
*/
|
|
139
130
|
declare function registerRWAInvestor(props: RegisterRWAInvestorProps): Promise<RegisterRWAInvestorResult>;
|
|
140
131
|
//#endregion
|
|
141
|
-
export { GreenlistMidasGatewayProps, RWAKycFailure, RegisterMidasInvestorProps, RegisterRWAInvestorProps, RegisterRWAInvestorResult, RegisterSecuritizeInvestorProps, greenlistMidasGateway, registerMidasInvestor, registerRWAInvestor, registerSecuritizeInvestor
|
|
132
|
+
export { DEFAULT_MIDAS_ADMIN, GreenlistMidasGatewayProps, RWAKycFailure, RegisterMidasInvestorProps, RegisterRWAInvestorProps, RegisterRWAInvestorResult, RegisterSecuritizeInvestorProps, getSecuritizeAdmin, greenlistMidasGateway, registerMidasInvestor, registerRWAInvestor, registerSecuritizeInvestor };
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { ILogger } from "../onchain/types/logger.js";
|
|
2
|
+
import { OnchainSDK } from "../onchain/OnchainSDK.js";
|
|
2
3
|
import "../onchain/index.js";
|
|
3
4
|
import { AnvilClient } from "./createAnvilClient.js";
|
|
4
5
|
import { Address } from "viem";
|
|
@@ -22,14 +23,44 @@ interface UnpauseMidasIssuanceVaultProps {
|
|
|
22
23
|
*/
|
|
23
24
|
type RestoreMidasIssuanceVaultPause = () => Promise<void>;
|
|
24
25
|
/**
|
|
25
|
-
* Unpauses a
|
|
26
|
-
*
|
|
27
|
-
* callback that restores the original pause
|
|
26
|
+
* Unpauses a Midas issuance vault on an anvil fork so that `depositInstant`
|
|
27
|
+
* stops reverting with `Pausable: paused` (global) or `Pausable: fn paused`
|
|
28
|
+
* (per-selector), and returns a callback that restores the original pause
|
|
29
|
+
* state of each layer that was cleared.
|
|
28
30
|
*
|
|
29
31
|
* Impersonates `admin` and grants it `pauseAdminRole()` when missing, same as
|
|
30
32
|
* `greenlistMidasGateway` does with the greenlist roles. The grant is not
|
|
31
33
|
* reverted by the callback, only the pause state is.
|
|
32
34
|
*/
|
|
33
35
|
declare function unpauseMidasIssuanceVault(props: UnpauseMidasIssuanceVaultProps): Promise<RestoreMidasIssuanceVaultPause>;
|
|
36
|
+
/**
|
|
37
|
+
* One Midas credit suite: a credit manager with a Midas gateway adapter,
|
|
38
|
+
* or with a Midas degen NFT when it has no such adapter.
|
|
39
|
+
*/
|
|
40
|
+
interface MidasCreditSuite {
|
|
41
|
+
creditManager: Address;
|
|
42
|
+
gateway: Address;
|
|
43
|
+
mToken: Address;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Midas credit suites of the loaded credit managers.
|
|
47
|
+
*
|
|
48
|
+
* A manager with a gateway adapter is a suite on its own, so its degen NFT
|
|
49
|
+
* is not consulted. Suites that only have a Midas degen NFT read `mToken`
|
|
50
|
+
* from the gateway.
|
|
51
|
+
*/
|
|
52
|
+
declare function discoverMidasCreditSuites(sdk: OnchainSDK): Promise<MidasCreditSuite[]>;
|
|
53
|
+
/**
|
|
54
|
+
* Gateways of the Midas credit suites of the loaded credit managers.
|
|
55
|
+
*/
|
|
56
|
+
declare function discoverMidasGateways(sdk: OnchainSDK): Promise<Address[]>;
|
|
57
|
+
/**
|
|
58
|
+
* mTokens of the Midas credit suites of the loaded credit managers.
|
|
59
|
+
*
|
|
60
|
+
* A manager with a gateway adapter contributes that adapter's mToken, so its
|
|
61
|
+
* degen NFT is not consulted. Suites that only have a Midas degen NFT
|
|
62
|
+
* contribute the mToken read from the gateway.
|
|
63
|
+
*/
|
|
64
|
+
declare function discoverMidasMTokens(sdk: OnchainSDK): Promise<Address[]>;
|
|
34
65
|
//#endregion
|
|
35
|
-
export { RestoreMidasIssuanceVaultPause, UnpauseMidasIssuanceVaultProps, unpauseMidasIssuanceVault };
|
|
66
|
+
export { MidasCreditSuite, RestoreMidasIssuanceVaultPause, UnpauseMidasIssuanceVaultProps, discoverMidasCreditSuites, discoverMidasGateways, discoverMidasMTokens, unpauseMidasIssuanceVault };
|
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
import { ILogger } from "../onchain/types/logger.js";
|
|
2
2
|
import "../onchain/index.js";
|
|
3
3
|
import { AnvilClient } from "./createAnvilClient.js";
|
|
4
|
-
import { Address
|
|
4
|
+
import { Address } from "viem";
|
|
5
5
|
//#region src/dev/securitizeUtils.d.ts
|
|
6
6
|
interface ClaimDSTokenProps {
|
|
7
7
|
anvil: AnvilClient;
|
|
8
8
|
investor: Address;
|
|
9
|
-
adminPrivateKey: Hex;
|
|
10
9
|
/**
|
|
11
10
|
* DSToken addresses
|
|
12
11
|
*/
|
|
@@ -24,11 +23,6 @@ type ClaimDSTokensProps = Omit<ClaimDSTokenProps, "token"> & {
|
|
|
24
23
|
};
|
|
25
24
|
interface EnableDSTokenBackDatingProps {
|
|
26
25
|
anvil: AnvilClient;
|
|
27
|
-
/**
|
|
28
|
-
* Securitize DS admin with sufficient trust to call compliance setters
|
|
29
|
-
* (same key used for issueTokens / registerInvestor)
|
|
30
|
-
*/
|
|
31
|
-
adminPrivateKey: Hex;
|
|
32
26
|
/**
|
|
33
27
|
* DSToken addresses whose compliance configuration should allow back-dating
|
|
34
28
|
*/
|
|
@@ -46,8 +40,8 @@ type RestoreDSTokenBackDating = () => Promise<void>;
|
|
|
46
40
|
* honoured: DS protocol silently replaces it with `block.timestamp` otherwise,
|
|
47
41
|
* and freshly minted tokens stay under lock-up.
|
|
48
42
|
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
43
|
+
* Impersonates the DS trust-service admin of each token. Ownable `owner()` of
|
|
44
|
+
* the compliance configuration service alone is not enough.
|
|
51
45
|
*
|
|
52
46
|
* The flag is only read while tokens are issued, so restoring it does not
|
|
53
47
|
* re-lock tokens minted in the meantime.
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { IGearboxError } from "./base.js";
|
|
2
2
|
import { CreditAccountFrozenError, LiquidatorNotEligibleError, NotEmergencyLiquidatorError, creditAccountFrozen, liquidatorNotEligible, notEmergencyLiquidator } from "./liquidation-errors.js";
|
|
3
|
-
import { BorrowLimitCause, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet } from "./operation-errors.js";
|
|
3
|
+
import { AccountNotMidasGreenlistedError, BorrowLimitCause, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, LeverageOutOfRangeError, MarketExpiredError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, ReservePriceLimitedError, accountNotMidasGreenlisted, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, marketExpired, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet } from "./operation-errors.js";
|
|
4
4
|
import { UnpriceableTokenError, unpriceableTokenError } from "./oracle-errors.js";
|
|
5
5
|
import { CreditAccountNotEmptyError, CreditAccountNotFoundError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, UnexpectedFailureError, UnsupportedCollateralTokenError, UnsupportedTokenPairError, WithdrawalInProgressError, creditAccountNotEmpty, creditAccountNotFound, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, unexpectedFailure, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress } from "./prepare-errors.js";
|
|
6
6
|
import { InvalidDelayedIntentError, MalformedTransactionError, PoolOperationPreviewError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedZapperFunctionError, malformedTransaction } from "./preview-errors.js";
|
|
7
|
-
export { BorrowLimitCause, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, IGearboxError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, InvalidDelayedIntentError, LeverageOutOfRangeError, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, PoolOperationPreviewError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, liquidatorNotEligible, malformedTransaction, marketExpired, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, rwaOpenRequirementsNotMet, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress };
|
|
7
|
+
export { AccountNotMidasGreenlistedError, BorrowLimitCause, CreditAccountFrozenError, CreditAccountNotEmptyError, CreditAccountNotFoundError, CreditManagerPausedError, DebtOutOfRangeError, ForbiddenTokenError, IGearboxError, InsufficientAllowanceError, InsufficientBalanceError, InsufficientCollateralError, InsufficientPoolLiquidityError, InvalidDelayedIntentError, LeverageOutOfRangeError, LiquidatorNotEligibleError, MalformedTransactionError, MarketExpiredError, MultipleDelayedWithdrawalsError, NoDelayedRouteError, NoRecordedIntentError, NoStrategyTargetCollateralError, NotEmergencyLiquidatorError, PoolOperationPreviewError, PoolPausedError, PoolSunsetError, QuotaCountExceededError, QuotaLimitReachedError, RWAOpenRequirementsError, ReservePriceLimitedError, UnexpectedFailureError, UnpriceableTokenError, UnsupportedCollateralTokenError, UnsupportedOperationError, UnsupportedPoolFunctionError, UnsupportedTargetError, UnsupportedTokenPairError, UnsupportedZapperFunctionError, WithdrawalInProgressError, accountNotMidasGreenlisted, creditAccountFrozen, creditAccountNotEmpty, creditAccountNotFound, creditManagerPaused, debtOutOfRange, forbiddenToken, insufficientAllowance, insufficientBalance, insufficientCollateral, insufficientPoolLiquidity, leverageOutOfRange, liquidatorNotEligible, malformedTransaction, marketExpired, multipleDelayedWithdrawals, noDelayedRoute, noRecordedIntent, noStrategyTargetCollateral, notEmergencyLiquidator, poolPaused, poolSunset, quotaCountExceeded, quotaLimitReached, reservePriceLimited, rwaOpenRequirementsNotMet, unexpectedFailure, unpriceableTokenError, unsupportedCollateralToken, unsupportedTokenPair, withdrawalInProgress };
|