@morpho-org/morpho-sdk 6.0.0-next.2 → 6.0.0-next.4
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/MIGRATION-v5-to-v6.md +88 -32
- package/README.md +9 -7
- package/lib/cjs/abis.d.ts +7 -2844
- package/lib/cjs/abis.js +3 -1951
- package/lib/cjs/actions/blue/borrow.d.ts +3 -2
- package/lib/cjs/actions/blue/borrow.js +3 -2
- package/lib/cjs/actions/blue/common.js +1 -9
- package/lib/cjs/actions/blue/refinance.d.ts +2 -2
- package/lib/cjs/actions/blue/refinance.js +2 -2
- package/lib/cjs/actions/blue/repay.d.ts +1 -1
- package/lib/cjs/actions/blue/repay.js +1 -1
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +2 -2
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +2 -2
- package/lib/cjs/actions/blue/supply.d.ts +2 -2
- package/lib/cjs/actions/blue/supply.js +2 -2
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +2 -2
- package/lib/cjs/actions/blue/supplyCollateral.js +2 -2
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +3 -2
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +3 -2
- package/lib/cjs/actions/blue/withdraw.d.ts +3 -3
- package/lib/cjs/actions/blue/withdraw.js +3 -3
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +2 -2
- package/lib/cjs/actions/blue/withdrawCollateral.js +2 -2
- package/lib/cjs/actions/bundles/common.d.ts +6 -2
- package/lib/cjs/actions/bundles/common.js +31 -5
- package/lib/cjs/actions/index.d.ts +0 -1
- package/lib/cjs/actions/index.js +0 -1
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -8
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +11 -16
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +5 -6
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +4 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +4 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +5 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +6 -11
- package/lib/cjs/actions/requirements/encode/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/encode/index.js +0 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +5 -6
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -6
- package/lib/cjs/actions/requirements/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/index.js +0 -1
- package/lib/cjs/actions/vaultV1/deposit.d.ts +1 -2
- package/lib/cjs/actions/vaultV1/deposit.js +1 -2
- package/lib/cjs/actions/vaultV1/inKindRedeem.d.ts +7 -5
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +11 -7
- package/lib/cjs/actions/vaultV2/deposit.d.ts +1 -2
- package/lib/cjs/actions/vaultV2/deposit.js +1 -2
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +1 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +3 -3
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +7 -5
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +11 -7
- package/lib/cjs/augment/AccrualPosition.d.ts +1 -0
- package/lib/cjs/augment.d.ts +0 -1
- package/lib/cjs/augment.js +0 -1
- package/lib/cjs/blue/abis.d.ts +5 -5
- package/lib/cjs/blue/abis.js +3 -7
- package/lib/cjs/blue/entities.d.ts +10 -8
- package/lib/cjs/blue/entities.js +3 -3
- package/lib/cjs/blue/errors.d.ts +4 -2
- package/lib/cjs/blue/errors.js +3 -1
- package/lib/cjs/blue/fetch.d.ts +5 -3
- package/lib/cjs/blue/fetch.js +3 -3
- package/lib/cjs/blue/types.d.ts +2 -4
- package/lib/cjs/blue/utils.d.ts +6 -4
- package/lib/cjs/blue/utils.js +3 -3
- package/lib/cjs/client/morphoViemExtension.d.ts +1 -1
- package/lib/cjs/client/morphoViemExtension.js +1 -1
- package/lib/cjs/constants.d.ts +3 -37
- package/lib/cjs/constants.js +1 -39
- package/lib/cjs/entities/blue/blue.d.ts +30 -265
- package/lib/cjs/entities/blue/blue.js +1 -205
- package/lib/cjs/entities/index.d.ts +11 -66
- package/lib/cjs/entities/index.js +3 -21
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -2
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +8 -3
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +13 -5
- package/lib/cjs/entities/vaultV1/vaultV1.js +16 -10
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +40 -19
- package/lib/cjs/entities/vaultV2/vaultV2.js +57 -26
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +4 -21
- package/lib/cjs/errors.d.ts +5 -47
- package/lib/cjs/errors.js +4 -46
- package/lib/cjs/fetch.d.ts +5 -17
- package/lib/cjs/fetch.js +3 -17
- package/lib/cjs/helpers/constant.d.ts +0 -2
- package/lib/cjs/helpers/constant.js +0 -2
- package/lib/cjs/helpers/index.d.ts +2 -3
- package/lib/cjs/helpers/index.js +1 -9
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +11 -5
- package/lib/cjs/helpers/slippage.d.ts +1 -103
- package/lib/cjs/helpers/slippage.js +0 -150
- package/lib/cjs/helpers/utilization.d.ts +12 -10
- package/lib/cjs/helpers/utilization.js +27 -12
- package/lib/cjs/helpers/validate.d.ts +1 -24
- package/lib/cjs/helpers/validate.js +2 -49
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +1 -3
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +48 -15
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +48 -15
- package/lib/cjs/midnight/errors.d.ts +1 -1
- package/lib/cjs/midnight/errors.js +2 -1
- package/lib/cjs/types/action.d.ts +17 -65
- package/lib/cjs/types/action.js +11 -4
- package/lib/cjs/types/error.d.ts +50 -381
- package/lib/cjs/types/error.js +64 -395
- package/lib/cjs/types/sharedLiquidity.d.ts +1 -117
- package/lib/cjs/types.d.ts +2 -18
- package/lib/cjs/utils.d.ts +10 -35
- package/lib/cjs/utils.js +4 -36
- package/lib/esm/abis.d.ts +7 -2844
- package/lib/esm/abis.js +7 -1950
- package/lib/esm/actions/blue/borrow.d.ts +3 -2
- package/lib/esm/actions/blue/borrow.js +3 -2
- package/lib/esm/actions/blue/common.js +1 -9
- package/lib/esm/actions/blue/refinance.d.ts +2 -2
- package/lib/esm/actions/blue/refinance.js +2 -2
- package/lib/esm/actions/blue/repay.d.ts +1 -1
- package/lib/esm/actions/blue/repay.js +1 -1
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +2 -2
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +2 -2
- package/lib/esm/actions/blue/supply.d.ts +2 -2
- package/lib/esm/actions/blue/supply.js +2 -2
- package/lib/esm/actions/blue/supplyCollateral.d.ts +2 -2
- package/lib/esm/actions/blue/supplyCollateral.js +2 -2
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -2
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +3 -2
- package/lib/esm/actions/blue/withdraw.d.ts +3 -3
- package/lib/esm/actions/blue/withdraw.js +3 -3
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +2 -2
- package/lib/esm/actions/blue/withdrawCollateral.js +2 -2
- package/lib/esm/actions/bundles/common.d.ts +6 -2
- package/lib/esm/actions/bundles/common.js +32 -6
- package/lib/esm/actions/index.d.ts +0 -1
- package/lib/esm/actions/index.js +0 -1
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +6 -8
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +12 -17
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +5 -6
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +4 -5
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +4 -4
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +4 -5
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +5 -5
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +6 -11
- package/lib/esm/actions/requirements/encode/index.d.ts +0 -1
- package/lib/esm/actions/requirements/encode/index.js +0 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +5 -6
- package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -6
- package/lib/esm/actions/requirements/index.d.ts +0 -1
- package/lib/esm/actions/requirements/index.js +0 -1
- package/lib/esm/actions/vaultV1/deposit.d.ts +1 -2
- package/lib/esm/actions/vaultV1/deposit.js +1 -2
- package/lib/esm/actions/vaultV1/inKindRedeem.d.ts +7 -5
- package/lib/esm/actions/vaultV1/inKindRedeem.js +11 -7
- package/lib/esm/actions/vaultV2/deposit.d.ts +1 -2
- package/lib/esm/actions/vaultV2/deposit.js +1 -2
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +1 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +3 -3
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +7 -5
- package/lib/esm/actions/vaultV2/inKindRedeem.js +11 -7
- package/lib/esm/augment/AccrualPosition.d.ts +1 -0
- package/lib/esm/augment.d.ts +0 -1
- package/lib/esm/augment.js +0 -1
- package/lib/esm/blue/abis.d.ts +5 -5
- package/lib/esm/blue/abis.js +5 -5
- package/lib/esm/blue/entities.d.ts +10 -8
- package/lib/esm/blue/entities.js +5 -3
- package/lib/esm/blue/errors.d.ts +4 -2
- package/lib/esm/blue/errors.js +4 -2
- package/lib/esm/blue/fetch.d.ts +5 -3
- package/lib/esm/blue/fetch.js +5 -3
- package/lib/esm/blue/types.d.ts +2 -4
- package/lib/esm/blue/utils.d.ts +6 -4
- package/lib/esm/blue/utils.js +6 -4
- package/lib/esm/client/morphoViemExtension.d.ts +1 -1
- package/lib/esm/client/morphoViemExtension.js +1 -1
- package/lib/esm/constants.d.ts +3 -37
- package/lib/esm/constants.js +3 -37
- package/lib/esm/entities/blue/blue.d.ts +30 -265
- package/lib/esm/entities/blue/blue.js +4 -208
- package/lib/esm/entities/index.d.ts +11 -66
- package/lib/esm/entities/index.js +5 -18
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +5 -2
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +8 -3
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +13 -5
- package/lib/esm/entities/vaultV1/vaultV1.js +19 -13
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +40 -19
- package/lib/esm/entities/vaultV2/vaultV2.js +61 -30
- package/lib/esm/entities/vaultV2BlueReallocationData.js +2 -19
- package/lib/esm/errors.d.ts +5 -47
- package/lib/esm/errors.js +5 -47
- package/lib/esm/fetch.d.ts +5 -17
- package/lib/esm/fetch.js +5 -17
- package/lib/esm/helpers/constant.d.ts +0 -2
- package/lib/esm/helpers/constant.js +0 -2
- package/lib/esm/helpers/index.d.ts +2 -3
- package/lib/esm/helpers/index.js +2 -3
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +11 -5
- package/lib/esm/helpers/slippage.d.ts +1 -103
- package/lib/esm/helpers/slippage.js +1 -147
- package/lib/esm/helpers/utilization.d.ts +12 -10
- package/lib/esm/helpers/utilization.js +26 -11
- package/lib/esm/helpers/validate.d.ts +1 -24
- package/lib/esm/helpers/validate.js +2 -48
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +1 -3
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +48 -15
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +48 -15
- package/lib/esm/midnight/errors.d.ts +1 -1
- package/lib/esm/midnight/errors.js +1 -1
- package/lib/esm/types/action.d.ts +17 -65
- package/lib/esm/types/action.js +12 -5
- package/lib/esm/types/error.d.ts +50 -381
- package/lib/esm/types/error.js +58 -377
- package/lib/esm/types/sharedLiquidity.d.ts +1 -117
- package/lib/esm/types.d.ts +2 -18
- package/lib/esm/utils.d.ts +10 -35
- package/lib/esm/utils.js +9 -34
- package/package.json +6 -17
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -88
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -152
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -53
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -74
- package/lib/cjs/actions/requirements/generalAdapter/index.d.ts +0 -3
- package/lib/cjs/actions/requirements/generalAdapter/index.js +0 -19
- package/lib/cjs/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
- package/lib/cjs/actions/signatures/getBlueAuthorizationAction.js +0 -48
- package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +0 -58
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +0 -119
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -50
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -45
- package/lib/cjs/actions/signatures/index.d.ts +0 -3
- package/lib/cjs/actions/signatures/index.js +0 -19
- package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -11
- package/lib/cjs/augment/VaultMarketPublicAllocatorConfig.js +0 -8
- package/lib/cjs/bundler/actions.d.ts +0 -797
- package/lib/cjs/bundler/actions.js +0 -1371
- package/lib/cjs/bundler/index.d.ts +0 -2
- package/lib/cjs/bundler/index.js +0 -18
- package/lib/cjs/bundler/types.d.ts +0 -235
- package/lib/cjs/bundler/types.js +0 -2
- package/lib/cjs/entities/vaultV1ReallocationData.d.ts +0 -332
- package/lib/cjs/entities/vaultV1ReallocationData.js +0 -557
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +0 -80
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +0 -245
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +0 -44
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +0 -84
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.d.ts +0 -88
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +0 -148
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +0 -40
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +0 -49
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +0 -57
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +0 -70
- package/lib/esm/actions/requirements/generalAdapter/index.d.ts +0 -3
- package/lib/esm/actions/requirements/generalAdapter/index.js +0 -3
- package/lib/esm/actions/signatures/getBlueAuthorizationAction.d.ts +0 -29
- package/lib/esm/actions/signatures/getBlueAuthorizationAction.js +0 -44
- package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +0 -58
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +0 -115
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +0 -50
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +0 -41
- package/lib/esm/actions/signatures/index.d.ts +0 -3
- package/lib/esm/actions/signatures/index.js +0 -3
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.d.ts +0 -11
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +0 -7
- package/lib/esm/bundler/actions.d.ts +0 -797
- package/lib/esm/bundler/actions.js +0 -1368
- package/lib/esm/bundler/index.d.ts +0 -2
- package/lib/esm/bundler/index.js +0 -2
- package/lib/esm/bundler/types.d.ts +0 -235
- package/lib/esm/bundler/types.js +0 -1
- package/lib/esm/entities/vaultV1ReallocationData.d.ts +0 -332
- package/lib/esm/entities/vaultV1ReallocationData.js +0 -559
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +0 -80
- package/lib/esm/helpers/computeVaultV1Reallocations.js +0 -241
|
@@ -262,23 +262,34 @@ export function computeVaultV2ForceWithdrawPlan(params) {
|
|
|
262
262
|
* The result is the **denominator of {@link computeMinForceWithdrawSharePrice}** — the largest share
|
|
263
263
|
* burn the realized exit price is measured against. It takes the max over the two supplied snapshots
|
|
264
264
|
* because interest lowers the burn while management fees raise it, so neither snapshot alone bounds
|
|
265
|
-
* execution. The entity passes
|
|
266
|
-
* underestimates the burn a stale fee-bearing vault realizes —
|
|
267
|
-
* management fees before burning shares —
|
|
268
|
-
*
|
|
269
|
-
*
|
|
270
|
-
*
|
|
265
|
+
* execution. The entity passes the raw `lastUpdate` snapshot and the same vault accrued to `now`
|
|
266
|
+
* (execution time): the raw snapshot underestimates the burn a stale fee-bearing vault realizes —
|
|
267
|
+
* the first withdrawal accrues pending management fees before burning shares — while the `now`
|
|
268
|
+
* accrual underestimates it when it projects interest the chain has not realized (a wall clock
|
|
269
|
+
* running ahead of the chain, or a capped `maxRate`); either alone would lift the floor above the
|
|
270
|
+
* faithful price and trip `SlippageExceeded`. Accruing to `now`, not the caller-chosen `deadline`,
|
|
271
|
+
* tracks execution without letting a long deadline silently weaken the guard; `slippageTolerance`
|
|
272
|
+
* absorbs the residual drift until inclusion.
|
|
271
273
|
*
|
|
272
|
-
* This is **not** the share allowance to authorize. The
|
|
273
|
-
*
|
|
274
|
-
*
|
|
275
|
-
* `
|
|
276
|
-
*
|
|
274
|
+
* This is **not** the share allowance to authorize. The contract measures the *net* burn, which
|
|
275
|
+
* fee mints to `owner` shrink, and the raw snapshot mints none while the `now` accrual mints
|
|
276
|
+
* `computeVaultV2ForceWithdrawFeeSharesMinted({ vaultData, owner, timestamp: now })`; so the
|
|
277
|
+
* entity nets each endpoint before taking the max (`max(burnRaw, burnNow - feeSharesNow)`) rather
|
|
278
|
+
* than subtracting the `now` fee from a gross max. The allowance is
|
|
279
|
+
* `min(max(mulDivUp(exitAssets, RAY, max(min(mulDivDown(minSharePriceE27, WAD - slippageTolerance,
|
|
280
|
+
* WAD), minSharePriceE27 - 1), 1)), mulDivUp(exitAssets, RAY, minSharePriceE27) + 1)
|
|
281
|
+
* + computeVaultV2ForceWithdrawFeeSharesMinted({ vaultData, owner, timestamp: deadline }),
|
|
282
|
+
* maxUint256)`: the permit pays for the *gross* burn, covering a burn at least one tolerance step
|
|
283
|
+
* below the floor whenever the floor exceeds one RAY unit and, in any case, at least one share
|
|
284
|
+
* above the burn at the floor, so a price within that headroom below the floor reverts on the
|
|
285
|
+
* contract's `minSharePriceE27` check rather than on the allowance; a deeper drop can still
|
|
286
|
+
* surface as an ERC-20 allowance underflow.
|
|
277
287
|
*
|
|
278
288
|
* @param params - Share-bound inputs.
|
|
279
289
|
* @param params.vaultData - Pre-fetched Vault V2 accrual snapshot.
|
|
280
290
|
* @param params.deadlineVaultData - The same vault accrued to a second timestamp; the max of the two
|
|
281
|
-
* share burns is returned. The entity
|
|
291
|
+
* share burns is returned. The entity calls this twice — the raw snapshot for both parameters,
|
|
292
|
+
* then the `now` accrual for both — and nets each result before taking the max.
|
|
282
293
|
* @param params.plan - Plan from {@link computeVaultV2ForceWithdrawPlan}.
|
|
283
294
|
* @returns An upper bound, in vault shares, of what the exit burns.
|
|
284
295
|
* @example
|
|
@@ -290,7 +301,12 @@ export function computeVaultV2ForceWithdrawPlan(params) {
|
|
|
290
301
|
* } from "@morpho-org/morpho-sdk";
|
|
291
302
|
*
|
|
292
303
|
* const { vault: nowVaultData } = vaultData.accrueInterest(now);
|
|
293
|
-
* const
|
|
304
|
+
* const sharesBurntRaw = computeVaultV2ForceWithdrawSharesBurnt({
|
|
305
|
+
* vaultData,
|
|
306
|
+
* deadlineVaultData: vaultData,
|
|
307
|
+
* plan,
|
|
308
|
+
* });
|
|
309
|
+
* const sharesBurntNow = computeVaultV2ForceWithdrawSharesBurnt({
|
|
294
310
|
* vaultData: nowVaultData,
|
|
295
311
|
* deadlineVaultData: nowVaultData,
|
|
296
312
|
* plan,
|
|
@@ -300,9 +316,26 @@ export function computeVaultV2ForceWithdrawPlan(params) {
|
|
|
300
316
|
* owner,
|
|
301
317
|
* timestamp: now,
|
|
302
318
|
* });
|
|
303
|
-
* const sharesBurntForFloor =
|
|
319
|
+
* const sharesBurntForFloor = MathLib.max(
|
|
320
|
+
* sharesBurntRaw,
|
|
321
|
+
* sharesBurntNow - feeSharesNow,
|
|
322
|
+
* );
|
|
323
|
+
* const allowanceSharePriceE27 = MathLib.max(
|
|
324
|
+
* MathLib.min(
|
|
325
|
+
* MathLib.mulDivDown(
|
|
326
|
+
* minSharePriceE27,
|
|
327
|
+
* MathLib.WAD - slippageTolerance,
|
|
328
|
+
* MathLib.WAD,
|
|
329
|
+
* ),
|
|
330
|
+
* minSharePriceE27 - 1n,
|
|
331
|
+
* ),
|
|
332
|
+
* 1n,
|
|
333
|
+
* );
|
|
304
334
|
* const requiredShareAllowance = MathLib.min(
|
|
305
|
-
* MathLib.
|
|
335
|
+
* MathLib.max(
|
|
336
|
+
* MathLib.mulDivUp(exitAssets, MathLib.RAY, allowanceSharePriceE27),
|
|
337
|
+
* MathLib.mulDivUp(exitAssets, MathLib.RAY, minSharePriceE27) + 1n,
|
|
338
|
+
* ) +
|
|
306
339
|
* computeVaultV2ForceWithdrawFeeSharesMinted({
|
|
307
340
|
* vaultData,
|
|
308
341
|
* owner,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
1
|
+
export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
@@ -1 +1 @@
|
|
|
1
|
-
export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
1
|
+
export { ChainIdMismatchError, InvalidEcrecoverSignatureVError, InvalidMarketParameterError, InvalidMidnightApiQuoteTargetError, InvalidMidnightApiResponseError, InvalidOfferGroupError, InvalidOfferParameterError, InvalidPositionAccrualStateError, InvalidPositionAccrualTimestampError, InvalidPositionLossFactorError, InvalidTickSpacingError, InvalidTreeError, InvalidTreeHeightError, InvalidTypedDataSignatureError, MidnightApiError, MidnightMempoolValidationError, PayloadDecodeError, PriceGreaterThanOneError, SettlementFeeExceedsPriceError, TickOutOfRangeError, UnknownCollateralIndexError, } from "@morpho-org/midnight-sdk";
|
|
@@ -417,20 +417,6 @@ export interface Transaction<TAction extends BaseAction = TransactionAction> {
|
|
|
417
417
|
readonly data: Hex;
|
|
418
418
|
readonly action: TAction;
|
|
419
419
|
}
|
|
420
|
-
/**
|
|
421
|
-
* Enforces that at least one deposit amount source is provided.
|
|
422
|
-
*
|
|
423
|
-
* - `amount` alone: standard ERC20 deposit.
|
|
424
|
-
* - `nativeAmount` alone: pure native-wrap deposit (vault asset must be wNative).
|
|
425
|
-
* - Both: mixed deposit (ERC20 transfer + native wrap).
|
|
426
|
-
*/
|
|
427
|
-
export type DepositAmountArgs = {
|
|
428
|
-
amount: bigint;
|
|
429
|
-
nativeAmount?: bigint;
|
|
430
|
-
} | {
|
|
431
|
-
nativeAmount: bigint;
|
|
432
|
-
amount?: bigint;
|
|
433
|
-
};
|
|
434
420
|
/** Mutually exclusive ERC-20 or native funding accepted by fixed bundles entrypoints. */
|
|
435
421
|
export type BundlesFundingArgs = {
|
|
436
422
|
readonly amount: bigint;
|
|
@@ -458,8 +444,7 @@ export type VaultV1MigrateToV2AmountArgs = {
|
|
|
458
444
|
* Holds the pre-resolved arguments for an ERC-2612 `permit`: the signed approval
|
|
459
445
|
* of `amount` of `asset` from `owner` to the permitted spender, bounded by the
|
|
460
446
|
* `deadline` timestamp and consuming the given `nonce`. The associated
|
|
461
|
-
* {@link PermitAction} identifies the permitted
|
|
462
|
-
* contracts and the GeneralAdapter1 periphery.
|
|
447
|
+
* {@link PermitAction} identifies the permitted fixed-bundle contract.
|
|
463
448
|
*/
|
|
464
449
|
export interface PermitArgs {
|
|
465
450
|
readonly owner: Address;
|
|
@@ -469,25 +454,10 @@ export interface PermitArgs {
|
|
|
469
454
|
readonly amount: bigint;
|
|
470
455
|
readonly deadline: bigint;
|
|
471
456
|
}
|
|
472
|
-
/**
|
|
473
|
-
* Holds the pre-resolved arguments for a Permit2 `permit` bundler call. It
|
|
474
|
-
* mirrors {@link PermitArgs} but adds the Permit2 allowance `expiration` (when
|
|
475
|
-
* the on-chain allowance lapses) alongside the signature `deadline` (by when the
|
|
476
|
-
* signature must be submitted).
|
|
477
|
-
*/
|
|
478
|
-
export interface Permit2Args {
|
|
479
|
-
readonly owner: Address;
|
|
480
|
-
readonly nonce: bigint;
|
|
481
|
-
readonly asset: Address;
|
|
482
|
-
readonly signature: Hex;
|
|
483
|
-
readonly amount: bigint;
|
|
484
|
-
readonly deadline: bigint;
|
|
485
|
-
readonly expiration: bigint;
|
|
486
|
-
}
|
|
487
457
|
/**
|
|
488
458
|
* Signed Morpho Blue authorization payload produced when an integrator opts into offchain
|
|
489
|
-
* signatures (`supportSignature: true`).
|
|
490
|
-
*
|
|
459
|
+
* signatures (`supportSignature: true`). BlueBundlesV1 encodes it into its
|
|
460
|
+
* signed-authorization struct.
|
|
491
461
|
*/
|
|
492
462
|
export interface AuthorizationSignatureArgs {
|
|
493
463
|
/** Account granting the authorization (the position owner). */
|
|
@@ -527,15 +497,6 @@ export interface PermitAction extends BaseAction<"permit", {
|
|
|
527
497
|
*/
|
|
528
498
|
readonly typedData?: RequirementTypedData;
|
|
529
499
|
}
|
|
530
|
-
export interface Permit2Action extends BaseAction<"permit2", {
|
|
531
|
-
spender: Address;
|
|
532
|
-
amount: bigint;
|
|
533
|
-
deadline: bigint;
|
|
534
|
-
expiration: bigint;
|
|
535
|
-
}> {
|
|
536
|
-
/** EIP-712 payload to sign for this Permit2 AllowanceTransfer. See {@link PermitAction.typedData}. */
|
|
537
|
-
readonly typedData?: RequirementTypedData;
|
|
538
|
-
}
|
|
539
500
|
/** Signable Permit2 SignatureTransfer requirement for a fixed bundles token pull. */
|
|
540
501
|
export interface Permit2SignatureTransferAction extends BaseAction<"permit2SignatureTransfer", {
|
|
541
502
|
readonly spender: Address;
|
|
@@ -547,8 +508,7 @@ export interface Permit2SignatureTransferAction extends BaseAction<"permit2Signa
|
|
|
547
508
|
readonly typedData?: RequirementTypedData;
|
|
548
509
|
}
|
|
549
510
|
/**
|
|
550
|
-
* Signable Morpho authorization requirement
|
|
551
|
-
* GeneralAdapter1 for Bundler3 flows or BlueBundlesV1 for direct Blue writes.
|
|
511
|
+
* Signable Morpho authorization requirement for direct BlueBundlesV1 writes.
|
|
552
512
|
*/
|
|
553
513
|
export interface AuthorizationAction extends BaseAction<"authorization", {
|
|
554
514
|
authorized: Address;
|
|
@@ -575,27 +535,22 @@ export interface MidnightOfferRootSignatureAction extends BaseAction<"midnightOf
|
|
|
575
535
|
readonly typedData?: RequirementTypedData;
|
|
576
536
|
}
|
|
577
537
|
/** Action metadata supported by signature requirements. */
|
|
578
|
-
export type SignatureRequirementAction = PermitAction |
|
|
538
|
+
export type SignatureRequirementAction = PermitAction | Permit2SignatureTransferAction | AuthorizationAction | MidnightOfferRootSignatureAction;
|
|
579
539
|
/** Argument payloads returned by signature requirements. */
|
|
580
|
-
export type RequirementSignatureArgs = PermitArgs |
|
|
540
|
+
export type RequirementSignatureArgs = PermitArgs | AuthorizationSignatureArgs | MidnightOfferRootSignatureArgs;
|
|
581
541
|
/** A signed ERC-2612 permit requirement. */
|
|
582
542
|
export interface Erc2612RequirementSignature {
|
|
583
543
|
readonly args: Readonly<PermitArgs>;
|
|
584
544
|
readonly action: PermitAction;
|
|
585
545
|
}
|
|
586
|
-
/** A signed
|
|
587
|
-
export
|
|
588
|
-
readonly args: Readonly<Permit2Args>;
|
|
589
|
-
readonly action: Permit2Action;
|
|
590
|
-
}
|
|
591
|
-
/** A signed ERC-2612 permit or Permit2 AllowanceTransfer requirement. */
|
|
592
|
-
export type PermitRequirementSignature = Erc2612RequirementSignature | Permit2AllowanceRequirementSignature;
|
|
546
|
+
/** A signed ERC-2612 permit requirement accepted by vault-share bundle calls. */
|
|
547
|
+
export type PermitRequirementSignature = Erc2612RequirementSignature;
|
|
593
548
|
/** A signed Permit2 SignatureTransfer requirement used by fixed bundles contracts. */
|
|
594
549
|
export interface Permit2SignatureTransferRequirementSignature {
|
|
595
550
|
readonly args: Readonly<PermitArgs>;
|
|
596
551
|
readonly action: Permit2SignatureTransferAction;
|
|
597
552
|
}
|
|
598
|
-
/** A signed Morpho authorization consumed by
|
|
553
|
+
/** A signed Morpho authorization consumed by a direct BlueBundlesV1 call. */
|
|
599
554
|
export interface AuthorizationRequirementSignature {
|
|
600
555
|
readonly args: AuthorizationSignatureArgs;
|
|
601
556
|
readonly action: AuthorizationAction;
|
|
@@ -607,7 +562,7 @@ export interface MidnightOfferRootSignature {
|
|
|
607
562
|
}
|
|
608
563
|
/**
|
|
609
564
|
* The deep-frozen output of `Requirement.sign()`. Discriminated on `action.type`:
|
|
610
|
-
* `"permit"`
|
|
565
|
+
* `"permit"` carries token-approval args, `"permit2SignatureTransfer"` carries a
|
|
611
566
|
* bundles SignatureTransfer, `"authorization"` carries the signed Morpho authorization,
|
|
612
567
|
* and Midnight adds `"midnightOfferRootSignature"`.
|
|
613
568
|
*/
|
|
@@ -644,20 +599,16 @@ export interface Requirement<TSignatureOrAction extends RequirementSignature | S
|
|
|
644
599
|
readonly typedData: RequirementTypedData;
|
|
645
600
|
};
|
|
646
601
|
}
|
|
647
|
-
/** Bundler3 token signature requirement. */
|
|
648
|
-
export type Bundler3TokenSignatureRequirement = Requirement<PermitRequirementSignature>;
|
|
649
602
|
/** ERC-2612 or Permit2 SignatureTransfer requirement consumed by a fixed bundles contract. */
|
|
650
603
|
export type BundlesTokenSignatureRequirement = Requirement<BundlesTokenRequirementSignature>;
|
|
651
604
|
/** Midnight Ecrecover offer-root signature requirement. */
|
|
652
605
|
export type MidnightOfferRootRequirement = Requirement<MidnightOfferRootSignatureAction, MidnightOfferRootSignatureArgs>;
|
|
653
606
|
/** Any token signature requirement supported by an SDK transaction route. */
|
|
654
|
-
export type TokenSignatureRequirement =
|
|
655
|
-
/** Bundler3 token signature result. */
|
|
656
|
-
export type Bundler3TokenRequirementSignature = PermitRequirementSignature;
|
|
607
|
+
export type TokenSignatureRequirement = BundlesTokenSignatureRequirement;
|
|
657
608
|
/** Token signature result consumed by a fixed bundles contract. */
|
|
658
609
|
export type BundlesTokenRequirementSignature = Erc2612RequirementSignature | Permit2SignatureTransferRequirementSignature;
|
|
659
610
|
/** Any token signature result supported by an SDK transaction route. */
|
|
660
|
-
export type TokenRequirementSignature =
|
|
611
|
+
export type TokenRequirementSignature = BundlesTokenRequirementSignature;
|
|
661
612
|
/** Any signature result returned by an action-output signature requirement. */
|
|
662
613
|
export type AnyRequirementSignature = TokenRequirementSignature | AuthorizationRequirementSignature | MidnightOfferRootSignature;
|
|
663
614
|
/** Any signature requirement returned by an entity action output. */
|
|
@@ -689,10 +640,10 @@ export declare function isRequirementSignature<T extends RequirementSignature =
|
|
|
689
640
|
export declare function isRequirementSignature(requirement: CallRequirement | Requirement | undefined): requirement is Requirement;
|
|
690
641
|
export declare function isRequirementSignature(requirement: ActionRequirement | undefined): requirement is SignatureRequirement;
|
|
691
642
|
/**
|
|
692
|
-
* Narrows a {@link RequirementSignature} to
|
|
643
|
+
* Narrows a {@link RequirementSignature} to an ERC-2612 permit signature.
|
|
693
644
|
*
|
|
694
645
|
* @param signature - The signed requirement to test.
|
|
695
|
-
* @returns `true` when `signature.action.type` is `"permit"
|
|
646
|
+
* @returns `true` when `signature.action.type` is `"permit"`.
|
|
696
647
|
*/
|
|
697
648
|
export declare function isPermitSignature(signature: RequirementSignature): signature is PermitRequirementSignature;
|
|
698
649
|
/**
|
|
@@ -728,7 +679,7 @@ export declare function isAuthorizationSignature(signature: RequirementSignature
|
|
|
728
679
|
export declare function isMidnightOfferRootSignature(signature: RequirementSignature): signature is MidnightOfferRootSignature;
|
|
729
680
|
/** The typed requirement-signature slots a transaction builder consumes, split from a `buildTx` array. */
|
|
730
681
|
export interface SelectedRequirementSignatures {
|
|
731
|
-
/** The single ERC-2612
|
|
682
|
+
/** The single ERC-2612 signature, when present. */
|
|
732
683
|
readonly permit?: PermitRequirementSignature;
|
|
733
684
|
/** The single Permit2 SignatureTransfer signature, when present. */
|
|
734
685
|
readonly permit2SignatureTransfer?: Permit2SignatureTransferRequirementSignature;
|
|
@@ -748,12 +699,13 @@ export interface SelectedRequirementSignatures {
|
|
|
748
699
|
*
|
|
749
700
|
* @param signatures - The signatures passed to `buildTx`.
|
|
750
701
|
* @param accepts - Which signature kinds this operation consumes.
|
|
751
|
-
* @param accepts.permit - Whether an ERC-2612
|
|
702
|
+
* @param accepts.permit - Whether an ERC-2612 signature is consumed.
|
|
752
703
|
* @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
|
|
753
704
|
* @param accepts.authorization - Whether a Morpho authorization signature is consumed.
|
|
754
705
|
* @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
|
|
755
706
|
* @returns The accepted signature in each typed slot, when present.
|
|
756
707
|
* @throws {AmbiguousRequirementSignaturesError} when more than one signature of an accepted kind is present.
|
|
708
|
+
* @throws {UnsupportedRequirementSignatureError} when a signature has an unsupported action type.
|
|
757
709
|
* @throws {UnexpectedRequirementSignatureError} when a signature of a kind the operation does not consume is present.
|
|
758
710
|
* @example
|
|
759
711
|
* ```ts
|
package/lib/esm/types/action.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { AmbiguousRequirementSignaturesError, UnexpectedRequirementSignatureError, } from "./error.js";
|
|
1
|
+
import { AmbiguousRequirementSignaturesError, UnexpectedRequirementSignatureError, UnsupportedRequirementSignatureError, } from "./error.js";
|
|
2
2
|
export function isRequirementApproval(requirement) {
|
|
3
3
|
return (typeof requirement === "object" &&
|
|
4
4
|
requirement !== null &&
|
|
@@ -32,13 +32,13 @@ export function isRequirementSignature(requirement) {
|
|
|
32
32
|
typeof requirement.sign === "function");
|
|
33
33
|
}
|
|
34
34
|
/**
|
|
35
|
-
* Narrows a {@link RequirementSignature} to
|
|
35
|
+
* Narrows a {@link RequirementSignature} to an ERC-2612 permit signature.
|
|
36
36
|
*
|
|
37
37
|
* @param signature - The signed requirement to test.
|
|
38
|
-
* @returns `true` when `signature.action.type` is `"permit"
|
|
38
|
+
* @returns `true` when `signature.action.type` is `"permit"`.
|
|
39
39
|
*/
|
|
40
40
|
export function isPermitSignature(signature) {
|
|
41
|
-
return
|
|
41
|
+
return signature.action.type === "permit";
|
|
42
42
|
}
|
|
43
43
|
/**
|
|
44
44
|
* Narrows a {@link RequirementSignature} to a Permit2 SignatureTransfer result.
|
|
@@ -88,12 +88,13 @@ export function isMidnightOfferRootSignature(signature) {
|
|
|
88
88
|
*
|
|
89
89
|
* @param signatures - The signatures passed to `buildTx`.
|
|
90
90
|
* @param accepts - Which signature kinds this operation consumes.
|
|
91
|
-
* @param accepts.permit - Whether an ERC-2612
|
|
91
|
+
* @param accepts.permit - Whether an ERC-2612 signature is consumed.
|
|
92
92
|
* @param accepts.permit2SignatureTransfer - Whether a Permit2 SignatureTransfer is consumed.
|
|
93
93
|
* @param accepts.authorization - Whether a Morpho authorization signature is consumed.
|
|
94
94
|
* @param accepts.midnightOfferRoot - Whether a Midnight offer-root signature is consumed.
|
|
95
95
|
* @returns The accepted signature in each typed slot, when present.
|
|
96
96
|
* @throws {AmbiguousRequirementSignaturesError} when more than one signature of an accepted kind is present.
|
|
97
|
+
* @throws {UnsupportedRequirementSignatureError} when a signature has an unsupported action type.
|
|
97
98
|
* @throws {UnexpectedRequirementSignatureError} when a signature of a kind the operation does not consume is present.
|
|
98
99
|
* @example
|
|
99
100
|
* ```ts
|
|
@@ -112,6 +113,12 @@ export function selectRequirementSignatures(signatures, accepts) {
|
|
|
112
113
|
const permit2Transfers = signatures.filter(isPermit2SignatureTransferSignature);
|
|
113
114
|
const authorizations = signatures.filter(isAuthorizationSignature);
|
|
114
115
|
const midnightOfferRoots = signatures.filter(isMidnightOfferRootSignature);
|
|
116
|
+
const unsupported = signatures.find((signature) => !isPermitSignature(signature) &&
|
|
117
|
+
!isPermit2SignatureTransferSignature(signature) &&
|
|
118
|
+
!isAuthorizationSignature(signature) &&
|
|
119
|
+
!isMidnightOfferRootSignature(signature));
|
|
120
|
+
if (unsupported != null)
|
|
121
|
+
throw new UnsupportedRequirementSignatureError(unsupported.action.type);
|
|
115
122
|
if (!accepts.permit && permits.length > 0)
|
|
116
123
|
throw new UnexpectedRequirementSignatureError("permit");
|
|
117
124
|
if (!accepts.permit2SignatureTransfer && permit2Transfers.length > 0)
|