@morpho-org/morpho-sdk 10.0.0-next.0 → 10.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +104 -12
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +1 -5
- package/lib/cjs/actions/blue/common.js +4 -2
- package/lib/cjs/actions/blue/withdrawBuyCallback.js +2 -1
- package/lib/cjs/actions/bundles/common.js +20 -14
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +2 -1
- package/lib/cjs/actions/midnight/cancelOffers.js +2 -1
- package/lib/cjs/actions/midnight/supplyCollateralBatch.js +4 -2
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +2 -1
- package/lib/cjs/actions/midnight/takeBorrow.js +2 -1
- package/lib/cjs/actions/midnight/takeLend.js +2 -1
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +2 -1
- package/lib/cjs/actions/midnight/takeWithdraw.js +2 -1
- package/lib/cjs/actions/midnight/withdrawCollateralBatch.js +4 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +2 -11
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +2 -1
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +2 -1
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +6 -3
- package/lib/cjs/actions/vaultV1/migrateToV2.js +1 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +4 -2
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +4 -2
- package/lib/cjs/blue/abis.d.ts +1 -1
- package/lib/cjs/blue/abis.js +1 -5
- package/lib/cjs/blue/entities.d.ts +4 -4
- package/lib/cjs/blue/entities.js +1 -3
- package/lib/cjs/blue/errors.d.ts +2 -2
- package/lib/cjs/blue/errors.js +1 -5
- package/lib/cjs/blue/fetch.d.ts +2 -2
- package/lib/cjs/blue/fetch.js +1 -3
- package/lib/cjs/blue/utils.d.ts +1 -1
- package/lib/cjs/blue/utils.js +1 -2
- package/lib/cjs/entities/blue/blue.js +8 -4
- package/lib/cjs/entities/index.d.ts +4 -4
- package/lib/cjs/entities/index.js +1 -3
- package/lib/cjs/entities/midnight/deadline.js +2 -1
- package/lib/cjs/entities/midnight/midnight.js +14 -7
- package/lib/cjs/entities/midnight/publication.js +73 -44
- package/lib/cjs/entities/requirements/assertContractCode.js +4 -2
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +9 -13
- package/lib/cjs/entities/requirements/getErc2612Permit.js +10 -5
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +2 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +7 -1
- package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.d.ts +21 -0
- package/lib/cjs/entities/requirements/getVaultV1InKindRedeemRequirements.js +111 -0
- package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.d.ts +20 -0
- package/lib/cjs/entities/requirements/getVaultV2ForceWithdrawRequirements.js +76 -0
- package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.d.ts +21 -0
- package/lib/cjs/entities/requirements/getVaultV2InKindRedeemRequirements.js +93 -0
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.d.ts +25 -0
- package/lib/cjs/entities/vaultV1/inKindRedeemQuote.js +85 -0
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.d.ts +20 -0
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.js +37 -0
- package/lib/cjs/entities/vaultV1/vaultV1.js +51 -181
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.d.ts +25 -0
- package/lib/cjs/entities/vaultV2/forceWithdrawQuote.js +189 -0
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.d.ts +28 -0
- package/lib/cjs/entities/vaultV2/inKindRedeemQuote.js +110 -0
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +8 -34
- package/lib/cjs/entities/vaultV2/vaultV2.js +62 -429
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +2 -3
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +346 -234
- package/lib/cjs/errors.d.ts +4 -4
- package/lib/cjs/errors.js +6 -7
- package/lib/cjs/fetch.d.ts +2 -2
- package/lib/cjs/fetch.js +1 -3
- package/lib/cjs/helpers/deadShares.js +34 -19
- package/lib/cjs/helpers/encodeMidnightCalldata.js +4 -2
- package/lib/cjs/helpers/metadata.js +12 -6
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +10 -5
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +6 -3
- package/lib/cjs/helpers/utilization.js +10 -5
- package/lib/cjs/helpers/validate.js +12 -6
- package/lib/cjs/helpers/validateMidnightBounds.js +2 -1
- package/lib/cjs/helpers/validateMidnightCollateralBatch.js +2 -1
- package/lib/cjs/helpers/validateMidnightPublication.js +4 -2
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +44 -22
- package/lib/cjs/helpers/validatePositiveInput.js +2 -1
- package/lib/cjs/helpers/validateTakeableOffers.js +2 -1
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +14 -7
- package/lib/cjs/index.d.ts +2 -2
- package/lib/cjs/index.js +10 -1
- package/lib/cjs/midnight/errors.d.ts +1 -2
- package/lib/cjs/midnight/errors.js +4 -5
- package/lib/cjs/transactionPlan/approval.js +12 -1
- package/lib/cjs/transactionPlan/deposit.d.ts +22 -0
- package/lib/cjs/transactionPlan/deposit.js +139 -0
- package/lib/cjs/transactionPlan/error.d.ts +10 -8
- package/lib/cjs/transactionPlan/error.js +10 -8
- package/lib/cjs/transactionPlan/getTokenPermit.js +2 -1
- package/lib/cjs/transactionPlan/index.d.ts +18 -0
- package/lib/cjs/transactionPlan/index.js +23 -5
- package/lib/cjs/transactionPlan/intent.d.ts +3 -3
- package/lib/cjs/transactionPlan/intent.js +14 -7
- package/lib/cjs/transactionPlan/permit.d.ts +1 -1
- package/lib/cjs/transactionPlan/permit.js +86 -20
- package/lib/cjs/transactionPlan/plan.d.ts +16 -6
- package/lib/cjs/transactionPlan/plan.js +72 -22
- package/lib/cjs/transactionPlan/redeem.d.ts +18 -0
- package/lib/cjs/transactionPlan/redeem.js +63 -0
- package/lib/cjs/transactionPlan/requirements.d.ts +4 -3
- package/lib/cjs/transactionPlan/requirements.js +12 -6
- package/lib/cjs/transactionPlan/serde.d.ts +2 -2
- package/lib/cjs/transactionPlan/serde.js +41 -15
- package/lib/cjs/transactionPlan/shareSpending.d.ts +18 -0
- package/lib/cjs/transactionPlan/shareSpending.js +50 -0
- package/lib/cjs/transactionPlan/types.d.ts +117 -11
- package/lib/cjs/transactionPlan/validateActions.js +11 -1
- package/lib/cjs/transactionPlan/validation.js +6 -3
- package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +93 -0
- package/lib/cjs/transactionPlan/vaultv1/deposit.js +94 -0
- package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.d.ts +96 -0
- package/lib/cjs/transactionPlan/vaultv1/inKindRedeem.js +203 -0
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +94 -0
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +217 -0
- package/lib/cjs/transactionPlan/vaultv1/redeem.d.ts +69 -0
- package/lib/cjs/transactionPlan/vaultv1/redeem.js +78 -0
- package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +77 -0
- package/lib/cjs/transactionPlan/vaultv1/withdraw.js +88 -0
- package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +14 -31
- package/lib/cjs/transactionPlan/vaultv2/deposit.js +15 -141
- package/lib/cjs/transactionPlan/vaultv2/forceRedeem.d.ts +74 -0
- package/lib/cjs/transactionPlan/vaultv2/forceRedeem.js +155 -0
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +98 -0
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +206 -0
- package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.d.ts +113 -0
- package/lib/cjs/transactionPlan/vaultv2/inKindRedeem.js +206 -0
- package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +84 -0
- package/lib/cjs/transactionPlan/vaultv2/redeem.js +86 -0
- package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +14 -27
- package/lib/cjs/transactionPlan/vaultv2/withdraw.js +17 -124
- package/lib/cjs/transactionPlan/version.js +2 -1
- package/lib/cjs/transactionPlan/withdraw.d.ts +18 -0
- package/lib/cjs/transactionPlan/withdraw.js +94 -0
- package/lib/cjs/types/action.js +16 -8
- package/lib/cjs/types/error.d.ts +8 -1
- package/lib/cjs/types/error.js +10 -1
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +2 -4
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/blue/common.js +4 -2
- package/lib/esm/actions/blue/withdrawBuyCallback.js +2 -1
- package/lib/esm/actions/bundles/common.js +20 -14
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +2 -1
- package/lib/esm/actions/midnight/cancelOffers.js +2 -1
- package/lib/esm/actions/midnight/supplyCollateralBatch.js +4 -2
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +2 -1
- package/lib/esm/actions/midnight/takeBorrow.js +2 -1
- package/lib/esm/actions/midnight/takeLend.js +2 -1
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +2 -1
- package/lib/esm/actions/midnight/takeWithdraw.js +2 -1
- package/lib/esm/actions/midnight/withdrawCollateralBatch.js +4 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +4 -13
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +2 -1
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +2 -1
- package/lib/esm/actions/vaultV1/inKindRedeem.js +6 -3
- package/lib/esm/actions/vaultV1/migrateToV2.js +1 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +4 -2
- package/lib/esm/actions/vaultV2/inKindRedeem.js +4 -2
- package/lib/esm/blue/abis.d.ts +1 -1
- package/lib/esm/blue/abis.js +1 -1
- package/lib/esm/blue/entities.d.ts +4 -4
- package/lib/esm/blue/entities.js +2 -2
- package/lib/esm/blue/errors.d.ts +2 -2
- package/lib/esm/blue/errors.js +2 -2
- package/lib/esm/blue/fetch.d.ts +2 -2
- package/lib/esm/blue/fetch.js +2 -2
- package/lib/esm/blue/utils.d.ts +1 -1
- package/lib/esm/blue/utils.js +1 -1
- package/lib/esm/entities/blue/blue.js +8 -4
- package/lib/esm/entities/index.d.ts +4 -4
- package/lib/esm/entities/index.js +2 -2
- package/lib/esm/entities/midnight/deadline.js +2 -1
- package/lib/esm/entities/midnight/midnight.js +14 -7
- package/lib/esm/entities/midnight/publication.js +73 -44
- package/lib/esm/entities/requirements/assertContractCode.js +4 -2
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +10 -14
- package/lib/esm/entities/requirements/getErc2612Permit.js +10 -5
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +2 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +7 -1
- package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.d.ts +21 -0
- package/lib/esm/entities/requirements/getVaultV1InKindRedeemRequirements.js +108 -0
- package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.d.ts +20 -0
- package/lib/esm/entities/requirements/getVaultV2ForceWithdrawRequirements.js +73 -0
- package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.d.ts +21 -0
- package/lib/esm/entities/requirements/getVaultV2InKindRedeemRequirements.js +90 -0
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.d.ts +25 -0
- package/lib/esm/entities/vaultV1/inKindRedeemQuote.js +82 -0
- package/lib/esm/entities/vaultV1/migrateToV2Quote.d.ts +20 -0
- package/lib/esm/entities/vaultV1/migrateToV2Quote.js +34 -0
- package/lib/esm/entities/vaultV1/vaultV1.js +57 -187
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.d.ts +25 -0
- package/lib/esm/entities/vaultV2/forceWithdrawQuote.js +186 -0
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.d.ts +28 -0
- package/lib/esm/entities/vaultV2/inKindRedeemQuote.js +107 -0
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +8 -34
- package/lib/esm/entities/vaultV2/vaultV2.js +70 -437
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +2 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.js +346 -234
- package/lib/esm/errors.d.ts +4 -4
- package/lib/esm/errors.js +4 -4
- package/lib/esm/fetch.d.ts +2 -2
- package/lib/esm/fetch.js +2 -2
- package/lib/esm/helpers/deadShares.js +35 -20
- package/lib/esm/helpers/encodeMidnightCalldata.js +4 -2
- package/lib/esm/helpers/metadata.js +12 -6
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +10 -5
- package/lib/esm/helpers/previewVaultV2InKindRedeem.js +6 -3
- package/lib/esm/helpers/utilization.js +10 -5
- package/lib/esm/helpers/validate.js +12 -6
- package/lib/esm/helpers/validateMidnightBounds.js +2 -1
- package/lib/esm/helpers/validateMidnightCollateralBatch.js +2 -1
- package/lib/esm/helpers/validateMidnightPublication.js +4 -2
- package/lib/esm/helpers/validateMidnightTakeFeasibility.js +44 -22
- package/lib/esm/helpers/validatePositiveInput.js +2 -1
- package/lib/esm/helpers/validateTakeableOffers.js +2 -1
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +14 -7
- package/lib/esm/index.d.ts +2 -2
- package/lib/esm/index.js +1 -1
- package/lib/esm/midnight/errors.d.ts +1 -2
- package/lib/esm/midnight/errors.js +1 -2
- package/lib/esm/transactionPlan/approval.js +13 -2
- package/lib/esm/transactionPlan/deposit.d.ts +22 -0
- package/lib/esm/transactionPlan/deposit.js +135 -0
- package/lib/esm/transactionPlan/error.d.ts +10 -8
- package/lib/esm/transactionPlan/error.js +10 -8
- package/lib/esm/transactionPlan/getTokenPermit.js +2 -1
- package/lib/esm/transactionPlan/index.d.ts +18 -0
- package/lib/esm/transactionPlan/index.js +9 -0
- package/lib/esm/transactionPlan/intent.d.ts +3 -3
- package/lib/esm/transactionPlan/intent.js +14 -7
- package/lib/esm/transactionPlan/permit.d.ts +1 -1
- package/lib/esm/transactionPlan/permit.js +86 -20
- package/lib/esm/transactionPlan/plan.d.ts +16 -6
- package/lib/esm/transactionPlan/plan.js +68 -18
- package/lib/esm/transactionPlan/redeem.d.ts +18 -0
- package/lib/esm/transactionPlan/redeem.js +59 -0
- package/lib/esm/transactionPlan/requirements.d.ts +4 -3
- package/lib/esm/transactionPlan/requirements.js +12 -6
- package/lib/esm/transactionPlan/serde.d.ts +2 -2
- package/lib/esm/transactionPlan/serde.js +41 -15
- package/lib/esm/transactionPlan/shareSpending.d.ts +18 -0
- package/lib/esm/transactionPlan/shareSpending.js +47 -0
- package/lib/esm/transactionPlan/types.d.ts +117 -11
- package/lib/esm/transactionPlan/validateActions.js +11 -1
- package/lib/esm/transactionPlan/validation.js +6 -3
- package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +93 -0
- package/lib/esm/transactionPlan/vaultv1/deposit.js +90 -0
- package/lib/esm/transactionPlan/vaultv1/inKindRedeem.d.ts +96 -0
- package/lib/esm/transactionPlan/vaultv1/inKindRedeem.js +198 -0
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +94 -0
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +212 -0
- package/lib/esm/transactionPlan/vaultv1/redeem.d.ts +69 -0
- package/lib/esm/transactionPlan/vaultv1/redeem.js +74 -0
- package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +77 -0
- package/lib/esm/transactionPlan/vaultv1/withdraw.js +84 -0
- package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +14 -31
- package/lib/esm/transactionPlan/vaultv2/deposit.js +17 -142
- package/lib/esm/transactionPlan/vaultv2/forceRedeem.d.ts +74 -0
- package/lib/esm/transactionPlan/vaultv2/forceRedeem.js +150 -0
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +98 -0
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +201 -0
- package/lib/esm/transactionPlan/vaultv2/inKindRedeem.d.ts +113 -0
- package/lib/esm/transactionPlan/vaultv2/inKindRedeem.js +201 -0
- package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +84 -0
- package/lib/esm/transactionPlan/vaultv2/redeem.js +82 -0
- package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +14 -27
- package/lib/esm/transactionPlan/vaultv2/withdraw.js +19 -125
- package/lib/esm/transactionPlan/version.js +2 -1
- package/lib/esm/transactionPlan/withdraw.d.ts +18 -0
- package/lib/esm/transactionPlan/withdraw.js +90 -0
- package/lib/esm/types/action.js +16 -8
- package/lib/esm/types/error.d.ts +8 -1
- package/lib/esm/types/error.js +10 -1
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +15 -15
|
@@ -1,10 +1,10 @@
|
|
|
1
|
-
export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter,
|
|
1
|
+
export type { IAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket, IMarketParams, IPosition,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
IPreLiquidationParams,
|
|
4
4
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
-
IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig,
|
|
6
|
-
export { AccrualPosition, AccrualVault, AccrualVaultV2,
|
|
5
|
+
IPreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
|
|
6
|
+
export { AccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market, MarketParams, Position,
|
|
7
7
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
8
8
|
PreLiquidationParams,
|
|
9
9
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
10
|
-
PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig,
|
|
10
|
+
PreLiquidationPosition, Token, User, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
package/lib/cjs/blue/entities.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.
|
|
3
|
+
exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.User = exports.Token = exports.PreLiquidationPosition = exports.PreLiquidationParams = exports.Position = exports.MarketParams = exports.Market = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.AccrualPosition = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "AccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
|
|
6
6
|
Object.defineProperty(exports, "AccrualVault", { enumerable: true, get: function () { return blue_sdk_1.AccrualVault; } });
|
|
7
7
|
Object.defineProperty(exports, "AccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2; } });
|
|
8
|
-
Object.defineProperty(exports, "AccrualVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MidnightAdapter; } });
|
|
9
8
|
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1Adapter; } });
|
|
10
9
|
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1AdapterV2; } });
|
|
11
10
|
Object.defineProperty(exports, "AccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -33,7 +32,6 @@ Object.defineProperty(exports, "VaultV2", { enumerable: true, get: function () {
|
|
|
33
32
|
Object.defineProperty(exports, "VaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Adapter; } });
|
|
34
33
|
Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfig; } });
|
|
35
34
|
Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfig; } });
|
|
36
|
-
Object.defineProperty(exports, "VaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MidnightAdapter; } });
|
|
37
35
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1Adapter; } });
|
|
38
36
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1AdapterV2; } });
|
|
39
37
|
Object.defineProperty(exports, "VaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoVaultV1Adapter; } });
|
package/lib/cjs/blue/errors.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError,
|
|
1
|
+
export { BlueErrors, DivisionByZeroError, IncompleteChainRegistryError, InvalidAddressError, InvalidBitLengthError, InvalidMarketParamsError, RegistryValueAlreadyRegisteredError, UnknownAddressError, UnknownDataError, UnknownFactory, UnknownMarketAllocationError, UnknownMarketParamsError, UnknownOfFactory, UnknownTokenError, UnknownTokenPriceError, UnknownVaultConfigError, UnsupportedChainIdError, UnsupportedMarketIrmError,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
UnsupportedPreLiquidationParamsError, UnsupportedVaultV2AdapterError, VaultV2Errors, } from "@morpho-org/blue-sdk";
|
|
4
|
-
export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError,
|
|
4
|
+
export { getUnsupportedVaultV2Adapter, InvalidNumberError, InvalidPermitDomainChainIdError, InvalidPermitDomainVerifyingContractError, isUnknownOfFactoryError, MalformedTokenMetadataError, MarketParamsIdMismatchError, MissingPermitDomainNameError, NonTupleReturnValueError, Permit2ExpirationOutOfRangeError, UnknownAbiFunctionError, UnnamedAbiOutputsError, UnsupportedPermitDomainExtensionsError, } from "@morpho-org/blue-sdk-viem";
|
package/lib/cjs/blue/errors.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.UnsupportedPermitDomainExtensionsError = exports.
|
|
3
|
+
exports.UnsupportedPermitDomainExtensionsError = exports.UnnamedAbiOutputsError = exports.UnknownAbiFunctionError = exports.Permit2ExpirationOutOfRangeError = exports.NonTupleReturnValueError = exports.MissingPermitDomainNameError = exports.MarketParamsIdMismatchError = exports.MalformedTokenMetadataError = exports.isUnknownOfFactoryError = exports.InvalidPermitDomainVerifyingContractError = exports.InvalidPermitDomainChainIdError = exports.InvalidNumberError = exports.getUnsupportedVaultV2Adapter = exports.VaultV2Errors = exports.UnsupportedVaultV2AdapterError = exports.UnsupportedPreLiquidationParamsError = exports.UnsupportedMarketIrmError = exports.UnsupportedChainIdError = exports.UnknownVaultConfigError = exports.UnknownTokenPriceError = exports.UnknownTokenError = exports.UnknownOfFactory = exports.UnknownMarketParamsError = exports.UnknownMarketAllocationError = exports.UnknownFactory = exports.UnknownDataError = exports.UnknownAddressError = exports.RegistryValueAlreadyRegisteredError = exports.InvalidMarketParamsError = exports.InvalidBitLengthError = exports.InvalidAddressError = exports.IncompleteChainRegistryError = exports.DivisionByZeroError = exports.BlueErrors = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "BlueErrors", { enumerable: true, get: function () { return blue_sdk_1.BlueErrors; } });
|
|
6
6
|
Object.defineProperty(exports, "DivisionByZeroError", { enumerable: true, get: function () { return blue_sdk_1.DivisionByZeroError; } });
|
|
@@ -8,9 +8,6 @@ Object.defineProperty(exports, "IncompleteChainRegistryError", { enumerable: tru
|
|
|
8
8
|
Object.defineProperty(exports, "InvalidAddressError", { enumerable: true, get: function () { return blue_sdk_1.InvalidAddressError; } });
|
|
9
9
|
Object.defineProperty(exports, "InvalidBitLengthError", { enumerable: true, get: function () { return blue_sdk_1.InvalidBitLengthError; } });
|
|
10
10
|
Object.defineProperty(exports, "InvalidMarketParamsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidMarketParamsError; } });
|
|
11
|
-
Object.defineProperty(exports, "InvalidPositionAccrualStateError", { enumerable: true, get: function () { return blue_sdk_1.InvalidPositionAccrualStateError; } });
|
|
12
|
-
Object.defineProperty(exports, "InvalidPositionLossFactorError", { enumerable: true, get: function () { return blue_sdk_1.InvalidPositionLossFactorError; } });
|
|
13
|
-
Object.defineProperty(exports, "InvalidVaultV2MidnightAdapterMarketsError", { enumerable: true, get: function () { return blue_sdk_1.InvalidVaultV2MidnightAdapterMarketsError; } });
|
|
14
11
|
Object.defineProperty(exports, "RegistryValueAlreadyRegisteredError", { enumerable: true, get: function () { return blue_sdk_1.RegistryValueAlreadyRegisteredError; } });
|
|
15
12
|
Object.defineProperty(exports, "UnknownAddressError", { enumerable: true, get: function () { return blue_sdk_1.UnknownAddressError; } });
|
|
16
13
|
Object.defineProperty(exports, "UnknownDataError", { enumerable: true, get: function () { return blue_sdk_1.UnknownDataError; } });
|
|
@@ -40,5 +37,4 @@ Object.defineProperty(exports, "NonTupleReturnValueError", { enumerable: true, g
|
|
|
40
37
|
Object.defineProperty(exports, "Permit2ExpirationOutOfRangeError", { enumerable: true, get: function () { return blue_sdk_viem_1.Permit2ExpirationOutOfRangeError; } });
|
|
41
38
|
Object.defineProperty(exports, "UnknownAbiFunctionError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnknownAbiFunctionError; } });
|
|
42
39
|
Object.defineProperty(exports, "UnnamedAbiOutputsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnnamedAbiOutputsError; } });
|
|
43
|
-
Object.defineProperty(exports, "UnresolvedBlockNumberError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnresolvedBlockNumberError; } });
|
|
44
40
|
Object.defineProperty(exports, "UnsupportedPermitDomainExtensionsError", { enumerable: true, get: function () { return blue_sdk_viem_1.UnsupportedPermitDomainExtensionsError; } });
|
package/lib/cjs/blue/fetch.d.ts
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter,
|
|
1
|
+
export { fetchAccrualPosition, fetchAccrualVault, fetchAccrualVaultV2, fetchAccrualVaultV2Adapter, fetchAccrualVaultV2MorphoMarketV1Adapter, fetchAccrualVaultV2MorphoMarketV1AdapterV2, fetchAccrualVaultV2MorphoVaultV1Adapter, fetchHolding, fetchMarket, fetchMarketParams, fetchPosition,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
fetchPreLiquidationParams,
|
|
4
4
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
-
fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData,
|
|
5
|
+
fetchPreLiquidationPosition, fetchToken, fetchUser, fetchVault, fetchVaultConfig, fetchVaultMarketAllocation, fetchVaultMarketConfig, fetchVaultUser, fetchVaultV2, fetchVaultV2Adapter, fetchVaultV2BlueMarketPublicAllocatorConfig, fetchVaultV2BluePublicAllocatorConfig, fetchVaultV2BluePublicAllocatorData, fetchVaultV2MorphoMarketV1Adapter, fetchVaultV2MorphoMarketV1AdapterV2, fetchVaultV2MorphoVaultV1Adapter, } from "@morpho-org/blue-sdk-viem";
|
package/lib/cjs/blue/fetch.js
CHANGED
|
@@ -1,12 +1,11 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.
|
|
3
|
+
exports.fetchVaultV2MorphoVaultV1Adapter = exports.fetchVaultV2MorphoMarketV1AdapterV2 = exports.fetchVaultV2MorphoMarketV1Adapter = exports.fetchVaultV2BluePublicAllocatorData = exports.fetchVaultV2BluePublicAllocatorConfig = exports.fetchVaultV2BlueMarketPublicAllocatorConfig = exports.fetchVaultV2Adapter = exports.fetchVaultV2 = exports.fetchVaultUser = exports.fetchVaultMarketConfig = exports.fetchVaultMarketAllocation = exports.fetchVaultConfig = exports.fetchVault = exports.fetchUser = exports.fetchToken = exports.fetchPreLiquidationPosition = exports.fetchPreLiquidationParams = exports.fetchPosition = exports.fetchMarketParams = exports.fetchMarket = exports.fetchHolding = exports.fetchAccrualVaultV2MorphoVaultV1Adapter = exports.fetchAccrualVaultV2MorphoMarketV1AdapterV2 = exports.fetchAccrualVaultV2MorphoMarketV1Adapter = exports.fetchAccrualVaultV2Adapter = exports.fetchAccrualVaultV2 = exports.fetchAccrualVault = exports.fetchAccrualPosition = void 0;
|
|
4
4
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
5
5
|
Object.defineProperty(exports, "fetchAccrualPosition", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualPosition; } });
|
|
6
6
|
Object.defineProperty(exports, "fetchAccrualVault", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVault; } });
|
|
7
7
|
Object.defineProperty(exports, "fetchAccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2; } });
|
|
8
8
|
Object.defineProperty(exports, "fetchAccrualVaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2Adapter; } });
|
|
9
|
-
Object.defineProperty(exports, "fetchAccrualVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MidnightAdapter; } });
|
|
10
9
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1Adapter; } });
|
|
11
10
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoMarketV1AdapterV2; } });
|
|
12
11
|
Object.defineProperty(exports, "fetchAccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchAccrualVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -30,7 +29,6 @@ Object.defineProperty(exports, "fetchVaultV2Adapter", { enumerable: true, get: f
|
|
|
30
29
|
Object.defineProperty(exports, "fetchVaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BlueMarketPublicAllocatorConfig; } });
|
|
31
30
|
Object.defineProperty(exports, "fetchVaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BluePublicAllocatorConfig; } });
|
|
32
31
|
Object.defineProperty(exports, "fetchVaultV2BluePublicAllocatorData", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2BluePublicAllocatorData; } });
|
|
33
|
-
Object.defineProperty(exports, "fetchVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MidnightAdapter; } });
|
|
34
32
|
Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1Adapter; } });
|
|
35
33
|
Object.defineProperty(exports, "fetchVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoMarketV1AdapterV2; } });
|
|
36
34
|
Object.defineProperty(exports, "fetchVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_viem_1.fetchVaultV2MorphoVaultV1Adapter; } });
|
package/lib/cjs/blue/utils.d.ts
CHANGED
|
@@ -3,5 +3,5 @@ export { AdaptiveCurveIrmLib, CapacityLimitReason,
|
|
|
3
3
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
4
4
|
defaultPreLiquidationParamsRegistry,
|
|
5
5
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
6
|
-
getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils,
|
|
6
|
+
getDefaultPreLiquidationParams, MarketUtils, MathLib, SharesMath, VaultUtils, VaultV2BlueMarketPublicAllocatorConfigUtils, VaultV2BluePublicAllocatorConfigUtils, VaultV2Utils, } from "@morpho-org/blue-sdk";
|
|
7
7
|
export { catchRevertOnly, decodeBytes32String, getAuthorizationTypedData, getPermit2PermitTypedData, getPermit2TransferFromTypedData, getPermitTypedData, isContractRevertError, isTransportError, isUndecodableResultError, MetaMorphoAction, optionalBoolean, readContractRestructured, restructure, safeGetAddress, safeParseNumber, safeParseUnits, } from "@morpho-org/blue-sdk-viem";
|
package/lib/cjs/blue/utils.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = exports.restructure = exports.readContractRestructured = exports.optionalBoolean = exports.MetaMorphoAction = exports.isUndecodableResultError = exports.isTransportError = exports.isContractRevertError = exports.getPermitTypedData = exports.getPermit2TransferFromTypedData = exports.getPermit2PermitTypedData = exports.getAuthorizationTypedData = exports.decodeBytes32String = exports.catchRevertOnly = exports.VaultV2Utils = exports.
|
|
3
|
+
exports.safeParseUnits = exports.safeParseNumber = exports.safeGetAddress = exports.restructure = exports.readContractRestructured = exports.optionalBoolean = exports.MetaMorphoAction = exports.isUndecodableResultError = exports.isTransportError = exports.isContractRevertError = exports.getPermitTypedData = exports.getPermit2TransferFromTypedData = exports.getPermit2PermitTypedData = exports.getAuthorizationTypedData = exports.decodeBytes32String = exports.catchRevertOnly = exports.VaultV2Utils = exports.VaultV2BluePublicAllocatorConfigUtils = exports.VaultV2BlueMarketPublicAllocatorConfigUtils = exports.VaultUtils = exports.SharesMath = exports.MathLib = exports.MarketUtils = exports.getDefaultPreLiquidationParams = exports.defaultPreLiquidationParamsRegistry = exports.CapacityLimitReason = exports.AdaptiveCurveIrmLib = void 0;
|
|
4
4
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
5
|
Object.defineProperty(exports, "AdaptiveCurveIrmLib", { enumerable: true, get: function () { return blue_sdk_1.AdaptiveCurveIrmLib; } });
|
|
6
6
|
Object.defineProperty(exports, "CapacityLimitReason", { enumerable: true, get: function () { return blue_sdk_1.CapacityLimitReason; } });
|
|
@@ -14,7 +14,6 @@ Object.defineProperty(exports, "SharesMath", { enumerable: true, get: function (
|
|
|
14
14
|
Object.defineProperty(exports, "VaultUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultUtils; } });
|
|
15
15
|
Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfigUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfigUtils; } });
|
|
16
16
|
Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfigUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfigUtils; } });
|
|
17
|
-
Object.defineProperty(exports, "VaultV2MidnightAdapterUtils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MidnightAdapterUtils; } });
|
|
18
17
|
Object.defineProperty(exports, "VaultV2Utils", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Utils; } });
|
|
19
18
|
var blue_sdk_viem_1 = require("@morpho-org/blue-sdk-viem");
|
|
20
19
|
Object.defineProperty(exports, "catchRevertOnly", { enumerable: true, get: function () { return blue_sdk_viem_1.catchRevertOnly; } });
|
|
@@ -162,8 +162,9 @@ class MorphoBlue {
|
|
|
162
162
|
const { userAddress, assets, nativeAmount, deadline, referralFeePct, referralFeeRecipient, } = params;
|
|
163
163
|
const createdAt = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
164
164
|
this.validateWriteCommon(params, createdAt);
|
|
165
|
-
if (assets <= 0n)
|
|
165
|
+
if (assets <= 0n) {
|
|
166
166
|
throw new index_js_3.NonPositiveInputError("assets", assets);
|
|
167
|
+
}
|
|
167
168
|
const nativeValue = (0, common_js_1.validateBlueBundlesV1NativeFunding)({
|
|
168
169
|
chainId: this.chainId,
|
|
169
170
|
token: this.marketParams.loanToken,
|
|
@@ -180,8 +181,9 @@ class MorphoBlue {
|
|
|
180
181
|
const now = suppliedNow ?? morpho_ts_1.Time.timestamp();
|
|
181
182
|
this.validateDeadline(deadline, now);
|
|
182
183
|
return this.assertWriteTargets().then(() => {
|
|
183
|
-
if (nativeValue > 0n)
|
|
184
|
+
if (nativeValue > 0n) {
|
|
184
185
|
return [];
|
|
186
|
+
}
|
|
185
187
|
return this.getTokenRequirements({
|
|
186
188
|
token: this.marketParams.loanToken,
|
|
187
189
|
amount: assets,
|
|
@@ -221,10 +223,12 @@ class MorphoBlue {
|
|
|
221
223
|
this.validateWriteCommon(params, createdAt);
|
|
222
224
|
const assets = ("assets" in params ? params.assets : undefined) ?? 0n;
|
|
223
225
|
const shares = ("shares" in params ? params.shares : undefined) ?? 0n;
|
|
224
|
-
if (assets < 0n)
|
|
226
|
+
if (assets < 0n) {
|
|
225
227
|
throw new index_js_3.NegativeInputError("assets", assets);
|
|
226
|
-
|
|
228
|
+
}
|
|
229
|
+
if (shares < 0n) {
|
|
227
230
|
throw new index_js_3.NegativeInputError("shares", shares);
|
|
231
|
+
}
|
|
228
232
|
if (assets > 0n && shares > 0n) {
|
|
229
233
|
throw new index_js_3.MutuallyExclusiveWithdrawAmountsError(this.marketParams.id);
|
|
230
234
|
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter,
|
|
1
|
+
export type { IAccrualPosition as IBlueAccrualPosition, IAccrualVault, IAccrualVaultV2, IAccrualVaultV2Adapter, IAccrualVaultV2MorphoMarketV1Adapter, IAccrualVaultV2MorphoMarketV1AdapterV2, IAccrualVaultV2MorphoVaultV1Adapter, IAssetBalances, IEip5267Domain, IHolding, IMarket as IBlueMarket, IMarketParams as IBlueMarketParams, IPosition as IBluePosition,
|
|
2
2
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
3
3
|
IPreLiquidationParams as IBluePreLiquidationParams,
|
|
4
4
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
5
|
-
IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig,
|
|
6
|
-
export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2,
|
|
5
|
+
IPreLiquidationPosition as IBluePreLiquidationPosition, IToken, IVault, IVaultConfig, IVaultMarketAllocation, IVaultMarketConfig, IVaultToken, IVaultUser, IVaultV2, IVaultV2Adapter, IVaultV2Allocation, IVaultV2BlueMarketPublicAllocatorConfig, IVaultV2BluePublicAllocatorConfig, IVaultV2MorphoMarketV1Adapter, IVaultV2MorphoMarketV1AdapterV2, IVaultV2MorphoVaultV1Adapter, PeripheralBalance, PeripheralBalanceType, } from "@morpho-org/blue-sdk";
|
|
6
|
+
export { AccrualPosition as BlueAccrualPosition, AccrualVault, AccrualVaultV2, AccrualVaultV2MorphoMarketV1Adapter, AccrualVaultV2MorphoMarketV1AdapterV2, AccrualVaultV2MorphoVaultV1Adapter, AssetBalances, ConstantWrappedToken, Eip5267Domain, ExchangeRateWrappedToken, Holding, Market as BlueMarket, MarketParams as BlueMarketParams, Position as BluePosition,
|
|
7
7
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
8
8
|
PreLiquidationParams as BluePreLiquidationParams,
|
|
9
9
|
/** @deprecated Pre-liquidation support is deprecated and will be removed in the next major. */
|
|
10
|
-
PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig,
|
|
10
|
+
PreLiquidationPosition as BluePreLiquidationPosition, Token, User as BlueUser, Vault, VaultConfig, VaultMarketAllocation, VaultMarketConfig, VaultToken, VaultUser, VaultV2, VaultV2Adapter, VaultV2BlueMarketPublicAllocatorConfig, VaultV2BluePublicAllocatorConfig, VaultV2MorphoMarketV1Adapter, VaultV2MorphoMarketV1AdapterV2, VaultV2MorphoVaultV1Adapter, WrappedToken, } from "@morpho-org/blue-sdk";
|
|
11
11
|
export type { AnyTree as MidnightAnyTree, AnyTreeSnapshot as MidnightAnyTreeSnapshot, BuildOfferParams as MidnightBuildOfferParams, CollateralParams as MidnightCollateralParams, EcrecoverTreeCreateRequest as MidnightEcrecoverTreeCreateRequest, GroupInput as MidnightGroupInput, IAccrualPosition as IMidnightAccrualPosition, ICollateralParams as IMidnightCollateralParams, IGroup as IMidnightGroup, IMarket as IMidnightMarket, IMarketParams as IMidnightMarketParams, IOffer as IMidnightOffer, IPosition as IMidnightPosition, MarketInput as MidnightMarketInput, OfferStruct as MidnightOfferStruct, PriceRatifierV1TreeCreateRequest as MidnightPriceRatifierV1TreeCreateRequest, RateRatifierV1TreeCreateRequest as MidnightRateRatifierV1TreeCreateRequest, RatifierKind as MidnightRatifierKind, RatifierTreeInput as MidnightRatifierTreeInput, RatifierTypes as MidnightRatifierTypes, SetterTreeCreateRequest as MidnightSetterTreeCreateRequest, SettlementFeeCbps as MidnightSettlementFeeCbps, TreeCreateParams as MidnightTreeCreateParams, TreeCreateRequest as MidnightTreeCreateRequest, TreeData as MidnightTreeData, TreeDescriptor as MidnightTreeDescriptor, TreeEntry as MidnightTreeEntry, TreeInput as MidnightTreeInput, TreeLike as MidnightTreeLike, TreeMempoolValidateParams as MidnightTreeMempoolValidateParams, TreeMempoolValidateRatification as MidnightTreeMempoolValidateRatification, TreeProof as MidnightTreeProof, TreeSnapshot as MidnightTreeSnapshot, TypedRatifierTreeInput as MidnightTypedRatifierTreeInput, TypedTreeMempoolValidateParams as MidnightTypedTreeMempoolValidateParams, } from "@morpho-org/midnight-sdk";
|
|
12
12
|
export { AccrualPosition as MidnightAccrualPosition, Group as MidnightGroup, Market as MidnightMarket, MarketParams as MidnightMarketParams, Offer as MidnightOffer, Position as MidnightPosition, Tree as MidnightTree, } from "@morpho-org/midnight-sdk";
|
|
13
13
|
export type { BlueActions, BlueTokenRequirementsParams, } from "./blue/index.js";
|
|
@@ -14,12 +14,11 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
|
14
14
|
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
15
|
};
|
|
16
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
-
exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = exports.MorphoVaultV1 = exports.MorphoMidnight = exports.MorphoBlue = exports.MidnightTree = exports.MidnightPosition = exports.MidnightOffer = exports.MidnightMarketParams = exports.MidnightMarket = exports.MidnightGroup = exports.MidnightAccrualPosition = exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.
|
|
17
|
+
exports.VaultV2BlueReallocationData = exports.MorphoVaultV2 = exports.MorphoVaultV1 = exports.MorphoMidnight = exports.MorphoBlue = exports.MidnightTree = exports.MidnightPosition = exports.MidnightOffer = exports.MidnightMarketParams = exports.MidnightMarket = exports.MidnightGroup = exports.MidnightAccrualPosition = exports.WrappedToken = exports.VaultV2MorphoVaultV1Adapter = exports.VaultV2MorphoMarketV1AdapterV2 = exports.VaultV2MorphoMarketV1Adapter = exports.VaultV2BluePublicAllocatorConfig = exports.VaultV2BlueMarketPublicAllocatorConfig = exports.VaultV2Adapter = exports.VaultV2 = exports.VaultUser = exports.VaultToken = exports.VaultMarketConfig = exports.VaultMarketAllocation = exports.VaultConfig = exports.Vault = exports.BlueUser = exports.Token = exports.BluePreLiquidationPosition = exports.BluePreLiquidationParams = exports.BluePosition = exports.BlueMarketParams = exports.BlueMarket = exports.Holding = exports.ExchangeRateWrappedToken = exports.Eip5267Domain = exports.ConstantWrappedToken = exports.AssetBalances = exports.AccrualVaultV2MorphoVaultV1Adapter = exports.AccrualVaultV2MorphoMarketV1AdapterV2 = exports.AccrualVaultV2MorphoMarketV1Adapter = exports.AccrualVaultV2 = exports.AccrualVault = exports.BlueAccrualPosition = void 0;
|
|
18
18
|
var blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
19
19
|
Object.defineProperty(exports, "BlueAccrualPosition", { enumerable: true, get: function () { return blue_sdk_1.AccrualPosition; } });
|
|
20
20
|
Object.defineProperty(exports, "AccrualVault", { enumerable: true, get: function () { return blue_sdk_1.AccrualVault; } });
|
|
21
21
|
Object.defineProperty(exports, "AccrualVaultV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2; } });
|
|
22
|
-
Object.defineProperty(exports, "AccrualVaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MidnightAdapter; } });
|
|
23
22
|
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1Adapter; } });
|
|
24
23
|
Object.defineProperty(exports, "AccrualVaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoMarketV1AdapterV2; } });
|
|
25
24
|
Object.defineProperty(exports, "AccrualVaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.AccrualVaultV2MorphoVaultV1Adapter; } });
|
|
@@ -47,7 +46,6 @@ Object.defineProperty(exports, "VaultV2", { enumerable: true, get: function () {
|
|
|
47
46
|
Object.defineProperty(exports, "VaultV2Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2Adapter; } });
|
|
48
47
|
Object.defineProperty(exports, "VaultV2BlueMarketPublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BlueMarketPublicAllocatorConfig; } });
|
|
49
48
|
Object.defineProperty(exports, "VaultV2BluePublicAllocatorConfig", { enumerable: true, get: function () { return blue_sdk_1.VaultV2BluePublicAllocatorConfig; } });
|
|
50
|
-
Object.defineProperty(exports, "VaultV2MidnightAdapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MidnightAdapter; } });
|
|
51
49
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1Adapter; } });
|
|
52
50
|
Object.defineProperty(exports, "VaultV2MorphoMarketV1AdapterV2", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoMarketV1AdapterV2; } });
|
|
53
51
|
Object.defineProperty(exports, "VaultV2MorphoVaultV1Adapter", { enumerable: true, get: function () { return blue_sdk_1.VaultV2MorphoVaultV1Adapter; } });
|
|
@@ -18,7 +18,8 @@ const index_js_1 = require("../../types/index.js");
|
|
|
18
18
|
* @internal
|
|
19
19
|
*/
|
|
20
20
|
const validateMidnightDeadline = (deadline, now = morpho_ts_1.Time.timestamp()) => {
|
|
21
|
-
if (deadline <= now)
|
|
21
|
+
if (deadline <= now) {
|
|
22
22
|
throw new index_js_1.ExpiredDeadlineError(deadline, now);
|
|
23
|
+
}
|
|
23
24
|
};
|
|
24
25
|
exports.validateMidnightDeadline = validateMidnightDeadline;
|
|
@@ -43,17 +43,20 @@ const validateTakeDeadlineWindow = (deadline, now = morpho_ts_1.Time.timestamp()
|
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
45
|
const assertNonNegativeAmount = (label, amount) => {
|
|
46
|
-
if (amount < 0n)
|
|
46
|
+
if (amount < 0n) {
|
|
47
47
|
throw new index_js_4.NegativeInputError(label, amount);
|
|
48
|
+
}
|
|
48
49
|
};
|
|
49
50
|
const assertPositiveAmount = (label, amount) => {
|
|
50
|
-
if (amount <= 0n)
|
|
51
|
+
if (amount <= 0n) {
|
|
51
52
|
throw new index_js_4.NonPositiveInputError(label, amount);
|
|
53
|
+
}
|
|
52
54
|
};
|
|
53
55
|
const rejectReduceOnlyOffers = (offers) => {
|
|
54
56
|
offers.forEach((offer, index) => {
|
|
55
|
-
if (offer.reduceOnly)
|
|
57
|
+
if (offer.reduceOnly) {
|
|
56
58
|
throw new index_js_4.MidnightOfferReduceOnlyError({ index });
|
|
59
|
+
}
|
|
57
60
|
});
|
|
58
61
|
};
|
|
59
62
|
const getOffersDataInternal = async ({ client, chainId, params, marketCreationTime = "expiry", }) => {
|
|
@@ -1968,8 +1971,9 @@ class MorphoMidnight {
|
|
|
1968
1971
|
// Reject the wrong exit intent before calling the mempool validation API.
|
|
1969
1972
|
(0, validateOfferSides_js_1.validateOfferSides)(tree.offers, false);
|
|
1970
1973
|
for (const [index, offer] of tree.offers.entries()) {
|
|
1971
|
-
if (!offer.reduceOnly)
|
|
1974
|
+
if (!offer.reduceOnly) {
|
|
1972
1975
|
throw new index_js_4.MidnightOfferNotReduceOnlyError({ index });
|
|
1976
|
+
}
|
|
1973
1977
|
}
|
|
1974
1978
|
return this.prepareBorrowOffers({ ...params, offers: tree });
|
|
1975
1979
|
}
|
|
@@ -2059,8 +2063,9 @@ class MorphoMidnight {
|
|
|
2059
2063
|
// Reject the wrong exit intent before calling the mempool validation API.
|
|
2060
2064
|
(0, validateOfferSides_js_1.validateOfferSides)(tree.offers, true);
|
|
2061
2065
|
for (const [index, offer] of tree.offers.entries()) {
|
|
2062
|
-
if (!offer.reduceOnly)
|
|
2066
|
+
if (!offer.reduceOnly) {
|
|
2063
2067
|
throw new index_js_4.MidnightOfferNotReduceOnlyError({ index });
|
|
2068
|
+
}
|
|
2064
2069
|
}
|
|
2065
2070
|
return this.prepareLendOffers({ ...params, offers: tree });
|
|
2066
2071
|
}
|
|
@@ -2272,8 +2277,9 @@ class MorphoMidnight {
|
|
|
2272
2277
|
if (!params.positionData) {
|
|
2273
2278
|
throw new index_js_4.MissingAccrualPositionError();
|
|
2274
2279
|
}
|
|
2275
|
-
if (params.positionData.user != null)
|
|
2280
|
+
if (params.positionData.user != null) {
|
|
2276
2281
|
(0, validateMidnightAccount_js_1.validateMidnightAddress)("positionData.user", params.positionData.user);
|
|
2282
|
+
}
|
|
2277
2283
|
if (params.positionData.user == null ||
|
|
2278
2284
|
!(0, viem_1.isAddressEqual)(params.positionData.user, params.accountAddress)) {
|
|
2279
2285
|
throw new index_js_4.AccrualPositionUserMismatchError(params.positionData.user ?? "unbound", params.accountAddress);
|
|
@@ -2288,8 +2294,9 @@ class MorphoMidnight {
|
|
|
2288
2294
|
if (params.units !== undefined && units <= 0n) {
|
|
2289
2295
|
throw new index_js_4.NonPositiveInputError("units", units);
|
|
2290
2296
|
}
|
|
2291
|
-
if (units <= 0n)
|
|
2297
|
+
if (units <= 0n) {
|
|
2292
2298
|
throw new index_js_4.NoMidnightCreditToRedeemError(market.id);
|
|
2299
|
+
}
|
|
2293
2300
|
(0, validateMidnightBounds_js_1.validateMidnightUint128Field)("units", units);
|
|
2294
2301
|
if (accrued.credit < units) {
|
|
2295
2302
|
throw new index_js_4.MidnightRedeemExceedsCreditError({
|
|
@@ -14,8 +14,9 @@ const midnightPublicationError_js_1 = require("../../types/midnightPublicationEr
|
|
|
14
14
|
// Midnight.sol `touchMarket` rejects markets maturing more than 100 years after creation.
|
|
15
15
|
const MAX_TIME_TO_MATURITY = 100n * 365n * 86400n;
|
|
16
16
|
function requirePublicationState(value) {
|
|
17
|
-
if (value === undefined)
|
|
17
|
+
if (value === undefined) {
|
|
18
18
|
throw new blue_sdk_1.UnknownDataError("Missing Midnight publication state.");
|
|
19
|
+
}
|
|
19
20
|
return value;
|
|
20
21
|
}
|
|
21
22
|
/** @internal */
|
|
@@ -222,21 +223,65 @@ async function fetchMidnightMakerOfferStates(params) {
|
|
|
222
223
|
const blockNumber = params.blockNumber ?? (await (0, actions_1.getBlockNumber)(params.client));
|
|
223
224
|
const block = await (0, actions_1.getBlock)(params.client, { blockNumber });
|
|
224
225
|
const midnight = (0, morpho_ts_1.getChainAddress)(params.chainId, "midnight");
|
|
226
|
+
const targets = collectPublicationReadTargets(params.tree);
|
|
227
|
+
const { collaterals } = targets;
|
|
228
|
+
const values = await readPublicationContractState({
|
|
229
|
+
client: params.client,
|
|
230
|
+
midnight,
|
|
231
|
+
blockNumber,
|
|
232
|
+
targets,
|
|
233
|
+
});
|
|
234
|
+
const { marketById, consumedByGroup, positionByOwner, collateralStateByMarket, } = indexPublicationContractState({ targets, values });
|
|
235
|
+
const codeByOracle = new Map(await Promise.all([...new Set(collaterals.map(({ oracleKey }) => oracleKey))].map(async (oracleKey) => [
|
|
236
|
+
oracleKey,
|
|
237
|
+
await (0, actions_1.getCode)(params.client, {
|
|
238
|
+
address: requirePublicationState(collaterals.find(({ oracleKey: key }) => key === oracleKey)).collateral.oracle,
|
|
239
|
+
blockNumber,
|
|
240
|
+
}),
|
|
241
|
+
])));
|
|
242
|
+
const states = params.tree.offers.map((offer) => {
|
|
243
|
+
const id = midnight_sdk_1.MarketUtils.toId(offer.market);
|
|
244
|
+
const market = requirePublicationState(marketById.get(id.toLowerCase()));
|
|
245
|
+
const groupKey = `${offer.maker.toLowerCase()}:${offer.group.toLowerCase()}`;
|
|
246
|
+
const owner = requirePublicationState(positionByOwner.get(`${id.toLowerCase()}:${offer.maker.toLowerCase()}`));
|
|
247
|
+
const uncreated = market.tickSpacing === 0;
|
|
248
|
+
const collateralStates = uncreated
|
|
249
|
+
? requirePublicationState(collateralStateByMarket.get(id.toLowerCase()))
|
|
250
|
+
: [];
|
|
251
|
+
return {
|
|
252
|
+
consumed: requirePublicationState(consumedByGroup.get(groupKey)),
|
|
253
|
+
tickSpacing: market.tickSpacing,
|
|
254
|
+
continuousFee: BigInt(market.continuousFee),
|
|
255
|
+
credit: owner.credit,
|
|
256
|
+
debt: owner.debt,
|
|
257
|
+
market,
|
|
258
|
+
lltvEnabled: collateralStates.map(({ lltvEnabled }) => lltvEnabled),
|
|
259
|
+
liquidationCursorEnabled: collateralStates.map(({ liquidationCursorEnabled }) => liquidationCursorEnabled),
|
|
260
|
+
oracleHasCode: uncreated
|
|
261
|
+
? (0, exports.offerMarketParams)(offer).collateralParams.map((collateral) => codeByOracle.get(collateral.oracle.toLowerCase()) !== undefined &&
|
|
262
|
+
codeByOracle.get(collateral.oracle.toLowerCase()) !== "0x")
|
|
263
|
+
: [],
|
|
264
|
+
};
|
|
265
|
+
});
|
|
266
|
+
return { states, now: block.timestamp };
|
|
267
|
+
}
|
|
268
|
+
/** Deduplicates the market, group, owner and collateral reads for a maker tree. @internal */
|
|
269
|
+
function collectPublicationReadTargets(tree) {
|
|
225
270
|
const markets = [
|
|
226
|
-
...new Map(
|
|
271
|
+
...new Map(tree.offers.map((offer) => {
|
|
227
272
|
const market = midnight_sdk_1.MarketParams.from((0, exports.offerMarketParams)(offer));
|
|
228
273
|
const id = midnight_sdk_1.MarketUtils.toId(market);
|
|
229
274
|
return [id.toLowerCase(), { id, market }];
|
|
230
275
|
})).values(),
|
|
231
276
|
];
|
|
232
277
|
const groups = [
|
|
233
|
-
...new Map(
|
|
278
|
+
...new Map(tree.offers.map((offer) => [
|
|
234
279
|
`${offer.maker.toLowerCase()}:${offer.group.toLowerCase()}`,
|
|
235
280
|
{ maker: offer.maker, group: offer.group },
|
|
236
281
|
])).values(),
|
|
237
282
|
];
|
|
238
283
|
const owners = [
|
|
239
|
-
...new Map(
|
|
284
|
+
...new Map(tree.offers.map((offer) => {
|
|
240
285
|
const id = midnight_sdk_1.MarketUtils.toId(offer.market);
|
|
241
286
|
return [
|
|
242
287
|
`${id.toLowerCase()}:${offer.maker.toLowerCase()}`,
|
|
@@ -255,50 +300,55 @@ async function fetchMidnightMakerOfferStates(params) {
|
|
|
255
300
|
market.loanToken,
|
|
256
301
|
])).values(),
|
|
257
302
|
];
|
|
258
|
-
|
|
259
|
-
|
|
303
|
+
return { markets, groups, owners, collaterals, defaultFeeTokens };
|
|
304
|
+
}
|
|
305
|
+
/** Reads contract state concurrently at the pinned publication block. @internal */
|
|
306
|
+
async function readPublicationContractState({ client, midnight, blockNumber, targets, }) {
|
|
307
|
+
const { markets, groups, owners, collaterals, defaultFeeTokens } = targets;
|
|
308
|
+
return Promise.all([
|
|
309
|
+
Promise.all(markets.map(({ id }) => (0, actions_1.readContract)(client, {
|
|
260
310
|
address: midnight,
|
|
261
311
|
abi: midnight_sdk_1.midnightAbi,
|
|
262
312
|
functionName: "marketState",
|
|
263
313
|
args: [id],
|
|
264
314
|
blockNumber,
|
|
265
315
|
}))),
|
|
266
|
-
Promise.all(groups.map(({ maker, group }) => (0, actions_1.readContract)(
|
|
316
|
+
Promise.all(groups.map(({ maker, group }) => (0, actions_1.readContract)(client, {
|
|
267
317
|
address: midnight,
|
|
268
318
|
abi: midnight_sdk_1.midnightAbi,
|
|
269
319
|
functionName: "consumed",
|
|
270
320
|
args: [maker, group],
|
|
271
321
|
blockNumber,
|
|
272
322
|
}))),
|
|
273
|
-
Promise.all(owners.map(({ id, maker }) => (0, actions_1.readContract)(
|
|
323
|
+
Promise.all(owners.map(({ id, maker }) => (0, actions_1.readContract)(client, {
|
|
274
324
|
address: midnight,
|
|
275
325
|
abi: midnight_sdk_1.midnightAbi,
|
|
276
326
|
functionName: "credit",
|
|
277
327
|
args: [id, maker],
|
|
278
328
|
blockNumber,
|
|
279
329
|
}))),
|
|
280
|
-
Promise.all(owners.map(({ id, maker }) => (0, actions_1.readContract)(
|
|
330
|
+
Promise.all(owners.map(({ id, maker }) => (0, actions_1.readContract)(client, {
|
|
281
331
|
address: midnight,
|
|
282
332
|
abi: midnight_sdk_1.midnightAbi,
|
|
283
333
|
functionName: "debt",
|
|
284
334
|
args: [id, maker],
|
|
285
335
|
blockNumber,
|
|
286
336
|
}))),
|
|
287
|
-
Promise.all(defaultFeeTokens.map((loanToken) => (0, actions_1.readContract)(
|
|
337
|
+
Promise.all(defaultFeeTokens.map((loanToken) => (0, actions_1.readContract)(client, {
|
|
288
338
|
address: midnight,
|
|
289
339
|
abi: midnight_sdk_1.midnightAbi,
|
|
290
340
|
functionName: "defaultContinuousFee",
|
|
291
341
|
args: [loanToken],
|
|
292
342
|
blockNumber,
|
|
293
343
|
}))),
|
|
294
|
-
Promise.all(collaterals.map(({ collateral }) => (0, actions_1.readContract)(
|
|
344
|
+
Promise.all(collaterals.map(({ collateral }) => (0, actions_1.readContract)(client, {
|
|
295
345
|
address: midnight,
|
|
296
346
|
abi: midnight_sdk_1.midnightAbi,
|
|
297
347
|
functionName: "isLltvEnabled",
|
|
298
348
|
args: [collateral.lltv],
|
|
299
349
|
blockNumber,
|
|
300
350
|
}))),
|
|
301
|
-
Promise.all(collaterals.map(({ collateral }) => (0, actions_1.readContract)(
|
|
351
|
+
Promise.all(collaterals.map(({ collateral }) => (0, actions_1.readContract)(client, {
|
|
302
352
|
address: midnight,
|
|
303
353
|
abi: midnight_sdk_1.midnightAbi,
|
|
304
354
|
functionName: "isLiquidationCursorEnabled",
|
|
@@ -306,6 +356,11 @@ async function fetchMidnightMakerOfferStates(params) {
|
|
|
306
356
|
blockNumber,
|
|
307
357
|
}))),
|
|
308
358
|
]);
|
|
359
|
+
}
|
|
360
|
+
/** Indexes validated contract results for per-offer publication state. @internal */
|
|
361
|
+
function indexPublicationContractState({ targets, values, }) {
|
|
362
|
+
const { markets, groups, owners, collaterals, defaultFeeTokens } = targets;
|
|
363
|
+
const [marketStates, consumedValues, creditValues, debtValues, defaultFees, lltvEnabledByCollateral, liquidationCursorEnabledByCollateral,] = values;
|
|
309
364
|
const defaultFeeByLoanToken = new Map(defaultFeeTokens.map((loanToken, index) => [
|
|
310
365
|
loanToken.toLowerCase(),
|
|
311
366
|
requirePublicationState(defaultFees[index]),
|
|
@@ -351,38 +406,12 @@ async function fetchMidnightMakerOfferStates(params) {
|
|
|
351
406
|
id.toLowerCase(),
|
|
352
407
|
market.collateralParams.map((_, index) => requirePublicationState(collateralStateByKey.get(`${id.toLowerCase()}:${index}`))),
|
|
353
408
|
]));
|
|
354
|
-
|
|
355
|
-
|
|
356
|
-
|
|
357
|
-
|
|
358
|
-
|
|
359
|
-
|
|
360
|
-
])));
|
|
361
|
-
const states = params.tree.offers.map((offer) => {
|
|
362
|
-
const id = midnight_sdk_1.MarketUtils.toId(offer.market);
|
|
363
|
-
const market = requirePublicationState(marketById.get(id.toLowerCase()));
|
|
364
|
-
const groupKey = `${offer.maker.toLowerCase()}:${offer.group.toLowerCase()}`;
|
|
365
|
-
const owner = requirePublicationState(positionByOwner.get(`${id.toLowerCase()}:${offer.maker.toLowerCase()}`));
|
|
366
|
-
const uncreated = market.tickSpacing === 0;
|
|
367
|
-
const collateralStates = uncreated
|
|
368
|
-
? requirePublicationState(collateralStateByMarket.get(id.toLowerCase()))
|
|
369
|
-
: [];
|
|
370
|
-
return {
|
|
371
|
-
consumed: requirePublicationState(consumedByGroup.get(groupKey)),
|
|
372
|
-
tickSpacing: market.tickSpacing,
|
|
373
|
-
continuousFee: BigInt(market.continuousFee),
|
|
374
|
-
credit: owner.credit,
|
|
375
|
-
debt: owner.debt,
|
|
376
|
-
market,
|
|
377
|
-
lltvEnabled: collateralStates.map(({ lltvEnabled }) => lltvEnabled),
|
|
378
|
-
liquidationCursorEnabled: collateralStates.map(({ liquidationCursorEnabled }) => liquidationCursorEnabled),
|
|
379
|
-
oracleHasCode: uncreated
|
|
380
|
-
? (0, exports.offerMarketParams)(offer).collateralParams.map((collateral) => codeByOracle.get(collateral.oracle.toLowerCase()) !== undefined &&
|
|
381
|
-
codeByOracle.get(collateral.oracle.toLowerCase()) !== "0x")
|
|
382
|
-
: [],
|
|
383
|
-
};
|
|
384
|
-
});
|
|
385
|
-
return { states, now: block.timestamp };
|
|
409
|
+
return {
|
|
410
|
+
marketById,
|
|
411
|
+
consumedByGroup,
|
|
412
|
+
positionByOwner,
|
|
413
|
+
collateralStateByMarket,
|
|
414
|
+
};
|
|
386
415
|
}
|
|
387
416
|
/**
|
|
388
417
|
* Rejects offers with callbacks that the selected maker flow cannot execute.
|
|
@@ -53,8 +53,9 @@ exports.assertContractCode = assertContractCode;
|
|
|
53
53
|
const assertRegistryTargetsHaveCode = async (client, chainId, targets) => {
|
|
54
54
|
const seen = new Set();
|
|
55
55
|
for (const target of targets) {
|
|
56
|
-
if (seen.has(target.address))
|
|
56
|
+
if (seen.has(target.address)) {
|
|
57
57
|
continue;
|
|
58
|
+
}
|
|
58
59
|
seen.add(target.address);
|
|
59
60
|
try {
|
|
60
61
|
await (0, exports.assertContractCode)(client, {
|
|
@@ -64,8 +65,9 @@ const assertRegistryTargetsHaveCode = async (client, chainId, targets) => {
|
|
|
64
65
|
});
|
|
65
66
|
}
|
|
66
67
|
catch (error) {
|
|
67
|
-
if (!(error instanceof index_js_1.MissingContractCodeError))
|
|
68
|
+
if (!(error instanceof index_js_1.MissingContractCodeError)) {
|
|
68
69
|
throw error;
|
|
70
|
+
}
|
|
69
71
|
try {
|
|
70
72
|
await (0, validateClientChainId_js_1.validateClientChainId)(client, chainId);
|
|
71
73
|
}
|
|
@@ -8,6 +8,7 @@ const actions_1 = require("viem/actions");
|
|
|
8
8
|
const index_js_1 = require("../../actions/bundles/index.js");
|
|
9
9
|
const validateClientChainId_js_1 = require("../../actions/requirements/validateClientChainId.js");
|
|
10
10
|
const index_js_2 = require("../../helpers/index.js");
|
|
11
|
+
const validate_js_1 = require("../../helpers/validate.js");
|
|
11
12
|
const index_js_3 = require("../../types/index.js");
|
|
12
13
|
const getErc2612Permit_js_1 = require("./getErc2612Permit.js");
|
|
13
14
|
/**
|
|
@@ -96,16 +97,8 @@ const getBundlesTokenRequirements = async (viemClient, params) => {
|
|
|
96
97
|
max: viem_1.maxUint256,
|
|
97
98
|
});
|
|
98
99
|
}
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
}
|
|
102
|
-
if (params.deadline > viem_1.maxUint256) {
|
|
103
|
-
throw new index_js_3.InputExceedsMaxError({
|
|
104
|
-
field: "deadline",
|
|
105
|
-
value: params.deadline,
|
|
106
|
-
max: viem_1.maxUint256,
|
|
107
|
-
});
|
|
108
|
-
}
|
|
100
|
+
// Reject deadlines outside the positive uint256 range before reading state.
|
|
101
|
+
(0, validate_js_1.validateDeadline)(params.deadline);
|
|
109
102
|
// Reject an already-expired deadline before the RPC reads so a direct caller of this resolver
|
|
110
103
|
// never signs a permit for a supply the BlueBundlesV1 call would revert. The entity validates
|
|
111
104
|
// this too, but the exported resolver must guard its own callers.
|
|
@@ -113,8 +106,9 @@ const getBundlesTokenRequirements = async (viemClient, params) => {
|
|
|
113
106
|
if (params.deadline <= timestamp) {
|
|
114
107
|
throw new index_js_3.ExpiredDeadlineError(params.deadline, timestamp);
|
|
115
108
|
}
|
|
116
|
-
if (params.amount === 0n)
|
|
109
|
+
if (params.amount === 0n) {
|
|
117
110
|
return [];
|
|
111
|
+
}
|
|
118
112
|
await (0, validateClientChainId_js_1.validateClientChainId)(viemClient, params.chainId);
|
|
119
113
|
const allowance = await (0, actions_1.readContract)(viemClient, {
|
|
120
114
|
abi: viem_1.erc20Abi,
|
|
@@ -122,8 +116,9 @@ const getBundlesTokenRequirements = async (viemClient, params) => {
|
|
|
122
116
|
functionName: "allowance",
|
|
123
117
|
args: [params.owner, params.spender],
|
|
124
118
|
});
|
|
125
|
-
if (allowance >= params.amount)
|
|
119
|
+
if (allowance >= params.amount) {
|
|
126
120
|
return [];
|
|
121
|
+
}
|
|
127
122
|
const { dai } = (0, blue_sdk_1.getChainAddresses)(params.chainId);
|
|
128
123
|
const isDai = params.supportSignature &&
|
|
129
124
|
(0, morpho_ts_1.isDefined)(dai) &&
|
|
@@ -139,8 +134,9 @@ const getBundlesTokenRequirements = async (viemClient, params) => {
|
|
|
139
134
|
now: timestamp,
|
|
140
135
|
supportDeployless: params.supportDeployless,
|
|
141
136
|
});
|
|
142
|
-
if ((0, morpho_ts_1.isDefined)(permit))
|
|
137
|
+
if ((0, morpho_ts_1.isDefined)(permit)) {
|
|
143
138
|
return [permit];
|
|
139
|
+
}
|
|
144
140
|
}
|
|
145
141
|
return (0, index_js_1.resolveBundlesTokenRequirements)({
|
|
146
142
|
token: params.token,
|