@morpho-org/morpho-sdk 5.9.0 → 6.0.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION-v5-to-v6.md +404 -0
- package/README.md +127 -69
- package/lib/cjs/abis.d.ts +210 -0
- package/lib/cjs/abis.js +142 -2
- package/lib/cjs/actions/blue/borrow.d.ts +62 -61
- package/lib/cjs/actions/blue/borrow.js +48 -80
- package/lib/cjs/actions/blue/common.d.ts +86 -0
- package/lib/cjs/actions/blue/common.js +205 -0
- package/lib/cjs/actions/blue/refinance.d.ts +72 -112
- package/lib/cjs/actions/blue/refinance.js +97 -199
- package/lib/cjs/actions/blue/repay.d.ts +72 -68
- package/lib/cjs/actions/blue/repay.js +56 -118
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +85 -90
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +148 -137
- package/lib/cjs/actions/blue/supply.d.ts +62 -45
- package/lib/cjs/actions/blue/supply.js +94 -70
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +63 -40
- package/lib/cjs/actions/blue/supplyCollateral.js +52 -69
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +82 -90
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +133 -120
- package/lib/cjs/actions/blue/withdraw.d.ts +68 -79
- package/lib/cjs/actions/blue/withdraw.js +101 -97
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +56 -28
- package/lib/cjs/actions/blue/withdrawCollateral.js +45 -50
- package/lib/cjs/actions/bundles/common.d.ts +200 -0
- package/lib/cjs/actions/bundles/common.js +469 -0
- package/lib/cjs/actions/bundles/index.d.ts +3 -0
- package/lib/cjs/actions/bundles/index.js +23 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
- package/lib/cjs/actions/bundles/resolveBundlesTokenRequirements.js +125 -0
- package/lib/cjs/actions/index.d.ts +2 -1
- package/lib/cjs/actions/index.js +1 -0
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +2 -2
- package/lib/cjs/actions/midnight/takeBorrow.js +2 -2
- package/lib/cjs/actions/midnight/takeLend.d.ts +2 -2
- package/lib/cjs/actions/midnight/takeLend.js +2 -2
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +29 -17
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +60 -19
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.js +72 -0
- package/lib/cjs/actions/requirements/blue/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/blue/index.js +1 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +30 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +8 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +39 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +61 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +123 -0
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -4
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +6 -5
- package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/index.js +1 -0
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +6 -4
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +6 -4
- package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +4 -0
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +22 -30
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +18 -66
- package/lib/cjs/actions/vaultV1/deposit.d.ts +73 -57
- package/lib/cjs/actions/vaultV1/deposit.js +110 -109
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +43 -66
- package/lib/cjs/actions/vaultV1/migrateToV2.js +91 -104
- package/lib/cjs/actions/vaultV1/redeem.d.ts +30 -23
- package/lib/cjs/actions/vaultV1/redeem.js +56 -33
- package/lib/cjs/actions/vaultV1/withdraw.d.ts +58 -24
- package/lib/cjs/actions/vaultV1/withdraw.js +86 -34
- package/lib/cjs/actions/vaultV2/deposit.d.ts +74 -57
- package/lib/cjs/actions/vaultV2/deposit.js +111 -109
- package/lib/cjs/actions/vaultV2/redeem.d.ts +30 -24
- package/lib/cjs/actions/vaultV2/redeem.js +56 -34
- package/lib/cjs/actions/vaultV2/withdraw.d.ts +58 -25
- package/lib/cjs/actions/vaultV2/withdraw.js +86 -35
- package/lib/cjs/bundler/actions.d.ts +4 -4
- package/lib/cjs/bundler/actions.js +4 -4
- package/lib/cjs/client/morphoViemExtension.d.ts +2 -1
- package/lib/cjs/client/morphoViemExtension.js +2 -1
- package/lib/cjs/entities/blue/blue.d.ts +806 -374
- package/lib/cjs/entities/blue/blue.js +449 -696
- package/lib/cjs/entities/index.d.ts +2 -0
- package/lib/cjs/entities/index.js +15 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.d.ts +87 -0
- package/lib/cjs/entities/requirements/getBundlesTokenRequirements.js +203 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
- package/lib/cjs/entities/requirements/getVaultBundlesSharesRequirements.js +74 -0
- package/lib/cjs/entities/requirements/index.d.ts +1 -0
- package/lib/cjs/entities/requirements/index.js +17 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +348 -98
- package/lib/cjs/entities/vaultV1/vaultV1.js +322 -120
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +221 -68
- package/lib/cjs/entities/vaultV2/vaultV2.js +219 -77
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +3 -9
- package/lib/cjs/helpers/index.d.ts +2 -1
- package/lib/cjs/helpers/index.js +5 -1
- package/lib/cjs/helpers/referralFee.d.ts +21 -0
- package/lib/cjs/helpers/referralFee.js +35 -0
- package/lib/cjs/helpers/slippage.d.ts +90 -1
- package/lib/cjs/helpers/slippage.js +123 -0
- package/lib/cjs/helpers/validate.d.ts +16 -23
- package/lib/cjs/helpers/validate.js +41 -48
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +3 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types/action.d.ts +303 -210
- package/lib/cjs/types/action.js +29 -2
- package/lib/cjs/types/client.d.ts +9 -0
- package/lib/cjs/types/error.d.ts +193 -18
- package/lib/cjs/types/error.js +267 -24
- package/lib/cjs/types/sharedLiquidity.d.ts +0 -7
- package/lib/esm/abis.d.ts +210 -0
- package/lib/esm/abis.js +140 -0
- package/lib/esm/actions/blue/borrow.d.ts +62 -61
- package/lib/esm/actions/blue/borrow.js +48 -80
- package/lib/esm/actions/blue/common.d.ts +86 -0
- package/lib/esm/actions/blue/common.js +193 -0
- package/lib/esm/actions/blue/refinance.d.ts +72 -112
- package/lib/esm/actions/blue/refinance.js +98 -200
- package/lib/esm/actions/blue/repay.d.ts +72 -68
- package/lib/esm/actions/blue/repay.js +56 -118
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +85 -90
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +149 -138
- package/lib/esm/actions/blue/supply.d.ts +62 -45
- package/lib/esm/actions/blue/supply.js +94 -70
- package/lib/esm/actions/blue/supplyCollateral.d.ts +63 -40
- package/lib/esm/actions/blue/supplyCollateral.js +52 -69
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +82 -90
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +134 -121
- package/lib/esm/actions/blue/withdraw.d.ts +68 -79
- package/lib/esm/actions/blue/withdraw.js +100 -96
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +56 -28
- package/lib/esm/actions/blue/withdrawCollateral.js +45 -50
- package/lib/esm/actions/bundles/common.d.ts +200 -0
- package/lib/esm/actions/bundles/common.js +457 -0
- package/lib/esm/actions/bundles/index.d.ts +3 -0
- package/lib/esm/actions/bundles/index.js +2 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.d.ts +76 -0
- package/lib/esm/actions/bundles/resolveBundlesTokenRequirements.js +121 -0
- package/lib/esm/actions/index.d.ts +2 -1
- package/lib/esm/actions/index.js +1 -0
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +2 -2
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +2 -2
- package/lib/esm/actions/midnight/takeBorrow.d.ts +2 -2
- package/lib/esm/actions/midnight/takeBorrow.js +2 -2
- package/lib/esm/actions/midnight/takeLend.d.ts +2 -2
- package/lib/esm/actions/midnight/takeLend.js +2 -2
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +29 -17
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +63 -22
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.js +68 -0
- package/lib/esm/actions/requirements/blue/index.d.ts +1 -0
- package/lib/esm/actions/requirements/blue/index.js +1 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +31 -6
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +9 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +40 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts +61 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.js +119 -0
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +4 -4
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +6 -5
- package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/index.js +1 -0
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +6 -4
- package/lib/esm/actions/requirements/getRequirementsApproval.js +6 -4
- package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +5 -1
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.d.ts +22 -30
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +19 -67
- package/lib/esm/actions/vaultV1/deposit.d.ts +73 -57
- package/lib/esm/actions/vaultV1/deposit.js +112 -111
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +43 -66
- package/lib/esm/actions/vaultV1/migrateToV2.js +93 -106
- package/lib/esm/actions/vaultV1/redeem.d.ts +30 -23
- package/lib/esm/actions/vaultV1/redeem.js +56 -33
- package/lib/esm/actions/vaultV1/withdraw.d.ts +58 -24
- package/lib/esm/actions/vaultV1/withdraw.js +86 -34
- package/lib/esm/actions/vaultV2/deposit.d.ts +74 -57
- package/lib/esm/actions/vaultV2/deposit.js +113 -111
- package/lib/esm/actions/vaultV2/redeem.d.ts +30 -24
- package/lib/esm/actions/vaultV2/redeem.js +56 -34
- package/lib/esm/actions/vaultV2/withdraw.d.ts +58 -25
- package/lib/esm/actions/vaultV2/withdraw.js +86 -35
- package/lib/esm/bundler/actions.d.ts +4 -4
- package/lib/esm/bundler/actions.js +4 -4
- package/lib/esm/client/morphoViemExtension.d.ts +2 -1
- package/lib/esm/client/morphoViemExtension.js +2 -1
- package/lib/esm/entities/blue/blue.d.ts +806 -374
- package/lib/esm/entities/blue/blue.js +455 -702
- package/lib/esm/entities/index.d.ts +2 -0
- package/lib/esm/entities/index.js +1 -0
- package/lib/esm/entities/midnight/midnight.d.ts +2 -2
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.d.ts +87 -0
- package/lib/esm/entities/requirements/getBundlesTokenRequirements.js +199 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.d.ts +28 -0
- package/lib/esm/entities/requirements/getVaultBundlesSharesRequirements.js +70 -0
- package/lib/esm/entities/requirements/index.d.ts +1 -0
- package/lib/esm/entities/requirements/index.js +1 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +348 -98
- package/lib/esm/entities/vaultV1/vaultV1.js +326 -124
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +221 -68
- package/lib/esm/entities/vaultV2/vaultV2.js +222 -80
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/esm/helpers/computeVaultV1Reallocations.js +3 -9
- package/lib/esm/helpers/index.d.ts +2 -1
- package/lib/esm/helpers/index.js +2 -1
- package/lib/esm/helpers/referralFee.d.ts +21 -0
- package/lib/esm/helpers/referralFee.js +31 -0
- package/lib/esm/helpers/slippage.d.ts +90 -1
- package/lib/esm/helpers/slippage.js +122 -2
- package/lib/esm/helpers/validate.d.ts +16 -23
- package/lib/esm/helpers/validate.js +40 -48
- package/lib/esm/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/esm/helpers/validateRequirementSpender.js +3 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/types/action.d.ts +303 -210
- package/lib/esm/types/action.js +28 -2
- package/lib/esm/types/client.d.ts +9 -0
- package/lib/esm/types/error.d.ts +193 -18
- package/lib/esm/types/error.js +252 -21
- package/lib/esm/types/sharedLiquidity.d.ts +0 -7
- package/package.json +6 -5
- package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +0 -47
- package/lib/cjs/actions/blue/buildAssetFundingActions.js +0 -63
- package/lib/cjs/actions/blue/buildReallocationActions.d.ts +0 -69
- package/lib/cjs/actions/blue/buildReallocationActions.js +0 -141
- package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +0 -66
- package/lib/cjs/actions/blue/resolveRepayFunding.js +0 -85
- package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +0 -47
- package/lib/esm/actions/blue/buildAssetFundingActions.js +0 -59
- package/lib/esm/actions/blue/buildReallocationActions.d.ts +0 -69
- package/lib/esm/actions/blue/buildReallocationActions.js +0 -135
- package/lib/esm/actions/blue/resolveRepayFunding.d.ts +0 -66
- package/lib/esm/actions/blue/resolveRepayFunding.js +0 -81
package/lib/esm/types/error.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { UnknownDataError } from "@morpho-org/blue-sdk";
|
|
1
|
+
import { MathLib, UnknownDataError } from "@morpho-org/blue-sdk";
|
|
2
2
|
/**
|
|
3
3
|
* Thrown when a morpho-sdk input that must be non-negative is negative.
|
|
4
4
|
*
|
|
@@ -82,7 +82,7 @@ export class EmptyMarketParamsListError extends Error {
|
|
|
82
82
|
this.name = "EmptyMarketParamsListError";
|
|
83
83
|
}
|
|
84
84
|
}
|
|
85
|
-
/** Thrown when an
|
|
85
|
+
/** Thrown when an SDK operation deadline has already passed. */
|
|
86
86
|
export class ExpiredDeadlineError extends Error {
|
|
87
87
|
deadline;
|
|
88
88
|
timestamp;
|
|
@@ -91,7 +91,7 @@ export class ExpiredDeadlineError extends Error {
|
|
|
91
91
|
* @param timestamp - Current timestamp used for validation.
|
|
92
92
|
*/
|
|
93
93
|
constructor(deadline, timestamp) {
|
|
94
|
-
super(`Deadline "${deadline}" has expired at timestamp "${timestamp}". Choose a future deadline and rebuild the
|
|
94
|
+
super(`Deadline "${deadline}" has expired at timestamp "${timestamp}". Choose a future deadline and rebuild the operation.`);
|
|
95
95
|
this.deadline = deadline;
|
|
96
96
|
this.timestamp = timestamp;
|
|
97
97
|
this.name = "ExpiredDeadlineError";
|
|
@@ -230,8 +230,8 @@ export class VaultIsBlueFeeRecipientError extends Error {
|
|
|
230
230
|
this.name = "VaultIsBlueFeeRecipientError";
|
|
231
231
|
}
|
|
232
232
|
}
|
|
233
|
-
/** Thrown when a vault-shares requirement cannot be safely encoded as
|
|
234
|
-
export class
|
|
233
|
+
/** Thrown when a vault-shares requirement cannot be safely encoded as a bundles permit. */
|
|
234
|
+
export class BundlesPermitMismatchError extends Error {
|
|
235
235
|
/**
|
|
236
236
|
* @param params - Permit mismatch values used to explain the rejection.
|
|
237
237
|
* @param params.field - Permit field that does not match the exit.
|
|
@@ -243,13 +243,215 @@ export class VaultExitBundlesV1PermitMismatchError extends Error {
|
|
|
243
243
|
expected;
|
|
244
244
|
actual;
|
|
245
245
|
constructor(params) {
|
|
246
|
-
super(`
|
|
246
|
+
super(`Bundles permit ${params.field} mismatch: expected "${params.expected}", got "${params.actual}". Resolve and sign the requirements returned by this prepared operation.`, { cause: params.cause });
|
|
247
247
|
this.field = params.field;
|
|
248
248
|
this.expected = params.expected;
|
|
249
249
|
this.actual = params.actual;
|
|
250
|
+
this.name = "BundlesPermitMismatchError";
|
|
251
|
+
}
|
|
252
|
+
}
|
|
253
|
+
/**
|
|
254
|
+
* Thrown by the deprecated VaultExitBundlesV1 permit compatibility helper.
|
|
255
|
+
*
|
|
256
|
+
* @deprecated Use {@link BundlesPermitMismatchError} with `getBundlesSharesPermit`.
|
|
257
|
+
*/
|
|
258
|
+
export class VaultExitBundlesV1PermitMismatchError extends BundlesPermitMismatchError {
|
|
259
|
+
constructor(params) {
|
|
260
|
+
super(params);
|
|
261
|
+
this.message = `VaultExitBundlesV1 permit ${params.field} mismatch: expected "${params.expected}", got "${params.actual}". Rebuild and sign the vault-exit permit.`;
|
|
250
262
|
this.name = "VaultExitBundlesV1PermitMismatchError";
|
|
251
263
|
}
|
|
252
264
|
}
|
|
265
|
+
/** Thrown when a signed requirement cannot be safely encoded for a fixed bundles call. */
|
|
266
|
+
export class BundlesRequirementSignatureMismatchError extends Error {
|
|
267
|
+
/** Field whose signed value or encoding is invalid for the fixed bundles call. */
|
|
268
|
+
field;
|
|
269
|
+
/** Value required by the fixed bundles call. */
|
|
270
|
+
expected;
|
|
271
|
+
/** Value supplied by the signed requirement. */
|
|
272
|
+
actual;
|
|
273
|
+
/**
|
|
274
|
+
* @param params - Signature mismatch details.
|
|
275
|
+
* @param params.field - Field rejected by the converter.
|
|
276
|
+
* @param params.expected - Value required by the direct route.
|
|
277
|
+
* @param params.actual - Value supplied by the requirement.
|
|
278
|
+
* @param params.cause - Original signature parser failure, when applicable.
|
|
279
|
+
*/
|
|
280
|
+
constructor(params) {
|
|
281
|
+
super(`Bundles requirement ${params.field} mismatch: expected "${params.expected}", got "${params.actual}". Resolve and sign the requirements returned by this prepared operation.`, { cause: params.cause });
|
|
282
|
+
this.field = params.field;
|
|
283
|
+
this.expected = params.expected;
|
|
284
|
+
this.actual = params.actual;
|
|
285
|
+
this.name = "BundlesRequirementSignatureMismatchError";
|
|
286
|
+
}
|
|
287
|
+
}
|
|
288
|
+
/** @deprecated Use {@link BundlesRequirementSignatureMismatchError}. */
|
|
289
|
+
export { BundlesRequirementSignatureMismatchError as BlueBundlesV1RequirementSignatureMismatchError, };
|
|
290
|
+
/** Thrown when Permit2 SignatureTransfer is selected without an explicit unordered nonce. */
|
|
291
|
+
export class MissingPermit2SignatureTransferNonceError extends Error {
|
|
292
|
+
constructor() {
|
|
293
|
+
super("Permit2 SignatureTransfer requires an explicit unused permit2Nonce. Generate a unique uint256 nonce, pass it to getRequirements(), and resolve the requirements again.");
|
|
294
|
+
this.name = "MissingPermit2SignatureTransferNonceError";
|
|
295
|
+
}
|
|
296
|
+
}
|
|
297
|
+
/** @deprecated Use {@link MissingPermit2SignatureTransferNonceError}. */
|
|
298
|
+
export { MissingPermit2SignatureTransferNonceError as MissingPermit2TransferFromNonceError, };
|
|
299
|
+
/** Thrown when an explicit Permit2 SignatureTransfer unordered nonce is already consumed. */
|
|
300
|
+
export class Permit2SignatureTransferNonceAlreadyUsedError extends Error {
|
|
301
|
+
owner;
|
|
302
|
+
nonce;
|
|
303
|
+
/**
|
|
304
|
+
* @param owner - Permit2 token owner whose nonce is unavailable.
|
|
305
|
+
* @param nonce - Explicit unordered nonce that has already been consumed.
|
|
306
|
+
*/
|
|
307
|
+
constructor(owner, nonce) {
|
|
308
|
+
super(`Permit2 nonce "${nonce}" is already used for owner "${owner}". Generate a different uint256 permit2Nonce and resolve the requirements again.`);
|
|
309
|
+
this.owner = owner;
|
|
310
|
+
this.nonce = nonce;
|
|
311
|
+
this.name = "Permit2SignatureTransferNonceAlreadyUsedError";
|
|
312
|
+
}
|
|
313
|
+
}
|
|
314
|
+
/** Thrown when no unused Permit2 unordered nonce exists at or after the requested start nonce. */
|
|
315
|
+
export class NoUnusedPermit2NonceError extends Error {
|
|
316
|
+
owner;
|
|
317
|
+
startNonce;
|
|
318
|
+
/**
|
|
319
|
+
* @param owner - Permit2 token owner scanned for a free nonce.
|
|
320
|
+
* @param startNonce - Lowest nonce that was considered.
|
|
321
|
+
*/
|
|
322
|
+
constructor(owner, startNonce) {
|
|
323
|
+
super(`No unused Permit2 nonce found for owner "${owner}" at or after "${startNonce}". Pass a lower startNonce.`);
|
|
324
|
+
this.owner = owner;
|
|
325
|
+
this.startNonce = startNonce;
|
|
326
|
+
this.name = "NoUnusedPermit2NonceError";
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
/** @deprecated Use {@link Permit2SignatureTransferNonceAlreadyUsedError}. */
|
|
330
|
+
export { Permit2SignatureTransferNonceAlreadyUsedError as Permit2TransferFromNonceAlreadyUsedError, };
|
|
331
|
+
/** Thrown when native funding does not exactly match the contract's gross token pull. */
|
|
332
|
+
export class NativeFundingAmountMismatchError extends Error {
|
|
333
|
+
nativeAmount;
|
|
334
|
+
requiredAmount;
|
|
335
|
+
/**
|
|
336
|
+
* @param nativeAmount - Native value supplied with the transaction.
|
|
337
|
+
* @param requiredAmount - Gross amount the BlueBundlesV1 entrypoint funds.
|
|
338
|
+
*/
|
|
339
|
+
constructor(nativeAmount, requiredAmount) {
|
|
340
|
+
super(`Native funding must equal the full funded amount: expected "${requiredAmount}", got "${nativeAmount}". Use either native funding or ERC-20 funding, not both.`);
|
|
341
|
+
this.nativeAmount = nativeAmount;
|
|
342
|
+
this.requiredAmount = requiredAmount;
|
|
343
|
+
this.name = "NativeFundingAmountMismatchError";
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
/** Thrown when a positive referral fee has no recipient. */
|
|
347
|
+
export class ReferralFeeRecipientMissingError extends Error {
|
|
348
|
+
constructor() {
|
|
349
|
+
super("A positive referralFeePct requires referralFeeRecipient. Provide the recipient or set referralFeePct to zero.");
|
|
350
|
+
this.name = "ReferralFeeRecipientMissingError";
|
|
351
|
+
}
|
|
352
|
+
}
|
|
353
|
+
/** @deprecated Use {@link ReferralFeeRecipientMissingError}. */
|
|
354
|
+
export const MissingReferralFeeRecipientError = ReferralFeeRecipientMissingError;
|
|
355
|
+
/**
|
|
356
|
+
* Thrown when a referral fee percentage is outside the contract's `[0, WAD)` range.
|
|
357
|
+
*
|
|
358
|
+
* Extends {@link InputExceedsMaxError} — and reports the same `field`, `value`, and `max` the
|
|
359
|
+
* generic bound error used to carry for this input — so integrators already pattern-matching
|
|
360
|
+
* `InputExceedsMaxError` keep catching this failure.
|
|
361
|
+
*/
|
|
362
|
+
export class ReferralFeePctExceededError extends InputExceedsMaxError {
|
|
363
|
+
referralFeePct;
|
|
364
|
+
/** @param referralFeePct - WAD-scaled referral fee percentage supplied by the caller. */
|
|
365
|
+
constructor(referralFeePct) {
|
|
366
|
+
super({
|
|
367
|
+
field: "referralFeePct",
|
|
368
|
+
value: referralFeePct,
|
|
369
|
+
max: MathLib.WAD - 1n,
|
|
370
|
+
});
|
|
371
|
+
this.referralFeePct = referralFeePct;
|
|
372
|
+
this.message = `Referral fee percentage "${referralFeePct}" must be below WAD. Reduce referralFeePct or disable the referral fee.`;
|
|
373
|
+
this.name = "ReferralFeePctExceededError";
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/** Thrown when a fixed bundles call mixes ERC-20 and native funding. */
|
|
377
|
+
export class MixedBundlesFundingError extends Error {
|
|
378
|
+
constructor() {
|
|
379
|
+
super("Bundles funding accepts either amount or nativeAmount, not both. Choose one funding source and rebuild the transaction.");
|
|
380
|
+
this.name = "MixedBundlesFundingError";
|
|
381
|
+
}
|
|
382
|
+
}
|
|
383
|
+
/** Thrown when a vault migration specifies both assets and shares, or neither. */
|
|
384
|
+
export class AmountAndSharesExclusiveError extends Error {
|
|
385
|
+
constructor() {
|
|
386
|
+
super("Vault migration requires exactly one of assets or shares. Choose the desired withdrawal mode and rebuild the transaction.");
|
|
387
|
+
this.name = "AmountAndSharesExclusiveError";
|
|
388
|
+
}
|
|
389
|
+
}
|
|
390
|
+
/** Thrown when a vault migration selects the same source and destination vault. */
|
|
391
|
+
export class SameVaultMigrationError extends Error {
|
|
392
|
+
vault;
|
|
393
|
+
constructor(vault) {
|
|
394
|
+
super(`Source and destination vault are both "${vault}". Select a different destination vault.`);
|
|
395
|
+
this.vault = vault;
|
|
396
|
+
this.name = "SameVaultMigrationError";
|
|
397
|
+
}
|
|
398
|
+
}
|
|
399
|
+
/** Thrown when a BlueBundlesV1 reallocation source uses another loan token. */
|
|
400
|
+
export class ReallocationLoanTokenMismatchError extends Error {
|
|
401
|
+
expected;
|
|
402
|
+
actual;
|
|
403
|
+
/**
|
|
404
|
+
* @param expected - Loan token of the operation's target market.
|
|
405
|
+
* @param actual - Loan token found in the reallocation source market.
|
|
406
|
+
*/
|
|
407
|
+
constructor(expected, actual) {
|
|
408
|
+
super(`Reallocation source loan token "${actual}" does not match target loan token "${expected}". Recompute reallocations for the target market.`);
|
|
409
|
+
this.expected = expected;
|
|
410
|
+
this.actual = actual;
|
|
411
|
+
this.name = "ReallocationLoanTokenMismatchError";
|
|
412
|
+
}
|
|
413
|
+
}
|
|
414
|
+
/**
|
|
415
|
+
* Thrown when a Blue authorization operator is not one of the chain's registered Morpho operators
|
|
416
|
+
* (GeneralAdapter1 or BlueBundlesV1). Guards the exported authorization builder so a misconfigured
|
|
417
|
+
* `authorized` cannot grant an arbitrary address control over the user's Morpho positions.
|
|
418
|
+
*/
|
|
419
|
+
export class UnsupportedAuthorizationOperatorError extends Error {
|
|
420
|
+
authorized;
|
|
421
|
+
chainId;
|
|
422
|
+
/**
|
|
423
|
+
* @param authorized - The operator address rejected as unsupported.
|
|
424
|
+
* @param chainId - Chain whose registry was consulted for the supported operators.
|
|
425
|
+
*/
|
|
426
|
+
constructor(authorized, chainId) {
|
|
427
|
+
super(`Authorization operator "${authorized}" is not a supported Morpho operator on chain ${chainId}. Pass the chain's registered GeneralAdapter1 or BlueBundlesV1 address, or omit \`authorized\` to default to GeneralAdapter1.`);
|
|
428
|
+
this.authorized = authorized;
|
|
429
|
+
this.chainId = chainId;
|
|
430
|
+
this.name = "UnsupportedAuthorizationOperatorError";
|
|
431
|
+
}
|
|
432
|
+
}
|
|
433
|
+
/** Thrown when reallocations are attached to a combined call with no borrow leg. */
|
|
434
|
+
export class ReallocationsRequireBorrowError extends Error {
|
|
435
|
+
constructor() {
|
|
436
|
+
super("BlueBundlesV1 reallocations require a positive borrowAssets value. Remove the reallocations or add a borrow leg.");
|
|
437
|
+
this.name = "ReallocationsRequireBorrowError";
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
/** Thrown when repay funding cannot cover the requested assets and referral fee. */
|
|
441
|
+
export class MaxRepayAssetsBelowRepayAssetsError extends Error {
|
|
442
|
+
maxRepayAssets;
|
|
443
|
+
repayAssets;
|
|
444
|
+
/**
|
|
445
|
+
* @param maxRepayAssets - Maximum loan-token funding supplied to the bundle.
|
|
446
|
+
* @param repayAssets - Minimum funding required for the repayment and referral fee.
|
|
447
|
+
*/
|
|
448
|
+
constructor(maxRepayAssets, repayAssets) {
|
|
449
|
+
super(`maxRepayAssets "${maxRepayAssets}" cannot cover required repay funding "${repayAssets}". Increase maxRepayAssets to include the repayment and referral fee.`);
|
|
450
|
+
this.maxRepayAssets = maxRepayAssets;
|
|
451
|
+
this.repayAssets = repayAssets;
|
|
452
|
+
this.name = "MaxRepayAssetsBelowRepayAssetsError";
|
|
453
|
+
}
|
|
454
|
+
}
|
|
253
455
|
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
254
456
|
export const NonPositiveAssetAmountError = NonPositiveInputError;
|
|
255
457
|
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
@@ -604,11 +806,10 @@ export class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
|
604
806
|
}
|
|
605
807
|
}
|
|
606
808
|
/**
|
|
607
|
-
* Thrown when a
|
|
608
|
-
*
|
|
809
|
+
* Thrown when a reallocation entry passed to a high-level Blue write is not a valid
|
|
810
|
+
* {@link VaultV2BlueReallocation}: a non-object entry, or an entry carrying Vault V1
|
|
811
|
+
* `withdrawals`/`fee` fields that high-level Blue writes no longer accept.
|
|
609
812
|
*
|
|
610
|
-
* @deprecated Vault V1/V2 reallocation-shape dispatch will be removed in the next major. Use Vault
|
|
611
|
-
* V2 reallocations.
|
|
612
813
|
* @example
|
|
613
814
|
* ```ts
|
|
614
815
|
* import { InvalidReallocationShapeError } from "@morpho-org/morpho-sdk";
|
|
@@ -618,7 +819,7 @@ export class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
|
618
819
|
*/
|
|
619
820
|
export class InvalidReallocationShapeError extends Error {
|
|
620
821
|
constructor() {
|
|
621
|
-
super(
|
|
822
|
+
super("Reallocation entry is not a valid Vault V2 reallocation. High-level Blue writes accept only VaultV2BlueReallocation entries (e.g. from getVaultV2BlueReallocations()); compose Vault V1 reallocations via low-level Bundler3 actions.");
|
|
622
823
|
this.name = "InvalidReallocationShapeError";
|
|
623
824
|
}
|
|
624
825
|
}
|
|
@@ -1119,12 +1320,6 @@ export class VaultAssetMismatchError extends Error {
|
|
|
1119
1320
|
super(`Source vault asset ${sourceAsset} does not match target vault asset ${targetAsset}`);
|
|
1120
1321
|
}
|
|
1121
1322
|
}
|
|
1122
|
-
/** Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive). */
|
|
1123
|
-
export class BorrowAmountAndSharesExclusiveError extends Error {
|
|
1124
|
-
constructor(market) {
|
|
1125
|
-
super(`Exactly one of borrowAssets or borrowShares must be non-zero for market: ${market}. Both were provided.`);
|
|
1126
|
-
}
|
|
1127
|
-
}
|
|
1128
1323
|
/** Thrown when a refinance has identical source and target market ids (a refinance to the same market is a costly no-op). */
|
|
1129
1324
|
export class RefinanceSameMarketError extends Error {
|
|
1130
1325
|
constructor(market) {
|
|
@@ -1137,7 +1332,25 @@ export class RefinanceTokenMismatchError extends Error {
|
|
|
1137
1332
|
super(`Refinance source market ${sourceMarket} and target market ${targetMarket} must share the same loanToken and collateralToken.`);
|
|
1138
1333
|
}
|
|
1139
1334
|
}
|
|
1140
|
-
/**
|
|
1335
|
+
/**
|
|
1336
|
+
* Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive).
|
|
1337
|
+
*
|
|
1338
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1339
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1340
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1341
|
+
*/
|
|
1342
|
+
export class BorrowAmountAndSharesExclusiveError extends Error {
|
|
1343
|
+
constructor(market) {
|
|
1344
|
+
super(`Exactly one of borrowAssets or borrowShares must be non-zero for market: ${market}. Both were provided.`);
|
|
1345
|
+
}
|
|
1346
|
+
}
|
|
1347
|
+
/**
|
|
1348
|
+
* Thrown when a refinance's `collateralAmount` exceeds the source position's available collateral.
|
|
1349
|
+
*
|
|
1350
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1351
|
+
* partial collateral inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1352
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1353
|
+
*/
|
|
1141
1354
|
export class RefinanceExceedsCollateralError extends Error {
|
|
1142
1355
|
market;
|
|
1143
1356
|
requested;
|
|
@@ -1149,7 +1362,13 @@ export class RefinanceExceedsCollateralError extends Error {
|
|
|
1149
1362
|
this.available = params.available;
|
|
1150
1363
|
}
|
|
1151
1364
|
}
|
|
1152
|
-
/**
|
|
1365
|
+
/**
|
|
1366
|
+
* Thrown when a refinance's `borrowShares` exceeds the source position's outstanding borrow shares.
|
|
1367
|
+
*
|
|
1368
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1369
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1370
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1371
|
+
*/
|
|
1153
1372
|
export class RefinanceExceedsBorrowSharesError extends Error {
|
|
1154
1373
|
market;
|
|
1155
1374
|
requested;
|
|
@@ -1161,7 +1380,13 @@ export class RefinanceExceedsBorrowSharesError extends Error {
|
|
|
1161
1380
|
this.available = params.available;
|
|
1162
1381
|
}
|
|
1163
1382
|
}
|
|
1164
|
-
/**
|
|
1383
|
+
/**
|
|
1384
|
+
* Thrown when a refinance's `borrowAssets` exceeds the source position's outstanding debt assets.
|
|
1385
|
+
*
|
|
1386
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1387
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1388
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1389
|
+
*/
|
|
1165
1390
|
export class RefinanceExceedsBorrowAssetsError extends Error {
|
|
1166
1391
|
market;
|
|
1167
1392
|
requested;
|
|
@@ -1173,7 +1398,13 @@ export class RefinanceExceedsBorrowAssetsError extends Error {
|
|
|
1173
1398
|
this.available = params.available;
|
|
1174
1399
|
}
|
|
1175
1400
|
}
|
|
1176
|
-
/**
|
|
1401
|
+
/**
|
|
1402
|
+
* Thrown when a refinance in shares mode (`borrowShares > 0n`) omits the `borrowAssets` overshoot for the target borrow leg.
|
|
1403
|
+
*
|
|
1404
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1405
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1406
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1407
|
+
*/
|
|
1177
1408
|
export class RefinanceSharesMissingBorrowAssetsError extends Error {
|
|
1178
1409
|
constructor(market) {
|
|
1179
1410
|
super(`Refinance shares mode requires a positive borrowAssets overshoot for the target borrow leg (market: ${market}).`);
|
|
@@ -137,13 +137,6 @@ export interface VaultV2BlueReallocation {
|
|
|
137
137
|
/** Vault-configured WAD-scaled penalty rate passed to the allocator. */
|
|
138
138
|
readonly penalty: bigint;
|
|
139
139
|
}
|
|
140
|
-
/**
|
|
141
|
-
* A homogeneous Blue action plan containing only Vault V1 or only Vault V2 reallocations.
|
|
142
|
-
*
|
|
143
|
-
* Vault V1 members are deprecated for high-level Blue writes and will stop being accepted in the
|
|
144
|
-
* next major. Use Vault V2 members for new high-level integrations.
|
|
145
|
-
*/
|
|
146
|
-
export type BlueReallocationPlan = Iterable<VaultV1Reallocation> | Iterable<VaultV2BlueReallocation>;
|
|
147
140
|
/**
|
|
148
141
|
* Deprecated name for a Vault V1 reallocation.
|
|
149
142
|
*
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/morpho-sdk",
|
|
3
3
|
"description": "Abstraction layer for Morpho's complexity.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "6.0.0-next.1",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Foulks-Plb <https://x.com/FoulkPlb>"
|
|
@@ -157,13 +157,14 @@
|
|
|
157
157
|
"./lib/*/augment/*.js"
|
|
158
158
|
],
|
|
159
159
|
"files": [
|
|
160
|
-
"lib"
|
|
160
|
+
"lib",
|
|
161
|
+
"MIGRATION-v5-to-v6.md"
|
|
161
162
|
],
|
|
162
163
|
"dependencies": {
|
|
163
164
|
"zod": "^4.4.3",
|
|
164
165
|
"@morpho-org/blue-sdk": "^6.7.0",
|
|
165
|
-
"@morpho-org/blue-sdk-viem": "^5.5.0",
|
|
166
|
-
"@morpho-org/midnight-sdk": "^1.
|
|
166
|
+
"@morpho-org/blue-sdk-viem": "^5.5.1-next.0",
|
|
167
|
+
"@morpho-org/midnight-sdk": "^1.4.0-next.0",
|
|
167
168
|
"@morpho-org/morpho-ts": "^2.11.1"
|
|
168
169
|
},
|
|
169
170
|
"peerDependencies": {
|
|
@@ -172,7 +173,7 @@
|
|
|
172
173
|
"devDependencies": {
|
|
173
174
|
"dotenv": "^17.4.2",
|
|
174
175
|
"fast-check": "^4.9.0",
|
|
175
|
-
"typescript": "
|
|
176
|
+
"typescript": "7.0.2",
|
|
176
177
|
"viem": "^2.55.10",
|
|
177
178
|
"vitest": "^4.1.10",
|
|
178
179
|
"@morpho-org/test": "^2.10.0"
|
|
@@ -1,47 +0,0 @@
|
|
|
1
|
-
import type { Address } from "viem";
|
|
2
|
-
import type { Action } from "../../bundler/index.js";
|
|
3
|
-
import type { PermitRequirementSignature } from "../../types/index.js";
|
|
4
|
-
/** Parameters for {@link buildAssetFundingActions}. */
|
|
5
|
-
export interface BuildAssetFundingActionsParams {
|
|
6
|
-
/** Chain the operation runs on — resolves adapter addresses and validates wNative. */
|
|
7
|
-
readonly chainId: number;
|
|
8
|
-
/** Asset wrapped and/or pulled into `GeneralAdapter1` (loan token, collateral token, …). */
|
|
9
|
-
readonly asset: Address;
|
|
10
|
-
/** ERC-20 amount of `asset` to pull from the payer (`0n` on a fully-native funding). */
|
|
11
|
-
readonly erc20Amount: bigint;
|
|
12
|
-
/** Native ETH to wrap into wNative before the pull (`0n` when not wrapping). */
|
|
13
|
-
readonly nativeAmount: bigint;
|
|
14
|
-
/** Optional pre-signed permit/permit2 approval for the ERC-20 pull. */
|
|
15
|
-
readonly requirementSignature?: PermitRequirementSignature;
|
|
16
|
-
}
|
|
17
|
-
/**
|
|
18
|
-
* Builds the shared asset-funding actions — native wrapping followed by the ERC-20 pull — that move
|
|
19
|
-
* `asset` into `GeneralAdapter1` before a bundled Morpho operation (`blueSupply`,
|
|
20
|
-
* `blueSupplyCollateral`, `blueSupplyCollateralBorrow`, `blueRepay`, `blueRepayWithdrawCollateral`).
|
|
21
|
-
*
|
|
22
|
-
* Encode-only and synchronous: returns a fresh `Action[]` (never mutates its inputs, mirroring
|
|
23
|
-
* `buildVaultV2BlueReallocationActions`) and reads no on-chain state. When `nativeAmount > 0n`, validates
|
|
24
|
-
* `asset` is the chain's wNative and emits `nativeTransfer → wrapNative`. When `erc20Amount > 0n`,
|
|
25
|
-
* pulls the ERC-20 via a signed permit/permit2 (`requirementSignature`) or a plain
|
|
26
|
-
* `erc20TransferFrom` — `getTokenRequirementActions` emits the latter itself when no signature is
|
|
27
|
-
* supplied. A fully-native funding emits no ERC-20 action; funding nothing returns `[]`.
|
|
28
|
-
*
|
|
29
|
-
* Single source of truth for the native-wrap + ERC-20-pull composition every bundled Blue funding
|
|
30
|
-
* path depends on — a fix here applies to all of them instead of risking a silent divergence
|
|
31
|
-
* between copies.
|
|
32
|
-
*
|
|
33
|
-
* @param params - See {@link BuildAssetFundingActionsParams}.
|
|
34
|
-
* @returns The `nativeTransfer`/`wrapNative`/pull actions, in bundle order (empty when nothing is
|
|
35
|
-
* funded).
|
|
36
|
-
* @throws {ChainWNativeMissingError} when `nativeAmount > 0n` but the chain has no configured wNative.
|
|
37
|
-
* @throws {NativeAmountOnNonWNativeAssetError} when `nativeAmount > 0n` but `asset` is not the
|
|
38
|
-
* chain's wNative.
|
|
39
|
-
* @throws {DepositAssetMismatchError} from `getTokenRequirementActions` when `requirementSignature` is
|
|
40
|
-
* provided and the signed asset differs from `asset`.
|
|
41
|
-
* @throws {DepositAmountMismatchError} from `getTokenRequirementActions` when `requirementSignature` is
|
|
42
|
-
* provided and the signed amount differs from `erc20Amount`.
|
|
43
|
-
* @throws {Permit2ExpirationMissingError} from `getTokenRequirementActions` when a Permit2 requirement
|
|
44
|
-
* signature is missing its expiration.
|
|
45
|
-
* @internal
|
|
46
|
-
*/
|
|
47
|
-
export declare const buildAssetFundingActions: ({ chainId, asset, erc20Amount, nativeAmount, requirementSignature, }: BuildAssetFundingActionsParams) => Action[];
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildAssetFundingActions = void 0;
|
|
4
|
-
const blue_sdk_1 = require("@morpho-org/blue-sdk");
|
|
5
|
-
const index_js_1 = require("../../helpers/index.js");
|
|
6
|
-
const getTokenRequirementActions_js_1 = require("../signatures/getTokenRequirementActions.js");
|
|
7
|
-
/**
|
|
8
|
-
* Builds the shared asset-funding actions — native wrapping followed by the ERC-20 pull — that move
|
|
9
|
-
* `asset` into `GeneralAdapter1` before a bundled Morpho operation (`blueSupply`,
|
|
10
|
-
* `blueSupplyCollateral`, `blueSupplyCollateralBorrow`, `blueRepay`, `blueRepayWithdrawCollateral`).
|
|
11
|
-
*
|
|
12
|
-
* Encode-only and synchronous: returns a fresh `Action[]` (never mutates its inputs, mirroring
|
|
13
|
-
* `buildVaultV2BlueReallocationActions`) and reads no on-chain state. When `nativeAmount > 0n`, validates
|
|
14
|
-
* `asset` is the chain's wNative and emits `nativeTransfer → wrapNative`. When `erc20Amount > 0n`,
|
|
15
|
-
* pulls the ERC-20 via a signed permit/permit2 (`requirementSignature`) or a plain
|
|
16
|
-
* `erc20TransferFrom` — `getTokenRequirementActions` emits the latter itself when no signature is
|
|
17
|
-
* supplied. A fully-native funding emits no ERC-20 action; funding nothing returns `[]`.
|
|
18
|
-
*
|
|
19
|
-
* Single source of truth for the native-wrap + ERC-20-pull composition every bundled Blue funding
|
|
20
|
-
* path depends on — a fix here applies to all of them instead of risking a silent divergence
|
|
21
|
-
* between copies.
|
|
22
|
-
*
|
|
23
|
-
* @param params - See {@link BuildAssetFundingActionsParams}.
|
|
24
|
-
* @returns The `nativeTransfer`/`wrapNative`/pull actions, in bundle order (empty when nothing is
|
|
25
|
-
* funded).
|
|
26
|
-
* @throws {ChainWNativeMissingError} when `nativeAmount > 0n` but the chain has no configured wNative.
|
|
27
|
-
* @throws {NativeAmountOnNonWNativeAssetError} when `nativeAmount > 0n` but `asset` is not the
|
|
28
|
-
* chain's wNative.
|
|
29
|
-
* @throws {DepositAssetMismatchError} from `getTokenRequirementActions` when `requirementSignature` is
|
|
30
|
-
* provided and the signed asset differs from `asset`.
|
|
31
|
-
* @throws {DepositAmountMismatchError} from `getTokenRequirementActions` when `requirementSignature` is
|
|
32
|
-
* provided and the signed amount differs from `erc20Amount`.
|
|
33
|
-
* @throws {Permit2ExpirationMissingError} from `getTokenRequirementActions` when a Permit2 requirement
|
|
34
|
-
* signature is missing its expiration.
|
|
35
|
-
* @internal
|
|
36
|
-
*/
|
|
37
|
-
const buildAssetFundingActions = ({ chainId, asset, erc20Amount, nativeAmount, requirementSignature, }) => {
|
|
38
|
-
const { bundler3: { generalAdapter1, bundler3 }, } = (0, blue_sdk_1.getChainAddresses)(chainId);
|
|
39
|
-
const actions = [];
|
|
40
|
-
// Wrap native into wNative before pulling the ERC-20 remainder.
|
|
41
|
-
if (nativeAmount > 0n) {
|
|
42
|
-
(0, index_js_1.validateNativeAsset)(chainId, asset);
|
|
43
|
-
actions.push({
|
|
44
|
-
type: "nativeTransfer",
|
|
45
|
-
args: [bundler3, generalAdapter1, nativeAmount, false],
|
|
46
|
-
}, {
|
|
47
|
-
type: "wrapNative",
|
|
48
|
-
args: [nativeAmount, generalAdapter1, false],
|
|
49
|
-
});
|
|
50
|
-
}
|
|
51
|
-
// Pull the ERC-20 portion (0 on a fully native funding). getTokenRequirementActions emits a plain
|
|
52
|
-
// erc20TransferFrom itself when no permit/permit2 signature is supplied.
|
|
53
|
-
if (erc20Amount > 0n) {
|
|
54
|
-
actions.push(...(0, getTokenRequirementActions_js_1.getTokenRequirementActions)({
|
|
55
|
-
asset,
|
|
56
|
-
amount: erc20Amount,
|
|
57
|
-
recipient: generalAdapter1,
|
|
58
|
-
requirementSignature,
|
|
59
|
-
}));
|
|
60
|
-
}
|
|
61
|
-
return actions;
|
|
62
|
-
};
|
|
63
|
-
exports.buildAssetFundingActions = buildAssetFundingActions;
|
|
@@ -1,69 +0,0 @@
|
|
|
1
|
-
import { type MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import type { Action } from "../../bundler/index.js";
|
|
3
|
-
import type { BlueReallocationPlan, VaultV1Reallocation, VaultV2BlueReallocation } from "../../types/index.js";
|
|
4
|
-
/**
|
|
5
|
-
* Builds PublicAllocator V1 reallocation actions for a Morpho Blue target market.
|
|
6
|
-
*
|
|
7
|
-
* Preserves the supplied reallocation order and aggregates each allocator call's native fee.
|
|
8
|
-
*
|
|
9
|
-
* @param params.reallocations - Validated Vault V1 reallocations to execute.
|
|
10
|
-
* @param params.targetMarketParams - Morpho Blue market receiving the reallocated liquidity.
|
|
11
|
-
* @returns The reallocation actions and aggregate native fee, with zero V2 penalty assets.
|
|
12
|
-
* @internal
|
|
13
|
-
*/
|
|
14
|
-
export declare const buildVaultV1ReallocationActions: ({ reallocations, targetMarketParams, }: {
|
|
15
|
-
readonly reallocations: readonly VaultV1Reallocation[];
|
|
16
|
-
readonly targetMarketParams: MarketParams;
|
|
17
|
-
}) => {
|
|
18
|
-
actions: Action[];
|
|
19
|
-
fee: bigint;
|
|
20
|
-
penaltyAssets: bigint;
|
|
21
|
-
};
|
|
22
|
-
/**
|
|
23
|
-
* Builds BluePublicAllocator reallocation actions for a Morpho Blue target market.
|
|
24
|
-
*
|
|
25
|
-
* Prepends one aggregate loan-token funding action when penalties are non-zero, then builds one
|
|
26
|
-
* allocator action per validated Vault V2 reallocation.
|
|
27
|
-
*
|
|
28
|
-
* @param params.chainId - Chain whose registered Bundler3 and allocator addresses are used.
|
|
29
|
-
* @param params.reallocations - Validated Vault V2 Blue reallocations to execute.
|
|
30
|
-
* @param params.targetMarketParams - Morpho Blue market receiving the reallocated liquidity.
|
|
31
|
-
* @param params.penaltyFundingSource - Optional source of penalty assets. Defaults to the
|
|
32
|
-
* transaction initiator.
|
|
33
|
-
* @returns The funding and reallocation actions and aggregate penalty assets, with zero native fee.
|
|
34
|
-
* @internal
|
|
35
|
-
*/
|
|
36
|
-
export declare const buildVaultV2BlueReallocationActions: ({ chainId, reallocations, targetMarketParams, penaltyFundingSource, }: {
|
|
37
|
-
readonly chainId: number;
|
|
38
|
-
readonly reallocations: readonly VaultV2BlueReallocation[];
|
|
39
|
-
readonly targetMarketParams: MarketParams;
|
|
40
|
-
readonly penaltyFundingSource?: "initiator" | "generalAdapter1";
|
|
41
|
-
}) => {
|
|
42
|
-
actions: Action[];
|
|
43
|
-
fee: bigint;
|
|
44
|
-
penaltyAssets: bigint;
|
|
45
|
-
};
|
|
46
|
-
/**
|
|
47
|
-
* Validates a homogeneous Blue reallocation plan and builds its Bundler actions.
|
|
48
|
-
*
|
|
49
|
-
* Dispatches Vault V1 and Vault V2 plans to their version-specific builders. V1 plans aggregate
|
|
50
|
-
* native fees, while V2 plans aggregate loan-token penalties using the selected funding source.
|
|
51
|
-
*
|
|
52
|
-
* @param params.chainId - Chain whose registered Bundler3 and allocator addresses are used.
|
|
53
|
-
* @param params.reallocations - Optional homogeneous Vault V1 or Vault V2 reallocation plan.
|
|
54
|
-
* @param params.targetMarketParams - Morpho Blue market receiving the reallocated liquidity.
|
|
55
|
-
* @param params.penaltyFundingSource - Optional source of V2 penalty assets. Defaults to the
|
|
56
|
-
* transaction initiator.
|
|
57
|
-
* @returns The reallocation actions, aggregate V1 native fee, and aggregate V2 penalty assets.
|
|
58
|
-
* @internal
|
|
59
|
-
*/
|
|
60
|
-
export declare const buildBlueReallocationActions: ({ chainId, reallocations, targetMarketParams, penaltyFundingSource, }: {
|
|
61
|
-
readonly chainId: number;
|
|
62
|
-
readonly reallocations: BlueReallocationPlan | undefined;
|
|
63
|
-
readonly targetMarketParams: MarketParams;
|
|
64
|
-
readonly penaltyFundingSource?: "initiator" | "generalAdapter1";
|
|
65
|
-
}) => {
|
|
66
|
-
actions: Action[];
|
|
67
|
-
fee: bigint;
|
|
68
|
-
penaltyAssets: bigint;
|
|
69
|
-
};
|