@morpho-org/morpho-sdk 10.1.0 → 10.2.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/lib/cjs/actions/blue/borrow.d.ts +11 -3
- package/lib/cjs/actions/blue/borrow.internal.js +1 -0
- package/lib/cjs/actions/blue/borrow.js +8 -2
- package/lib/cjs/actions/blue/common.d.ts +4 -1
- package/lib/cjs/actions/blue/common.js +17 -3
- package/lib/cjs/actions/blue/refinance.d.ts +11 -3
- package/lib/cjs/actions/blue/refinance.internal.js +4 -1
- package/lib/cjs/actions/blue/refinance.js +8 -2
- package/lib/cjs/actions/blue/refinanceValidation.d.ts +3 -2
- package/lib/cjs/actions/blue/refinanceValidation.js +10 -6
- package/lib/cjs/actions/blue/repay.d.ts +4 -3
- package/lib/cjs/actions/blue/repay.js +3 -2
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +3 -2
- package/lib/cjs/actions/blue/supply.d.ts +5 -3
- package/lib/cjs/actions/blue/supply.js +4 -2
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +4 -3
- package/lib/cjs/actions/blue/supplyCollateral.js +3 -2
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +11 -3
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.d.ts +2 -0
- package/lib/cjs/actions/blue/supplyCollateralBorrow.internal.js +5 -1
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +8 -2
- package/lib/cjs/actions/blue/withdraw.d.ts +11 -3
- package/lib/cjs/actions/blue/withdraw.internal.js +4 -1
- package/lib/cjs/actions/blue/withdraw.js +8 -2
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +4 -3
- package/lib/cjs/actions/blue/withdrawCollateral.js +3 -2
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +0 -1
- package/lib/cjs/actions/midnight/takeBorrow.js +0 -1
- package/lib/cjs/actions/midnight/takeLend.js +0 -1
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +0 -1
- package/lib/cjs/actions/midnight/takeWithdraw.js +0 -1
- package/lib/cjs/actions/vaultV1/deposit.d.ts +2 -1
- package/lib/cjs/actions/vaultV1/deposit.js +2 -1
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +3 -2
- package/lib/cjs/actions/vaultV1/migrateToV2.js +2 -1
- package/lib/cjs/actions/vaultV1/redeem.d.ts +3 -2
- package/lib/cjs/actions/vaultV1/redeem.js +2 -1
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +2 -1
- package/lib/cjs/actions/vaultV1/withdraw.js +2 -1
- package/lib/cjs/actions/vaultV2/deposit.d.ts +2 -1
- package/lib/cjs/actions/vaultV2/deposit.js +2 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.d.ts +2 -1
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +2 -1
- package/lib/cjs/actions/vaultV2/redeem.d.ts +3 -2
- package/lib/cjs/actions/vaultV2/redeem.js +2 -1
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +2 -1
- package/lib/cjs/actions/vaultV2/withdraw.js +2 -1
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +2 -0
- package/lib/cjs/entities/blue/blue.d.ts +83 -20
- package/lib/cjs/entities/blue/blue.js +38 -12
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
- package/lib/cjs/entities/vaultV1/migrateToV2Quote.js +5 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +12 -6
- package/lib/cjs/entities/vaultV1/vaultV1.js +6 -0
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +12 -7
- package/lib/cjs/entities/vaultV2/vaultV2.js +4 -0
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +11 -2
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +19 -21
- package/lib/cjs/helpers/constant.d.ts +2 -0
- package/lib/cjs/helpers/constant.js +3 -1
- package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
- package/lib/cjs/helpers/getBlueBundlesV1QuoteTimestamp.js +18 -0
- package/lib/cjs/helpers/index.d.ts +1 -1
- package/lib/cjs/helpers/index.js +2 -1
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +4 -5
- package/lib/cjs/helpers/quoteBlueRepay.d.ts +7 -3
- package/lib/cjs/helpers/quoteBlueRepay.js +20 -7
- package/lib/cjs/helpers/reallocationPenalty.d.ts +10 -0
- package/lib/cjs/helpers/reallocationPenalty.js +32 -0
- package/lib/cjs/helpers/referralFee.d.ts +2 -1
- package/lib/cjs/helpers/referralFee.js +5 -1
- package/lib/cjs/helpers/validate.d.ts +31 -4
- package/lib/cjs/helpers/validate.js +48 -9
- package/lib/cjs/helpers/validateMidnightBounds.d.ts +1 -2
- package/lib/cjs/helpers/validateMidnightBounds.js +1 -2
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
- package/lib/cjs/helpers/validateMidnightTakeFeasibility.js +1 -1
- package/lib/cjs/transactionPlan/blue/borrow.d.ts +11 -5
- package/lib/cjs/transactionPlan/blue/borrow.js +26 -8
- package/lib/cjs/transactionPlan/blue/refinance.d.ts +9 -2
- package/lib/cjs/transactionPlan/blue/refinance.js +20 -3
- package/lib/cjs/transactionPlan/blue/repay.d.ts +1 -2
- package/lib/cjs/transactionPlan/blue/repay.js +1 -2
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/cjs/transactionPlan/blue/repayWithdrawCollateral.js +13 -4
- package/lib/cjs/transactionPlan/blue/supply.d.ts +1 -2
- package/lib/cjs/transactionPlan/blue/supply.js +1 -2
- package/lib/cjs/transactionPlan/blue/supplyCollateral.d.ts +2 -3
- package/lib/cjs/transactionPlan/blue/supplyCollateral.js +2 -3
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
- package/lib/cjs/transactionPlan/blue/supplyCollateralBorrow.js +23 -6
- package/lib/cjs/transactionPlan/blue/withdraw.d.ts +15 -5
- package/lib/cjs/transactionPlan/blue/withdraw.js +25 -6
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
- package/lib/cjs/transactionPlan/blue/withdrawCollateral.js +11 -7
- package/lib/cjs/transactionPlan/deposit.js +4 -0
- package/lib/cjs/transactionPlan/intent.d.ts +1 -1
- package/lib/cjs/transactionPlan/intent.js +4 -2
- package/lib/cjs/transactionPlan/plan.d.ts +8 -4
- package/lib/cjs/transactionPlan/plan.js +8 -4
- package/lib/cjs/transactionPlan/types.d.ts +6 -0
- package/lib/cjs/transactionPlan/vaultv1/deposit.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv1/deposit.js +3 -3
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv1/migrateToV2.js +7 -3
- package/lib/cjs/transactionPlan/vaultv1/redeem.d.ts +1 -2
- package/lib/cjs/transactionPlan/vaultv1/redeem.js +1 -2
- package/lib/cjs/transactionPlan/vaultv1/withdraw.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv1/withdraw.js +2 -3
- package/lib/cjs/transactionPlan/vaultv2/deposit.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv2/deposit.js +3 -3
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
- package/lib/cjs/transactionPlan/vaultv2/forceWithdraw.js +3 -3
- package/lib/cjs/transactionPlan/vaultv2/redeem.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv2/redeem.js +2 -3
- package/lib/cjs/transactionPlan/vaultv2/withdraw.d.ts +2 -3
- package/lib/cjs/transactionPlan/vaultv2/withdraw.js +2 -3
- package/lib/cjs/types/error.d.ts +7 -6
- package/lib/cjs/types/error.js +10 -9
- package/lib/cjs/types/sharedLiquidity.d.ts +7 -2
- package/lib/cjs/version.d.ts +1 -1
- package/lib/cjs/version.js +1 -1
- package/lib/esm/actions/blue/borrow.d.ts +11 -3
- package/lib/esm/actions/blue/borrow.internal.js +1 -0
- package/lib/esm/actions/blue/borrow.js +8 -2
- package/lib/esm/actions/blue/common.d.ts +4 -1
- package/lib/esm/actions/blue/common.js +17 -3
- package/lib/esm/actions/blue/refinance.d.ts +11 -3
- package/lib/esm/actions/blue/refinance.internal.js +4 -1
- package/lib/esm/actions/blue/refinance.js +8 -2
- package/lib/esm/actions/blue/refinanceValidation.d.ts +3 -2
- package/lib/esm/actions/blue/refinanceValidation.js +10 -6
- package/lib/esm/actions/blue/repay.d.ts +4 -3
- package/lib/esm/actions/blue/repay.js +3 -2
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +3 -2
- package/lib/esm/actions/blue/supply.d.ts +5 -3
- package/lib/esm/actions/blue/supply.js +4 -2
- package/lib/esm/actions/blue/supplyCollateral.d.ts +4 -3
- package/lib/esm/actions/blue/supplyCollateral.js +3 -2
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +11 -3
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.d.ts +2 -0
- package/lib/esm/actions/blue/supplyCollateralBorrow.internal.js +5 -1
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +8 -2
- package/lib/esm/actions/blue/withdraw.d.ts +11 -3
- package/lib/esm/actions/blue/withdraw.internal.js +4 -1
- package/lib/esm/actions/blue/withdraw.js +8 -2
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +4 -3
- package/lib/esm/actions/blue/withdrawCollateral.js +3 -2
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +1 -2
- package/lib/esm/actions/midnight/takeBorrow.js +1 -2
- package/lib/esm/actions/midnight/takeLend.js +1 -2
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +1 -2
- package/lib/esm/actions/midnight/takeWithdraw.js +1 -2
- package/lib/esm/actions/vaultV1/deposit.d.ts +2 -1
- package/lib/esm/actions/vaultV1/deposit.js +2 -1
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +3 -2
- package/lib/esm/actions/vaultV1/migrateToV2.js +2 -1
- package/lib/esm/actions/vaultV1/redeem.d.ts +3 -2
- package/lib/esm/actions/vaultV1/redeem.js +2 -1
- package/lib/esm/actions/vaultV1/withdraw.d.ts +2 -1
- package/lib/esm/actions/vaultV1/withdraw.js +2 -1
- package/lib/esm/actions/vaultV2/deposit.d.ts +2 -1
- package/lib/esm/actions/vaultV2/deposit.js +2 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.d.ts +2 -1
- package/lib/esm/actions/vaultV2/forceWithdraw.js +2 -1
- package/lib/esm/actions/vaultV2/redeem.d.ts +3 -2
- package/lib/esm/actions/vaultV2/redeem.js +2 -1
- package/lib/esm/actions/vaultV2/withdraw.d.ts +2 -1
- package/lib/esm/actions/vaultV2/withdraw.js +2 -1
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +83 -20
- package/lib/esm/entities/blue/blue.js +38 -12
- package/lib/esm/entities/vaultV1/migrateToV2Quote.d.ts +2 -0
- package/lib/esm/entities/vaultV1/migrateToV2Quote.js +5 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +12 -6
- package/lib/esm/entities/vaultV1/vaultV1.js +7 -1
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +12 -7
- package/lib/esm/entities/vaultV2/vaultV2.js +5 -1
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +11 -2
- package/lib/esm/entities/vaultV2BlueReallocationData.js +17 -19
- package/lib/esm/helpers/constant.d.ts +2 -0
- package/lib/esm/helpers/constant.js +2 -0
- package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.d.ts +10 -0
- package/lib/esm/helpers/getBlueBundlesV1QuoteTimestamp.js +15 -0
- package/lib/esm/helpers/index.d.ts +1 -1
- package/lib/esm/helpers/index.js +1 -1
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +3 -3
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +4 -5
- package/lib/esm/helpers/quoteBlueRepay.d.ts +7 -3
- package/lib/esm/helpers/quoteBlueRepay.js +21 -8
- package/lib/esm/helpers/reallocationPenalty.d.ts +10 -0
- package/lib/esm/helpers/reallocationPenalty.js +28 -0
- package/lib/esm/helpers/referralFee.d.ts +2 -1
- package/lib/esm/helpers/referralFee.js +5 -1
- package/lib/esm/helpers/validate.d.ts +31 -4
- package/lib/esm/helpers/validate.js +48 -11
- package/lib/esm/helpers/validateMidnightBounds.d.ts +1 -2
- package/lib/esm/helpers/validateMidnightBounds.js +1 -2
- package/lib/esm/helpers/validateMidnightTakeFeasibility.d.ts +2 -2
- package/lib/esm/helpers/validateMidnightTakeFeasibility.js +1 -1
- package/lib/esm/transactionPlan/blue/borrow.d.ts +11 -5
- package/lib/esm/transactionPlan/blue/borrow.js +27 -9
- package/lib/esm/transactionPlan/blue/refinance.d.ts +9 -2
- package/lib/esm/transactionPlan/blue/refinance.js +20 -3
- package/lib/esm/transactionPlan/blue/repay.d.ts +1 -2
- package/lib/esm/transactionPlan/blue/repay.js +1 -2
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.d.ts +4 -3
- package/lib/esm/transactionPlan/blue/repayWithdrawCollateral.js +13 -4
- package/lib/esm/transactionPlan/blue/supply.d.ts +1 -2
- package/lib/esm/transactionPlan/blue/supply.js +1 -2
- package/lib/esm/transactionPlan/blue/supplyCollateral.d.ts +2 -3
- package/lib/esm/transactionPlan/blue/supplyCollateral.js +2 -3
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.d.ts +10 -4
- package/lib/esm/transactionPlan/blue/supplyCollateralBorrow.js +23 -6
- package/lib/esm/transactionPlan/blue/withdraw.d.ts +15 -5
- package/lib/esm/transactionPlan/blue/withdraw.js +25 -6
- package/lib/esm/transactionPlan/blue/withdrawCollateral.d.ts +5 -5
- package/lib/esm/transactionPlan/blue/withdrawCollateral.js +11 -7
- package/lib/esm/transactionPlan/deposit.js +5 -1
- package/lib/esm/transactionPlan/intent.d.ts +1 -1
- package/lib/esm/transactionPlan/intent.js +4 -2
- package/lib/esm/transactionPlan/plan.d.ts +8 -4
- package/lib/esm/transactionPlan/plan.js +8 -4
- package/lib/esm/transactionPlan/types.d.ts +6 -0
- package/lib/esm/transactionPlan/vaultv1/deposit.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv1/deposit.js +3 -3
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv1/migrateToV2.js +8 -4
- package/lib/esm/transactionPlan/vaultv1/redeem.d.ts +1 -2
- package/lib/esm/transactionPlan/vaultv1/redeem.js +1 -2
- package/lib/esm/transactionPlan/vaultv1/withdraw.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv1/withdraw.js +2 -3
- package/lib/esm/transactionPlan/vaultv2/deposit.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv2/deposit.js +3 -3
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.d.ts +3 -3
- package/lib/esm/transactionPlan/vaultv2/forceWithdraw.js +3 -3
- package/lib/esm/transactionPlan/vaultv2/redeem.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv2/redeem.js +2 -3
- package/lib/esm/transactionPlan/vaultv2/withdraw.d.ts +2 -3
- package/lib/esm/transactionPlan/vaultv2/withdraw.js +2 -3
- package/lib/esm/types/error.d.ts +7 -6
- package/lib/esm/types/error.js +11 -10
- package/lib/esm/types/sharedLiquidity.d.ts +7 -2
- package/lib/esm/version.d.ts +1 -1
- package/lib/esm/version.js +1 -1
- package/package.json +3 -3
|
@@ -364,6 +364,7 @@ function encodeStep(action, requests) {
|
|
|
364
364
|
* @param step - Recipe to encode; missing signatures on unrelated supported steps do not block it.
|
|
365
365
|
* @returns A frozen `{ to, data, value, action }`, ready to simulate or submit. `data` ends with the plan's `calldataOrigin` when one was set.
|
|
366
366
|
* @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent.
|
|
367
|
+
* @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
|
|
367
368
|
* @throws {InvalidSignatureError} If a stored signature has high s, cannot recover a public key or does not match the request owner.
|
|
368
369
|
* @throws {UnsupportedTransactionPlanVersionError} If the plan version is unsupported.
|
|
369
370
|
* @throws {UnsupportedTransactionPlanActionError} If any plan step or the selected step names an unsupported action type.
|
|
@@ -377,13 +378,14 @@ function encodeStep(action, requests) {
|
|
|
377
378
|
* @throws {EmptyDeallocationsError} If a force-redeem step has no deallocations.
|
|
378
379
|
* @throws {EmptyMarketParamsListError} If a Vault V1 in-kind redemption step has no markets.
|
|
379
380
|
* @throws {ReferralFeePctExceededError} If the action's referral fee is at least WAD.
|
|
381
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
380
382
|
* @throws {ReferralFeeRecipientMissingError} If a positive referral fee has no nonzero recipient.
|
|
381
383
|
* @throws {IncompleteTransactionPlanError} If a referenced signature request or its signature is missing.
|
|
382
384
|
* @throws {TransactionPlanSignatureMismatchError} If a referenced request disagrees with the step's action or its encoding arguments.
|
|
383
385
|
* @throws {BundlesPermitMismatchError} If a stored signature cannot be parsed or a signed permit's encoding arguments do not match the step.
|
|
384
386
|
* @throws {MarketIdMismatchError} If a Blue market ID differs from its parameter tuple.
|
|
385
|
-
* @throws {NegativeInputError} If a Blue amount, native value, LTV bound or referral fee is negative.
|
|
386
|
-
* @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, or withdrawal-only funding is nonzero.
|
|
387
|
+
* @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative.
|
|
388
|
+
* @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), or withdrawal-only funding is nonzero.
|
|
387
389
|
* @throws {MutuallyExclusiveRepayAmountsError} If a Blue repayment specifies both nonzero assets and shares.
|
|
388
390
|
* @throws {MaxRepayAssetsBelowRepayAssetsError} If exact-asset funding cannot cover repayment plus referral fees.
|
|
389
391
|
* @throws {NativeFundingAmountMismatchError} If Blue native funding does not equal the full repayment cap.
|
|
@@ -460,6 +462,7 @@ export function buildTransaction(plan, step) {
|
|
|
460
462
|
* @param plan - Plan whose referenced signature requests all carry a signature.
|
|
461
463
|
* @returns Frozen SDK transactions in step order; discriminate on `action.type` for per-step handling.
|
|
462
464
|
* @throws {InvalidTransactionPlanError} If the plan header, action context, IDs or deadlines are inconsistent.
|
|
465
|
+
* @throws {InvalidBigIntInputError} If a supplied Blue maxPenalty is not a bigint; uint256 schema validation is performed by parseTransactionPlan, not this builder.
|
|
463
466
|
* @throws {InvalidSignatureError} If a stored signature has high s, cannot recover a public key or does not match the request owner.
|
|
464
467
|
* @throws {UnsupportedTransactionPlanVersionError} If the plan version is unsupported, including empty plans.
|
|
465
468
|
* @throws {UnsupportedTransactionPlanActionError} If any plan step names an unsupported action type, before reading requests.
|
|
@@ -473,13 +476,14 @@ export function buildTransaction(plan, step) {
|
|
|
473
476
|
* @throws {EmptyDeallocationsError} If a force-redeem step has no deallocations.
|
|
474
477
|
* @throws {EmptyMarketParamsListError} If a Vault V1 in-kind redemption step has no markets.
|
|
475
478
|
* @throws {ReferralFeePctExceededError} If an action's referral fee is at least WAD.
|
|
479
|
+
* @throws {MidnightReferralFeePctExceededError} when the referral fee is above 10% but below WAD.
|
|
476
480
|
* @throws {ReferralFeeRecipientMissingError} If a positive referral fee has no nonzero recipient.
|
|
477
481
|
* @throws {IncompleteTransactionPlanError} If any step references a signature request or signature that is missing.
|
|
478
482
|
* @throws {TransactionPlanSignatureMismatchError} If a referenced request disagrees with its action or encoding arguments.
|
|
479
483
|
* @throws {BundlesPermitMismatchError} If a stored signature cannot be parsed or a signed permit's encoding arguments do not match the step.
|
|
480
484
|
* @throws {MarketIdMismatchError} If a Blue market ID differs from its parameter tuple.
|
|
481
|
-
* @throws {NegativeInputError} If a Blue amount, native value, LTV bound or referral fee is negative.
|
|
482
|
-
* @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, or withdrawal-only funding is nonzero.
|
|
485
|
+
* @throws {NegativeInputError} If a Blue amount, native value, LTV bound, maxPenalty or referral fee is negative.
|
|
486
|
+
* @throws {InputExceedsMaxError} If a Blue amount, bound or deadline exceeds uint256, maxPenalty exceeds WAD, a reallocation penalty exceeds maxPenalty (default zero, rejecting any positive penalty), or withdrawal-only funding is nonzero.
|
|
483
487
|
* @throws {MutuallyExclusiveRepayAmountsError} If a Blue repayment specifies both nonzero assets and shares.
|
|
484
488
|
* @throws {MaxRepayAssetsBelowRepayAssetsError} If exact-asset funding cannot cover repayment plus referral fees.
|
|
485
489
|
* @throws {NativeFundingAmountMismatchError} If Blue native funding does not equal the full repayment cap.
|
|
@@ -87,6 +87,8 @@ export type Action = {
|
|
|
87
87
|
readonly marketParams: MarketParams;
|
|
88
88
|
readonly borrowAssets: bigint;
|
|
89
89
|
readonly maxLtv: bigint;
|
|
90
|
+
/** Maximum WAD-scaled penalty rate per reallocation, defaulting to zero; it does not bound total proceeds lost. */
|
|
91
|
+
readonly maxPenalty?: bigint;
|
|
90
92
|
readonly reallocations: readonly VaultV2BlueReallocation[];
|
|
91
93
|
readonly deadline: bigint;
|
|
92
94
|
readonly referralFeePct: bigint;
|
|
@@ -123,6 +125,8 @@ export type Action = {
|
|
|
123
125
|
readonly marketParams: Pick<MarketParams, "loanToken" | "collateralToken" | "oracle" | "irm" | "lltv">;
|
|
124
126
|
readonly withdrawAssets: bigint;
|
|
125
127
|
readonly withdrawShares: bigint;
|
|
128
|
+
/** Maximum WAD-scaled penalty rate per reallocation, defaulting to zero; it does not bound total proceeds lost. */
|
|
129
|
+
readonly maxPenalty?: bigint;
|
|
126
130
|
readonly reallocations: readonly VaultV2BlueReallocation[];
|
|
127
131
|
readonly deadline: bigint;
|
|
128
132
|
readonly referralFeePct: bigint;
|
|
@@ -264,6 +268,8 @@ export type Action = {
|
|
|
264
268
|
readonly sourceMarketParams: Readonly<MarketParams>;
|
|
265
269
|
readonly destinationMarketParams: Readonly<MarketParams>;
|
|
266
270
|
readonly maxLtv: bigint;
|
|
271
|
+
/** Maximum WAD-scaled penalty rate per reallocation, defaulting to zero; it does not bound the total penalty added to destination debt. */
|
|
272
|
+
readonly maxPenalty?: bigint;
|
|
267
273
|
readonly deadline: bigint;
|
|
268
274
|
readonly referralFeePct: bigint;
|
|
269
275
|
readonly referralFeeRecipient: Address;
|
|
@@ -41,7 +41,7 @@ export interface VaultV1DepositPlanParams extends DepositPlanParams<AccrualVault
|
|
|
41
41
|
* @param params.account - Non-zero account funding, signing and sending the deposit.
|
|
42
42
|
* @param params.assets - Positive gross deposit in asset base units, before referral fees.
|
|
43
43
|
* @param params.funding.type - Optional funding source: `"erc20"` (default) or `"native"`; native funding requires the vault asset to be wNative.
|
|
44
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be
|
|
44
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be at most 1,000.
|
|
45
45
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
46
46
|
* @param params.slippageTolerance - Optional WAD-scaled tolerance for the share-price bound; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
|
|
47
47
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
@@ -50,16 +50,16 @@ export interface VaultV1DepositPlanParams extends DepositPlanParams<AccrualVault
|
|
|
50
50
|
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to each built transaction's calldata.
|
|
51
51
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
52
52
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
53
|
+
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
53
54
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
54
55
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
55
56
|
* @throws {NonPositiveInputError} when `expiresAt`, `assets`, net assets or previewed shares are not positive.
|
|
56
57
|
* @throws {ExpiredDeadlineError} when `expiresAt` is not in the future.
|
|
57
58
|
* @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
|
|
58
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
59
|
+
* @throws {InputExceedsMaxError} when `expiresAt` exceeds seven days after `now`, `referralFee.bps` exceeds 1,000 or `assets` exceeds uint256.
|
|
59
60
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
|
|
60
61
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
61
62
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
62
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
63
63
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
64
64
|
* @throws {NativeAmountOnNonWNativeVaultError} when native funding targets a vault whose asset is not wNative.
|
|
65
65
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
@@ -15,7 +15,7 @@ import { getVaultPermit } from "../permit.js";
|
|
|
15
15
|
* @param params.account - Non-zero account funding, signing and sending the deposit.
|
|
16
16
|
* @param params.assets - Positive gross deposit in asset base units, before referral fees.
|
|
17
17
|
* @param params.funding.type - Optional funding source: `"erc20"` (default) or `"native"`; native funding requires the vault asset to be wNative.
|
|
18
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be
|
|
18
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be at most 1,000.
|
|
19
19
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
20
20
|
* @param params.slippageTolerance - Optional WAD-scaled tolerance for the share-price bound; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
|
|
21
21
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
@@ -24,16 +24,16 @@ import { getVaultPermit } from "../permit.js";
|
|
|
24
24
|
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to each built transaction's calldata.
|
|
25
25
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
26
26
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
27
|
+
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
27
28
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
28
29
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
29
30
|
* @throws {NonPositiveInputError} when `expiresAt`, `assets`, net assets or previewed shares are not positive.
|
|
30
31
|
* @throws {ExpiredDeadlineError} when `expiresAt` is not in the future.
|
|
31
32
|
* @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
|
|
32
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
33
|
+
* @throws {InputExceedsMaxError} when `expiresAt` exceeds seven days after `now`, `referralFee.bps` exceeds 1,000 or `assets` exceeds uint256.
|
|
33
34
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
|
|
34
35
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
35
36
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
36
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
37
37
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
38
38
|
* @throws {NativeAmountOnNonWNativeVaultError} when native funding targets a vault whose asset is not wNative.
|
|
39
39
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
@@ -41,7 +41,7 @@ export type VaultV1MigrateToV2PlanParams = Omit<IntentParams, "deployless"> & Re
|
|
|
41
41
|
* @param params.account - Non-zero account approving or permitting shares and sending the migration.
|
|
42
42
|
* @param params.assets - Positive gross migration in asset base units, before referral fees; mutually exclusive with `shares`.
|
|
43
43
|
* @param params.shares - Positive source share amount to migrate; mutually exclusive with `assets`.
|
|
44
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be
|
|
44
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be at most 1,000.
|
|
45
45
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
46
46
|
* @param params.slippageTolerance - Optional WAD-scaled tolerance for the destination price and source share allowance quotes; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
|
|
47
47
|
* @param params.supportSignature - Optional unlimited ERC-2612 share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient. Vault V1 shares support ERC-2612; no Permit2 is used.
|
|
@@ -49,6 +49,7 @@ export type VaultV1MigrateToV2PlanParams = Omit<IntentParams, "deployless"> & Re
|
|
|
49
49
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
50
50
|
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to each built transaction's calldata.
|
|
51
51
|
* @returns A static migration plan with any required source share approval or permit.
|
|
52
|
+
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
52
53
|
* @throws {VaultAssetMismatchError} If the vault assets differ.
|
|
53
54
|
* @throws {SameVaultMigrationError} If source and target are identical.
|
|
54
55
|
* @throws {AmountAndSharesExclusiveError} If both or neither amount is supplied.
|
|
@@ -56,11 +57,10 @@ export type VaultV1MigrateToV2PlanParams = Omit<IntentParams, "deployless"> & Re
|
|
|
56
57
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
57
58
|
* @throws {NonPositiveInputError} when `expiresAt`, the selected amount, net migrated assets or previewed shares are not positive.
|
|
58
59
|
* @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
|
|
59
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
60
|
+
* @throws {InputExceedsMaxError} when `expiresAt` exceeds seven days after `now`, `referralFee.bps` exceeds 1,000 or the selected amount exceeds uint256.
|
|
60
61
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
|
|
61
62
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
62
63
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
63
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
64
64
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
65
65
|
* @throws {ExpiredDeadlineError} If the expiry is not in the future.
|
|
66
66
|
* @throws {ChainIdMismatchError} If the client targets another chain.
|
|
@@ -4,7 +4,7 @@ import { isAddressEqual } from "viem";
|
|
|
4
4
|
import { normalizeBundlesCommonParams, selectBundlesSharesPermitSignature, } from "../../actions/bundles/common.js";
|
|
5
5
|
import { vaultV1MigrateToV2 } from "../../actions/vaultV1/migrateToV2.js";
|
|
6
6
|
import { computeVaultV1MigrateToV2Quote } from "../../entities/vaultV1/migrateToV2Quote.js";
|
|
7
|
-
import { validateSlippageTolerance, validateUint256Field, } from "../../helpers/validate.js";
|
|
7
|
+
import { validateReferenceTime, validateSlippageTolerance, validateUint256Field, validateVaultDepositDeadline, } from "../../helpers/validate.js";
|
|
8
8
|
import { AmountAndSharesExclusiveError, NonPositiveInputError, SameVaultMigrationError, VaultAssetMismatchError, } from "../../types/index.js";
|
|
9
9
|
import { InvalidTransactionPlanError } from "../error.js";
|
|
10
10
|
import { resolveIntent } from "../intent.js";
|
|
@@ -54,7 +54,7 @@ export function validateMigrateToV2PlanAction(action, path) {
|
|
|
54
54
|
* @param params.account - Non-zero account approving or permitting shares and sending the migration.
|
|
55
55
|
* @param params.assets - Positive gross migration in asset base units, before referral fees; mutually exclusive with `shares`.
|
|
56
56
|
* @param params.shares - Positive source share amount to migrate; mutually exclusive with `assets`.
|
|
57
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be
|
|
57
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be at most 1,000.
|
|
58
58
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
59
59
|
* @param params.slippageTolerance - Optional WAD-scaled tolerance for the destination price and source share allowance quotes; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
|
|
60
60
|
* @param params.supportSignature - Optional unlimited ERC-2612 share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient. Vault V1 shares support ERC-2612; no Permit2 is used.
|
|
@@ -62,6 +62,7 @@ export function validateMigrateToV2PlanAction(action, path) {
|
|
|
62
62
|
* @param params.expiresAt - Optional Unix timestamp in seconds as a safe integer, later than `now`; defaults to `now + 2h`.
|
|
63
63
|
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to each built transaction's calldata.
|
|
64
64
|
* @returns A static migration plan with any required source share approval or permit.
|
|
65
|
+
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
65
66
|
* @throws {VaultAssetMismatchError} If the vault assets differ.
|
|
66
67
|
* @throws {SameVaultMigrationError} If source and target are identical.
|
|
67
68
|
* @throws {AmountAndSharesExclusiveError} If both or neither amount is supplied.
|
|
@@ -69,11 +70,10 @@ export function validateMigrateToV2PlanAction(action, path) {
|
|
|
69
70
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
70
71
|
* @throws {NonPositiveInputError} when `expiresAt`, the selected amount, net migrated assets or previewed shares are not positive.
|
|
71
72
|
* @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
|
|
72
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
73
|
+
* @throws {InputExceedsMaxError} when `expiresAt` exceeds seven days after `now`, `referralFee.bps` exceeds 1,000 or the selected amount exceeds uint256.
|
|
73
74
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
|
|
74
75
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
75
76
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
76
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
77
77
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
78
78
|
* @throws {ExpiredDeadlineError} If the expiry is not in the future.
|
|
79
79
|
* @throws {ChainIdMismatchError} If the client targets another chain.
|
|
@@ -104,7 +104,11 @@ export function validateMigrateToV2PlanAction(action, path) {
|
|
|
104
104
|
export async function prepareVaultV1MigrateToV2(client, params) {
|
|
105
105
|
const { sourceVault, targetVault, chainId, account } = params;
|
|
106
106
|
const now = params.now ?? Time.timestamp();
|
|
107
|
+
// Reject a non-bigint clock before deriving the default expiry.
|
|
108
|
+
validateReferenceTime(now);
|
|
107
109
|
const intent = resolveIntent(params, now);
|
|
110
|
+
// Report the plan's public expiry field before computing the shared quote.
|
|
111
|
+
validateVaultDepositDeadline(intent.deadline, { now, field: "expiresAt" });
|
|
108
112
|
const slippageTolerance = params.slippageTolerance ?? DEFAULT_SLIPPAGE_TOLERANCE;
|
|
109
113
|
validateSlippageTolerance(slippageTolerance);
|
|
110
114
|
if (!isAddressEqual(sourceVault.asset, targetVault.asset)) {
|
|
@@ -37,10 +37,9 @@ export interface VaultV1RedeemPlanParams extends RedeemPlanParams {
|
|
|
37
37
|
* @throws {NonPositiveInputError} when `expiresAt` or `shares` is not positive.
|
|
38
38
|
* @throws {ExpiredDeadlineError} when `expiresAt` is not in the future.
|
|
39
39
|
* @throws {NegativeInputError} when `referralFee.bps` is negative.
|
|
40
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
40
|
+
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 1,000 or `shares` exceeds uint256.
|
|
41
41
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
42
42
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
43
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
44
43
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
45
44
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
46
45
|
* @throws {MissingContractCodeError} when VaultBundlesV1 is absent.
|
|
@@ -22,10 +22,9 @@ import { prepareVaultRedeem } from "../redeem.js";
|
|
|
22
22
|
* @throws {NonPositiveInputError} when `expiresAt` or `shares` is not positive.
|
|
23
23
|
* @throws {ExpiredDeadlineError} when `expiresAt` is not in the future.
|
|
24
24
|
* @throws {NegativeInputError} when `referralFee.bps` is negative.
|
|
25
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
25
|
+
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 1,000 or `shares` exceeds uint256.
|
|
26
26
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
27
27
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
28
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
29
28
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
30
29
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
31
30
|
* @throws {MissingContractCodeError} when VaultBundlesV1 is absent.
|
|
@@ -31,7 +31,7 @@ export interface VaultV1WithdrawPlanParams extends WithdrawPlanParams<AccrualVau
|
|
|
31
31
|
* @param params.chainId - Chain containing the vault and registered VaultBundlesV1 contract.
|
|
32
32
|
* @param params.account - Non-zero account approving or permitting shares and sending the withdrawal.
|
|
33
33
|
* @param params.assets - Positive gross withdrawal in asset base units, before referral fees.
|
|
34
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be
|
|
34
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be at most 1,000.
|
|
35
35
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
36
36
|
* @param params.supportSignature - Optional unlimited share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient.
|
|
37
37
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
@@ -43,10 +43,9 @@ export interface VaultV1WithdrawPlanParams extends WithdrawPlanParams<AccrualVau
|
|
|
43
43
|
* @throws {NonPositiveInputError} when `expiresAt`, `assets` or the computed required shares are not positive.
|
|
44
44
|
* @throws {ExpiredDeadlineError} when `expiresAt` is not in the future.
|
|
45
45
|
* @throws {NegativeInputError} when `referralFee.bps` is negative.
|
|
46
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
46
|
+
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 1,000 or `assets` exceeds uint256.
|
|
47
47
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
48
48
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
49
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
50
49
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
51
50
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
52
51
|
* @throws {MissingContractCodeError} when the VaultBundlesV1 contract is absent.
|
|
@@ -17,7 +17,7 @@ import { prepareVaultWithdraw } from "../withdraw.js";
|
|
|
17
17
|
* @param params.chainId - Chain containing the vault and registered VaultBundlesV1 contract.
|
|
18
18
|
* @param params.account - Non-zero account approving or permitting shares and sending the withdrawal.
|
|
19
19
|
* @param params.assets - Positive gross withdrawal in asset base units, before referral fees.
|
|
20
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be
|
|
20
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross amount; defaults to zero and must be at most 1,000.
|
|
21
21
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
22
22
|
* @param params.supportSignature - Optional unlimited share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient.
|
|
23
23
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
@@ -29,10 +29,9 @@ import { prepareVaultWithdraw } from "../withdraw.js";
|
|
|
29
29
|
* @throws {NonPositiveInputError} when `expiresAt`, `assets` or the computed required shares are not positive.
|
|
30
30
|
* @throws {ExpiredDeadlineError} when `expiresAt` is not in the future.
|
|
31
31
|
* @throws {NegativeInputError} when `referralFee.bps` is negative.
|
|
32
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
32
|
+
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 1,000 or `assets` exceeds uint256.
|
|
33
33
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
34
34
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
35
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
36
35
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
37
36
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
38
37
|
* @throws {MissingContractCodeError} when the VaultBundlesV1 contract is absent.
|
|
@@ -20,7 +20,7 @@ export interface VaultV2DepositPlanParams extends DepositPlanParams<AccrualVault
|
|
|
20
20
|
* @param params.account - Non-zero account funding, signing and sending the deposit.
|
|
21
21
|
* @param params.assets - Positive gross deposit in asset base units, before referral fees.
|
|
22
22
|
* @param params.funding.type - Optional funding source: `"erc20"` (default) or `"native"`; native funding requires the vault asset to be wNative.
|
|
23
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross assets; defaults to zero and must be
|
|
23
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross assets; defaults to zero and must be at most 1,000.
|
|
24
24
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
25
25
|
* @param params.slippageTolerance - Optional WAD-scaled tolerance for the share-price bound; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
|
|
26
26
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
@@ -29,16 +29,16 @@ export interface VaultV2DepositPlanParams extends DepositPlanParams<AccrualVault
|
|
|
29
29
|
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to each built transaction's calldata.
|
|
30
30
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
31
31
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
32
|
+
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
32
33
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
33
34
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
34
35
|
* @throws {NonPositiveInputError} when `expiresAt`, `assets`, net assets or previewed shares are not positive.
|
|
35
36
|
* @throws {ExpiredDeadlineError} when `expiresAt` is at or before `now` (device clock when `now` is omitted).
|
|
36
37
|
* @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
|
|
37
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
38
|
+
* @throws {InputExceedsMaxError} when `expiresAt` exceeds seven days after `now`, `referralFee.bps` exceeds 1,000 or `assets` exceeds uint256.
|
|
38
39
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
|
|
39
40
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
40
41
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
41
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
42
42
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
43
43
|
* @throws {NativeAmountOnNonWNativeVaultError} when native funding targets a vault whose asset is not wNative.
|
|
44
44
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
@@ -14,7 +14,7 @@ import { getVaultPermit } from "../permit.js";
|
|
|
14
14
|
* @param params.account - Non-zero account funding, signing and sending the deposit.
|
|
15
15
|
* @param params.assets - Positive gross deposit in asset base units, before referral fees.
|
|
16
16
|
* @param params.funding.type - Optional funding source: `"erc20"` (default) or `"native"`; native funding requires the vault asset to be wNative.
|
|
17
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross assets; defaults to zero and must be
|
|
17
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross assets; defaults to zero and must be at most 1,000.
|
|
18
18
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
19
19
|
* @param params.slippageTolerance - Optional WAD-scaled tolerance for the share-price bound; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
|
|
20
20
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; when enabled, falls back to direct approval if no permit is available.
|
|
@@ -23,16 +23,16 @@ import { getVaultPermit } from "../permit.js";
|
|
|
23
23
|
* @param params.calldataOrigin - Optional non-empty, even-length hex bytes appended to each built transaction's calldata.
|
|
24
24
|
* @param params.deployless - Optional permission to use deployless aggregation for token permit metadata reads.
|
|
25
25
|
* @returns A plan with approvals, concrete signature requests and the deposit step.
|
|
26
|
+
* @throws {InvalidBigIntInputError} when `now` is not a bigint.
|
|
26
27
|
* @throws {ZeroAccountError} when `account` is the zero address.
|
|
27
28
|
* @throws {NonIntegerInputError} when `expiresAt` or `referralFee.bps` is not a safe integer.
|
|
28
29
|
* @throws {NonPositiveInputError} when `expiresAt`, `assets`, net assets or previewed shares are not positive.
|
|
29
30
|
* @throws {ExpiredDeadlineError} when `expiresAt` is at or before `now` (device clock when `now` is omitted).
|
|
30
31
|
* @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
|
|
31
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
32
|
+
* @throws {InputExceedsMaxError} when `expiresAt` exceeds seven days after `now`, `referralFee.bps` exceeds 1,000 or `assets` exceeds uint256.
|
|
32
33
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
|
|
33
34
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
34
35
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
35
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
36
36
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
37
37
|
* @throws {NativeAmountOnNonWNativeVaultError} when native funding targets a vault whose asset is not wNative.
|
|
38
38
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
@@ -39,7 +39,7 @@ export interface VaultV2ForceWithdrawPlanParams extends Omit<IntentParams, "depl
|
|
|
39
39
|
* @param params.assets - Positive penalty-inclusive exit assets in asset base units; received assets exclude penalties and referral fees.
|
|
40
40
|
* @param params.adapter - Optional assertion that this address is the vault's sole supported adapter.
|
|
41
41
|
* @param params.slippageTolerance - Optional WAD-scaled tolerance used to derive the realized share-price floor; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
|
|
42
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of withdrawn assets, after penalties; defaults to zero and must be
|
|
42
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of withdrawn assets, after penalties; defaults to zero and must be at most 1,000. The fee is deducted after the share-price check.
|
|
43
43
|
* @param params.referralFee.recipient - Optional fee recipient; must be non-zero when the fee is positive.
|
|
44
44
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; insufficient allowance produces an unlimited direct share approval, or an unlimited share permit when `true`.
|
|
45
45
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
@@ -52,11 +52,11 @@ export interface VaultV2ForceWithdrawPlanParams extends Omit<IntentParams, "depl
|
|
|
52
52
|
* @throws {ExpiredDeadlineError} when the expiry has elapsed, including during requirement resolution.
|
|
53
53
|
* @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
|
|
54
54
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
|
|
55
|
-
* @throws {InputExceedsMaxError} when
|
|
55
|
+
* @throws {InputExceedsMaxError} when an input exceeds uint256 or the expiry exceeds the fee-projection horizon.
|
|
56
56
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
57
57
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
58
58
|
* @throws {ChainIdMismatchError} when the client declares or serves another chain.
|
|
59
|
-
* @throws {
|
|
59
|
+
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 1,000.
|
|
60
60
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
61
61
|
* @throws {VaultV2SingleAdapterRequiredError} when the snapshot does not have exactly one adapter.
|
|
62
62
|
* @throws {AdapterNotPartOfVaultError} when the adapter assertion does not match the vault's adapter.
|
|
@@ -24,7 +24,7 @@ import { validatePlanFields, validateVaultPlanAction } from "../validation.js";
|
|
|
24
24
|
* @param params.assets - Positive penalty-inclusive exit assets in asset base units; received assets exclude penalties and referral fees.
|
|
25
25
|
* @param params.adapter - Optional assertion that this address is the vault's sole supported adapter.
|
|
26
26
|
* @param params.slippageTolerance - Optional WAD-scaled tolerance used to derive the realized share-price floor; defaults to `DEFAULT_SLIPPAGE_TOLERANCE` and must not exceed `MAX_SLIPPAGE_TOLERANCE`.
|
|
27
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of withdrawn assets, after penalties; defaults to zero and must be
|
|
27
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of withdrawn assets, after penalties; defaults to zero and must be at most 1,000. The fee is deducted after the share-price check.
|
|
28
28
|
* @param params.referralFee.recipient - Optional fee recipient; must be non-zero when the fee is positive.
|
|
29
29
|
* @param params.supportSignature - Optional ERC-2612 preference, defaulting to `false`; insufficient allowance produces an unlimited direct share approval, or an unlimited share permit when `true`.
|
|
30
30
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
@@ -37,11 +37,11 @@ import { validatePlanFields, validateVaultPlanAction } from "../validation.js";
|
|
|
37
37
|
* @throws {ExpiredDeadlineError} when the expiry has elapsed, including during requirement resolution.
|
|
38
38
|
* @throws {NegativeInputError} when `referralFee.bps` or `slippageTolerance` is negative.
|
|
39
39
|
* @throws {ExcessiveSlippageToleranceError} when `slippageTolerance` exceeds `MAX_SLIPPAGE_TOLERANCE`.
|
|
40
|
-
* @throws {InputExceedsMaxError} when
|
|
40
|
+
* @throws {InputExceedsMaxError} when an input exceeds uint256 or the expiry exceeds the fee-projection horizon.
|
|
41
41
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
42
42
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
43
43
|
* @throws {ChainIdMismatchError} when the client declares or serves another chain.
|
|
44
|
-
* @throws {
|
|
44
|
+
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 1,000.
|
|
45
45
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
46
46
|
* @throws {VaultV2SingleAdapterRequiredError} when the snapshot does not have exactly one adapter.
|
|
47
47
|
* @throws {AdapterNotPartOfVaultError} when the adapter assertion does not match the vault's adapter.
|
|
@@ -35,7 +35,7 @@ export interface VaultV2RedeemPlanParams extends RedeemPlanParams {
|
|
|
35
35
|
* @param params.chainId - Chain containing the vault and registered VaultBundlesV1 contract.
|
|
36
36
|
* @param params.account - Non-zero share owner, permit signer and transaction sender; receives the net assets.
|
|
37
37
|
* @param params.shares - Positive exact shares to burn, in share base units; use the account's balance for full redemption.
|
|
38
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of gross redeemed assets; defaults to zero and must be
|
|
38
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of gross redeemed assets; defaults to zero and must be at most 1,000.
|
|
39
39
|
* @param params.referralFee.recipient - Optional fee recipient; must be non-zero when the fee is positive.
|
|
40
40
|
* @param params.supportSignature - Optional ERC-2612 share-permit preference; defaults to `false` for direct approval.
|
|
41
41
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
@@ -48,10 +48,9 @@ export interface VaultV2RedeemPlanParams extends RedeemPlanParams {
|
|
|
48
48
|
* @throws {NonPositiveInputError} when `expiresAt` or `shares` is not positive.
|
|
49
49
|
* @throws {ExpiredDeadlineError} when `expiresAt` is not in the future.
|
|
50
50
|
* @throws {NegativeInputError} when `referralFee.bps` is negative.
|
|
51
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
51
|
+
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 1,000 or `shares` exceeds uint256.
|
|
52
52
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
53
53
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
54
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
55
54
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no non-zero recipient.
|
|
56
55
|
* @throws {ChainIdMismatchError} when the declared or RPC chain differs from `chainId`.
|
|
57
56
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
@@ -12,7 +12,7 @@ import { prepareVaultRedeem } from "../redeem.js";
|
|
|
12
12
|
* @param params.chainId - Chain containing the vault and registered VaultBundlesV1 contract.
|
|
13
13
|
* @param params.account - Non-zero share owner, permit signer and transaction sender; receives the net assets.
|
|
14
14
|
* @param params.shares - Positive exact shares to burn, in share base units; use the account's balance for full redemption.
|
|
15
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of gross redeemed assets; defaults to zero and must be
|
|
15
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of gross redeemed assets; defaults to zero and must be at most 1,000.
|
|
16
16
|
* @param params.referralFee.recipient - Optional fee recipient; must be non-zero when the fee is positive.
|
|
17
17
|
* @param params.supportSignature - Optional ERC-2612 share-permit preference; defaults to `false` for direct approval.
|
|
18
18
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
@@ -25,10 +25,9 @@ import { prepareVaultRedeem } from "../redeem.js";
|
|
|
25
25
|
* @throws {NonPositiveInputError} when `expiresAt` or `shares` is not positive.
|
|
26
26
|
* @throws {ExpiredDeadlineError} when `expiresAt` is not in the future.
|
|
27
27
|
* @throws {NegativeInputError} when `referralFee.bps` is negative.
|
|
28
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
28
|
+
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 1,000 or `shares` exceeds uint256.
|
|
29
29
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
30
30
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
31
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
32
31
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no non-zero recipient.
|
|
33
32
|
* @throws {ChainIdMismatchError} when the declared or RPC chain differs from `chainId`.
|
|
34
33
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
@@ -23,7 +23,7 @@ export interface VaultV2WithdrawPlanParams extends WithdrawPlanParams<AccrualVau
|
|
|
23
23
|
* @param params.chainId - Chain containing the vault and registered VaultBundlesV1 contract.
|
|
24
24
|
* @param params.account - Non-zero account approving or permitting shares and sending the withdrawal.
|
|
25
25
|
* @param params.assets - Positive gross withdrawal in asset base units, before referral fees.
|
|
26
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross assets; defaults to zero and must be
|
|
26
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross assets; defaults to zero and must be at most 1,000.
|
|
27
27
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
28
28
|
* @param params.supportSignature - Optional unlimited share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient.
|
|
29
29
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
@@ -35,10 +35,9 @@ export interface VaultV2WithdrawPlanParams extends WithdrawPlanParams<AccrualVau
|
|
|
35
35
|
* @throws {NonPositiveInputError} when `expiresAt`, `assets` or the computed required shares are not positive.
|
|
36
36
|
* @throws {ExpiredDeadlineError} when `expiresAt` is at or before `now` (device clock when `now` is omitted).
|
|
37
37
|
* @throws {NegativeInputError} when `referralFee.bps` is negative.
|
|
38
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
38
|
+
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 1,000 or `assets` exceeds uint256.
|
|
39
39
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
40
40
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
41
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
42
41
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
43
42
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
44
43
|
* @throws {MissingContractCodeError} when the VaultBundlesV1 contract is absent.
|
|
@@ -17,7 +17,7 @@ import { prepareVaultWithdraw } from "../withdraw.js";
|
|
|
17
17
|
* @param params.chainId - Chain containing the vault and registered VaultBundlesV1 contract.
|
|
18
18
|
* @param params.account - Non-zero account approving or permitting shares and sending the withdrawal.
|
|
19
19
|
* @param params.assets - Positive gross withdrawal in asset base units, before referral fees.
|
|
20
|
-
* @param params.referralFee.bps - Optional integer fee in basis points of the gross assets; defaults to zero and must be
|
|
20
|
+
* @param params.referralFee.bps - Optional integer fee in basis points of the gross assets; defaults to zero and must be at most 1,000.
|
|
21
21
|
* @param params.referralFee.recipient - Recipient of the optional fee; must be non-zero when the fee is positive.
|
|
22
22
|
* @param params.supportSignature - Optional unlimited share-permit preference, defaulting to `false`; otherwise uses unlimited direct share approval when allowance is insufficient.
|
|
23
23
|
* @param params.now - Reference timestamp in seconds, normally the latest block's `timestamp`; uses the device clock when omitted.
|
|
@@ -29,10 +29,9 @@ import { prepareVaultWithdraw } from "../withdraw.js";
|
|
|
29
29
|
* @throws {NonPositiveInputError} when `expiresAt`, `assets` or the computed required shares are not positive.
|
|
30
30
|
* @throws {ExpiredDeadlineError} when `expiresAt` is at or before `now` (device clock when `now` is omitted).
|
|
31
31
|
* @throws {NegativeInputError} when `referralFee.bps` is negative.
|
|
32
|
-
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds
|
|
32
|
+
* @throws {InputExceedsMaxError} when `referralFee.bps` exceeds 1,000 or `assets` exceeds uint256.
|
|
33
33
|
* @throws {InvalidCalldataOriginError} when `calldataOrigin` is empty, malformed or has an odd number of hex digits.
|
|
34
34
|
* @throws {InvalidTransactionPlanError} when `account` is malformed or `calldataOrigin` exceeds 1 MiB.
|
|
35
|
-
* @throws {ReferralFeePctExceededError} when `referralFee.bps` equals 10,000; the normalized fee must be below WAD.
|
|
36
35
|
* @throws {ReferralFeeRecipientMissingError} when a positive referral fee has no recipient or a zero recipient.
|
|
37
36
|
* @throws {ChainIdMismatchError} when the client targets another chain.
|
|
38
37
|
* @throws {MissingContractCodeError} when the VaultBundlesV1 contract is absent.
|
package/lib/esm/types/error.d.ts
CHANGED
|
@@ -597,11 +597,12 @@ export declare class ReferralFeeRecipientMissingError extends Error {
|
|
|
597
597
|
constructor();
|
|
598
598
|
}
|
|
599
599
|
/**
|
|
600
|
-
* Thrown when a referral fee percentage is
|
|
600
|
+
* Thrown when a referral fee percentage is at least WAD, the contract's exclusive upper bound.
|
|
601
|
+
* The SDK also rejects lower fees above 10% with {@link MidnightReferralFeePctExceededError}.
|
|
601
602
|
*
|
|
602
|
-
* Extends {@link InputExceedsMaxError}
|
|
603
|
-
*
|
|
604
|
-
* `
|
|
603
|
+
* Extends {@link InputExceedsMaxError} with `field: "referralFeePct"` so integrators already
|
|
604
|
+
* pattern-matching `InputExceedsMaxError` keep catching this failure. Its `max` is the SDK's 10%
|
|
605
|
+
* cap (`WAD / 10n`), the largest fee the SDK accepts.
|
|
605
606
|
*/
|
|
606
607
|
export declare class ReferralFeePctExceededError extends InputExceedsMaxError {
|
|
607
608
|
readonly referralFeePct: bigint;
|
|
@@ -609,8 +610,8 @@ export declare class ReferralFeePctExceededError extends InputExceedsMaxError {
|
|
|
609
610
|
constructor(referralFeePct: bigint);
|
|
610
611
|
}
|
|
611
612
|
/**
|
|
612
|
-
* Thrown when the SDK's 10% (`WAD / 10n`)
|
|
613
|
-
*
|
|
613
|
+
* Thrown when a referral fee below WAD exceeds the SDK's 10% (`WAD / 10n`) cap.
|
|
614
|
+
* The name is retained from the original Midnight-only cap.
|
|
614
615
|
*/
|
|
615
616
|
export declare class MidnightReferralFeePctExceededError extends InputExceedsMaxError {
|
|
616
617
|
readonly referralFeePct: bigint;
|
package/lib/esm/types/error.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { UnknownDataError } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { Payload } from "@morpho-org/midnight-sdk";
|
|
3
3
|
import { MIDNIGHT_MAX_REFERRAL_FEE_PCT } from "../helpers/constant.js";
|
|
4
4
|
/**
|
|
@@ -686,11 +686,12 @@ export class ReferralFeeRecipientMissingError extends Error {
|
|
|
686
686
|
}
|
|
687
687
|
}
|
|
688
688
|
/**
|
|
689
|
-
* Thrown when a referral fee percentage is
|
|
689
|
+
* Thrown when a referral fee percentage is at least WAD, the contract's exclusive upper bound.
|
|
690
|
+
* The SDK also rejects lower fees above 10% with {@link MidnightReferralFeePctExceededError}.
|
|
690
691
|
*
|
|
691
|
-
* Extends {@link InputExceedsMaxError}
|
|
692
|
-
*
|
|
693
|
-
* `
|
|
692
|
+
* Extends {@link InputExceedsMaxError} with `field: "referralFeePct"` so integrators already
|
|
693
|
+
* pattern-matching `InputExceedsMaxError` keep catching this failure. Its `max` is the SDK's 10%
|
|
694
|
+
* cap (`WAD / 10n`), the largest fee the SDK accepts.
|
|
694
695
|
*/
|
|
695
696
|
export class ReferralFeePctExceededError extends InputExceedsMaxError {
|
|
696
697
|
referralFeePct;
|
|
@@ -699,16 +700,16 @@ export class ReferralFeePctExceededError extends InputExceedsMaxError {
|
|
|
699
700
|
super({
|
|
700
701
|
field: "referralFeePct",
|
|
701
702
|
value: referralFeePct,
|
|
702
|
-
max:
|
|
703
|
+
max: MIDNIGHT_MAX_REFERRAL_FEE_PCT,
|
|
703
704
|
});
|
|
704
705
|
this.referralFeePct = referralFeePct;
|
|
705
|
-
this.message = `Referral fee percentage "${referralFeePct}" must be below WAD
|
|
706
|
+
this.message = `Referral fee percentage "${referralFeePct}" must be below WAD; the SDK also caps referral fees at 10%. Reduce referralFeePct or disable the referral fee.`;
|
|
706
707
|
this.name = "ReferralFeePctExceededError";
|
|
707
708
|
}
|
|
708
709
|
}
|
|
709
710
|
/**
|
|
710
|
-
* Thrown when the SDK's 10% (`WAD / 10n`)
|
|
711
|
-
*
|
|
711
|
+
* Thrown when a referral fee below WAD exceeds the SDK's 10% (`WAD / 10n`) cap.
|
|
712
|
+
* The name is retained from the original Midnight-only cap.
|
|
712
713
|
*/
|
|
713
714
|
export class MidnightReferralFeePctExceededError extends InputExceedsMaxError {
|
|
714
715
|
referralFeePct;
|
|
@@ -724,7 +725,7 @@ export class MidnightReferralFeePctExceededError extends InputExceedsMaxError {
|
|
|
724
725
|
max: MIDNIGHT_MAX_REFERRAL_FEE_PCT,
|
|
725
726
|
});
|
|
726
727
|
this.referralFeePct = referralFeePct;
|
|
727
|
-
this.message = `Referral fee "${referralFeePct}" exceeds the SDK's 10%
|
|
728
|
+
this.message = `Referral fee "${referralFeePct}" exceeds the SDK's 10% referral-fee cap "${MIDNIGHT_MAX_REFERRAL_FEE_PCT}". Reduce referralFeePct.`;
|
|
728
729
|
this.name = "MidnightReferralFeePctExceededError";
|
|
729
730
|
}
|
|
730
731
|
}
|
|
@@ -78,8 +78,13 @@ export interface VaultV2BluePublicAllocatorOptions {
|
|
|
78
78
|
* plan on the destination-market handle (for example,
|
|
79
79
|
* `client.morpho.blue(destination.marketParams, chainId)`), not the source
|
|
80
80
|
* handle. Pass the source position's `borrowAssets` accrued to
|
|
81
|
-
*
|
|
82
|
-
* `
|
|
81
|
+
* the resolved plan expiry (or the required action deadline for entity
|
|
82
|
+
* `refinance`) as `operation.amount`. With
|
|
83
|
+
* `minTs = max(now, source.lastUpdate, destination.lastUpdate)`, the horizon is
|
|
84
|
+
* `max(minTs, resolved expiry)`. For `prepareBlueRefinance`, omitted `expiresAt`
|
|
85
|
+
* resolves to `now + 2h`, not `minTs + 2h`. Only when the resolved expiry exceeds
|
|
86
|
+
* `minTs + 365 days`, use `minTs + 2h` for unlimited-deadline sentinel
|
|
87
|
+
* compatibility. The optional `operation.referralFeePct` is WAD-scaled.
|
|
83
88
|
* The planner includes the referral fee and its own allocator-leg penalties
|
|
84
89
|
* in destination debt, so penalized legs also cover their own penalty.
|
|
85
90
|
* Refinance never uses vaults with a 100% penalty.
|