@gearbox-protocol/sdk 17.0.0-next.3 → 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 +19 -7
- 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 +33 -12
- 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 +12 -10
- package/dist/cjs/onchain/validation/bundles/checkIncreaseDebt.js +28 -0
- 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/checkSimulation.js +1 -1
- package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +1 -1
- package/dist/cjs/onchain/validation/checks/checkDebtLimits.js +2 -5
- 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 +19 -7
- 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 +33 -12
- 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 +12 -10
- 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/checkSimulation.js +1 -1
- package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +1 -1
- package/dist/esm/onchain/validation/checks/checkDebtLimits.js +2 -5
- 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 +65 -11
- 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/credit/types.d.ts +2 -2
- 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 +3 -3
- 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/onchain/validation/bundles/checkDraw.js +0 -28
- 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
|
@@ -7,8 +7,8 @@ import { toTargetDecimals } from "./utils/common.js";
|
|
|
7
7
|
import { createOraclePaths } from "./utils/router-path.js";
|
|
8
8
|
import { planFinishClaimOnly, planFinishCloseAccount, planFinishDecreaseLeverage, planFinishWithdraw } from "./plan.js";
|
|
9
9
|
import { instantOutput } from "./operations.js";
|
|
10
|
-
import { realize } from "./realize.js";
|
|
11
10
|
import { accountView } from "./view.js";
|
|
11
|
+
import { realize } from "./realize.js";
|
|
12
12
|
//#region src/onchain/accounts/intents/tail.ts
|
|
13
13
|
/**
|
|
14
14
|
* The second half of a delayed intent: the claim, then whatever the intent
|
|
@@ -203,6 +203,7 @@ function buildMockSdk(args) {
|
|
|
203
203
|
liquidationThresholds,
|
|
204
204
|
collateralTokens,
|
|
205
205
|
feeInterest: args.feeInterest ?? 0,
|
|
206
|
+
maxEnabledTokens: args.maxEnabledTokens ?? 4,
|
|
206
207
|
maxLeverage: (collateral, targetHF) => calcMaxLeverage(liquidationThresholds.get(collateral) ?? 0, targetHF)
|
|
207
208
|
},
|
|
208
209
|
creditFacade: {
|
|
@@ -2,6 +2,24 @@ import { AddressMap } from "../../../utils/AddressMap.js";
|
|
|
2
2
|
//#region src/onchain/accounts/intents/utils/common.ts
|
|
3
3
|
/** Case-insensitive address equality. */
|
|
4
4
|
const eq = (a, b) => a.toLowerCase() === b.toLowerCase();
|
|
5
|
+
/**
|
|
6
|
+
* The suite and market behind a credit manager, or nothing where the register
|
|
7
|
+
* has no entry for it.
|
|
8
|
+
*
|
|
9
|
+
* For the reads a form calls on every keystroke, including before the SDK has
|
|
10
|
+
* finished attaching: a question the register cannot answer yet is not an
|
|
11
|
+
* error. Everything that prepares a transaction wants the throw instead.
|
|
12
|
+
*/
|
|
13
|
+
function resolveCreditManager(sdk, creditManager) {
|
|
14
|
+
try {
|
|
15
|
+
return {
|
|
16
|
+
suite: sdk.marketRegister.findCreditManager(creditManager),
|
|
17
|
+
market: sdk.marketRegister.findByCreditManager(creditManager)
|
|
18
|
+
};
|
|
19
|
+
} catch {
|
|
20
|
+
return;
|
|
21
|
+
}
|
|
22
|
+
}
|
|
5
23
|
function toTargetDecimals(fromAmount, fromToken, toToken, sdk) {
|
|
6
24
|
const fromDecimals = sdk.tokensMeta.get(fromToken)?.decimals ?? 18;
|
|
7
25
|
const toDecimals = sdk.tokensMeta.get(toToken)?.decimals ?? 18;
|
|
@@ -37,4 +55,4 @@ function toRouterCaSlice(creditAccount, expectedBalances = []) {
|
|
|
37
55
|
};
|
|
38
56
|
}
|
|
39
57
|
//#endregion
|
|
40
|
-
export { eq, toRouterCaSlice, toTargetDecimals };
|
|
58
|
+
export { eq, resolveCreditManager, toRouterCaSlice, toTargetDecimals };
|
|
@@ -26,6 +26,26 @@ function toCreditAccountSlice(ca) {
|
|
|
26
26
|
};
|
|
27
27
|
}
|
|
28
28
|
/**
|
|
29
|
+
* The slice a flow that has no account yet quotes against.
|
|
30
|
+
*
|
|
31
|
+
* Nothing of it exists on chain until the transaction lands, and nothing has
|
|
32
|
+
* to: the pathfinder is asked about the credit manager, and every balance the
|
|
33
|
+
* flow reasons about is one the transaction itself puts there. The zero
|
|
34
|
+
* address stands in for the account so the shape is complete.
|
|
35
|
+
*/
|
|
36
|
+
function unopenedAccountSlice(args) {
|
|
37
|
+
return {
|
|
38
|
+
creditAccount: "0x0000000000000000000000000000000000000000",
|
|
39
|
+
creditManager: args.creditManager.toLowerCase(),
|
|
40
|
+
creditFacade: args.creditFacade.toLowerCase(),
|
|
41
|
+
underlying: args.underlying.toLowerCase(),
|
|
42
|
+
enabledTokensMask: 0n,
|
|
43
|
+
totalDebtUSD: 0n,
|
|
44
|
+
totalDebt: 0n,
|
|
45
|
+
tokens: []
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
29
49
|
* Reads an account by address and narrows it to {@link CreditAccountSlice}.
|
|
30
50
|
*
|
|
31
51
|
* The shared read model's `StrategyPosition` carries neither `tokens` nor
|
|
@@ -40,4 +60,4 @@ async function fetchCreditAccountSlice(sdk, creditAccount) {
|
|
|
40
60
|
return toCreditAccountSlice(data);
|
|
41
61
|
}
|
|
42
62
|
//#endregion
|
|
43
|
-
export { fetchCreditAccountSlice, toCreditAccountSlice };
|
|
63
|
+
export { fetchCreditAccountSlice, toCreditAccountSlice, unopenedAccountSlice };
|
|
@@ -1,11 +1,11 @@
|
|
|
1
|
-
import { eq, toRouterCaSlice, toTargetDecimals } from "./common.js";
|
|
1
|
+
import { eq, resolveCreditManager, toRouterCaSlice, toTargetDecimals } from "./common.js";
|
|
2
2
|
import { isPhantomToken, isRedemptionPhantomToken, pickFattestNonPhantomToken, rankAccountTokens } from "./pick-token.js";
|
|
3
3
|
import { adjustStateToSnapshot } from "./adjust-state-to-snapshot.js";
|
|
4
4
|
import { assembleOperationCalls } from "./assemble-operation-calls.js";
|
|
5
5
|
import { calcBorrowedAmountPlusInterestAndFees } from "./borrowed-amount-plus-interest-and-fees.js";
|
|
6
|
-
import { fetchCreditAccountSlice, toCreditAccountSlice } from "./credit-account-slice.js";
|
|
6
|
+
import { fetchCreditAccountSlice, toCreditAccountSlice, unopenedAccountSlice } from "./credit-account-slice.js";
|
|
7
7
|
import { OperationLedger } from "./ledger.js";
|
|
8
8
|
import { collectPriceImpact, lossRate, startProbe } from "./price-impact.js";
|
|
9
9
|
import { clearedQuotas, getQuotasForUpdate, quotasAfterUpdate } from "./quotas-for-update.js";
|
|
10
10
|
import { createOraclePaths, createRouterPaths } from "./router-path.js";
|
|
11
|
-
export { OperationLedger, adjustStateToSnapshot, assembleOperationCalls, calcBorrowedAmountPlusInterestAndFees, clearedQuotas, collectPriceImpact, createOraclePaths, createRouterPaths, eq, fetchCreditAccountSlice, getQuotasForUpdate, isPhantomToken, isRedemptionPhantomToken, lossRate, pickFattestNonPhantomToken, quotasAfterUpdate, rankAccountTokens, startProbe, toCreditAccountSlice, toRouterCaSlice, toTargetDecimals };
|
|
11
|
+
export { OperationLedger, adjustStateToSnapshot, assembleOperationCalls, calcBorrowedAmountPlusInterestAndFees, clearedQuotas, collectPriceImpact, createOraclePaths, createRouterPaths, eq, fetchCreditAccountSlice, getQuotasForUpdate, isPhantomToken, isRedemptionPhantomToken, lossRate, pickFattestNonPhantomToken, quotasAfterUpdate, rankAccountTokens, resolveCreditManager, startProbe, toCreditAccountSlice, toRouterCaSlice, toTargetDecimals, unopenedAccountSlice };
|
|
@@ -18,12 +18,12 @@ function probeBasket(balances, oracle) {
|
|
|
18
18
|
if (usd > 0n) basketWad += usd * WAD / PRICE_DECIMALS;
|
|
19
19
|
}
|
|
20
20
|
if (basketWad <= 0n) return;
|
|
21
|
-
const probeWad = PROBE_UNIT_USD_WAD;
|
|
22
21
|
const scaled = balances.map((asset) => ({
|
|
23
22
|
token: asset.token,
|
|
24
|
-
balance: asset.balance *
|
|
23
|
+
balance: asset.balance * PROBE_UNIT_USD_WAD / basketWad
|
|
25
24
|
}));
|
|
26
|
-
|
|
25
|
+
const probeWad = scaled.reduce((sum, a) => sum + oracle.safeConvertToUSD(a.token, a.balance).value * WAD / PRICE_DECIMALS, 0n);
|
|
26
|
+
if (probeWad <= 0n) return;
|
|
27
27
|
return {
|
|
28
28
|
balances: scaled,
|
|
29
29
|
basketWad,
|
|
@@ -85,12 +85,15 @@ async function collectPriceImpact(probes, ctx) {
|
|
|
85
85
|
lossUnd += loss;
|
|
86
86
|
}
|
|
87
87
|
if (expectedUnd <= 0n) return;
|
|
88
|
-
return
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
88
|
+
return {
|
|
89
|
+
...lossRate({
|
|
90
|
+
lossUnd,
|
|
91
|
+
expectedUnd,
|
|
92
|
+
totalValue: ctx.totalValue,
|
|
93
|
+
netValue: ctx.netValue
|
|
94
|
+
}),
|
|
95
|
+
absolutePriceImpact: ctx.toUnderlyingAmount(-lossUnd)
|
|
96
|
+
};
|
|
94
97
|
}
|
|
95
98
|
//#endregion
|
|
96
99
|
export { collectPriceImpact, lossRate, startProbe };
|
|
@@ -2,11 +2,8 @@ import { toRouterCaSlice } from "./common.js";
|
|
|
2
2
|
import { startProbe } from "./price-impact.js";
|
|
3
3
|
//#region src/onchain/accounts/intents/utils/router-path.ts
|
|
4
4
|
/**
|
|
5
|
-
* The engine's only door to the pathfinder
|
|
6
|
-
*
|
|
7
|
-
* Deliberately not a quoter abstraction with an oracle-priced twin: paths are
|
|
8
|
-
* always resolved on-chain, because a preview whose swap amounts came from
|
|
9
|
-
* oracle prices could not produce the calldata that realises them.
|
|
5
|
+
* The engine's only door to the pathfinder, and the only quoter whose legs can
|
|
6
|
+
* be sent. {@link createOraclePaths} is the twin for a walk that only projects.
|
|
10
7
|
*/
|
|
11
8
|
function createRouterPaths(args) {
|
|
12
9
|
const { sdk, creditAccount, slippage } = args;
|
|
@@ -91,6 +88,7 @@ function createRouterPaths(args) {
|
|
|
91
88
|
amount,
|
|
92
89
|
keep
|
|
93
90
|
});
|
|
91
|
+
if (leg.calls.length === 0) throw new Error("swap: missing router calls");
|
|
94
92
|
return {
|
|
95
93
|
...leg,
|
|
96
94
|
probe: probe && {
|
|
@@ -107,6 +105,7 @@ function createRouterPaths(args) {
|
|
|
107
105
|
route: async (quoted) => (await quoteClose(quoted)).amount
|
|
108
106
|
});
|
|
109
107
|
const { amount, minAmount, calls } = await quoteClose(balances);
|
|
108
|
+
if (calls.length === 0 && minAmount > 0n) throw new Error("closeAll: missing router calls");
|
|
110
109
|
const leg = {
|
|
111
110
|
amount,
|
|
112
111
|
minAmount,
|
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { BigIntMath } from "../../utils/bigint-math.js";
|
|
2
|
+
import "../../utils/index.js";
|
|
3
|
+
import { MIN_HEALTH_FACTOR_FACADE } from "../../validation/helpers/health-factor-limits.js";
|
|
4
|
+
import "../../validation/index.js";
|
|
5
|
+
import { eq } from "./utils/common.js";
|
|
6
|
+
import { maxProportionalWithdrawal } from "./math.js";
|
|
7
|
+
import { collateralValuation } from "./collateral-valuation.js";
|
|
8
|
+
import { accountView } from "./view.js";
|
|
9
|
+
//#region src/onchain/accounts/intents/withdraw-limits.ts
|
|
10
|
+
/**
|
|
11
|
+
* Every limit a `WITHDRAW` answers to, in underlying units.
|
|
12
|
+
*
|
|
13
|
+
* The one place they are assembled, so the figure a form is offered and the
|
|
14
|
+
* figure the collateral guard names when it turns a withdrawal down cannot
|
|
15
|
+
* drift apart: `CreditAccountOperationsService` reports this, and the guard
|
|
16
|
+
* quotes it back.
|
|
17
|
+
*
|
|
18
|
+
* @param props - Account slice, the SDK holding its market, and optionally the
|
|
19
|
+
* collateral the withdrawal would be funded from
|
|
20
|
+
* @returns The three limits, see {@link WithdrawCeilings}
|
|
21
|
+
**/
|
|
22
|
+
function withdrawLimits(props) {
|
|
23
|
+
const { creditAccount, sdk } = props;
|
|
24
|
+
const view = accountView(creditAccount, sdk);
|
|
25
|
+
const partial = maxProportionalWithdrawal(view, view.debtLimits);
|
|
26
|
+
const safe = maxSafeWithdrawal({
|
|
27
|
+
...props,
|
|
28
|
+
targetHF: BigInt(MIN_HEALTH_FACTOR_FACADE)
|
|
29
|
+
});
|
|
30
|
+
return {
|
|
31
|
+
partial,
|
|
32
|
+
safePartial: BigIntMath.min(partial, safe),
|
|
33
|
+
exit: view.collateral > 0n ? view.collateral : 0n
|
|
34
|
+
};
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Largest proportional withdrawal the safe-price collateral check still clears,
|
|
38
|
+
* in underlying units.
|
|
39
|
+
*
|
|
40
|
+
* A withdrawal hands funds over, so the facade weighs the account it leaves
|
|
41
|
+
* behind at safe prices rather than main ones — see {@link collateralValuation}.
|
|
42
|
+
* That is a second limit on top of the facade's `debtLimits`, and the two are
|
|
43
|
+
* independent: a caller wanting the amount a form may actually offer takes the
|
|
44
|
+
* lesser of this and `maxProportionalWithdrawal`.
|
|
45
|
+
*
|
|
46
|
+
* The arithmetic is the check solved for the amount. Taking `W` out at fixed
|
|
47
|
+
* leverage repays `dD = D·W/C`, so `W·TVL/C` of value is sold out of the source
|
|
48
|
+
* token; each dollar of that sale costs the check the source's threshold times
|
|
49
|
+
* its safe-to-main price ratio, while the repayment relieves `targetHF` per
|
|
50
|
+
* dollar of debt. Both terms are linear in `W`, which is why one division
|
|
51
|
+
* answers instead of a search — and why the answer is exact rather than a
|
|
52
|
+
* bound, as long as the plan really does fund itself from `sourceToken`.
|
|
53
|
+
*
|
|
54
|
+
* Two consequences worth stating, because they surprise:
|
|
55
|
+
*
|
|
56
|
+
* - An account whose collateral is entirely a token the reserve feed marks
|
|
57
|
+
* down cannot withdraw at all once it is under the threshold. A proportional
|
|
58
|
+
* withdrawal scales collateral and debt together, so it leaves the safe-price
|
|
59
|
+
* factor exactly where it found it — no amount climbs back over.
|
|
60
|
+
* - Leaving entirely is never refused for this reason: the exit settles the
|
|
61
|
+
* debt instead of shrinking it, and a check with no debt to divide by has
|
|
62
|
+
* nothing to refuse.
|
|
63
|
+
*
|
|
64
|
+
* @returns Amount in underlying units. The account's net value when safe prices
|
|
65
|
+
* do not limit the withdrawal at all, so the caller's `min` is a no-op; `0n`
|
|
66
|
+
* when the account already sits below `targetHF` at safe prices, and only the
|
|
67
|
+
* exit is left
|
|
68
|
+
**/
|
|
69
|
+
function maxSafeWithdrawal(props) {
|
|
70
|
+
const { creditAccount, sdk, targetHF } = props;
|
|
71
|
+
const view = accountView(creditAccount, sdk);
|
|
72
|
+
if (view.collateral <= 0n) return 0n;
|
|
73
|
+
if (view.debt === 0n) return view.collateral;
|
|
74
|
+
const valuation = collateralValuation(creditAccount, sdk);
|
|
75
|
+
const source = props.sourceToken ?? view.fattest();
|
|
76
|
+
const holding = source === void 0 ? void 0 : creditAccount.tokens.find((t) => eq(t.token, source));
|
|
77
|
+
if (!holding) return view.collateral;
|
|
78
|
+
let total = 0n;
|
|
79
|
+
for (const t of creditAccount.tokens) if (valuation.counts(t)) total += valuation.weigh(t);
|
|
80
|
+
const debtUsd = valuation.mainUsd(valuation.underlying, view.debt);
|
|
81
|
+
if (debtUsd === void 0 || debtUsd <= 0n) return view.collateral;
|
|
82
|
+
const slack = total - debtUsd * targetHF;
|
|
83
|
+
if (slack < 0n) return 0n;
|
|
84
|
+
const sourceMainUsd = valuation.mainUsd(holding.token, holding.balance);
|
|
85
|
+
if (sourceMainUsd === void 0 || sourceMainUsd <= 0n) return view.collateral;
|
|
86
|
+
const sourceRate = valuation.lt(holding.token) * valuation.checkedUsd(holding);
|
|
87
|
+
const tvlUsd = valuation.mainUsd(valuation.underlying, view.collateral + view.debt);
|
|
88
|
+
if (tvlUsd === void 0) return view.collateral;
|
|
89
|
+
const drain = sourceRate * tvlUsd - targetHF * debtUsd * sourceMainUsd;
|
|
90
|
+
if (drain <= 0n) return view.collateral;
|
|
91
|
+
const limit = view.collateral * slack * sourceMainUsd / drain;
|
|
92
|
+
return limit < view.collateral ? limit : view.collateral;
|
|
93
|
+
}
|
|
94
|
+
//#endregion
|
|
95
|
+
export { maxSafeWithdrawal, withdrawLimits };
|
|
@@ -9,9 +9,9 @@ import "../../utils/index.js";
|
|
|
9
9
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
10
10
|
import "../../base/index.js";
|
|
11
11
|
import { usdToNumber } from "../../market/math.js";
|
|
12
|
+
import { RWA_LIQUIDATOR_MIDAS } from "../../market/rwa/midas/constants.js";
|
|
12
13
|
import { matchesLiquidatableAccountFilter } from "../../../model/liquidations.js";
|
|
13
14
|
import "../../../model/index.js";
|
|
14
|
-
import { RWA_LIQUIDATOR_MIDAS } from "../../market/rwa/midas/constants.js";
|
|
15
15
|
import { RWA_LIQUIDATOR_SECURITIZE } from "../../market/rwa/securitize/constants.js";
|
|
16
16
|
import { dominantCollateral } from "../../market/credit/collateralUtils.js";
|
|
17
17
|
import { MidasLiquidatorContract } from "../../market/rwa/midas/MidasLiquidatorContract.js";
|
|
@@ -32,7 +32,6 @@ const AP_WETH_GATEWAY = "WETH_GATEWAY";
|
|
|
32
32
|
const AP_WETH_TOKEN = "WETH_TOKEN";
|
|
33
33
|
const AP_ZAPPER_REGISTER = "ZAPPER_REGISTER";
|
|
34
34
|
const AP_ZERO_PRICE_FEED = "ZERO_PRICE_FEED";
|
|
35
|
-
const AP_RWA_COMPRESSOR = "GLOBAL::RWA_COMPRESSOR";
|
|
36
35
|
const AP_REDEMPTION_LOGGER = "LOCAL::REDEMPTION_LOGGER";
|
|
37
36
|
/**
|
|
38
37
|
* Default address provider address for v3.1.0
|
|
@@ -40,4 +39,4 @@ const AP_REDEMPTION_LOGGER = "LOCAL::REDEMPTION_LOGGER";
|
|
|
40
39
|
*/
|
|
41
40
|
const ADDRESS_PROVIDER_V310 = "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38";
|
|
42
41
|
//#endregion
|
|
43
|
-
export { ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER,
|
|
42
|
+
export { ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, NO_VERSION };
|
|
@@ -1,8 +1,8 @@
|
|
|
1
|
-
import { ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER,
|
|
1
|
+
import { ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, NO_VERSION } from "./address-provider.js";
|
|
2
2
|
import { ADDRESS_0X0, MULTICALL_ADDRESS, NATIVE_ADDRESS, NOT_DEPLOYED } from "./addresses.js";
|
|
3
3
|
import { BotPermissions, botPermissionsToString } from "./bot-permissions.js";
|
|
4
4
|
import { DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, WAD, WAD_DECIMALS_POW, halfRAY, isZeroBalance } from "./math.js";
|
|
5
5
|
import { BLOCKS_PER_WEEK_BY_NETWORK, RAMP_DURATION_BY_NETWORK } from "./networks.js";
|
|
6
6
|
import { PERIPHERY_CONTRACTS } from "./periphery.js";
|
|
7
7
|
import { VERSION_RANGE_310, isV310, isVersionRange } from "./versions.js";
|
|
8
|
-
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER,
|
|
8
|
+
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, BLOCKS_PER_WEEK_BY_NETWORK, BotPermissions, DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, MULTICALL_ADDRESS, NATIVE_ADDRESS, NOT_DEPLOYED, NO_VERSION, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, VERSION_RANGE_310, WAD, WAD_DECIMALS_POW, botPermissionsToString, halfRAY, isV310, isVersionRange, isZeroBalance };
|
|
@@ -1,14 +1,11 @@
|
|
|
1
1
|
import { iVersionAbi } from "../../abi/iVersion.js";
|
|
2
|
-
import
|
|
2
|
+
import "../constants/address-provider.js";
|
|
3
3
|
import { isV310 } from "../constants/versions.js";
|
|
4
4
|
import "../constants/index.js";
|
|
5
5
|
import { hexEq } from "../utils/hex.js";
|
|
6
6
|
import { AddressProviderV310Contract } from "./AddressProviderV310Contract.js";
|
|
7
7
|
//#region src/onchain/core/createAddressProvider.ts
|
|
8
|
-
const OVERRIDE_ADDRESSES = {
|
|
9
|
-
[AP_PRICE_FEED_COMPRESSOR]: { 311: "0x1fA2637B9fab0CD14290A7EE908DDc9688a15120" },
|
|
10
|
-
[AP_MARKET_COMPRESSOR]: { 311: "0x0C27F242f6e9F2A9AD3261bE6e439De3B948bcA2" }
|
|
11
|
-
} };
|
|
8
|
+
const OVERRIDE_ADDRESSES = {};
|
|
12
9
|
async function createAddressProvider(sdk, address) {
|
|
13
10
|
let v;
|
|
14
11
|
if (hexEq(address, "0xF7f0a609BfAb9a0A98786951ef10e5FE26cC1E38")) v = 310n;
|
|
@@ -11,7 +11,7 @@ import { NetworkType, SUPPORTED_NETWORKS, chains, findCuratorMarketConfigurator,
|
|
|
11
11
|
import { detectNetwork } from "./chain/detectNetwork.js";
|
|
12
12
|
import "./chain/index.js";
|
|
13
13
|
import { etherscanApiUrl, etherscanUrl } from "./utils/etherscan.js";
|
|
14
|
-
import { ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER,
|
|
14
|
+
import { ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, NO_VERSION } from "./constants/address-provider.js";
|
|
15
15
|
import { ADDRESS_0X0, MULTICALL_ADDRESS, NATIVE_ADDRESS, NOT_DEPLOYED } from "./constants/addresses.js";
|
|
16
16
|
import { BotPermissions, botPermissionsToString } from "./constants/bot-permissions.js";
|
|
17
17
|
import { DUST_THRESHOLD, LEVERAGE_DECIMALS, MAX_INT, MAX_UINT16, MAX_UINT256, MIN_INT96, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PRICE_DECIMALS, PRICE_DECIMALS_POW, RAY, RAY_DECIMALS_POW, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, WAD, WAD_DECIMALS_POW, halfRAY, isZeroBalance } from "./constants/math.js";
|
|
@@ -149,29 +149,34 @@ import { estimateRawTxGas, sendRawTx } from "./utils/viem/sendRawTx.js";
|
|
|
149
149
|
import { watchBlocksAsync } from "./utils/viem/watchBlocksAsync.js";
|
|
150
150
|
import "./utils/viem/index.js";
|
|
151
151
|
import { collateralPriceInUnderlying } from "./market/oracle/collateralPriceInUnderlying.js";
|
|
152
|
-
import { isUpdatablePriceFeed } from "./market/pricefeeds/isUpdatablePriceFeed.js";
|
|
153
152
|
import { PriceFeedRef } from "./market/pricefeeds/PriceFeedRef.js";
|
|
154
153
|
import { AbstractPriceFeedContract, PartialPriceFeedInitError } from "./market/pricefeeds/AbstractPriceFeed.js";
|
|
155
154
|
import { AbstractLPPriceFeedContract, isLPPriceFeed } from "./market/pricefeeds/AbstractLPPriceFeed.js";
|
|
156
|
-
import { BalancerStablePriceFeedContract } from "./market/pricefeeds/BalancerStablePriceFeed.js";
|
|
157
|
-
import { BalancerWeightedPriceFeedContract } from "./market/pricefeeds/BalancerWeightedPriceFeed.js";
|
|
158
|
-
import { BoundedPriceFeedContract } from "./market/pricefeeds/BoundedPriceFeed.js";
|
|
159
|
-
import { CompositePriceFeedContract } from "./market/pricefeeds/CompositePriceFeed.js";
|
|
160
|
-
import {
|
|
161
|
-
import {
|
|
162
|
-
import {
|
|
163
|
-
import {
|
|
164
|
-
import {
|
|
165
|
-
import {
|
|
166
|
-
import { MellowLRTPriceFeedContract } from "./market/pricefeeds/MellowLRTPriceFeed.js";
|
|
167
|
-
import { PendleTWAPPTPriceFeed } from "./market/pricefeeds/PendleTWAPPTPriceFeed.js";
|
|
168
|
-
import { PythPriceFeed } from "./market/pricefeeds/PythPriceFeed.js";
|
|
169
|
-
import { RedstonePriceFeedContract } from "./market/pricefeeds/RedstonePriceFeed.js";
|
|
155
|
+
import { BalancerStablePriceFeedContract } from "./market/pricefeeds/feeds/BalancerStablePriceFeed.js";
|
|
156
|
+
import { BalancerWeightedPriceFeedContract } from "./market/pricefeeds/feeds/BalancerWeightedPriceFeed.js";
|
|
157
|
+
import { BoundedPriceFeedContract } from "./market/pricefeeds/feeds/BoundedPriceFeed.js";
|
|
158
|
+
import { CompositePriceFeedContract } from "./market/pricefeeds/feeds/CompositePriceFeed.js";
|
|
159
|
+
import { ConstantPriceFeedContract } from "./market/pricefeeds/feeds/ConstantPriceFeed.js";
|
|
160
|
+
import { CurveCryptoPriceFeedContract } from "./market/pricefeeds/feeds/CurveCryptoPriceFeed.js";
|
|
161
|
+
import { CurveStablePriceFeedContract } from "./market/pricefeeds/feeds/CurveStablePriceFeed.js";
|
|
162
|
+
import { CurveUSDPriceFeedContract } from "./market/pricefeeds/feeds/CurveUSDPriceFeed.js";
|
|
163
|
+
import { Erc4626PriceFeedContract } from "./market/pricefeeds/feeds/Erc4626PriceFeed.js";
|
|
164
|
+
import { ExternalPriceFeedContract } from "./market/pricefeeds/feeds/ExternalPriceFeed.js";
|
|
165
|
+
import { MellowLRTPriceFeedContract } from "./market/pricefeeds/feeds/MellowLRTPriceFeed.js";
|
|
166
|
+
import { PendleTWAPPTPriceFeed } from "./market/pricefeeds/feeds/PendleTWAPPTPriceFeed.js";
|
|
167
|
+
import { PythPriceFeed } from "./market/pricefeeds/feeds/PythPriceFeed.js";
|
|
168
|
+
import { RedstonePriceFeedContract } from "./market/pricefeeds/feeds/RedstonePriceFeed.js";
|
|
169
|
+
import { WstETHPriceFeedContract } from "./market/pricefeeds/feeds/WstETHPriceFeed.js";
|
|
170
|
+
import { YearnPriceFeedContract } from "./market/pricefeeds/feeds/YearnPriceFeed.js";
|
|
171
|
+
import { ZeroPriceFeedContract } from "./market/pricefeeds/feeds/ZeroPriceFeed.js";
|
|
172
|
+
import { PriceFeedRegistry } from "./market/pricefeeds/PriceFeedRegistry.js";
|
|
170
173
|
import { fetchRedstonePayloads } from "./market/pricefeeds/updates/fetchRedstonePayloads.js";
|
|
171
|
-
import {
|
|
172
|
-
import {
|
|
173
|
-
import {
|
|
174
|
-
import {
|
|
174
|
+
import { getRawPriceUpdates } from "./market/pricefeeds/updates/getRawPriceUpdates.js";
|
|
175
|
+
import { isUpdatablePriceFeed } from "./market/pricefeeds/updates/isUpdatablePriceFeed.js";
|
|
176
|
+
import { PriceUpdatesCache } from "./market/pricefeeds/updates/PriceUpdatesCache.js";
|
|
177
|
+
import { RedstoneOptions, RedstoneUpdater } from "./market/pricefeeds/updates/RedstoneUpdater.js";
|
|
178
|
+
import { updatableDependencies } from "./market/pricefeeds/updates/updatableDependencies.js";
|
|
179
|
+
import { UpdatablePriceFeedRegistry } from "./market/pricefeeds/updates/UpdatablePriceFeedRegistry.js";
|
|
175
180
|
import { PriceOracleV310Contract } from "./market/oracle/PriceOracleV310Contract.js";
|
|
176
181
|
import { createPriceOracle } from "./market/oracle/createPriceOracle.js";
|
|
177
182
|
import { GaugeContract } from "./market/pool/GaugeContract.js";
|
|
@@ -188,7 +193,7 @@ import { MidasLiquidatorContract } from "./market/rwa/midas/MidasLiquidatorContr
|
|
|
188
193
|
import { SecuritizeDegenNFT } from "./market/rwa/securitize/SecuritizeDegenNFT.js";
|
|
189
194
|
import { SecuritizeLiquidatorContract } from "./market/rwa/securitize/SecuritizeLiquidatorContract.js";
|
|
190
195
|
import { SecuritizeRWAFactory } from "./market/rwa/securitize/SecuritizeRWAFactory.js";
|
|
191
|
-
import { RWARegistry } from "./market/rwa/RWARegistry.js";
|
|
196
|
+
import { RWARegistry, RWA_COMPRESSOR_ADDRESS } from "./market/rwa/RWARegistry.js";
|
|
192
197
|
import { isRWAFactory } from "./market/rwa/types.js";
|
|
193
198
|
import "./market/index.js";
|
|
194
199
|
import { CreditAccountCompressorV310Contract } from "./accounts/credit-account-compressor/CreditAccountCompressorV310Contract.js";
|
|
@@ -212,15 +217,17 @@ import { checkPoolPaused } from "./validation/checks/checkPoolPaused.js";
|
|
|
212
217
|
import { checkPoolSunset } from "./validation/checks/checkPoolSunset.js";
|
|
213
218
|
import { checkQuotaCount } from "./validation/checks/checkQuotaCount.js";
|
|
214
219
|
import { checkQuotaLimit } from "./validation/checks/checkQuotaLimit.js";
|
|
220
|
+
import { checkReservePriceLimited } from "./validation/checks/checkReservePriceLimited.js";
|
|
215
221
|
import { checkAccountQuotas } from "./validation/bundles/checkAccountQuotas.js";
|
|
216
222
|
import { checkWalletAllowance } from "./validation/bundles/checkWalletAllowance.js";
|
|
217
223
|
import { checkWalletBalance } from "./validation/bundles/checkWalletBalance.js";
|
|
218
224
|
import { checkCollateralFunding } from "./validation/bundles/checkCollateralFunding.js";
|
|
219
|
-
import { checkDraw } from "./validation/bundles/checkDraw.js";
|
|
220
225
|
import { checkHealthFactors } from "./validation/bundles/checkHealthFactors.js";
|
|
226
|
+
import { checkIncreaseDebt } from "./validation/bundles/checkIncreaseDebt.js";
|
|
227
|
+
import { checkIncreaseQuota } from "./validation/bundles/checkIncreaseQuota.js";
|
|
221
228
|
import { checkMarket } from "./validation/bundles/checkMarket.js";
|
|
222
229
|
import { checkObtained } from "./validation/bundles/checkObtained.js";
|
|
223
|
-
import {
|
|
230
|
+
import { checkMidasAccountGreenlist } from "./validation/bundles/checkMidasAccountGreenlist.js";
|
|
224
231
|
import { checkRWAOpenRequirements } from "./validation/bundles/checkRWAOpenRequirements.js";
|
|
225
232
|
import { checkRWAOpening } from "./validation/bundles/checkRWAOpening.js";
|
|
226
233
|
import { checkCreditOperation } from "./validation/bundles/checkCreditOperation.js";
|
|
@@ -291,6 +298,7 @@ import { classifyCloseOrRepay, isCloseOrRepay } from "./preview/preview/detectCl
|
|
|
291
298
|
import { detectDelayedClaim, resolveDelayedClaimIntent } from "./preview/preview/detectDelayedClaim.js";
|
|
292
299
|
import { detectDelayedOperation } from "./preview/preview/detectDelayedOperation.js";
|
|
293
300
|
import { estimateClaimableAt } from "./preview/preview/estimateClaimableAt.js";
|
|
301
|
+
import { midasGreenlistsAccount } from "./preview/preview/midasGreenlistsAccount.js";
|
|
294
302
|
import { previewAdjustStrategyPosition } from "./preview/preview/previewAdjustStrategyPosition.js";
|
|
295
303
|
import { previewExitOrRepayStrategyPosition } from "./preview/preview/previewExitOrRepayStrategyPosition.js";
|
|
296
304
|
import { makeReplayState, replayInnerOperations } from "./preview/preview/replayInnerOperations.js";
|
|
@@ -298,4 +306,4 @@ import { replayMulticall } from "./preview/preview/replayMulticall.js";
|
|
|
298
306
|
import { previewOperation } from "./preview/preview/previewOperation.js";
|
|
299
307
|
import "./preview/index.js";
|
|
300
308
|
import "./types/index.js";
|
|
301
|
-
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_RWA_COMPRESSOR, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegister, PriceOracleV310Contract, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstonePriceFeedContract, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkDraw, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkQuotasAsked, checkRWAOpenRequirements, checkRWAOpening, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, usdToNumber, watchBlocksAsync };
|
|
309
|
+
export { ADDRESS_0X0, ADDRESS_PROVIDER_V310, AP_ACCOUNT_FACTORY, AP_ACL, AP_BOT_LIST, AP_BYTECODE_REPOSITORY, AP_CONTRACTS_REGISTER, AP_CONTROLLER_TIMELOCK, AP_CREDIT_ACCOUNT_COMPRESSOR, AP_CREDIT_SUITE_COMPRESSOR, AP_DATA_COMPRESSOR, AP_DELEVERAGE_BOT_HV, AP_DELEVERAGE_BOT_LV, AP_DELEVERAGE_BOT_PEGGED, AP_GAUGE_COMPRESSOR, AP_GEAR_STAKING, AP_GEAR_TOKEN, AP_INFLATION_ATTACK_BLOCKER, AP_INSOLVENCY_CHECKER, AP_MARKET_COMPRESSOR, AP_MARKET_CONFIGURATOR, AP_PARTIAL_LIQUIDATION_BOT, AP_PERIPHERY_COMPRESSOR, AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE, AP_PRICE_ORACLE, AP_REDEMPTION_LOGGER, AP_REWARDS_COMPRESSOR, AP_ROUTER, AP_TOKEN_COMPRESSOR, AP_TREASURY, AP_WETH_GATEWAY, AP_WETH_TOKEN, AP_ZAPPER_REGISTER, AP_ZERO_PRICE_FEED, AbstractAdapterContract, AbstractLPPriceFeedContract, AbstractPriceFeedContract, AbstractWithdrawalCompressorContract, AccountBotsService, AccountMigratorAdapterContract, AdapterType, AddressMap, AddressProviderV310Contract, AddressSet, AssetsMap, BLOCKS_PER_WEEK_BY_NETWORK, BalancerStablePriceFeedContract, BalancerV3PoolStatus, BalancerV3RouterAdapterContract, BalancerV3WrapperAdapterContract, BalancerWeightedPriceFeedContract, BaseContract, BasePlugin, BigIntMath, BotPermissions, BoundedPriceFeedContract, CamelotV3AdapterContract, ChainContractsRegister, ChainNotConfiguredError, CompositePriceFeedContract, ConstantPriceFeedContract, Construct, ContractParseError, ConvexV1BaseRewardPoolAdapterContract, ConvexV1BoosterAdapterContract, CreditAccountCompressor, CreditAccountCompressorV310Contract, CreditAccountOperationsService, CreditAccountState, CreditAccountsServiceV310, CreditConfiguratorV310Contract, CreditFacadeV310BaseContract, CreditFacadeV310Contract, CreditManagerV310Contract, CreditSuite, Curve2AssetsAdapterContract, Curve3AssetsAdapterContract, Curve4AssetsAdapterContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, CurveV1AdapterStETHContract, CurveV1StableNGAdapterContract, DEFAULT_QUOTA_BUFFER_BPS, DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, DELAYED_INTENT_TYPES, DELAYED_INTENT_VERSION, DUST_THRESHOLD, DaiUsdsAdapterContract, ERC4626AdapterContract, ERC4626ReferralAdapterContract, EXECUTE_BYTES_SELECTOR, Erc4626PriceFeedContract, ExternalPriceFeedContract, FluidDexAdapterContract, GaugeContract, IERC20ZapperContract, IETHZapperContract, InfinifiGatewayAdapterContract, InfinifiUnwindingGatewayAdapterContract, KelpLRTDepositPoolAdapterContract, KelpLRTWithdrawalManagerAdapterContract, LEVERAGE_DECIMALS, LIQUIDATION_APPROVAL_BUFFER, LIQUIDATION_COMPRESSOR_V313_ADDRESS, LidoV1AdapterContract, LinearInterestRateModelContract, LiquidationsService, MAX_INT, MAX_LEVERAGE_BUFFER_BPS, MAX_UINT16, MAX_UINT256, MIN_HEALTH_FACTOR_FACADE, MIN_HEALTH_FACTOR_FORM, MIN_HF_LIMITED, MIN_INT96, MIN_SAFE_HEALTH_FACTOR_FORM, MULTICALL_ADDRESS, MarketRegister, MarketSuite, MellowClaimerAdapterContract, MellowDVVAdapterContract, MellowERC4626VaultAdapterContract, MellowLRTPriceFeedContract, MellowWrapperAdapterContract, MidasDegenNFT, MidasGatewayAdapterContract, MidasIssuanceVaultAdapterContract, MidasLiquidatorContract, MidasRedemptionVaultAdapterContract, MissingSerializedParamsError, MultichainConstruct, MultichainLiquidationsService, MultichainOpportunitiesService, MultichainPositionsService, MultichainSDK, NATIVE_ADDRESS, NON_STRATEGY_PHANTOM_TOKEN_TYPES, NOT_DEPLOYED, NO_VERSION, NetworkType, OnchainSDK, OpportunitiesService, PARTIAL_LIQUIDATION_BUFFER_BPS, PERCENTAGE_DECIMALS, PERCENTAGE_FACTOR, PERCENTAGE_FACTOR_1KK, PERIPHERY_CONTRACTS, PHANTOM_TOKEN_CONTRACT_TYPES, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, PRICE_DECIMALS, PRICE_DECIMALS_POW, PartialPriceFeedInitError, PendlePairStatus, PendleRouterAdapterContract, PendleTWAPPTPriceFeed, PendleTokenType, PeripheryCompressorV310Contract, PluginStateVersionError, PoolService, PoolSuite, PoolV310Contract, PositionsService, PriceFeedRef, PriceFeedRegistry, PriceOracleV310Contract, PriceUpdatesCache, PythPriceFeed, RAMP_DURATION_BY_NETWORK, RAY, RAY_DECIMALS_POW, RWARegistry, RWA_COMPRESSOR_ADDRESS, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND, RedemptionLoggerV310Contract, RedstoneOptions, RedstonePriceFeedContract, RedstoneUpdater, RouterV310Contract, SDKConstruct, SECONDS_PER_YEAR, SLIPPAGE_DECIMALS, STATE_VERSION, SUPPORTED_NETWORKS, SdkAlreadyAttachedError, SdkChainMismatchError, SdkMissingChainStateError, SdkNotAttachedError, SdkRWADataNotLoadedError, SdkStateVersionMismatchError, SdkSyncFailedError, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeOnRampAdapterContract, SecuritizeRWAFactory, SecuritizeRedemptionGatewayAdapterContract, SimulateWithPriceUpdatesError, SimulationError, StakingRewardsAdapterContract, TokensMeta, TraderJoePoolVersion, TraderJoeRouterAdapterContract, TypedObjectUtils, UniswapV2AdapterContract, UniswapV3AdapterContract, UniswapV4AdapterContract, UpdatablePriceFeedRegistry, UpshiftVaultAdapterContract, VERSION_RANGE_310, VelodromeV2RouterAdapterContract, VotingContractStatus, WAD, WAD_DECIMALS_POW, WithdrawalCompressorV310Contract, WithdrawalCompressorV311Contract, WithdrawalCompressorV313Contract, WstETHPriceFeedContract, WstETHV1AdapterContract, YearnPriceFeedContract, ZapperContract, ZeroPriceFeedContract, ZodAddress, ZodBigInt, ZodHex, accountSnapshotFromCreditAccountData, adapterActionAbi, adapterActionSelectors, adapterActionSignatures, adapterConstructorAbi, allTransfersAsTokenAmounts, amountOf, assetsMap, attachOptionsSchema, botPermissionsToString, bpsToRay, buildDelayedStrategyPositionOperationPreview, bytes32ToString, calcBorrowApy, calcBorrowRate, calcDefaultQuota, calcEffectiveBorrowApy, calcHealthFactor, calcLiquidationPrice, calcLiquidationPriceForTarget, calcMaxLeverage, calcNetStrategyApy, calcPositionLeverage, calcQuotaRate, calcQuotaUpdate, calcRecommendedQuota, calcTimeToLiquidationMs, calcUtilization, calcUtilizationRaw, chains, checkAccountQuotas, checkBorrowLimit, checkCollateralFunding, checkCollateralised, checkCreditAccountFrozen, checkCreditManagerPaused, checkCreditOperation, checkDebtLimits, checkEmergencyLiquidator, checkForbiddenToken, checkHealthFactors, checkIncreaseDebt, checkIncreaseQuota, checkLeverage, checkLiquidation, checkLiquidationEligibility, checkLiquidationFunding, checkLiquidatorEligible, checkMarket, checkMarketExpired, checkMidasAccountGreenlist, checkObtained, checkOperation, checkPoolFunding, checkPoolLiquidity, checkPoolOperation, checkPoolPaused, checkPoolSunset, checkQuotaCount, checkQuotaLimit, checkRWAOpenRequirements, checkRWAOpening, checkReservePriceLimited, checkSimulation, checkWallet, checkWalletAllowance, checkWalletBalance, childLogger, classifyCloseOrRepay, classifyCurveOperation, classifyInnerOperations, collateralPriceInUnderlying, collectTraces, createAdapter, createAddressProvider, createPriceOracle, createRawTx, createRedemptionLogger, createRouter, createWithdrawalCompressor, createZapper, abi as creditFacadeV310Abi, curveAddLiquidityFromTransfers, curveRemoveLiquidityFromTransfers, decodeDelayedIntent, detectDelayedClaim, detectDelayedOperation, detectNetwork, dominantCollateral, encodeDelayedIntent, erc4626ReferralAdapterAbi, estimateClaimableAt, estimateRawTxGas, etherscanApiUrl, etherscanUrl, executeDelegatedMulticalls, executeMulticallBatches, expectedBalanceDeltas, fetchCreditAccountSlice, fetchRedstonePayloads, filterDust, filterDustUSD, findCallTo, findCallWithInput, findCuratorMarketConfigurator, findExecuteBytes, fmtBinaryMask, fnSigToName, formatBN, formatBNvalue, formatDuration, formatLeverage, formatNumberToString_, formatPercentage, formatTimestamp, functionArgsToMap, functionArgsToRecord, generateCastTraceCall, getAccountTargetCollateral, getAdapterActionAbi, getAdapterDeployParamsAbi, getAdapterType, getAssetType, getCastTraceArgs, getChain, getCuratorName, getFunctionSignature, getLegacyStrategyTarget, getNetworkType, getRawPriceUpdates, getSimulateWithPriceUpdatesError, getWithdrawalCompressorAddress, halfRAY, hasAdapterDeployParamsAbi, healthFactorBps, hexEq, hydrateAddressProvider, iBalancerV3RouterAbi, iBalancerV3RouterAdapterAbi, iBalancerV3WrapperAbi, iBalancerV3WrapperAdapterAbi, iBaseOnRampAbi, iBaseRewardPoolAbi, iBoosterAbi, iCamelotV3AdapterAbi, iCamelotV3RouterAbi, iConvexV1BaseRewardPoolAdapterAbi, iConvexV1BoosterAdapterAbi, iCreditAccountAbi, iCurvePoolAbi, iCurvePoolStableNGAbi, iCurvePool_2Abi, iCurvePool_3Abi, iCurvePool_4Abi, iCurveV1StableNgAdapterAbi, iCurveV1_2AssetsAdapterAbi, iCurveV1_3AssetsAdapterAbi, iCurveV1_4AssetsAdapterAbi, iDaiUsdsAbi, iDaiUsdsAdapterAbi, iERC4626Abi, iERC4626ReferralAbi, iFluidDexAbi, iFluidDexAdapterAbi, iInfinifiGatewayAbi, iInfinifiGatewayAdapterAbi, iInfinifiUnwindingGatewayAbi, iInfinifiUnwindingGatewayAdapterAbi, iKelpLRTDepositPoolGatewayAbi, iKelpLRTWithdrawalManagerGatewayAbi, iKelpLrtDepositPoolAdapterAbi, iKelpLrtDepositPoolGatewayAbi, iKelpLrtWithdrawalManagerAdapterAbi, iKelpLrtWithdrawalManagerGatewayAbi, iLidoV1AdapterAbi, iMellow4626VaultAdapterAbi, iMellowClaimerAbi, iMellowClaimerAdapterAbi, iMellowWrapperAbi, iMellowWrapperAdapterAbi, iMidasGatewayAdapterV311Abi, iMidasGatewayV311Abi, iMidasIssuanceVaultAdapterV310Abi, iMidasIssuanceVaultV310Abi, iMidasRedemptionVaultAdapterV310Abi, iMidasRedemptionVaultGatewayV310Abi, iPendleRouterAbi, iPendleRouterAdapterAbi, iSecuritizeOnRampAbi, iSecuritizeOnRampAdapterV310Abi, iSecuritizeRedemptionGatewayAdapterV311Abi, iSecuritizeRedemptionGatewayV311Abi, iStakingRewardsAbi, iStakingRewardsAdapterAbi, iTraderJoeRouterAbi, iTraderJoeRouterAdapterAbi, iUniswapV2AdapterAbi, iUniswapV2Router02Abi, iUniswapV3Abi, iUniswapV3AdapterAbi, iUniswapV4AdapterAbi, iUniswapV4GatewayAbi, iUpshiftVaultAdapterAbi, iUpshiftVaultGatewayAbi, iVelodromeV2RouterAbi, iVelodromeV2RouterAdapterAbi, isCloseOrRepay, isDust, isLPPriceFeed, isPhantomToken, isPoolOperation, isPublicNetwork, isRWAFactory, isRWAOperation, isRWAToken, isStrategyCollateral, isSunsetPool, isSunsetStrategy, isSupportedNetwork, isUpdatablePriceFeed, isV310, isVersionRange, isZeroBalance, iwstETHAbi, iwstEthv1AdapterAbi, json_parse, json_stringify, lidoV1_WETHGatewayAbi, makeReplayState, mellowDvvAdapterAbi, midasGreenlistsAccount, minSeizedAmount, numberWithCommas, onchainSDKOptionsSchema, optimalHFForPartialLiquidation, optimalRepaidAmount, parseAdapterAction, parseAdapterDeployParams, parseFacadeOperationCalldata, parseOperationCalldata, parsePoolOperationCalldata, parsePosNegAmount, parseRWAFactoryOperationCalldata, percentFmt, pickStrategyTargetCollateral, previewAdjustStrategyPosition, previewExitOrRepayStrategyPosition, previewOperation, raise, rayToBps, rayToNumber, replayInnerOperations, replayMulticall, resolveDelayedClaimIntent, resolveProtocolCall, retry, rewardsFromTransfers, roundUpQuota, sendRawTx, shortAddress, shortHash, simulateCall, simulateMulticall, simulateWithPriceUpdates, soleNonUnderlyingCollateral, strategyName, swapFromTransfers, toAddress, toBN, toBigInt, toChainIds, toClaimableWithdrawal, toCreditAccountSlice, toNetTransfers, toPendingWithdrawal, toRequestableWithdrawal, toSignificant, toToken, toTokenAmount, toWithdrawalStatus, updatableDependencies, usdToNumber, watchBlocksAsync };
|
|
@@ -19,7 +19,7 @@ const adapterConstructorAbi = {
|
|
|
19
19
|
["INFINIFI_GATEWAY"]: { 310: BASIC_ADAPTER_ABI },
|
|
20
20
|
["LIDO_V1"]: { 310: BASIC_ADAPTER_ABI },
|
|
21
21
|
["LIDO_WSTETH_V1"]: { 310: BASIC_ADAPTER_ABI },
|
|
22
|
-
["MIDAS_GATEWAY"]: { 311:
|
|
22
|
+
["MIDAS_GATEWAY"]: { 311: BASIC_ADAPTER_ABI },
|
|
23
23
|
["MIDAS_REDEMPTION_VAULT"]: {
|
|
24
24
|
310: BASIC_ADAPTER_ABI,
|
|
25
25
|
311: BASIC_ADAPTER_ABI
|
|
@@ -65,7 +65,7 @@ const adapterConstructorAbi = {
|
|
|
65
65
|
["INFINIFI_UNWINDING"]: { 310: PHANTOM_TOKEN_ADAPTER_ABI },
|
|
66
66
|
["SECURITIZE_REDEMPTION"]: {
|
|
67
67
|
310: PHANTOM_TOKEN_ADAPTER_ABI,
|
|
68
|
-
311:
|
|
68
|
+
311: BASIC_ADAPTER_ABI
|
|
69
69
|
},
|
|
70
70
|
["STAKING_REWARDS"]: { 312: STAKING_REWARDS_ADAPTER_ABI },
|
|
71
71
|
["MIDAS_ISSUANCE_VAULT"]: {
|
|
@@ -128,6 +128,12 @@ var AbstractAdapterContract = class extends BaseContract {
|
|
|
128
128
|
return false;
|
|
129
129
|
}
|
|
130
130
|
/**
|
|
131
|
+
* {@inheritDoc IAdapterContract.openingCalls}
|
|
132
|
+
*/
|
|
133
|
+
async openingCalls() {
|
|
134
|
+
return [];
|
|
135
|
+
}
|
|
136
|
+
/**
|
|
131
137
|
* Applies the balance changes of a decoded adapter call to the running
|
|
132
138
|
* balances, mutating them in place. Overrides should express changes via
|
|
133
139
|
* {@link setLeftover} (diff-style calls) and {@link spendExact}
|
|
@@ -5,7 +5,7 @@ import "../abi/adapters/index.js";
|
|
|
5
5
|
import { iMidasGatewayV311Abi } from "../abi/midas/iMidasGatewayV311.js";
|
|
6
6
|
import "../abi/index.js";
|
|
7
7
|
import { AbstractAdapterContract } from "./AbstractAdapter.js";
|
|
8
|
-
import { decodeAbiParameters, decodeFunctionData, encodeFunctionData, isAddressEqual, zeroAddress } from "viem";
|
|
8
|
+
import { decodeAbiParameters, decodeFunctionData, encodeFunctionData, getAddress, isAddressEqual, zeroAddress } from "viem";
|
|
9
9
|
//#region src/onchain/market/adapters/contracts/MidasGatewayAdapterContract.ts
|
|
10
10
|
const abi = iMidasGatewayAdapterV311Abi;
|
|
11
11
|
const protocolAbi = iMidasGatewayV311Abi;
|
|
@@ -13,6 +13,12 @@ const receiveGreenlistCalldata = encodeFunctionData({
|
|
|
13
13
|
abi,
|
|
14
14
|
functionName: "receiveGreenlist"
|
|
15
15
|
});
|
|
16
|
+
const MGLOBAL_MTOKEN = getAddress("0x7433806912Eae67919e66aea853d46Fa0aef98A8");
|
|
17
|
+
/**
|
|
18
|
+
* Permissionless gateways have no greenlist and reject `receiveGreenlist`,
|
|
19
|
+
* see MidasMode in integrations-v3
|
|
20
|
+
*/
|
|
21
|
+
const MIDAS_MODE_PERMISSIONLESS = 0;
|
|
16
22
|
var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
|
|
17
23
|
#version;
|
|
18
24
|
#gateway;
|
|
@@ -20,6 +26,7 @@ var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
|
|
|
20
26
|
#quoteToken;
|
|
21
27
|
#phantomToken;
|
|
22
28
|
#referrerId;
|
|
29
|
+
#mode;
|
|
23
30
|
constructor(sdk, args) {
|
|
24
31
|
super(sdk, {
|
|
25
32
|
...args,
|
|
@@ -125,6 +132,35 @@ var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
|
|
|
125
132
|
if (this.#referrerId === void 0) throw new MissingSerializedParamsError("referrerId");
|
|
126
133
|
return this.#referrerId;
|
|
127
134
|
}
|
|
135
|
+
/**
|
|
136
|
+
* Gateway `mode` is immutable on-chain, so the first read is reused.
|
|
137
|
+
*/
|
|
138
|
+
async mode() {
|
|
139
|
+
if (!this.#mode) this.#mode = this.client.readContract({
|
|
140
|
+
address: this.targetContract,
|
|
141
|
+
abi: this.protocolAbi,
|
|
142
|
+
functionName: "mode"
|
|
143
|
+
});
|
|
144
|
+
return this.#mode;
|
|
145
|
+
}
|
|
146
|
+
/**
|
|
147
|
+
* {@inheritDoc IAdapterContract.openingCalls}
|
|
148
|
+
*/
|
|
149
|
+
async openingCalls() {
|
|
150
|
+
if (isAddressEqual(this.mToken, MGLOBAL_MTOKEN)) {
|
|
151
|
+
this.logger?.debug(`midas: skipping receiveGreenlist for mGLOBAL ${this.mToken}`);
|
|
152
|
+
return [];
|
|
153
|
+
}
|
|
154
|
+
if (await this.mode() === MIDAS_MODE_PERMISSIONLESS) {
|
|
155
|
+
this.logger?.debug(`midas: gateway ${this.targetContract} is permissionless, nothing to greenlist`);
|
|
156
|
+
return [];
|
|
157
|
+
}
|
|
158
|
+
this.logger?.debug(`midas: greenlisting the credit account via gateway adapter ${this.address}`);
|
|
159
|
+
return [{
|
|
160
|
+
target: this.address,
|
|
161
|
+
callData: receiveGreenlistCalldata
|
|
162
|
+
}];
|
|
163
|
+
}
|
|
128
164
|
stateHuman(raw) {
|
|
129
165
|
return {
|
|
130
166
|
...super.stateHuman(raw),
|
|
@@ -169,14 +205,22 @@ var MidasGatewayAdapterContract = class extends AbstractAdapterContract {
|
|
|
169
205
|
return { redeemer };
|
|
170
206
|
}
|
|
171
207
|
/**
|
|
172
|
-
* `receiveGreenlist()
|
|
173
|
-
*
|
|
174
|
-
* mToken: it only greenlists the credit account and is balance-neutral,
|
|
175
|
-
* so it is legal outside a bracket and leaves balances untouched.
|
|
208
|
+
* Whether `calldata` is `receiveGreenlist()`, the call that grants the
|
|
209
|
+
* Midas greenlisted role to the credit account.
|
|
176
210
|
*/
|
|
177
|
-
|
|
211
|
+
isReceiveGreenlist(calldata) {
|
|
178
212
|
return calldata === receiveGreenlistCalldata;
|
|
179
213
|
}
|
|
214
|
+
/**
|
|
215
|
+
* `receiveGreenlist()` is prepended by {@link openingCalls} before the
|
|
216
|
+
* balance bracket when a permissioned mToken is minted: it only grants
|
|
217
|
+
* the Midas greenlisted role to the credit account and is
|
|
218
|
+
* balance-neutral, so it is legal outside a bracket and leaves balances
|
|
219
|
+
* untouched.
|
|
220
|
+
*/
|
|
221
|
+
replayOutOfBracketCall(_balances, calldata) {
|
|
222
|
+
return this.isReceiveGreenlist(calldata);
|
|
223
|
+
}
|
|
180
224
|
applyBalanceChanges(balances, decoded) {
|
|
181
225
|
switch (decoded.functionName) {
|
|
182
226
|
case "depositInstantDiff": {
|