@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,7 +1,7 @@
|
|
|
1
|
-
import { AbstractLPPriceFeedContract } from "
|
|
2
|
-
import { wstEthPriceFeedAbi } from "
|
|
3
|
-
import "
|
|
4
|
-
//#region src/onchain/market/pricefeeds/WstETHPriceFeed.ts
|
|
1
|
+
import { AbstractLPPriceFeedContract } from "../AbstractLPPriceFeed.js";
|
|
2
|
+
import { wstEthPriceFeedAbi } from "../../../abi/oracles.js";
|
|
3
|
+
import "../../../abi/index.js";
|
|
4
|
+
//#region src/onchain/market/pricefeeds/feeds/WstETHPriceFeed.ts
|
|
5
5
|
var WstETHPriceFeedContract = class extends AbstractLPPriceFeedContract {
|
|
6
6
|
constructor(options, args) {
|
|
7
7
|
super(options, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AbstractLPPriceFeedContract } from "
|
|
2
|
-
import { yearnPriceFeedAbi } from "
|
|
3
|
-
import "
|
|
4
|
-
//#region src/onchain/market/pricefeeds/YearnPriceFeed.ts
|
|
1
|
+
import { AbstractLPPriceFeedContract } from "../AbstractLPPriceFeed.js";
|
|
2
|
+
import { yearnPriceFeedAbi } from "../../../abi/oracles.js";
|
|
3
|
+
import "../../../abi/index.js";
|
|
4
|
+
//#region src/onchain/market/pricefeeds/feeds/YearnPriceFeed.ts
|
|
5
5
|
var YearnPriceFeedContract = class extends AbstractLPPriceFeedContract {
|
|
6
6
|
constructor(options, args) {
|
|
7
7
|
super(options, {
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import { AbstractPriceFeedContract } from "
|
|
2
|
-
import { zeroPriceFeedAbi } from "
|
|
3
|
-
import "
|
|
4
|
-
//#region src/onchain/market/pricefeeds/ZeroPriceFeed.ts
|
|
1
|
+
import { AbstractPriceFeedContract } from "../AbstractPriceFeed.js";
|
|
2
|
+
import { zeroPriceFeedAbi } from "../../../abi/oracles.js";
|
|
3
|
+
import "../../../abi/index.js";
|
|
4
|
+
//#region src/onchain/market/pricefeeds/feeds/ZeroPriceFeed.ts
|
|
5
5
|
var ZeroPriceFeedContract = class extends AbstractPriceFeedContract {
|
|
6
6
|
constructor(options, args) {
|
|
7
7
|
super(options, {
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import { BalancerStablePriceFeedContract } from "./BalancerStablePriceFeed.js";
|
|
2
|
+
import { BalancerWeightedPriceFeedContract } from "./BalancerWeightedPriceFeed.js";
|
|
3
|
+
import { BoundedPriceFeedContract } from "./BoundedPriceFeed.js";
|
|
4
|
+
import { CompositePriceFeedContract } from "./CompositePriceFeed.js";
|
|
5
|
+
import { ConstantPriceFeedContract } from "./ConstantPriceFeed.js";
|
|
6
|
+
import { CurveCryptoPriceFeedContract } from "./CurveCryptoPriceFeed.js";
|
|
7
|
+
import { CurveStablePriceFeedContract } from "./CurveStablePriceFeed.js";
|
|
8
|
+
import { CurveUSDPriceFeedContract } from "./CurveUSDPriceFeed.js";
|
|
9
|
+
import { Erc4626PriceFeedContract } from "./Erc4626PriceFeed.js";
|
|
10
|
+
import { ExternalPriceFeedContract } from "./ExternalPriceFeed.js";
|
|
11
|
+
import { MellowLRTPriceFeedContract } from "./MellowLRTPriceFeed.js";
|
|
12
|
+
import { PendleTWAPPTPriceFeed } from "./PendleTWAPPTPriceFeed.js";
|
|
13
|
+
import { PythPriceFeed } from "./PythPriceFeed.js";
|
|
14
|
+
import { RedstonePriceFeedContract } from "./RedstonePriceFeed.js";
|
|
15
|
+
import { WstETHPriceFeedContract } from "./WstETHPriceFeed.js";
|
|
16
|
+
import { YearnPriceFeedContract } from "./YearnPriceFeed.js";
|
|
17
|
+
import { ZeroPriceFeedContract } from "./ZeroPriceFeed.js";
|
|
18
|
+
export { BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CompositePriceFeedContract, ConstantPriceFeedContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, MellowLRTPriceFeedContract, PendleTWAPPTPriceFeed, PythPriceFeed, RedstonePriceFeedContract, WstETHPriceFeedContract, YearnPriceFeedContract, ZeroPriceFeedContract };
|
|
@@ -1,26 +1,32 @@
|
|
|
1
|
-
import { isUpdatablePriceFeed } from "./isUpdatablePriceFeed.js";
|
|
2
1
|
import { PriceFeedRef } from "./PriceFeedRef.js";
|
|
3
2
|
import { AbstractPriceFeedContract, PartialPriceFeedInitError } from "./AbstractPriceFeed.js";
|
|
4
3
|
import { AbstractLPPriceFeedContract, isLPPriceFeed } from "./AbstractLPPriceFeed.js";
|
|
5
|
-
import { BalancerStablePriceFeedContract } from "./BalancerStablePriceFeed.js";
|
|
6
|
-
import { BalancerWeightedPriceFeedContract } from "./BalancerWeightedPriceFeed.js";
|
|
7
|
-
import { BoundedPriceFeedContract } from "./BoundedPriceFeed.js";
|
|
8
|
-
import { CompositePriceFeedContract } from "./CompositePriceFeed.js";
|
|
9
|
-
import {
|
|
10
|
-
import {
|
|
11
|
-
import {
|
|
12
|
-
import {
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
15
|
-
import { MellowLRTPriceFeedContract } from "./MellowLRTPriceFeed.js";
|
|
16
|
-
import { PendleTWAPPTPriceFeed } from "./PendleTWAPPTPriceFeed.js";
|
|
17
|
-
import { PythPriceFeed } from "./PythPriceFeed.js";
|
|
18
|
-
import { RedstonePriceFeedContract } from "./RedstonePriceFeed.js";
|
|
4
|
+
import { BalancerStablePriceFeedContract } from "./feeds/BalancerStablePriceFeed.js";
|
|
5
|
+
import { BalancerWeightedPriceFeedContract } from "./feeds/BalancerWeightedPriceFeed.js";
|
|
6
|
+
import { BoundedPriceFeedContract } from "./feeds/BoundedPriceFeed.js";
|
|
7
|
+
import { CompositePriceFeedContract } from "./feeds/CompositePriceFeed.js";
|
|
8
|
+
import { ConstantPriceFeedContract } from "./feeds/ConstantPriceFeed.js";
|
|
9
|
+
import { CurveCryptoPriceFeedContract } from "./feeds/CurveCryptoPriceFeed.js";
|
|
10
|
+
import { CurveStablePriceFeedContract } from "./feeds/CurveStablePriceFeed.js";
|
|
11
|
+
import { CurveUSDPriceFeedContract } from "./feeds/CurveUSDPriceFeed.js";
|
|
12
|
+
import { Erc4626PriceFeedContract } from "./feeds/Erc4626PriceFeed.js";
|
|
13
|
+
import { ExternalPriceFeedContract } from "./feeds/ExternalPriceFeed.js";
|
|
14
|
+
import { MellowLRTPriceFeedContract } from "./feeds/MellowLRTPriceFeed.js";
|
|
15
|
+
import { PendleTWAPPTPriceFeed } from "./feeds/PendleTWAPPTPriceFeed.js";
|
|
16
|
+
import { PythPriceFeed } from "./feeds/PythPriceFeed.js";
|
|
17
|
+
import { RedstonePriceFeedContract } from "./feeds/RedstonePriceFeed.js";
|
|
18
|
+
import { WstETHPriceFeedContract } from "./feeds/WstETHPriceFeed.js";
|
|
19
|
+
import { YearnPriceFeedContract } from "./feeds/YearnPriceFeed.js";
|
|
20
|
+
import { ZeroPriceFeedContract } from "./feeds/ZeroPriceFeed.js";
|
|
21
|
+
import "./feeds/index.js";
|
|
22
|
+
import { PriceFeedRegistry } from "./PriceFeedRegistry.js";
|
|
23
|
+
import "./types.js";
|
|
19
24
|
import { fetchRedstonePayloads } from "./updates/fetchRedstonePayloads.js";
|
|
25
|
+
import { getRawPriceUpdates } from "./updates/getRawPriceUpdates.js";
|
|
26
|
+
import { isUpdatablePriceFeed } from "./updates/isUpdatablePriceFeed.js";
|
|
27
|
+
import { PriceUpdatesCache } from "./updates/PriceUpdatesCache.js";
|
|
28
|
+
import { RedstoneOptions, RedstoneUpdater } from "./updates/RedstoneUpdater.js";
|
|
29
|
+
import { updatableDependencies } from "./updates/updatableDependencies.js";
|
|
30
|
+
import { UpdatablePriceFeedRegistry } from "./updates/UpdatablePriceFeedRegistry.js";
|
|
20
31
|
import "./updates/index.js";
|
|
21
|
-
|
|
22
|
-
import { YearnPriceFeedContract } from "./YearnPriceFeed.js";
|
|
23
|
-
import { ZeroPriceFeedContract } from "./ZeroPriceFeed.js";
|
|
24
|
-
import { PriceFeedRegister } from "./PriceFeedsRegister.js";
|
|
25
|
-
import "./types.js";
|
|
26
|
-
export { AbstractLPPriceFeedContract, AbstractPriceFeedContract, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CompositePriceFeedContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, MellowLRTPriceFeedContract, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PriceFeedRef, PriceFeedRegister, PythPriceFeed, RedstonePriceFeedContract, WstETHPriceFeedContract, YearnPriceFeedContract, ZeroPriceFeedContract, fetchRedstonePayloads, getRawPriceUpdates, isLPPriceFeed, isUpdatablePriceFeed };
|
|
32
|
+
export { AbstractLPPriceFeedContract, AbstractPriceFeedContract, BalancerStablePriceFeedContract, BalancerWeightedPriceFeedContract, BoundedPriceFeedContract, CompositePriceFeedContract, ConstantPriceFeedContract, CurveCryptoPriceFeedContract, CurveStablePriceFeedContract, CurveUSDPriceFeedContract, Erc4626PriceFeedContract, ExternalPriceFeedContract, MellowLRTPriceFeedContract, PartialPriceFeedInitError, PendleTWAPPTPriceFeed, PriceFeedRef, PriceFeedRegistry, PriceUpdatesCache, PythPriceFeed, RedstoneOptions, RedstonePriceFeedContract, RedstoneUpdater, UpdatablePriceFeedRegistry, WstETHPriceFeedContract, YearnPriceFeedContract, ZeroPriceFeedContract, fetchRedstonePayloads, getRawPriceUpdates, isLPPriceFeed, isUpdatablePriceFeed, updatableDependencies };
|
|
@@ -0,0 +1,188 @@
|
|
|
1
|
+
import { createRawTx } from "../../../utils/createRawTx.js";
|
|
2
|
+
import { AP_PRICE_FEED_COMPRESSOR, AP_PRICE_FEED_STORE } from "../../../constants/address-provider.js";
|
|
3
|
+
import { ADDRESS_0X0 } from "../../../constants/addresses.js";
|
|
4
|
+
import { VERSION_RANGE_310 } from "../../../constants/versions.js";
|
|
5
|
+
import "../../../constants/index.js";
|
|
6
|
+
import "../../../utils/index.js";
|
|
7
|
+
import { priceFeedCompressorAbi } from "../../../../abi/compressors/priceFeedCompressor.js";
|
|
8
|
+
import { PriceFeedRegistry } from "../PriceFeedRegistry.js";
|
|
9
|
+
import { getRawPriceUpdates } from "./getRawPriceUpdates.js";
|
|
10
|
+
import { isUpdatablePriceFeed } from "./isUpdatablePriceFeed.js";
|
|
11
|
+
import { RedstoneUpdater } from "./RedstoneUpdater.js";
|
|
12
|
+
import { Hooks } from "../../../utils/internal/Hooks.js";
|
|
13
|
+
import "../../../utils/internal/index.js";
|
|
14
|
+
import { updatableDependencies } from "./updatableDependencies.js";
|
|
15
|
+
import { parseAbi } from "viem";
|
|
16
|
+
//#region src/onchain/market/pricefeeds/updates/UpdatablePriceFeedRegistry.ts
|
|
17
|
+
/**
|
|
18
|
+
* {@link PriceFeedRegistry} that also orchestrates off-chain price updates
|
|
19
|
+
* (Redstone, etc.).
|
|
20
|
+
**/
|
|
21
|
+
var UpdatablePriceFeedRegistry = class extends PriceFeedRegistry {
|
|
22
|
+
#hooks = new Hooks();
|
|
23
|
+
#updaters;
|
|
24
|
+
#latestUpdate;
|
|
25
|
+
constructor(sdk, opts = {}) {
|
|
26
|
+
super(sdk);
|
|
27
|
+
this.#updaters = [new RedstoneUpdater(sdk, opts.redstone)];
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* @internal
|
|
31
|
+
* Registers a callback for price-feed registry lifecycle events.
|
|
32
|
+
* @param event - Event name.
|
|
33
|
+
* @param handler - Callback to invoke.
|
|
34
|
+
**/
|
|
35
|
+
addHook = this.#hooks.addHook.bind(this.#hooks);
|
|
36
|
+
/**
|
|
37
|
+
* @internal
|
|
38
|
+
* Removes a previously registered hook.
|
|
39
|
+
* @param event - Event name.
|
|
40
|
+
* @param handler - Callback to remove.
|
|
41
|
+
**/
|
|
42
|
+
removeHook = this.#hooks.removeHook.bind(this.#hooks);
|
|
43
|
+
/**
|
|
44
|
+
* Generates transactions to push fresh off-chain prices to updatable feeds.
|
|
45
|
+
*
|
|
46
|
+
* @param priceFeeds - Top-level price feeds whose updatable dependencies
|
|
47
|
+
* will be resolved, or a filter (`{ main: true }` / `{ reserve: true }`)
|
|
48
|
+
* to gather feeds from all oracles. When omitted, all registered feeds
|
|
49
|
+
* are used.
|
|
50
|
+
**/
|
|
51
|
+
async generatePriceFeedsUpdateTxs(priceFeeds) {
|
|
52
|
+
let updateables = this.feeds;
|
|
53
|
+
let filterRemark = "";
|
|
54
|
+
if (priceFeeds) {
|
|
55
|
+
if (Array.isArray(priceFeeds)) updateables = priceFeeds.flatMap((pf) => updatableDependencies(pf));
|
|
56
|
+
else if ("main" in priceFeeds && priceFeeds.main) {
|
|
57
|
+
filterRemark = " main";
|
|
58
|
+
updateables = this.sdk.marketRegister.priceOracles.flatMap((o) => o.mainPriceFeeds.values()).flatMap((pf) => updatableDependencies(pf.priceFeed));
|
|
59
|
+
} else if ("reserve" in priceFeeds && priceFeeds.reserve) {
|
|
60
|
+
filterRemark = " reserve";
|
|
61
|
+
updateables = this.sdk.marketRegister.priceOracles.flatMap((o) => o.reservePriceFeeds.values()).flatMap((pf) => updatableDependencies(pf.priceFeed));
|
|
62
|
+
}
|
|
63
|
+
}
|
|
64
|
+
return this.#generateUpdateTxs(updateables, filterRemark);
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Similar to {@link generatePriceFeedsUpdateTxs}, but returns raw structures instead of transactions
|
|
68
|
+
* @param priceFeeds
|
|
69
|
+
* @returns
|
|
70
|
+
*/
|
|
71
|
+
async generatePriceFeedsUpdates(priceFeeds) {
|
|
72
|
+
const updates = await this.generatePriceFeedsUpdateTxs(priceFeeds);
|
|
73
|
+
return getRawPriceUpdates(updates);
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Similar to {@link generatePriceFeedsUpdates}, but returns raw transaction to PriceFeedStore.updatePrices
|
|
77
|
+
* @param priceFeeds
|
|
78
|
+
* @returns
|
|
79
|
+
*/
|
|
80
|
+
async getPriceFeedStoreUpdateTx(priceFeeds) {
|
|
81
|
+
const pfs = this.sdk.addressProvider.getAddress(AP_PRICE_FEED_STORE);
|
|
82
|
+
const updates = await this.generatePriceFeedsUpdates(priceFeeds);
|
|
83
|
+
return createRawTx(pfs, {
|
|
84
|
+
abi: parseAbi(["function updatePrices((address,bytes)[])"]),
|
|
85
|
+
functionName: "updatePrices",
|
|
86
|
+
args: [updates.map((u) => [u.priceFeed, u.data])]
|
|
87
|
+
});
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* Similar to {@link generatePriceFeedsUpdateTxs}, but will generate necessary price update transactions for external price feeds (not known to sdk)
|
|
91
|
+
* This does not add feeds to this registry, so they won't be implicitly included in future generatePriceFeedsUpdateTxs calls
|
|
92
|
+
* @param feeds
|
|
93
|
+
* @param block
|
|
94
|
+
* @returns
|
|
95
|
+
*/
|
|
96
|
+
async generateExternalPriceFeedsUpdateTxs(feeds, block) {
|
|
97
|
+
const [priceFeedCompressorAddress] = this.sdk.addressProvider.mustGetLatest(AP_PRICE_FEED_COMPRESSOR, VERSION_RANGE_310);
|
|
98
|
+
const blockParam = block ?? { blockNumber: this.sdk.currentBlock };
|
|
99
|
+
const leaves = (await this.client.readContract({
|
|
100
|
+
address: priceFeedCompressorAddress,
|
|
101
|
+
abi: priceFeedCompressorAbi,
|
|
102
|
+
functionName: "loadPriceFeedTree",
|
|
103
|
+
args: [feeds],
|
|
104
|
+
...blockParam,
|
|
105
|
+
gas: this.sdk.gasLimit
|
|
106
|
+
})).map((node) => this.get(node.baseParams.addr) ?? this.create(node)).filter(isUpdatablePriceFeed);
|
|
107
|
+
return this.#generateUpdateTxs(leaves, "");
|
|
108
|
+
}
|
|
109
|
+
/**
|
|
110
|
+
* Similar to {@link generateExternalPriceFeedsUpdateTxs}, but returns raw structures instead of transactions
|
|
111
|
+
* @param feeds
|
|
112
|
+
* @param block
|
|
113
|
+
* @returns
|
|
114
|
+
*/
|
|
115
|
+
async generateExternalPriceFeedsUpdates(feeds, block) {
|
|
116
|
+
const updates = await this.generateExternalPriceFeedsUpdateTxs(feeds, block);
|
|
117
|
+
return getRawPriceUpdates(updates);
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Loads PARTIAL information about all updatable price feeds from MarketCompressor
|
|
121
|
+
* Discovered price feeds are not saved anywhere in PriceFeedRegistry, and can later be used to load price feed updates
|
|
122
|
+
*/
|
|
123
|
+
async getPartialUpdatablePriceFeeds(configurators) {
|
|
124
|
+
const [priceFeedCompressorAddress] = this.sdk.addressProvider.mustGetLatest(AP_PRICE_FEED_COMPRESSOR, VERSION_RANGE_310);
|
|
125
|
+
this.logger?.debug({ configurators }, `calling getUpdatablePriceFeeds in block ${this.sdk.currentBlock}`);
|
|
126
|
+
const result = await this.client.readContract({
|
|
127
|
+
address: priceFeedCompressorAddress,
|
|
128
|
+
abi: priceFeedCompressorAbi,
|
|
129
|
+
functionName: "getUpdatablePriceFeeds",
|
|
130
|
+
args: [{
|
|
131
|
+
configurators,
|
|
132
|
+
pools: [],
|
|
133
|
+
underlying: ADDRESS_0X0
|
|
134
|
+
}],
|
|
135
|
+
blockNumber: this.sdk.currentBlock,
|
|
136
|
+
gas: this.sdk.gasLimit
|
|
137
|
+
});
|
|
138
|
+
this.logger?.debug(`loaded ${result.length} partial updatable price feeds in block ${this.sdk.currentBlock}`);
|
|
139
|
+
return result.map((baseParams) => this.create({ baseParams }));
|
|
140
|
+
}
|
|
141
|
+
/**
|
|
142
|
+
* @internal
|
|
143
|
+
* Diagnostic snapshot of the most recent price-update round, or
|
|
144
|
+
* `undefined` if no updates have been generated yet.
|
|
145
|
+
**/
|
|
146
|
+
get latestUpdate() {
|
|
147
|
+
return this.#latestUpdate;
|
|
148
|
+
}
|
|
149
|
+
/**
|
|
150
|
+
* @internal
|
|
151
|
+
* Returns true if any of the updaters are in historical mode
|
|
152
|
+
*/
|
|
153
|
+
get historical() {
|
|
154
|
+
return this.#updaters.some((u) => u.historical);
|
|
155
|
+
}
|
|
156
|
+
async #generateUpdateTxs(updateables, filterRemark) {
|
|
157
|
+
if (updateables.length === 0) return {
|
|
158
|
+
txs: [],
|
|
159
|
+
timestamp: 0
|
|
160
|
+
};
|
|
161
|
+
const txs = [];
|
|
162
|
+
const latestUpdate = {
|
|
163
|
+
updates: [],
|
|
164
|
+
timestamp: Math.floor(Date.now() / 1e3)
|
|
165
|
+
};
|
|
166
|
+
const updates = (await Promise.all(this.#updaters.map((u) => u.getUpdateTxs([...updateables]).catch(() => [])))).flat();
|
|
167
|
+
let maxTimestamp = 0;
|
|
168
|
+
for (const tx of updates) {
|
|
169
|
+
const { data } = tx;
|
|
170
|
+
const { timestamp } = data;
|
|
171
|
+
if (timestamp > maxTimestamp) maxTimestamp = timestamp;
|
|
172
|
+
txs.push(tx);
|
|
173
|
+
latestUpdate.updates.push(data);
|
|
174
|
+
}
|
|
175
|
+
txs.sort((a, b) => a.raw.to.toLowerCase().localeCompare(b.raw.to.toLowerCase()));
|
|
176
|
+
const result = {
|
|
177
|
+
txs,
|
|
178
|
+
timestamp: maxTimestamp
|
|
179
|
+
};
|
|
180
|
+
const tsDelta = BigInt(maxTimestamp) - this.sdk.timestamp;
|
|
181
|
+
this.logger?.debug(`generated ${txs.length}${filterRemark} price feed update transactions, timestamp: ${maxTimestamp} (delta ${tsDelta})`);
|
|
182
|
+
if (txs.length) await this.#hooks.triggerHooks("updatesGenerated", result);
|
|
183
|
+
this.#latestUpdate = latestUpdate;
|
|
184
|
+
return result;
|
|
185
|
+
}
|
|
186
|
+
};
|
|
187
|
+
//#endregion
|
|
188
|
+
export { UpdatablePriceFeedRegistry };
|
package/dist/esm/onchain/market/pricefeeds/{getRawPriceUpdates.js → updates/getRawPriceUpdates.js}
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { iUpdatablePriceFeedAbi } from "
|
|
1
|
+
import { iUpdatablePriceFeedAbi } from "../../../../abi/iUpdatablePriceFeed.js";
|
|
2
2
|
import { decodeFunctionData } from "viem";
|
|
3
|
-
//#region src/onchain/market/pricefeeds/getRawPriceUpdates.ts
|
|
3
|
+
//#region src/onchain/market/pricefeeds/updates/getRawPriceUpdates.ts
|
|
4
4
|
function getRawPriceUpdates(updates) {
|
|
5
5
|
return updates.txs.map((tx) => {
|
|
6
6
|
const data = decodeFunctionData({
|
|
@@ -1,4 +1,8 @@
|
|
|
1
1
|
import { fetchRedstonePayloads } from "./fetchRedstonePayloads.js";
|
|
2
|
+
import { getRawPriceUpdates } from "./getRawPriceUpdates.js";
|
|
3
|
+
import { isUpdatablePriceFeed } from "./isUpdatablePriceFeed.js";
|
|
2
4
|
import { PriceUpdatesCache } from "./PriceUpdatesCache.js";
|
|
3
5
|
import { RedstoneOptions, RedstoneUpdater } from "./RedstoneUpdater.js";
|
|
4
|
-
|
|
6
|
+
import { updatableDependencies } from "./updatableDependencies.js";
|
|
7
|
+
import { UpdatablePriceFeedRegistry } from "./UpdatablePriceFeedRegistry.js";
|
|
8
|
+
export { PriceUpdatesCache, RedstoneOptions, RedstoneUpdater, UpdatablePriceFeedRegistry, fetchRedstonePayloads, getRawPriceUpdates, isUpdatablePriceFeed, updatableDependencies };
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { isUpdatablePriceFeed } from "./isUpdatablePriceFeed.js";
|
|
2
|
+
//#region src/onchain/market/pricefeeds/updates/updatableDependencies.ts
|
|
3
|
+
/**
|
|
4
|
+
* Collects updatable feeds in this feed's dependency tree, including this
|
|
5
|
+
* feed itself when it is updatable.
|
|
6
|
+
**/
|
|
7
|
+
function updatableDependencies(feed) {
|
|
8
|
+
if (!feed.loaded) return [feed];
|
|
9
|
+
const underlying = feed.underlyingPriceFeeds.flatMap((ref) => updatableDependencies(ref.priceFeed));
|
|
10
|
+
return isUpdatablePriceFeed(feed) ? [feed, ...underlying] : underlying;
|
|
11
|
+
}
|
|
12
|
+
//#endregion
|
|
13
|
+
export { updatableDependencies };
|
|
@@ -1,8 +1,5 @@
|
|
|
1
1
|
import { AddressMap } from "../../utils/AddressMap.js";
|
|
2
2
|
import { bytes32ToString } from "../../utils/bytes32ToString.js";
|
|
3
|
-
import { AP_RWA_COMPRESSOR } from "../../constants/address-provider.js";
|
|
4
|
-
import { VERSION_RANGE_310 } from "../../constants/versions.js";
|
|
5
|
-
import "../../constants/index.js";
|
|
6
3
|
import "../../utils/index.js";
|
|
7
4
|
import { SDKConstruct } from "../../base/SDKConstruct.js";
|
|
8
5
|
import { RWA_ON_DEMAND_LP_MONOPOLIZED, RWA_UNDERLYING_DEFAULT, RWA_UNDERLYING_ON_DEMAND } from "../../base/token-types.js";
|
|
@@ -14,6 +11,7 @@ import { SecuritizeRWAFactory } from "./securitize/SecuritizeRWAFactory.js";
|
|
|
14
11
|
import "./securitize/index.js";
|
|
15
12
|
import { decodeAbiParameters } from "viem";
|
|
16
13
|
//#region src/onchain/market/rwa/RWARegistry.ts
|
|
14
|
+
const RWA_COMPRESSOR_ADDRESS = "0x9Bff226505632930BA1897E7943e90A2f7D0D9f7";
|
|
17
15
|
/**
|
|
18
16
|
* Registry of RWA underlying tokens and RWA factory contracts.
|
|
19
17
|
*
|
|
@@ -41,11 +39,10 @@ var RWARegistry = class extends SDKConstruct {
|
|
|
41
39
|
getLoadMulticalls(configurators, rwaFactories = []) {
|
|
42
40
|
this.#requestedFactories = rwaFactories;
|
|
43
41
|
if (!rwaFactories.length) return [];
|
|
44
|
-
const [rwaCompressorAddress] = this.sdk.addressProvider.mustGetLatest(AP_RWA_COMPRESSOR, VERSION_RANGE_310);
|
|
45
42
|
return [{
|
|
46
43
|
call: {
|
|
47
44
|
abi: iRWACompressorAbi,
|
|
48
|
-
address:
|
|
45
|
+
address: RWA_COMPRESSOR_ADDRESS,
|
|
49
46
|
functionName: "getRWAMarketsData",
|
|
50
47
|
args: [configurators, rwaFactories]
|
|
51
48
|
},
|
|
@@ -83,10 +80,9 @@ var RWARegistry = class extends SDKConstruct {
|
|
|
83
80
|
let factories = this.#factories.values();
|
|
84
81
|
if (factories_?.length) factories = factories_.map((f) => this.#factories.mustGet(f));
|
|
85
82
|
if (!factories.length) return [];
|
|
86
|
-
const [rwaCompressorAddress] = this.sdk.addressProvider.mustGetLatest(AP_RWA_COMPRESSOR, VERSION_RANGE_310);
|
|
87
83
|
const resp = await this.client.readContract({
|
|
88
84
|
abi: iRWACompressorAbi,
|
|
89
|
-
address:
|
|
85
|
+
address: RWA_COMPRESSOR_ADDRESS,
|
|
90
86
|
functionName: "getRWAInvestorData",
|
|
91
87
|
args: [investor, factories.map((f) => f.address)],
|
|
92
88
|
blockNumber
|
|
@@ -284,4 +280,4 @@ var RWARegistry = class extends SDKConstruct {
|
|
|
284
280
|
}
|
|
285
281
|
};
|
|
286
282
|
//#endregion
|
|
287
|
-
export { RWARegistry };
|
|
283
|
+
export { RWARegistry, RWA_COMPRESSOR_ADDRESS };
|
|
@@ -7,6 +7,6 @@ import { SecuritizeDegenNFT } from "./securitize/SecuritizeDegenNFT.js";
|
|
|
7
7
|
import { SecuritizeLiquidatorContract } from "./securitize/SecuritizeLiquidatorContract.js";
|
|
8
8
|
import { SecuritizeRWAFactory } from "./securitize/SecuritizeRWAFactory.js";
|
|
9
9
|
import "./securitize/index.js";
|
|
10
|
-
import { RWARegistry } from "./RWARegistry.js";
|
|
10
|
+
import { RWARegistry, RWA_COMPRESSOR_ADDRESS } from "./RWARegistry.js";
|
|
11
11
|
import { isRWAFactory } from "./types.js";
|
|
12
|
-
export { DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, MidasDegenNFT, MidasLiquidatorContract, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWARegistry, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeRWAFactory, isRWAFactory };
|
|
12
|
+
export { DEGEN_NFT_MIDAS, DEGEN_NFT_SECURITIZE, MidasDegenNFT, MidasLiquidatorContract, PHANTOM_TOKEN_MIDAS_REDEMPTION, PHANTOM_TOKEN_SECURITIZE_REDEMPTION, RWARegistry, RWA_COMPRESSOR_ADDRESS, RWA_LIQUIDATOR_MIDAS, RWA_LIQUIDATOR_SECURITIZE, SecuritizeDegenNFT, SecuritizeLiquidatorContract, SecuritizeRWAFactory, isRWAFactory };
|
|
@@ -5,14 +5,23 @@ import "../../adapters/abi/index.js";
|
|
|
5
5
|
import { iMidasDegenNFTAbi } from "../../../../abi/rwa/iMidasDegenNFT.js";
|
|
6
6
|
import "./constants.js";
|
|
7
7
|
import { iMidasAccessControlAbi } from "../../../../abi/rwa/iMidasAccessControl.js";
|
|
8
|
+
import { KYC_REGISTRATION_LINKS } from "../../../../model/rwa.js";
|
|
9
|
+
import "../../../../model/index.js";
|
|
8
10
|
import { decodeAbiParameters } from "viem";
|
|
9
11
|
//#region src/onchain/market/rwa/midas/MidasDegenNFT.ts
|
|
10
12
|
const abi = iMidasDegenNFTAbi;
|
|
13
|
+
/**
|
|
14
|
+
* Midas is an RWA protocol without a factory: accounts open through the plain
|
|
15
|
+
* facade. Only a Permissioned-mode gateway deploys a degen NFT, so a Midas
|
|
16
|
+
* strategy that does not require KYC has no NFT at all.
|
|
17
|
+
*/
|
|
11
18
|
var MidasDegenNFT = class extends BaseContract {
|
|
12
19
|
protocol = "midas";
|
|
20
|
+
registrationLink = KYC_REGISTRATION_LINKS.midas;
|
|
13
21
|
gateway;
|
|
14
22
|
accessControl;
|
|
15
23
|
greenlistedRole;
|
|
24
|
+
#mToken;
|
|
16
25
|
constructor(sdk, baseParams) {
|
|
17
26
|
super(sdk, {
|
|
18
27
|
...baseParams,
|
|
@@ -30,9 +39,26 @@ var MidasDegenNFT = class extends BaseContract {
|
|
|
30
39
|
this.accessControl = accessControl;
|
|
31
40
|
this.greenlistedRole = greenlistedRole;
|
|
32
41
|
}
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
42
|
+
async getTokens() {
|
|
43
|
+
return [await this.#mTokenAddress()];
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Same predicate `MidasDegenNFT.burn` reverts on; the mToken rides along in
|
|
47
|
+
* the batch until it is cached.
|
|
48
|
+
*/
|
|
49
|
+
async getOpenAccountRequirements(wallet, _props) {
|
|
50
|
+
const token = this.#mToken;
|
|
51
|
+
if (token !== void 0) return {
|
|
52
|
+
protocol: "midas",
|
|
53
|
+
token,
|
|
54
|
+
greenlisted: await this.client.readContract({
|
|
55
|
+
abi: iMidasAccessControlAbi,
|
|
56
|
+
address: this.accessControl,
|
|
57
|
+
functionName: "hasRole",
|
|
58
|
+
args: [this.greenlistedRole, wallet]
|
|
59
|
+
})
|
|
60
|
+
};
|
|
61
|
+
const [greenlisted, mToken] = await this.client.multicall({
|
|
36
62
|
allowFailure: false,
|
|
37
63
|
contracts: [{
|
|
38
64
|
abi: iMidasAccessControlAbi,
|
|
@@ -45,11 +71,25 @@ var MidasDegenNFT = class extends BaseContract {
|
|
|
45
71
|
functionName: "mToken"
|
|
46
72
|
}]
|
|
47
73
|
});
|
|
74
|
+
this.#mToken = mToken;
|
|
48
75
|
return {
|
|
49
|
-
|
|
50
|
-
token
|
|
76
|
+
protocol: "midas",
|
|
77
|
+
token: mToken,
|
|
78
|
+
greenlisted
|
|
51
79
|
};
|
|
52
80
|
}
|
|
81
|
+
isRegistered(requirements) {
|
|
82
|
+
return requirements.greenlisted;
|
|
83
|
+
}
|
|
84
|
+
getMissingRequirements() {}
|
|
85
|
+
async #mTokenAddress() {
|
|
86
|
+
if (this.#mToken === void 0) this.#mToken = await this.client.readContract({
|
|
87
|
+
abi: iMidasGatewayV311Abi,
|
|
88
|
+
address: this.gateway,
|
|
89
|
+
functionName: "mToken"
|
|
90
|
+
});
|
|
91
|
+
return this.#mToken;
|
|
92
|
+
}
|
|
53
93
|
};
|
|
54
94
|
//#endregion
|
|
55
95
|
export { MidasDegenNFT };
|
|
@@ -1,13 +1,23 @@
|
|
|
1
|
+
import { AddressSet } from "../../../utils/AddressSet.js";
|
|
2
|
+
import "../../../utils/index.js";
|
|
1
3
|
import { BaseContract } from "../../../base/BaseContract.js";
|
|
2
4
|
import "../../../base/index.js";
|
|
5
|
+
import { KYC_REGISTRATION_LINKS } from "../../../../model/rwa.js";
|
|
6
|
+
import "../../../../model/index.js";
|
|
3
7
|
import { DEGEN_NFT_SECURITIZE } from "./constants.js";
|
|
4
8
|
import { iSecuritizeDegenNFTAbi } from "../../../../abi/rwa/iSecuritizeDegenNFT.js";
|
|
5
|
-
import { isAddressEqual } from "viem";
|
|
6
9
|
//#region src/onchain/market/rwa/securitize/SecuritizeDegenNFT.ts
|
|
7
10
|
const abi = iSecuritizeDegenNFTAbi;
|
|
11
|
+
/**
|
|
12
|
+
* Securitize always has a factory, which deploys this NFT. DS-token data,
|
|
13
|
+
* registrars and cached signatures live here; the factory only builds txs
|
|
14
|
+
* and looks up investor/wallet addresses.
|
|
15
|
+
*/
|
|
8
16
|
var SecuritizeDegenNFT = class extends BaseContract {
|
|
9
17
|
protocol = "securitize";
|
|
18
|
+
registrationLink = KYC_REGISTRATION_LINKS.securitize;
|
|
10
19
|
factory;
|
|
20
|
+
#sdk;
|
|
11
21
|
constructor(sdk, address, factory) {
|
|
12
22
|
super(sdk, {
|
|
13
23
|
addr: address,
|
|
@@ -16,19 +26,54 @@ var SecuritizeDegenNFT = class extends BaseContract {
|
|
|
16
26
|
name: "SecuritizeDegenNFT",
|
|
17
27
|
abi
|
|
18
28
|
});
|
|
29
|
+
this.#sdk = sdk;
|
|
19
30
|
this.factory = factory;
|
|
20
31
|
}
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
32
|
+
async getTokens() {
|
|
33
|
+
return this.factory.getTokens();
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* Registration on Securitize is the protocol-side KYC step; pending
|
|
37
|
+
* EIP-712 signatures are tx-side leftover, not KYC.
|
|
38
|
+
*/
|
|
39
|
+
async getOpenAccountRequirements(wallet, props) {
|
|
40
|
+
const tokensToRegister = new AddressSet(this.factory.getTokens()).has(props.tokenOutAddress) ? new AddressSet([props.tokenOutAddress]) : new AddressSet();
|
|
41
|
+
if (tokensToRegister.size === 0) return {
|
|
42
|
+
protocol: "securitize",
|
|
43
|
+
factory: this.factory.address,
|
|
44
|
+
securitizeTokensToRegister: [],
|
|
45
|
+
tokensToRegister: [],
|
|
46
|
+
requiredSignatures: []
|
|
47
|
+
};
|
|
48
|
+
const [investorData] = await this.#sdk.rwa.getInvestorData(wallet, [this.factory.address]);
|
|
49
|
+
const registredTokens = new AddressSet(investorData.registeredTokens);
|
|
50
|
+
const signedTokens = new AddressSet(investorData.cachedSignatures.map((s) => s.token));
|
|
51
|
+
const unsignedTokens = tokensToRegister.difference(signedTokens);
|
|
52
|
+
const securitizeTokensToRegister = tokensToRegister.difference(registredTokens);
|
|
53
|
+
const requiredSignatures = investorData.registerVaultMessages.filter((m) => unsignedTokens.has(m.message.token));
|
|
54
|
+
return {
|
|
55
|
+
protocol: "securitize",
|
|
56
|
+
factory: this.factory.address,
|
|
57
|
+
securitizeTokensToRegister: Array.from(securitizeTokensToRegister),
|
|
58
|
+
tokensToRegister: Array.from(tokensToRegister),
|
|
59
|
+
requiredSignatures
|
|
27
60
|
};
|
|
28
|
-
|
|
61
|
+
}
|
|
62
|
+
isRegistered(requirements) {
|
|
63
|
+
return requirements.securitizeTokensToRegister.length === 0;
|
|
64
|
+
}
|
|
65
|
+
/**
|
|
66
|
+
* A required signature is omitted when `providedArgs.signaturesToCache`
|
|
67
|
+
* already carries a signature for the same token: the transaction caches it
|
|
68
|
+
* on-chain as part of the operation.
|
|
69
|
+
*/
|
|
70
|
+
getMissingRequirements(requirements, providedArgs) {
|
|
71
|
+
const providedTokens = new AddressSet((providedArgs?.signaturesToCache ?? []).map((s) => s.token));
|
|
72
|
+
const requiredSignatures = requirements.requiredSignatures.filter((message) => !providedTokens.has(message.message.token));
|
|
73
|
+
if (requiredSignatures.length === 0) return;
|
|
29
74
|
return {
|
|
30
|
-
|
|
31
|
-
|
|
75
|
+
protocol: "securitize",
|
|
76
|
+
requiredSignatures
|
|
32
77
|
};
|
|
33
78
|
}
|
|
34
79
|
};
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import { AddressMap } from "../../../utils/AddressMap.js";
|
|
2
|
-
import { AddressSet } from "../../../utils/AddressSet.js";
|
|
3
2
|
import "../../../utils/index.js";
|
|
4
3
|
import { BaseContract } from "../../../base/BaseContract.js";
|
|
5
4
|
import "../../../base/index.js";
|
|
@@ -11,7 +10,6 @@ import { decodeAbiParameters } from "viem";
|
|
|
11
10
|
//#region src/onchain/market/rwa/securitize/SecuritizeRWAFactory.ts
|
|
12
11
|
const abi = iSecuritizeRWAFactoryAbi;
|
|
13
12
|
var SecuritizeRWAFactory = class extends BaseContract {
|
|
14
|
-
#sdk;
|
|
15
13
|
#investorCache = new AddressMap();
|
|
16
14
|
degenNFT;
|
|
17
15
|
owner;
|
|
@@ -23,7 +21,6 @@ var SecuritizeRWAFactory = class extends BaseContract {
|
|
|
23
21
|
name: "SecuritizeRWAFactory",
|
|
24
22
|
abi
|
|
25
23
|
});
|
|
26
|
-
this.#sdk = sdk;
|
|
27
24
|
const decoded = decodeAbiParameters([
|
|
28
25
|
{
|
|
29
26
|
name: "owner",
|
|
@@ -184,40 +181,6 @@ var SecuritizeRWAFactory = class extends BaseContract {
|
|
|
184
181
|
});
|
|
185
182
|
}
|
|
186
183
|
/**
|
|
187
|
-
* {@inheritDoc IRWAFactory.getOpenAccountRequirements}
|
|
188
|
-
*/
|
|
189
|
-
async getOpenAccountRequirements(investor, props) {
|
|
190
|
-
const [investorData] = await this.#sdk.rwa.getInvestorData(investor, [this.address]);
|
|
191
|
-
const tokensToRegister = new AddressSet([props.tokenOutAddress]);
|
|
192
|
-
const registredTokens = new AddressSet(investorData.registeredTokens);
|
|
193
|
-
const signedTokens = new AddressSet(investorData.cachedSignatures.map((s) => s.token));
|
|
194
|
-
const unsignedTokens = tokensToRegister.difference(signedTokens);
|
|
195
|
-
const securitizeTokensToRegister = tokensToRegister.difference(registredTokens);
|
|
196
|
-
const requiredSignatures = investorData.registerVaultMessages.filter((m) => unsignedTokens.has(m.message.token));
|
|
197
|
-
return {
|
|
198
|
-
type: RWA_FACTORY_SECURITIZE,
|
|
199
|
-
securitizeTokensToRegister: Array.from(securitizeTokensToRegister),
|
|
200
|
-
tokensToRegister: Array.from(tokensToRegister),
|
|
201
|
-
requiredSignatures
|
|
202
|
-
};
|
|
203
|
-
}
|
|
204
|
-
/**
|
|
205
|
-
* {@inheritDoc IRWAFactory.getMissingRequirements}
|
|
206
|
-
*
|
|
207
|
-
* A required signature is omitted when `providedArgs.signaturesToCache`
|
|
208
|
-
* already carries a signature for the same token: the transaction caches it
|
|
209
|
-
* on-chain as part of the operation.
|
|
210
|
-
*/
|
|
211
|
-
getMissingRequirements(requirements, providedArgs) {
|
|
212
|
-
const providedTokens = new AddressSet((providedArgs?.signaturesToCache ?? []).map((s) => s.token));
|
|
213
|
-
const requiredSignatures = requirements.requiredSignatures.filter((message) => !providedTokens.has(message.message.token));
|
|
214
|
-
if (requiredSignatures.length === 0) return;
|
|
215
|
-
return {
|
|
216
|
-
type: RWA_FACTORY_SECURITIZE,
|
|
217
|
-
requiredSignatures
|
|
218
|
-
};
|
|
219
|
-
}
|
|
220
|
-
/**
|
|
221
184
|
* {@inheritDoc IRWAFactory.openCreditAccount}
|
|
222
185
|
*/
|
|
223
186
|
openCreditAccount(creditManager, calls, args) {
|