@gearbox-protocol/sdk 17.0.0-next.4 → 17.1.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/dev/abi.js +14 -15
- package/dist/cjs/dev/claimFromFaucet.js +4 -8
- package/dist/cjs/dev/createAnvilClient.js +35 -17
- package/dist/cjs/dev/index.js +7 -2
- package/dist/cjs/dev/kycUtils.js +66 -58
- package/dist/cjs/dev/midasUtils.js +113 -16
- package/dist/cjs/dev/securitizeUtils.js +82 -42
- package/dist/cjs/dev/withdrawalUtils.js +3 -6
- package/dist/cjs/model/errors/index.js +2 -0
- package/dist/cjs/model/errors/operation-errors.js +19 -1
- package/dist/cjs/model/index.js +4 -2
- package/dist/cjs/model/rwa.js +4 -4
- package/dist/cjs/model/rwa.schema.js +4 -4
- package/dist/cjs/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/cjs/onchain/OnchainSDK.js +3 -3
- package/dist/cjs/onchain/accounts/CreditAccountsServiceV310.js +2 -17
- package/dist/cjs/onchain/accounts/intents/borrow.js +140 -0
- package/dist/cjs/onchain/accounts/intents/collateral-valuation.js +41 -0
- package/dist/cjs/onchain/accounts/intents/guards.js +15 -3
- package/dist/cjs/onchain/accounts/intents/index.js +107 -20
- package/dist/cjs/onchain/accounts/intents/leverage-band.js +2 -12
- package/dist/cjs/onchain/accounts/intents/math.js +12 -3
- package/dist/cjs/onchain/accounts/intents/maxBorrow.js +89 -0
- package/dist/cjs/onchain/accounts/intents/maxWithdrawCollateral.js +15 -41
- package/dist/cjs/onchain/accounts/intents/open-strategy.js +8 -46
- package/dist/cjs/onchain/accounts/intents/operations.js +0 -1
- package/dist/cjs/onchain/accounts/intents/plan.js +1 -8
- package/dist/cjs/onchain/accounts/intents/realize.js +61 -4
- package/dist/cjs/onchain/accounts/intents/tail.js +1 -1
- package/dist/cjs/onchain/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/cjs/onchain/accounts/intents/utils/common.js +19 -0
- package/dist/cjs/onchain/accounts/intents/utils/credit-account-slice.js +21 -0
- package/dist/cjs/onchain/accounts/intents/utils/index.js +2 -0
- package/dist/cjs/onchain/accounts/intents/utils/price-impact.js +12 -9
- package/dist/cjs/onchain/accounts/intents/utils/router-path.js +4 -5
- package/dist/cjs/onchain/accounts/intents/withdraw-limits.js +97 -0
- package/dist/cjs/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/cjs/onchain/constants/address-provider.js +0 -2
- package/dist/cjs/onchain/constants/index.js +0 -1
- package/dist/cjs/onchain/core/createAddressProvider.js +2 -5
- package/dist/cjs/onchain/index.js +60 -43
- package/dist/cjs/onchain/market/adapters/abi/conctructorAbi.js +2 -2
- package/dist/cjs/onchain/market/adapters/contracts/AbstractAdapter.js +6 -0
- package/dist/cjs/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +49 -5
- package/dist/cjs/onchain/market/credit/CreditSuite.js +26 -9
- package/dist/cjs/onchain/market/index.js +50 -38
- package/dist/cjs/onchain/market/oracle/PriceOracleBaseContract.js +3 -3
- package/dist/cjs/onchain/market/pricefeeds/AbstractPriceFeed.js +0 -5
- package/dist/cjs/onchain/market/pricefeeds/PriceFeedRegistry.js +127 -0
- package/dist/cjs/onchain/market/pricefeeds/{BalancerStablePriceFeed.js → feeds/BalancerStablePriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.js → feeds/BalancerWeightedPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{BoundedPriceFeed.js → feeds/BoundedPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{CompositePriceFeed.js → feeds/CompositePriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{ConstantPriceFeed.js → feeds/ConstantPriceFeed.js} +3 -3
- package/dist/cjs/onchain/market/pricefeeds/{CurveCryptoPriceFeed.js → feeds/CurveCryptoPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{CurveStablePriceFeed.js → feeds/CurveStablePriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{CurveUSDPriceFeed.js → feeds/CurveUSDPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{Erc4626PriceFeed.js → feeds/Erc4626PriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{ExternalPriceFeed.js → feeds/ExternalPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{MellowLRTPriceFeed.js → feeds/MellowLRTPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.js → feeds/PendleTWAPPTPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{PythPriceFeed.js → feeds/PythPriceFeed.js} +3 -3
- package/dist/cjs/onchain/market/pricefeeds/{RedstonePriceFeed.js → feeds/RedstonePriceFeed.js} +6 -6
- package/dist/cjs/onchain/market/pricefeeds/{WstETHPriceFeed.js → feeds/WstETHPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{YearnPriceFeed.js → feeds/YearnPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/{ZeroPriceFeed.js → feeds/ZeroPriceFeed.js} +4 -4
- package/dist/cjs/onchain/market/pricefeeds/feeds/index.js +35 -0
- package/dist/cjs/onchain/market/pricefeeds/index.js +51 -39
- package/dist/cjs/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.js +189 -0
- package/dist/cjs/onchain/market/pricefeeds/{getRawPriceUpdates.js → updates/getRawPriceUpdates.js} +2 -2
- package/dist/cjs/onchain/market/pricefeeds/updates/index.js +8 -0
- package/dist/cjs/onchain/market/pricefeeds/{isUpdatablePriceFeed.js → updates/isUpdatablePriceFeed.js} +1 -1
- package/dist/cjs/onchain/market/pricefeeds/updates/updatableDependencies.js +14 -0
- package/dist/cjs/onchain/market/rwa/RWARegistry.js +4 -7
- package/dist/cjs/onchain/market/rwa/index.js +1 -0
- package/dist/cjs/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +56 -12
- package/dist/cjs/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
- package/dist/cjs/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
- package/dist/cjs/onchain/opportunities/OpportunitiesService.js +16 -4
- package/dist/cjs/onchain/pools/PoolService.js +7 -8
- package/dist/cjs/onchain/positions/calcHealthFactor.js +3 -3
- package/dist/cjs/onchain/preview/index.js +2 -0
- package/dist/cjs/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
- package/dist/cjs/onchain/preview/preview/index.js +2 -0
- package/dist/cjs/onchain/preview/preview/midasGreenlistsAccount.js +17 -0
- package/dist/cjs/onchain/preview/preview/previewOpenStrategyPosition.js +13 -16
- package/dist/cjs/onchain/preview/preview/previewOperation.js +19 -11
- package/dist/cjs/onchain/preview/preview/replayMulticall.js +4 -3
- package/dist/cjs/onchain/validation/bundles/checkCollateralFunding.js +3 -3
- package/dist/cjs/onchain/validation/bundles/checkCreditOperation.js +11 -9
- package/dist/cjs/onchain/validation/bundles/{checkDraw.js → checkIncreaseDebt.js} +10 -10
- package/dist/cjs/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
- package/dist/cjs/onchain/validation/bundles/checkMidasAccountGreenlist.js +44 -0
- package/dist/cjs/onchain/validation/bundles/checkPoolOperation.js +2 -8
- package/dist/cjs/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
- package/dist/cjs/onchain/validation/bundles/checkRWAOpening.js +18 -8
- package/dist/cjs/onchain/validation/bundles/index.js +6 -4
- package/dist/cjs/onchain/validation/checkOperation.js +0 -1
- package/dist/cjs/onchain/validation/checks/checkBorrowLimit.js +1 -1
- package/dist/cjs/onchain/validation/checks/checkPoolLiquidity.js +2 -9
- package/dist/cjs/onchain/validation/checks/checkReservePriceLimited.js +30 -0
- package/dist/cjs/onchain/validation/checks/index.js +2 -0
- package/dist/cjs/onchain/validation/index.js +8 -4
- package/dist/cjs/permissionless/utils/price-update/get-price-update-tx.js +2 -2
- package/dist/cjs/permissionless/utils/price-update/get-updatable-feeds.js +2 -2
- package/dist/cjs/sdk/execute/ExecuteApi.js +67 -7
- package/dist/cjs/sdk/opportunities/OpportunitiesNamespace.js +9 -3
- package/dist/cjs/sdk/prepare/PrepareApi.js +89 -14
- package/dist/esm/dev/abi.js +14 -15
- package/dist/esm/dev/claimFromFaucet.js +4 -8
- package/dist/esm/dev/createAnvilClient.js +36 -19
- package/dist/esm/dev/index.js +4 -4
- package/dist/esm/dev/kycUtils.js +66 -59
- package/dist/esm/dev/midasUtils.js +112 -18
- package/dist/esm/dev/securitizeUtils.js +84 -44
- package/dist/esm/dev/withdrawalUtils.js +3 -6
- package/dist/esm/model/errors/index.js +2 -2
- package/dist/esm/model/errors/operation-errors.js +18 -2
- package/dist/esm/model/index.js +4 -4
- package/dist/esm/model/rwa.js +4 -4
- package/dist/esm/model/rwa.schema.js +5 -5
- package/dist/esm/offchain/opportunities/OffchainOpportunities.js +1 -1
- package/dist/esm/onchain/OnchainSDK.js +3 -3
- package/dist/esm/onchain/accounts/CreditAccountsServiceV310.js +2 -17
- package/dist/esm/onchain/accounts/intents/borrow.js +138 -0
- package/dist/esm/onchain/accounts/intents/collateral-valuation.js +40 -0
- package/dist/esm/onchain/accounts/intents/guards.js +15 -3
- package/dist/esm/onchain/accounts/intents/index.js +107 -20
- package/dist/esm/onchain/accounts/intents/leverage-band.js +2 -12
- package/dist/esm/onchain/accounts/intents/math.js +13 -5
- package/dist/esm/onchain/accounts/intents/maxBorrow.js +87 -0
- package/dist/esm/onchain/accounts/intents/maxWithdrawCollateral.js +15 -41
- package/dist/esm/onchain/accounts/intents/open-strategy.js +8 -46
- package/dist/esm/onchain/accounts/intents/operations.js +0 -1
- package/dist/esm/onchain/accounts/intents/plan.js +1 -8
- package/dist/esm/onchain/accounts/intents/realize.js +61 -4
- package/dist/esm/onchain/accounts/intents/tail.js +1 -1
- package/dist/esm/onchain/accounts/intents/testing/sdk-mock.js +1 -0
- package/dist/esm/onchain/accounts/intents/utils/common.js +19 -1
- package/dist/esm/onchain/accounts/intents/utils/credit-account-slice.js +21 -1
- package/dist/esm/onchain/accounts/intents/utils/index.js +3 -3
- package/dist/esm/onchain/accounts/intents/utils/price-impact.js +12 -9
- package/dist/esm/onchain/accounts/intents/utils/router-path.js +4 -5
- package/dist/esm/onchain/accounts/intents/withdraw-limits.js +95 -0
- package/dist/esm/onchain/accounts/liquidations/LiquidationsService.js +1 -1
- package/dist/esm/onchain/constants/address-provider.js +1 -2
- package/dist/esm/onchain/constants/index.js +2 -2
- package/dist/esm/onchain/core/createAddressProvider.js +2 -5
- package/dist/esm/onchain/index.js +32 -24
- package/dist/esm/onchain/market/adapters/abi/conctructorAbi.js +2 -2
- package/dist/esm/onchain/market/adapters/contracts/AbstractAdapter.js +6 -0
- package/dist/esm/onchain/market/adapters/contracts/MidasGatewayAdapterContract.js +50 -6
- package/dist/esm/onchain/market/credit/CreditSuite.js +26 -9
- package/dist/esm/onchain/market/index.js +26 -21
- package/dist/esm/onchain/market/oracle/PriceOracleBaseContract.js +1 -1
- package/dist/esm/onchain/market/pricefeeds/AbstractPriceFeed.js +0 -5
- package/dist/esm/onchain/market/pricefeeds/PriceFeedRegistry.js +126 -0
- package/dist/esm/onchain/market/pricefeeds/{BalancerStablePriceFeed.js → feeds/BalancerStablePriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.js → feeds/BalancerWeightedPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{BoundedPriceFeed.js → feeds/BoundedPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{CompositePriceFeed.js → feeds/CompositePriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{ConstantPriceFeed.js → feeds/ConstantPriceFeed.js} +3 -3
- package/dist/esm/onchain/market/pricefeeds/{CurveCryptoPriceFeed.js → feeds/CurveCryptoPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{CurveStablePriceFeed.js → feeds/CurveStablePriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{CurveUSDPriceFeed.js → feeds/CurveUSDPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{Erc4626PriceFeed.js → feeds/Erc4626PriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{ExternalPriceFeed.js → feeds/ExternalPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{MellowLRTPriceFeed.js → feeds/MellowLRTPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.js → feeds/PendleTWAPPTPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{PythPriceFeed.js → feeds/PythPriceFeed.js} +3 -3
- package/dist/esm/onchain/market/pricefeeds/{RedstonePriceFeed.js → feeds/RedstonePriceFeed.js} +6 -6
- package/dist/esm/onchain/market/pricefeeds/{WstETHPriceFeed.js → feeds/WstETHPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{YearnPriceFeed.js → feeds/YearnPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/{ZeroPriceFeed.js → feeds/ZeroPriceFeed.js} +4 -4
- package/dist/esm/onchain/market/pricefeeds/feeds/index.js +18 -0
- package/dist/esm/onchain/market/pricefeeds/index.js +27 -21
- package/dist/esm/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.js +188 -0
- package/dist/esm/onchain/market/pricefeeds/{getRawPriceUpdates.js → updates/getRawPriceUpdates.js} +2 -2
- package/dist/esm/onchain/market/pricefeeds/updates/index.js +5 -1
- package/dist/esm/onchain/market/pricefeeds/{isUpdatablePriceFeed.js → updates/isUpdatablePriceFeed.js} +1 -1
- package/dist/esm/onchain/market/pricefeeds/updates/updatableDependencies.js +13 -0
- package/dist/esm/onchain/market/rwa/RWARegistry.js +4 -8
- package/dist/esm/onchain/market/rwa/index.js +2 -2
- package/dist/esm/onchain/market/rwa/midas/MidasDegenNFT.js +45 -5
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeDegenNFT.js +55 -10
- package/dist/esm/onchain/market/rwa/securitize/SecuritizeRWAFactory.js +0 -37
- package/dist/esm/onchain/opportunities/MultichainOpportunitiesService.js +8 -2
- package/dist/esm/onchain/opportunities/OpportunitiesService.js +16 -4
- package/dist/esm/onchain/pools/PoolService.js +7 -8
- package/dist/esm/onchain/positions/calcHealthFactor.js +3 -3
- package/dist/esm/onchain/preview/index.js +2 -1
- package/dist/esm/onchain/preview/parse/parseRWAFactoryOperationCalldata.js +2 -2
- package/dist/esm/onchain/preview/preview/index.js +2 -1
- package/dist/esm/onchain/preview/preview/midasGreenlistsAccount.js +16 -0
- package/dist/esm/onchain/preview/preview/previewOpenStrategyPosition.js +14 -17
- package/dist/esm/onchain/preview/preview/previewOperation.js +19 -11
- package/dist/esm/onchain/preview/preview/replayMulticall.js +4 -3
- package/dist/esm/onchain/validation/bundles/checkCollateralFunding.js +3 -3
- package/dist/esm/onchain/validation/bundles/checkCreditOperation.js +11 -9
- package/dist/esm/onchain/validation/bundles/checkIncreaseDebt.js +27 -0
- package/dist/esm/onchain/validation/bundles/{checkQuotasAsked.js → checkIncreaseQuota.js} +3 -3
- package/dist/esm/onchain/validation/bundles/checkMidasAccountGreenlist.js +43 -0
- package/dist/esm/onchain/validation/bundles/checkPoolOperation.js +2 -8
- package/dist/esm/onchain/validation/bundles/checkRWAOpenRequirements.js +9 -9
- package/dist/esm/onchain/validation/bundles/checkRWAOpening.js +18 -8
- package/dist/esm/onchain/validation/bundles/index.js +4 -3
- package/dist/esm/onchain/validation/checkOperation.js +0 -1
- package/dist/esm/onchain/validation/checks/checkBorrowLimit.js +1 -1
- package/dist/esm/onchain/validation/checks/checkPoolLiquidity.js +2 -9
- package/dist/esm/onchain/validation/checks/checkReservePriceLimited.js +29 -0
- package/dist/esm/onchain/validation/checks/index.js +2 -1
- package/dist/esm/onchain/validation/index.js +5 -3
- package/dist/esm/permissionless/utils/price-update/get-price-update-tx.js +1 -1
- package/dist/esm/permissionless/utils/price-update/get-updatable-feeds.js +1 -1
- package/dist/esm/sdk/execute/ExecuteApi.js +67 -7
- package/dist/esm/sdk/opportunities/OpportunitiesNamespace.js +9 -3
- package/dist/esm/sdk/prepare/PrepareApi.js +94 -19
- package/dist/types/dev/abi.d.ts +13 -15
- package/dist/types/dev/claimFromFaucet.d.ts +0 -1
- package/dist/types/dev/createAnvilClient.d.ts +10 -3
- package/dist/types/dev/index.d.ts +4 -4
- package/dist/types/dev/kycUtils.d.ts +15 -24
- package/dist/types/dev/midasUtils.d.ts +35 -4
- package/dist/types/dev/securitizeUtils.d.ts +3 -9
- package/dist/types/model/errors/index.d.ts +2 -2
- package/dist/types/model/errors/operation-errors.d.ts +62 -7
- package/dist/types/model/index.d.ts +5 -5
- package/dist/types/model/opportunities.d.ts +6 -7
- package/dist/types/model/previews.d.ts +25 -19
- package/dist/types/model/rwa.d.ts +47 -27
- package/dist/types/model/rwa.schema.d.ts +3 -3
- package/dist/types/offchain/opportunities/OffchainOpportunities.d.ts +1 -2
- package/dist/types/offchain/opportunities/types.d.ts +1 -4
- package/dist/types/onchain/OnchainSDK.d.ts +2 -2
- package/dist/types/onchain/accounts/index.d.ts +5 -4
- package/dist/types/onchain/accounts/intents/borrow.d.ts +141 -0
- package/dist/types/onchain/accounts/intents/collateral-valuation.d.ts +42 -0
- package/dist/types/onchain/accounts/intents/guards.d.ts +18 -2
- package/dist/types/onchain/accounts/intents/index.d.ts +103 -15
- package/dist/types/onchain/accounts/intents/math.d.ts +11 -3
- package/dist/types/onchain/accounts/intents/maxBorrow.d.ts +54 -0
- package/dist/types/onchain/accounts/intents/maxWithdrawCollateral.d.ts +3 -8
- package/dist/types/onchain/accounts/intents/open-strategy.d.ts +3 -17
- package/dist/types/onchain/accounts/intents/testing/sdk-mock.d.ts +2 -0
- package/dist/types/onchain/accounts/intents/tests/open-strategy.fixtures.d.ts +2 -2
- package/dist/types/onchain/accounts/intents/types.d.ts +51 -6
- package/dist/types/onchain/accounts/intents/utils/common.d.ts +15 -1
- package/dist/types/onchain/accounts/intents/utils/credit-account-slice.d.ts +14 -1
- package/dist/types/onchain/accounts/intents/utils/index.d.ts +3 -3
- package/dist/types/onchain/accounts/intents/utils/price-impact.d.ts +4 -1
- package/dist/types/onchain/accounts/intents/utils/router-path.d.ts +2 -5
- package/dist/types/onchain/accounts/intents/withdraw-limits.d.ts +80 -0
- package/dist/types/onchain/accounts/types.d.ts +4 -2
- package/dist/types/onchain/constants/address-provider.d.ts +1 -2
- package/dist/types/onchain/constants/index.d.ts +2 -2
- package/dist/types/onchain/index.d.ts +40 -31
- package/dist/types/onchain/market/adapters/contracts/AbstractAdapter.d.ts +6 -0
- package/dist/types/onchain/market/adapters/contracts/MidasGatewayAdapterContract.d.ts +20 -4
- package/dist/types/onchain/market/adapters/types.d.ts +8 -0
- package/dist/types/onchain/market/credit/CreditSuite.d.ts +13 -3
- package/dist/types/onchain/market/index.d.ts +29 -24
- package/dist/types/onchain/market/oracle/PriceOracleBaseContract.d.ts +2 -1
- package/dist/types/onchain/market/oracle/types.d.ts +2 -1
- package/dist/types/onchain/market/pool/types.d.ts +1 -1
- package/dist/types/onchain/market/pricefeeds/AbstractPriceFeed.d.ts +1 -2
- package/dist/types/onchain/market/pricefeeds/PriceFeedRegistry.d.ts +60 -0
- package/dist/types/onchain/market/pricefeeds/feeds/BalancerStablePriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/{BalancerWeightedPriceFeed.d.ts → feeds/BalancerWeightedPriceFeed.d.ts} +7 -7
- package/dist/types/onchain/market/pricefeeds/feeds/BoundedPriceFeed.d.ts +15 -0
- package/dist/types/onchain/market/pricefeeds/{CompositePriceFeed.d.ts → feeds/CompositePriceFeed.d.ts} +6 -6
- package/dist/types/onchain/market/pricefeeds/{ConstantPriceFeed.d.ts → feeds/ConstantPriceFeed.d.ts} +6 -6
- package/dist/types/onchain/market/pricefeeds/feeds/CurveCryptoPriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/feeds/CurveStablePriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/feeds/CurveUSDPriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/feeds/Erc4626PriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/feeds/ExternalPriceFeed.d.ts +11 -0
- package/dist/types/onchain/market/pricefeeds/feeds/MellowLRTPriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/{PendleTWAPPTPriceFeed.d.ts → feeds/PendleTWAPPTPriceFeed.d.ts} +3 -3
- package/dist/types/onchain/market/pricefeeds/{PythPriceFeed.d.ts → feeds/PythPriceFeed.d.ts} +3 -3
- package/dist/types/onchain/market/pricefeeds/{RedstonePriceFeed.d.ts → feeds/RedstonePriceFeed.d.ts} +9 -9
- package/dist/types/onchain/market/pricefeeds/feeds/WstETHPriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/feeds/YearnPriceFeed.d.ts +12 -0
- package/dist/types/onchain/market/pricefeeds/feeds/ZeroPriceFeed.d.ts +11 -0
- package/dist/types/onchain/market/pricefeeds/feeds/index.d.ts +18 -0
- package/dist/types/onchain/market/pricefeeds/index.d.ts +28 -22
- package/dist/types/onchain/market/pricefeeds/types.d.ts +1 -31
- package/dist/types/onchain/market/pricefeeds/updates/RedstoneUpdater.d.ts +1 -1
- package/dist/types/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.d.ts +106 -0
- package/dist/types/onchain/market/pricefeeds/updates/getRawPriceUpdates.d.ts +6 -0
- package/dist/types/onchain/market/pricefeeds/updates/index.d.ts +7 -3
- package/dist/types/onchain/market/pricefeeds/updates/isUpdatablePriceFeed.d.ts +6 -0
- package/dist/types/onchain/market/pricefeeds/updates/types.d.ts +56 -2
- package/dist/types/onchain/market/pricefeeds/updates/updatableDependencies.d.ts +10 -0
- package/dist/types/onchain/market/rwa/RWARegistry.d.ts +2 -1
- package/dist/types/onchain/market/rwa/index.d.ts +3 -3
- package/dist/types/onchain/market/rwa/midas/MidasDegenNFT.d.ts +19 -4
- package/dist/types/onchain/market/rwa/securitize/SecuritizeDegenNFT.d.ts +24 -4
- package/dist/types/onchain/market/rwa/securitize/SecuritizeRWAFactory.d.ts +2 -14
- package/dist/types/onchain/market/rwa/types.d.ts +39 -37
- package/dist/types/onchain/opportunities/MultichainOpportunitiesService.d.ts +5 -1
- package/dist/types/onchain/opportunities/OpportunitiesService.d.ts +10 -3
- package/dist/types/onchain/opportunities/types.d.ts +6 -1
- package/dist/types/onchain/pools/PoolService.d.ts +5 -0
- package/dist/types/onchain/pools/types.d.ts +9 -2
- package/dist/types/onchain/preview/index.d.ts +2 -1
- package/dist/types/onchain/preview/preview/index.d.ts +2 -1
- package/dist/types/onchain/preview/preview/midasGreenlistsAccount.d.ts +13 -0
- package/dist/types/onchain/preview/preview/previewOpenStrategyPosition.d.ts +5 -3
- package/dist/types/onchain/preview/preview/replayMulticall.d.ts +8 -7
- package/dist/types/onchain/validation/bundles/checkCreditOperation.d.ts +5 -4
- package/dist/types/onchain/validation/bundles/{checkDraw.d.ts → checkIncreaseDebt.d.ts} +7 -7
- package/dist/types/onchain/validation/bundles/{checkQuotasAsked.d.ts → checkIncreaseQuota.d.ts} +3 -3
- package/dist/types/onchain/validation/bundles/checkMidasAccountGreenlist.d.ts +22 -0
- package/dist/types/onchain/validation/bundles/checkPoolOperation.d.ts +1 -7
- package/dist/types/onchain/validation/bundles/checkRWAOpenRequirements.d.ts +2 -2
- package/dist/types/onchain/validation/bundles/checkRWAOpening.d.ts +9 -7
- package/dist/types/onchain/validation/bundles/index.d.ts +5 -4
- package/dist/types/onchain/validation/checks/checkBorrowLimit.d.ts +1 -1
- package/dist/types/onchain/validation/checks/checkDebtLimits.d.ts +2 -2
- package/dist/types/onchain/validation/checks/checkPoolLiquidity.d.ts +1 -8
- package/dist/types/onchain/validation/checks/checkReservePriceLimited.d.ts +31 -0
- package/dist/types/onchain/validation/checks/index.d.ts +2 -1
- package/dist/types/onchain/validation/index.d.ts +6 -4
- package/dist/types/onchain/validation/raise.d.ts +2 -2
- package/dist/types/sdk/execute/index.d.ts +2 -2
- package/dist/types/sdk/execute/types.d.ts +48 -6
- package/dist/types/sdk/index.d.ts +5 -4
- package/dist/types/sdk/opportunities/OpportunitiesNamespace.d.ts +5 -1
- package/dist/types/sdk/opportunities/types.d.ts +9 -3
- package/dist/types/sdk/prepare/PrepareApi.d.ts +16 -4
- package/dist/types/sdk/prepare/index.d.ts +4 -3
- package/dist/types/sdk/prepare/types.d.ts +200 -66
- package/package.json +1 -1
- package/dist/cjs/onchain/accounts/utils/midasUtils.js +0 -70
- package/dist/cjs/onchain/market/pricefeeds/PriceFeedsRegister.js +0 -301
- package/dist/cjs/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -61
- package/dist/cjs/plugins/degen-distributors/index.js +0 -4
- package/dist/cjs/plugins/degen-distributors/package.json +0 -1
- package/dist/cjs/plugins/degen-distributors/types.js +0 -1
- package/dist/cjs/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -114
- package/dist/cjs/plugins/delayed-withdrawal/index.js +0 -4
- package/dist/cjs/plugins/delayed-withdrawal/package.json +0 -1
- package/dist/cjs/plugins/delayed-withdrawal/types.js +0 -1
- package/dist/esm/onchain/accounts/utils/midasUtils.js +0 -69
- package/dist/esm/onchain/market/pricefeeds/PriceFeedsRegister.js +0 -300
- package/dist/esm/onchain/validation/bundles/checkDraw.js +0 -27
- package/dist/esm/plugins/degen-distributors/DegenDistributorsPlugin.js +0 -60
- package/dist/esm/plugins/degen-distributors/index.js +0 -3
- package/dist/esm/plugins/degen-distributors/package.json +0 -1
- package/dist/esm/plugins/degen-distributors/types.js +0 -1
- package/dist/esm/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.js +0 -113
- package/dist/esm/plugins/delayed-withdrawal/index.js +0 -3
- package/dist/esm/plugins/delayed-withdrawal/package.json +0 -1
- package/dist/esm/plugins/delayed-withdrawal/types.js +0 -1
- package/dist/types/onchain/accounts/utils/midasUtils.d.ts +0 -38
- package/dist/types/onchain/market/pricefeeds/BalancerStablePriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/BoundedPriceFeed.d.ts +0 -15
- package/dist/types/onchain/market/pricefeeds/CurveCryptoPriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/CurveStablePriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/CurveUSDPriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/Erc4626PriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/ExternalPriceFeed.d.ts +0 -11
- package/dist/types/onchain/market/pricefeeds/MellowLRTPriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/PriceFeedsRegister.d.ts +0 -180
- package/dist/types/onchain/market/pricefeeds/WstETHPriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/YearnPriceFeed.d.ts +0 -12
- package/dist/types/onchain/market/pricefeeds/ZeroPriceFeed.d.ts +0 -11
- package/dist/types/onchain/market/pricefeeds/getRawPriceUpdates.d.ts +0 -5
- package/dist/types/onchain/market/pricefeeds/isUpdatablePriceFeed.d.ts +0 -5
- package/dist/types/plugins/degen-distributors/DegenDistributorsPlugin.d.ts +0 -25
- package/dist/types/plugins/degen-distributors/index.d.ts +0 -3
- package/dist/types/plugins/degen-distributors/types.d.ts +0 -8
- package/dist/types/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.d.ts +0 -25
- package/dist/types/plugins/delayed-withdrawal/index.d.ts +0 -3
- package/dist/types/plugins/delayed-withdrawal/types.d.ts +0 -10
|
@@ -1,301 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_onchain_utils_AddressMap = require("../../utils/AddressMap.js");
|
|
3
|
-
const require_onchain_utils_bytes32ToString = require("../../utils/bytes32ToString.js");
|
|
4
|
-
const require_onchain_utils_createRawTx = require("../../utils/createRawTx.js");
|
|
5
|
-
const require_onchain_constants_address_provider = require("../../constants/address-provider.js");
|
|
6
|
-
const require_onchain_constants_addresses = require("../../constants/addresses.js");
|
|
7
|
-
const require_onchain_constants_versions = require("../../constants/versions.js");
|
|
8
|
-
require("../../constants/index.js");
|
|
9
|
-
require("../../utils/index.js");
|
|
10
|
-
const require_onchain_base_SDKConstruct = require("../../base/SDKConstruct.js");
|
|
11
|
-
require("../../base/index.js");
|
|
12
|
-
const require_abi_compressors_priceFeedCompressor = require("../../../abi/compressors/priceFeedCompressor.js");
|
|
13
|
-
const require_onchain_market_pricefeeds_AbstractPriceFeed = require("./AbstractPriceFeed.js");
|
|
14
|
-
const require_onchain_market_pricefeeds_BalancerStablePriceFeed = require("./BalancerStablePriceFeed.js");
|
|
15
|
-
const require_onchain_market_pricefeeds_BalancerWeightedPriceFeed = require("./BalancerWeightedPriceFeed.js");
|
|
16
|
-
const require_onchain_market_pricefeeds_BoundedPriceFeed = require("./BoundedPriceFeed.js");
|
|
17
|
-
const require_onchain_market_pricefeeds_CompositePriceFeed = require("./CompositePriceFeed.js");
|
|
18
|
-
const require_onchain_market_pricefeeds_CurveCryptoPriceFeed = require("./CurveCryptoPriceFeed.js");
|
|
19
|
-
const require_onchain_market_pricefeeds_CurveStablePriceFeed = require("./CurveStablePriceFeed.js");
|
|
20
|
-
const require_onchain_market_pricefeeds_CurveUSDPriceFeed = require("./CurveUSDPriceFeed.js");
|
|
21
|
-
const require_onchain_market_pricefeeds_Erc4626PriceFeed = require("./Erc4626PriceFeed.js");
|
|
22
|
-
const require_onchain_market_pricefeeds_ExternalPriceFeed = require("./ExternalPriceFeed.js");
|
|
23
|
-
const require_onchain_market_pricefeeds_getRawPriceUpdates = require("./getRawPriceUpdates.js");
|
|
24
|
-
const require_onchain_market_pricefeeds_MellowLRTPriceFeed = require("./MellowLRTPriceFeed.js");
|
|
25
|
-
const require_onchain_market_pricefeeds_PendleTWAPPTPriceFeed = require("./PendleTWAPPTPriceFeed.js");
|
|
26
|
-
const require_onchain_utils_internal_Hooks = require("../../utils/internal/Hooks.js");
|
|
27
|
-
require("../../utils/internal/index.js");
|
|
28
|
-
const require_onchain_market_pricefeeds_ConstantPriceFeed = require("./ConstantPriceFeed.js");
|
|
29
|
-
const require_onchain_market_pricefeeds_PythPriceFeed = require("./PythPriceFeed.js");
|
|
30
|
-
const require_onchain_market_pricefeeds_RedstonePriceFeed = require("./RedstonePriceFeed.js");
|
|
31
|
-
const require_onchain_market_pricefeeds_updates_RedstoneUpdater = require("./updates/RedstoneUpdater.js");
|
|
32
|
-
require("./updates/index.js");
|
|
33
|
-
const require_onchain_market_pricefeeds_WstETHPriceFeed = require("./WstETHPriceFeed.js");
|
|
34
|
-
const require_onchain_market_pricefeeds_YearnPriceFeed = require("./YearnPriceFeed.js");
|
|
35
|
-
const require_onchain_market_pricefeeds_ZeroPriceFeed = require("./ZeroPriceFeed.js");
|
|
36
|
-
let viem = require("viem");
|
|
37
|
-
//#region src/onchain/market/pricefeeds/PriceFeedsRegister.ts
|
|
38
|
-
/**
|
|
39
|
-
* Chain-level cache of price feed contract instances.
|
|
40
|
-
*
|
|
41
|
-
* All {@link IPriceOracleContract}s across different markets share a single
|
|
42
|
-
* `PriceFeedRegister`, avoiding duplicate contract wrappers for the same
|
|
43
|
-
* on-chain feed. The register also orchestrates off-chain price updates
|
|
44
|
-
* (Redstone, etc.).
|
|
45
|
-
**/
|
|
46
|
-
var PriceFeedRegister = class extends require_onchain_base_SDKConstruct.SDKConstruct {
|
|
47
|
-
#hooks = new require_onchain_utils_internal_Hooks.Hooks();
|
|
48
|
-
#updaters;
|
|
49
|
-
#feeds = new require_onchain_utils_AddressMap.AddressMap(void 0, "priceFeeds");
|
|
50
|
-
#latestUpdate;
|
|
51
|
-
constructor(sdk, opts = {}) {
|
|
52
|
-
super(sdk);
|
|
53
|
-
this.#updaters = [new require_onchain_market_pricefeeds_updates_RedstoneUpdater.RedstoneUpdater(sdk, opts?.redstone)];
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* @internal
|
|
57
|
-
* Registers a callback for price-feed register lifecycle events.
|
|
58
|
-
* @param event - Event name.
|
|
59
|
-
* @param handler - Callback to invoke.
|
|
60
|
-
**/
|
|
61
|
-
addHook = this.#hooks.addHook.bind(this.#hooks);
|
|
62
|
-
/**
|
|
63
|
-
* @internal
|
|
64
|
-
* Removes a previously registered hook.
|
|
65
|
-
* @param event - Event name.
|
|
66
|
-
* @param handler - Callback to remove.
|
|
67
|
-
**/
|
|
68
|
-
removeHook = this.#hooks.removeHook.bind(this.#hooks);
|
|
69
|
-
/**
|
|
70
|
-
* Returns all price feeds known to sdk
|
|
71
|
-
*/
|
|
72
|
-
get feeds() {
|
|
73
|
-
return this.#feeds.values();
|
|
74
|
-
}
|
|
75
|
-
/**
|
|
76
|
-
* Generates transactions to push fresh off-chain prices to updatable feeds.
|
|
77
|
-
*
|
|
78
|
-
* @param priceFeeds - Top-level price feeds whose updatable dependencies
|
|
79
|
-
* will be resolved, or a filter (`{ main: true }` / `{ reserve: true }`)
|
|
80
|
-
* to gather feeds from all oracles. When omitted, all registered feeds
|
|
81
|
-
* are used.
|
|
82
|
-
**/
|
|
83
|
-
async generatePriceFeedsUpdateTxs(priceFeeds) {
|
|
84
|
-
let updateables = this.#feeds.values();
|
|
85
|
-
let filterRemark = "";
|
|
86
|
-
if (priceFeeds) {
|
|
87
|
-
if (Array.isArray(priceFeeds)) updateables = priceFeeds.flatMap((pf) => pf.updatableDependencies());
|
|
88
|
-
else if ("main" in priceFeeds && priceFeeds.main) {
|
|
89
|
-
filterRemark = " main";
|
|
90
|
-
updateables = this.sdk.marketRegister.priceOracles.flatMap((o) => o.mainPriceFeeds.values()).flatMap((pf) => pf.priceFeed.updatableDependencies());
|
|
91
|
-
} else if ("reserve" in priceFeeds && priceFeeds.reserve) {
|
|
92
|
-
filterRemark = " reserve";
|
|
93
|
-
updateables = this.sdk.marketRegister.priceOracles.flatMap((o) => o.reservePriceFeeds.values()).flatMap((pf) => pf.priceFeed.updatableDependencies());
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
if (updateables.length === 0) return {
|
|
97
|
-
txs: [],
|
|
98
|
-
timestamp: 0
|
|
99
|
-
};
|
|
100
|
-
const txs = [];
|
|
101
|
-
const latestUpdate = {
|
|
102
|
-
updates: [],
|
|
103
|
-
timestamp: Math.floor(Date.now() / 1e3)
|
|
104
|
-
};
|
|
105
|
-
const updates = (await Promise.all(this.#updaters.map((u) => u.getUpdateTxs(updateables).catch(() => [])))).flat();
|
|
106
|
-
let maxTimestamp = 0;
|
|
107
|
-
for (const tx of updates) {
|
|
108
|
-
const { data } = tx;
|
|
109
|
-
const { timestamp } = data;
|
|
110
|
-
if (timestamp > maxTimestamp) maxTimestamp = timestamp;
|
|
111
|
-
txs.push(tx);
|
|
112
|
-
latestUpdate.updates.push(data);
|
|
113
|
-
}
|
|
114
|
-
txs.sort((a, b) => a.raw.to.toLowerCase().localeCompare(b.raw.to.toLowerCase()));
|
|
115
|
-
const result = {
|
|
116
|
-
txs,
|
|
117
|
-
timestamp: maxTimestamp
|
|
118
|
-
};
|
|
119
|
-
const tsDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
|
|
120
|
-
this.logger?.debug(`generated ${txs.length}${filterRemark} price feed update transactions, timestamp: ${maxTimestamp} (delta ${tsDelta})`);
|
|
121
|
-
if (txs.length) await this.#hooks.triggerHooks("updatesGenerated", result);
|
|
122
|
-
this.#latestUpdate = latestUpdate;
|
|
123
|
-
return result;
|
|
124
|
-
}
|
|
125
|
-
/**
|
|
126
|
-
* Similar to {@link generatePriceFeedsUpdateTxs}, but returns raw structures instead of transactions
|
|
127
|
-
* @param priceFeeds
|
|
128
|
-
* @returns
|
|
129
|
-
*/
|
|
130
|
-
async generatePriceFeedsUpdates(priceFeeds) {
|
|
131
|
-
const updates = await this.generatePriceFeedsUpdateTxs(priceFeeds);
|
|
132
|
-
return require_onchain_market_pricefeeds_getRawPriceUpdates.getRawPriceUpdates(updates);
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* Similar to {@link generatePriceFeedsUpdates}, but returns raw transaction to PriceFeedStore.updatePrices
|
|
136
|
-
* @param priceFeeds
|
|
137
|
-
* @returns
|
|
138
|
-
*/
|
|
139
|
-
async getPriceFeedStoreUpdateTx(priceFeeds) {
|
|
140
|
-
const pfs = this.sdk.addressProvider.getAddress(require_onchain_constants_address_provider.AP_PRICE_FEED_STORE);
|
|
141
|
-
const updates = await this.generatePriceFeedsUpdates(priceFeeds);
|
|
142
|
-
return require_onchain_utils_createRawTx.createRawTx(pfs, {
|
|
143
|
-
abi: (0, viem.parseAbi)(["function updatePrices((address,bytes)[])"]),
|
|
144
|
-
functionName: "updatePrices",
|
|
145
|
-
args: [updates.map((u) => [u.priceFeed, u.data])]
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
/**
|
|
149
|
-
* Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds (not known to sdk)
|
|
150
|
-
* This does not add feeds to this register, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
|
|
151
|
-
* @param feeds
|
|
152
|
-
* @param block
|
|
153
|
-
* @returns
|
|
154
|
-
*/
|
|
155
|
-
async generateExternalPriceFeedsUpdateTxs(feeds, block) {
|
|
156
|
-
const [priceFeedCompressorAddress] = this.sdk.addressProvider.mustGetLatest(require_onchain_constants_address_provider.AP_PRICE_FEED_COMPRESSOR, require_onchain_constants_versions.VERSION_RANGE_310);
|
|
157
|
-
const blockParam = block ?? { blockNumber: this.sdk.currentBlock };
|
|
158
|
-
const feedContracts = (await this.client.readContract({
|
|
159
|
-
address: priceFeedCompressorAddress,
|
|
160
|
-
abi: require_abi_compressors_priceFeedCompressor.priceFeedCompressorAbi,
|
|
161
|
-
functionName: "loadPriceFeedTree",
|
|
162
|
-
args: [feeds],
|
|
163
|
-
...blockParam,
|
|
164
|
-
gas: this.sdk.gasLimit
|
|
165
|
-
})).map((data) => this.#createUpdatableProxy(data));
|
|
166
|
-
return this.generatePriceFeedsUpdateTxs(feedContracts);
|
|
167
|
-
}
|
|
168
|
-
/**
|
|
169
|
-
* Similar to {@link generateExternalPriceFeedsUpdateTxs}, but returns raw structures instead of transactions
|
|
170
|
-
* @param feeds
|
|
171
|
-
* @param block
|
|
172
|
-
* @returns
|
|
173
|
-
*/
|
|
174
|
-
async generateExternalPriceFeedsUpdates(feeds, block) {
|
|
175
|
-
const updates = await this.generateExternalPriceFeedsUpdateTxs(feeds, block);
|
|
176
|
-
return require_onchain_market_pricefeeds_getRawPriceUpdates.getRawPriceUpdates(updates);
|
|
177
|
-
}
|
|
178
|
-
/**
|
|
179
|
-
* Checks whether a price feed is already registered at the given address.
|
|
180
|
-
* @param address - On-chain address to look up.
|
|
181
|
-
**/
|
|
182
|
-
has(address) {
|
|
183
|
-
return this.#feeds.has(address);
|
|
184
|
-
}
|
|
185
|
-
/**
|
|
186
|
-
* Returns the cached price feed contract at the given address.
|
|
187
|
-
* @param address - On-chain address to look up.
|
|
188
|
-
* @throws If no feed is registered at that address.
|
|
189
|
-
**/
|
|
190
|
-
mustGet(address) {
|
|
191
|
-
return this.#feeds.mustGet(address);
|
|
192
|
-
}
|
|
193
|
-
/**
|
|
194
|
-
* Inserts or updates a price feed from a full tree node.
|
|
195
|
-
*
|
|
196
|
-
* If a fully loaded feed already exists at the same address, only the
|
|
197
|
-
* answer is refreshed. Otherwise a new contract wrapper is created and
|
|
198
|
-
* cached.
|
|
199
|
-
*
|
|
200
|
-
* @param data - Full price feed tree node from the compressor.
|
|
201
|
-
* @returns The cached (or newly created) feed instance.
|
|
202
|
-
* @throws If the created feed is only partially initialized.
|
|
203
|
-
**/
|
|
204
|
-
upsert(data) {
|
|
205
|
-
const existing = this.#feeds.get(data.baseParams.addr);
|
|
206
|
-
if (existing?.loaded) {
|
|
207
|
-
existing.updateAnswer(data.answer);
|
|
208
|
-
return existing;
|
|
209
|
-
}
|
|
210
|
-
const feed = this.create(data);
|
|
211
|
-
if (!feed.loaded) throw new require_onchain_market_pricefeeds_AbstractPriceFeed.PartialPriceFeedInitError({
|
|
212
|
-
...data,
|
|
213
|
-
abi: [],
|
|
214
|
-
name: ""
|
|
215
|
-
});
|
|
216
|
-
this.#feeds.upsert(data.baseParams.addr, feed);
|
|
217
|
-
return feed;
|
|
218
|
-
}
|
|
219
|
-
/**
|
|
220
|
-
* Loads PARTIAL information about all updatable price feeds from MarketCompressor
|
|
221
|
-
* Discovered price feeds are not saved anywhere in PriceFeedRegister, and can later be used to load price feed updates
|
|
222
|
-
*/
|
|
223
|
-
async getPartialUpdatablePriceFeeds(configurators) {
|
|
224
|
-
const [priceFeedCompressorAddress] = this.sdk.addressProvider.mustGetLatest(require_onchain_constants_address_provider.AP_PRICE_FEED_COMPRESSOR, require_onchain_constants_versions.VERSION_RANGE_310);
|
|
225
|
-
this.logger?.debug({ configurators }, `calling getUpdatablePriceFeeds in block ${this.sdk.currentBlock}`);
|
|
226
|
-
const result = await this.client.readContract({
|
|
227
|
-
address: priceFeedCompressorAddress,
|
|
228
|
-
abi: require_abi_compressors_priceFeedCompressor.priceFeedCompressorAbi,
|
|
229
|
-
functionName: "getUpdatablePriceFeeds",
|
|
230
|
-
args: [{
|
|
231
|
-
configurators,
|
|
232
|
-
pools: [],
|
|
233
|
-
underlying: require_onchain_constants_addresses.ADDRESS_0X0
|
|
234
|
-
}],
|
|
235
|
-
blockNumber: this.sdk.currentBlock,
|
|
236
|
-
gas: this.sdk.gasLimit
|
|
237
|
-
});
|
|
238
|
-
this.logger?.debug(`loaded ${result.length} partial updatable price feeds in block ${this.sdk.currentBlock}`);
|
|
239
|
-
return result.map((baseParams) => this.#createUpdatableProxy({ baseParams }));
|
|
240
|
-
}
|
|
241
|
-
/**
|
|
242
|
-
* Instantiates the appropriate price feed contract wrapper based on
|
|
243
|
-
* the `contractType` discriminator in the node's base params.
|
|
244
|
-
*
|
|
245
|
-
* @param data - Partial or full price feed tree node.
|
|
246
|
-
* @returns A new (uncached) feed contract instance.
|
|
247
|
-
* @throws If the contract type is unsupported and strict mode is enabled.
|
|
248
|
-
**/
|
|
249
|
-
create(data) {
|
|
250
|
-
const contractType = require_onchain_utils_bytes32ToString.bytes32ToString(data.baseParams.contractType);
|
|
251
|
-
switch (contractType) {
|
|
252
|
-
case "PRICE_FEED::BALANCER_STABLE": return new require_onchain_market_pricefeeds_BalancerStablePriceFeed.BalancerStablePriceFeedContract(this.sdk, data);
|
|
253
|
-
case "PRICE_FEED::BALANCER_WEIGHTED": return new require_onchain_market_pricefeeds_BalancerWeightedPriceFeed.BalancerWeightedPriceFeedContract(this.sdk, data);
|
|
254
|
-
case "PRICE_FEED::BOUNDED": return new require_onchain_market_pricefeeds_BoundedPriceFeed.BoundedPriceFeedContract(this.sdk, data);
|
|
255
|
-
case "PRICE_FEED::COMPOSITE": return new require_onchain_market_pricefeeds_CompositePriceFeed.CompositePriceFeedContract(this.sdk, data);
|
|
256
|
-
case "PRICE_FEED::CONSTANT": return new require_onchain_market_pricefeeds_ConstantPriceFeed.ConstantPriceFeedContract(this.sdk, data);
|
|
257
|
-
case "PRICE_FEED::CURVE_CRYPTO": return new require_onchain_market_pricefeeds_CurveCryptoPriceFeed.CurveCryptoPriceFeedContract(this.sdk, data);
|
|
258
|
-
case "PRICE_FEED::CURVE_STABLE": return new require_onchain_market_pricefeeds_CurveStablePriceFeed.CurveStablePriceFeedContract(this.sdk, data);
|
|
259
|
-
case "PRICE_FEED::CURVE_USD": return new require_onchain_market_pricefeeds_CurveUSDPriceFeed.CurveUSDPriceFeedContract(this.sdk, data);
|
|
260
|
-
case "PRICE_FEED::ERC4626": return new require_onchain_market_pricefeeds_Erc4626PriceFeed.Erc4626PriceFeedContract(this.sdk, data);
|
|
261
|
-
case "PRICE_FEED::EXTERNAL": return new require_onchain_market_pricefeeds_ExternalPriceFeed.ExternalPriceFeedContract(this.sdk, data);
|
|
262
|
-
case "PRICE_FEED::MELLOW_LRT": return new require_onchain_market_pricefeeds_MellowLRTPriceFeed.MellowLRTPriceFeedContract(this.sdk, data);
|
|
263
|
-
case "PRICE_FEED::PENDLE_PT_TWAP": return new require_onchain_market_pricefeeds_PendleTWAPPTPriceFeed.PendleTWAPPTPriceFeed(this.sdk, data);
|
|
264
|
-
case "PRICE_FEED::PYTH": return new require_onchain_market_pricefeeds_PythPriceFeed.PythPriceFeed(this.sdk, data);
|
|
265
|
-
case "PRICE_FEED::REDSTONE": return new require_onchain_market_pricefeeds_RedstonePriceFeed.RedstonePriceFeedContract(this.sdk, data);
|
|
266
|
-
case "PRICE_FEED::WSTETH": return new require_onchain_market_pricefeeds_WstETHPriceFeed.WstETHPriceFeedContract(this.sdk, data);
|
|
267
|
-
case "PRICE_FEED::YEARN": return new require_onchain_market_pricefeeds_YearnPriceFeed.YearnPriceFeedContract(this.sdk, data);
|
|
268
|
-
case "PRICE_FEED::ZERO": return new require_onchain_market_pricefeeds_ZeroPriceFeed.ZeroPriceFeedContract(this.sdk, data);
|
|
269
|
-
default: {
|
|
270
|
-
const err = /* @__PURE__ */ new Error(`Price feed type ${contractType} not supported for price feed at ${data.baseParams.addr}`);
|
|
271
|
-
if (this.sdk.strictContractTypes) throw err;
|
|
272
|
-
this.logger?.error(err);
|
|
273
|
-
return new require_onchain_market_pricefeeds_ExternalPriceFeed.ExternalPriceFeedContract(this.sdk, data);
|
|
274
|
-
}
|
|
275
|
-
}
|
|
276
|
-
}
|
|
277
|
-
#createUpdatableProxy(data) {
|
|
278
|
-
const contract = this.#feeds.get(data.baseParams.addr) ?? this.create(data);
|
|
279
|
-
return new Proxy(contract, { get(target, prop) {
|
|
280
|
-
if (prop === "updatableDependencies") return () => [target];
|
|
281
|
-
return target[prop];
|
|
282
|
-
} });
|
|
283
|
-
}
|
|
284
|
-
/**
|
|
285
|
-
* @internal
|
|
286
|
-
* Diagnostic snapshot of the most recent price-update round, or
|
|
287
|
-
* `undefined` if no updates have been generated yet.
|
|
288
|
-
**/
|
|
289
|
-
get latestUpdate() {
|
|
290
|
-
return this.#latestUpdate;
|
|
291
|
-
}
|
|
292
|
-
/**
|
|
293
|
-
* @internal
|
|
294
|
-
* Returns true if any of the updaters are in historical mode
|
|
295
|
-
*/
|
|
296
|
-
get historical() {
|
|
297
|
-
return this.#updaters.some((u) => u.historical);
|
|
298
|
-
}
|
|
299
|
-
};
|
|
300
|
-
//#endregion
|
|
301
|
-
exports.PriceFeedRegister = PriceFeedRegister;
|
|
@@ -1,61 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_onchain_utils_AddressMap = require("../../onchain/utils/AddressMap.js");
|
|
3
|
-
const require_onchain_market_MarketConfiguratorContract = require("../../onchain/market/MarketConfiguratorContract.js");
|
|
4
|
-
const require_onchain_plugins_BasePlugin = require("../../onchain/plugins/BasePlugin.js");
|
|
5
|
-
require("../../onchain/index.js");
|
|
6
|
-
//#region src/plugins/degen-distributors/DegenDistributorsPlugin.ts
|
|
7
|
-
const MAP_LABEL = "degenDistributors";
|
|
8
|
-
var DegenDistributorsPlugin = class extends require_onchain_plugins_BasePlugin.BasePlugin {
|
|
9
|
-
#distributors;
|
|
10
|
-
async load(force) {
|
|
11
|
-
if (!force && this.loaded) return this.state;
|
|
12
|
-
const configurators = Object.values(this.sdk.marketRegister.markets.reduce((acc, market) => {
|
|
13
|
-
const cfgLC = market.configurator.address.toLowerCase();
|
|
14
|
-
acc[cfgLC] = market.configurator;
|
|
15
|
-
return acc;
|
|
16
|
-
}, {}));
|
|
17
|
-
this.sdk.logger?.debug(`loading degen distributors for ${this.sdk.networkType}`);
|
|
18
|
-
const distributors = await require_onchain_market_MarketConfiguratorContract.MarketConfiguratorContract.getPeripheryContractBatch(Object.values(configurators), this.sdk.client, "DEGEN_DISTRIBUTOR", this.sdk.currentBlock);
|
|
19
|
-
const distributorByConfigurator = configurators.reduce((acc, cfg, index) => {
|
|
20
|
-
const cfgLC = cfg.address.toLowerCase();
|
|
21
|
-
acc[cfgLC] = distributors[index];
|
|
22
|
-
return acc;
|
|
23
|
-
}, {});
|
|
24
|
-
this.#distributors = new require_onchain_utils_AddressMap.AddressMap(void 0, MAP_LABEL);
|
|
25
|
-
this.sdk.marketRegister.markets.forEach((m) => {
|
|
26
|
-
const pool = m.pool.pool.address;
|
|
27
|
-
const cfg = m.configurator.address;
|
|
28
|
-
const cfgLC = cfg.toLowerCase();
|
|
29
|
-
const r = distributorByConfigurator?.[cfgLC];
|
|
30
|
-
if (r.status === "success" && r.result.length > 0) this.#distributors?.upsert(pool, r.result[0]);
|
|
31
|
-
else this.sdk.logger?.warn(`failed to load degen distributor for market configurator ${this.labelAddress(cfg)} and pool ${this.labelAddress(pool)}: ${r.error}`);
|
|
32
|
-
});
|
|
33
|
-
return this.state;
|
|
34
|
-
}
|
|
35
|
-
get loaded() {
|
|
36
|
-
return !!this.#distributors;
|
|
37
|
-
}
|
|
38
|
-
/**
|
|
39
|
-
* Returns a map of pool addresses to degen distributor addresses
|
|
40
|
-
* @throws if degen distributor plugin is not attached
|
|
41
|
-
*/
|
|
42
|
-
get distributors() {
|
|
43
|
-
if (!this.#distributors) throw new Error("degen distributor plugin not attached");
|
|
44
|
-
return this.#distributors;
|
|
45
|
-
}
|
|
46
|
-
stateHuman(_) {
|
|
47
|
-
return this.distributors.entries().flatMap(([pool, distributor]) => ({
|
|
48
|
-
address: distributor,
|
|
49
|
-
version: this.version,
|
|
50
|
-
pool
|
|
51
|
-
}));
|
|
52
|
-
}
|
|
53
|
-
get state() {
|
|
54
|
-
return { distributors: this.distributors.asRecord() };
|
|
55
|
-
}
|
|
56
|
-
hydrate(state) {
|
|
57
|
-
this.#distributors = new require_onchain_utils_AddressMap.AddressMap(Object.entries(state.distributors), MAP_LABEL);
|
|
58
|
-
}
|
|
59
|
-
};
|
|
60
|
-
//#endregion
|
|
61
|
-
exports.DegenDistributorsPlugin = DegenDistributorsPlugin;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_plugins_degen_distributors_DegenDistributorsPlugin = require("./DegenDistributorsPlugin.js");
|
|
3
|
-
require("./types.js");
|
|
4
|
-
exports.DegenDistributorsPlugin = require_plugins_degen_distributors_DegenDistributorsPlugin.DegenDistributorsPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type": "commonjs"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -1,114 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_onchain_utils_AddressMap = require("../../onchain/utils/AddressMap.js");
|
|
3
|
-
const require_onchain_plugins_BasePlugin = require("../../onchain/plugins/BasePlugin.js");
|
|
4
|
-
require("../../onchain/index.js");
|
|
5
|
-
//#region src/plugins/delayed-withdrawal/DelayedWithdrawalPlugin.ts
|
|
6
|
-
const MAP_LABEL = "delayedWithdrawal";
|
|
7
|
-
var DelayedWithdrawalPlugin = class extends require_onchain_plugins_BasePlugin.BasePlugin {
|
|
8
|
-
async load(force) {
|
|
9
|
-
if (!force && this.loaded) return this.state;
|
|
10
|
-
await this.sdk.withdrawalCompressor?.loadWithdrawableAssets(force);
|
|
11
|
-
return this.state;
|
|
12
|
-
}
|
|
13
|
-
get loaded() {
|
|
14
|
-
return !!this.sdk.withdrawalCompressor?.state;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Returns a map of cmAddress -> array of delayed assets
|
|
18
|
-
* @throws if withdrawable assets have not been loaded
|
|
19
|
-
*/
|
|
20
|
-
get withdrawableAssets() {
|
|
21
|
-
const compressor = this.sdk.withdrawalCompressor;
|
|
22
|
-
if (!compressor?.state) throw new Error("withdrawable assets are not loaded");
|
|
23
|
-
const result = new require_onchain_utils_AddressMap.AddressMap(void 0, MAP_LABEL);
|
|
24
|
-
for (const cfg of compressor.getWithdrawableAssets()) {
|
|
25
|
-
const assets = result.get(cfg.creditManager) ?? [];
|
|
26
|
-
assets.push({
|
|
27
|
-
...cfg,
|
|
28
|
-
disabled: isConfigToOmit({
|
|
29
|
-
creditManager: cfg.creditManager,
|
|
30
|
-
token: cfg.token,
|
|
31
|
-
withdrawalPhantomToken: cfg.withdrawalPhantomToken,
|
|
32
|
-
underlying: cfg.underlying
|
|
33
|
-
})
|
|
34
|
-
});
|
|
35
|
-
result.upsert(cfg.creditManager, assets);
|
|
36
|
-
}
|
|
37
|
-
return result;
|
|
38
|
-
}
|
|
39
|
-
stateHuman(_) {
|
|
40
|
-
return this.withdrawableAssets.values().flatMap((cm) => {
|
|
41
|
-
return cm.map((a) => {
|
|
42
|
-
return {
|
|
43
|
-
address: a.creditManager,
|
|
44
|
-
version: this.version,
|
|
45
|
-
...a
|
|
46
|
-
};
|
|
47
|
-
});
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
get state() {
|
|
51
|
-
return {};
|
|
52
|
-
}
|
|
53
|
-
};
|
|
54
|
-
function getConfigKey(config) {
|
|
55
|
-
return `${config.creditManager}-${config.token}-${config.withdrawalPhantomToken}-${config.underlying}`.toLowerCase();
|
|
56
|
-
}
|
|
57
|
-
function isConfigToOmit(config) {
|
|
58
|
-
return !!CONFIGS_TO_OMIT_RECORD[getConfigKey(config)];
|
|
59
|
-
}
|
|
60
|
-
const CONFIGS_TO_OMIT_RECORD = [
|
|
61
|
-
{
|
|
62
|
-
creditManager: "0xf5edc34204e67e592bdcb84114571c9e4bd0bdf7",
|
|
63
|
-
token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
|
64
|
-
withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
|
|
65
|
-
underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
|
|
66
|
-
},
|
|
67
|
-
{
|
|
68
|
-
creditManager: "0xb79d6544839d169869476589d2e54014a074317b",
|
|
69
|
-
token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
|
70
|
-
withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
|
|
71
|
-
underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
|
|
72
|
-
},
|
|
73
|
-
{
|
|
74
|
-
creditManager: "0x79c6c1ce5b12abcc3e407ce8c160ee1160250921",
|
|
75
|
-
token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
|
76
|
-
withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
|
|
77
|
-
underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
|
|
78
|
-
},
|
|
79
|
-
{
|
|
80
|
-
creditManager: "0xc307a074bd5aec2d6ad1d9b74465c24a59b490fd",
|
|
81
|
-
token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
|
82
|
-
withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
|
|
83
|
-
underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
|
|
84
|
-
},
|
|
85
|
-
{
|
|
86
|
-
creditManager: "0x9a0fdf7cdab4604fc27ebeab4b3d57bd825e8ebe",
|
|
87
|
-
token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
|
88
|
-
withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
|
|
89
|
-
underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
|
|
90
|
-
},
|
|
91
|
-
{
|
|
92
|
-
creditManager: "0x06c0df5ac1f24bc2097b59ed8ee1db86bf0b09df",
|
|
93
|
-
token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
|
94
|
-
withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
|
|
95
|
-
underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
|
|
96
|
-
},
|
|
97
|
-
{
|
|
98
|
-
creditManager: "0x1128860755c6d452d9326e35d1672ca7c920b7c1",
|
|
99
|
-
token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
|
100
|
-
withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
|
|
101
|
-
underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
|
|
102
|
-
},
|
|
103
|
-
{
|
|
104
|
-
creditManager: "0x35e154be3c856c37d539aae90178fe5ac6d37644",
|
|
105
|
-
token: "0x7a4EffD87C2f3C55CA251080b1343b605f327E3a",
|
|
106
|
-
withdrawalPhantomToken: "0x6252467C2FefB61cB55180282943139BAeEA36c5",
|
|
107
|
-
underlying: "0x7f39C581F595B53c5cb19bD0b3f8dA6c935E2Ca0"
|
|
108
|
-
}
|
|
109
|
-
].reduce((acc, config) => {
|
|
110
|
-
acc[getConfigKey(config)] = config;
|
|
111
|
-
return acc;
|
|
112
|
-
}, {});
|
|
113
|
-
//#endregion
|
|
114
|
-
exports.DelayedWithdrawalPlugin = DelayedWithdrawalPlugin;
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_plugins_delayed_withdrawal_DelayedWithdrawalPlugin = require("./DelayedWithdrawalPlugin.js");
|
|
3
|
-
require("./types.js");
|
|
4
|
-
exports.DelayedWithdrawalPlugin = require_plugins_delayed_withdrawal_DelayedWithdrawalPlugin.DelayedWithdrawalPlugin;
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"type": "commonjs"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { AddressMap } from "../../utils/AddressMap.js";
|
|
2
|
-
import { encodeFunctionData, isAddressEqual, parseAbi } from "viem";
|
|
3
|
-
//#region src/onchain/accounts/utils/midasUtils.ts
|
|
4
|
-
const ADAPTER_MIDAS_GATEWAY = "ADAPTER::MIDAS_GATEWAY";
|
|
5
|
-
const ADAPTER_MIDAS_ISSUANCE_VAULT = "ADAPTER::MIDAS_ISSUANCE_VAULT";
|
|
6
|
-
/**
|
|
7
|
-
* Permissionless gateways have no greenlist and reject `receiveGreenlist`,
|
|
8
|
-
* see MidasMode in integrations-v3
|
|
9
|
-
*/
|
|
10
|
-
const MIDAS_MODE_PERMISSIONLESS = 0;
|
|
11
|
-
const iMidasGatewayAdapterExtAbi = parseAbi(["function receiveGreenlist() external returns (bool)"]);
|
|
12
|
-
const iMidasGatewayModeAbi = parseAbi(["function mode() external view returns (uint8)"]);
|
|
13
|
-
const receiveGreenlistCallData = encodeFunctionData({
|
|
14
|
-
abi: iMidasGatewayAdapterExtAbi,
|
|
15
|
-
functionName: "receiveGreenlist"
|
|
16
|
-
});
|
|
17
|
-
/**
|
|
18
|
-
* Prepends `MidasGatewayAdapter.receiveGreenlist()` to a credit facade
|
|
19
|
-
* multicall that mints an mToken through a Midas issuance vault.
|
|
20
|
-
*
|
|
21
|
-
* Permissioned and restricted-interface mTokens can only be held by greenlisted
|
|
22
|
-
* accounts, and a freshly opened credit account is never greenlisted, so the
|
|
23
|
-
* mint reverts with `WMAC: hasnt role` unless the account asks the gateway for
|
|
24
|
-
* the greenlist first. Greenlisting the borrower is not enough — the role is
|
|
25
|
-
* checked on the token holder, which is the credit account.
|
|
26
|
-
*
|
|
27
|
-
* Returns `calls` unchanged when nothing has to be greenlisted: no issuance
|
|
28
|
-
* vault is called, its mToken has no gateway adapter on this credit manager,
|
|
29
|
-
* the gateway is permissionless, or the call is already there.
|
|
30
|
-
*/
|
|
31
|
-
async function prependMidasReceiveGreenlist(props) {
|
|
32
|
-
const { cm, client, calls, logger } = props;
|
|
33
|
-
const adapters = Array.from(cm.creditManager.adapters.values());
|
|
34
|
-
const gatewayByMToken = AddressMap.fromMappedArray(adapters.filter((a) => a.contractType === ADAPTER_MIDAS_GATEWAY), (a) => a.mToken);
|
|
35
|
-
const calledVaults = adapters.filter((a) => a.contractType === ADAPTER_MIDAS_ISSUANCE_VAULT).filter((vault) => calls.some((call) => isAddressEqual(call.target, vault.address)));
|
|
36
|
-
if (gatewayByMToken.size === 0 || calledVaults.length === 0) return calls;
|
|
37
|
-
const gateways = new AddressMap();
|
|
38
|
-
for (const vault of calledVaults) {
|
|
39
|
-
const gateway = gatewayByMToken.get(vault.mToken);
|
|
40
|
-
if (!gateway) logger?.debug(`midas: no gateway adapter for mToken ${vault.mToken} minted by ${vault.address} on ${cm.name}, cannot greenlist the credit account`);
|
|
41
|
-
else if (calls.some((call) => isAddressEqual(call.target, gateway.address) && call.callData === receiveGreenlistCallData)) logger?.debug(`midas: gateway adapter ${gateway.address} already receives the greenlist`);
|
|
42
|
-
else gateways.upsert(gateway.address, gateway);
|
|
43
|
-
}
|
|
44
|
-
if (gateways.size === 0) return calls;
|
|
45
|
-
const uniqueGateways = gateways.values();
|
|
46
|
-
const modes = await client.multicall({
|
|
47
|
-
allowFailure: false,
|
|
48
|
-
contracts: uniqueGateways.map(({ targetContract }) => ({
|
|
49
|
-
address: targetContract,
|
|
50
|
-
abi: iMidasGatewayModeAbi,
|
|
51
|
-
functionName: "mode"
|
|
52
|
-
}))
|
|
53
|
-
});
|
|
54
|
-
const prepended = [];
|
|
55
|
-
for (const [i, gateway] of uniqueGateways.entries()) {
|
|
56
|
-
if (modes[i] === MIDAS_MODE_PERMISSIONLESS) {
|
|
57
|
-
logger?.debug(`midas: gateway ${gateway.targetContract} is permissionless, nothing to greenlist`);
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
logger?.debug(`midas: greenlisting the credit account via gateway adapter ${gateway.address}`);
|
|
61
|
-
prepended.push({
|
|
62
|
-
target: gateway.address,
|
|
63
|
-
callData: receiveGreenlistCallData
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
return prepended.length > 0 ? [...prepended, ...calls] : calls;
|
|
67
|
-
}
|
|
68
|
-
//#endregion
|
|
69
|
-
export { prependMidasReceiveGreenlist };
|