@morpho-org/morpho-sdk 5.9.0 → 6.0.0-next.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/MIGRATION-v5-to-v6.md +201 -0
- package/README.md +58 -40
- 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 +99 -0
- package/lib/cjs/actions/blue/common.js +318 -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/index.d.ts +1 -1
- 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/getBlueBundlesV1TokenRequirements.d.ts +80 -0
- package/lib/cjs/actions/requirements/blue/getBlueBundlesV1TokenRequirements.js +207 -0
- 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 +2 -0
- package/lib/cjs/actions/requirements/blue/index.js +2 -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 +7 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +33 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts +61 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.js +123 -0
- 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 +5 -4
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -4
- package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +4 -0
- 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 +447 -696
- package/lib/cjs/entities/index.d.ts +1 -0
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +3 -9
- package/lib/cjs/helpers/validate.d.ts +14 -23
- package/lib/cjs/helpers/validate.js +30 -48
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +2 -0
- package/lib/cjs/types/action.d.ts +146 -162
- package/lib/cjs/types/action.js +29 -2
- package/lib/cjs/types/client.d.ts +9 -0
- package/lib/cjs/types/error.d.ts +141 -14
- package/lib/cjs/types/error.js +198 -21
- package/lib/cjs/types/sharedLiquidity.d.ts +0 -7
- 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 +99 -0
- package/lib/esm/actions/blue/common.js +306 -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/index.d.ts +1 -1
- 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/getBlueBundlesV1TokenRequirements.d.ts +80 -0
- package/lib/esm/actions/requirements/blue/getBlueBundlesV1TokenRequirements.js +203 -0
- 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 +2 -0
- package/lib/esm/actions/requirements/blue/index.js +2 -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 +8 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +34 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts +61 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.js +119 -0
- 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 +5 -4
- package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -4
- package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +5 -1
- 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 +453 -702
- package/lib/esm/entities/index.d.ts +1 -0
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +3 -9
- package/lib/esm/helpers/computeVaultV1Reallocations.js +3 -9
- package/lib/esm/helpers/validate.d.ts +14 -23
- package/lib/esm/helpers/validate.js +30 -48
- package/lib/esm/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/esm/helpers/validateRequirementSpender.js +2 -0
- package/lib/esm/types/action.d.ts +146 -162
- package/lib/esm/types/action.js +28 -2
- package/lib/esm/types/client.d.ts +9 -0
- package/lib/esm/types/error.d.ts +141 -14
- package/lib/esm/types/error.js +184 -17
- package/lib/esm/types/sharedLiquidity.d.ts +0 -7
- package/package.json +4 -3
- 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.d.ts
CHANGED
|
@@ -68,7 +68,7 @@ export declare class InputExceedsMaxError extends Error {
|
|
|
68
68
|
export declare class EmptyMarketParamsListError extends Error {
|
|
69
69
|
constructor();
|
|
70
70
|
}
|
|
71
|
-
/** Thrown when an
|
|
71
|
+
/** Thrown when an SDK operation deadline has already passed. */
|
|
72
72
|
export declare class ExpiredDeadlineError extends Error {
|
|
73
73
|
readonly deadline: bigint;
|
|
74
74
|
readonly timestamp: bigint;
|
|
@@ -203,6 +203,104 @@ export declare class VaultExitBundlesV1PermitMismatchError extends Error {
|
|
|
203
203
|
readonly cause?: unknown;
|
|
204
204
|
});
|
|
205
205
|
}
|
|
206
|
+
/** Thrown when a signed requirement cannot be safely encoded for BlueBundlesV1. */
|
|
207
|
+
export declare class BlueBundlesV1RequirementSignatureMismatchError extends Error {
|
|
208
|
+
/** Field whose signed value or encoding is invalid for the direct BlueBundlesV1 call. */
|
|
209
|
+
readonly field: "type" | "authorized" | "isAuthorized" | "deadline" | "signature";
|
|
210
|
+
/** Value required by BlueBundlesV1. */
|
|
211
|
+
readonly expected: string;
|
|
212
|
+
/** Value supplied by the signed requirement. */
|
|
213
|
+
readonly actual: string;
|
|
214
|
+
/**
|
|
215
|
+
* @param params - Signature mismatch details.
|
|
216
|
+
* @param params.field - Field rejected by the converter.
|
|
217
|
+
* @param params.expected - Value required by the direct route.
|
|
218
|
+
* @param params.actual - Value supplied by the requirement.
|
|
219
|
+
* @param params.cause - Original signature parser failure, when applicable.
|
|
220
|
+
*/
|
|
221
|
+
constructor(params: {
|
|
222
|
+
field: "type" | "authorized" | "isAuthorized" | "deadline" | "signature";
|
|
223
|
+
expected: string;
|
|
224
|
+
actual: string;
|
|
225
|
+
cause?: unknown;
|
|
226
|
+
});
|
|
227
|
+
}
|
|
228
|
+
/** Thrown when Permit2 SignatureTransfer is selected without an explicit unordered nonce. */
|
|
229
|
+
export declare class MissingPermit2TransferFromNonceError extends Error {
|
|
230
|
+
constructor();
|
|
231
|
+
}
|
|
232
|
+
/** Thrown when an explicit Permit2 SignatureTransfer unordered nonce is already consumed. */
|
|
233
|
+
export declare class Permit2TransferFromNonceAlreadyUsedError extends Error {
|
|
234
|
+
readonly owner: Address;
|
|
235
|
+
readonly nonce: bigint;
|
|
236
|
+
/**
|
|
237
|
+
* @param owner - Permit2 token owner whose nonce is unavailable.
|
|
238
|
+
* @param nonce - Explicit unordered nonce that has already been consumed.
|
|
239
|
+
*/
|
|
240
|
+
constructor(owner: Address, nonce: bigint);
|
|
241
|
+
}
|
|
242
|
+
/** Thrown when no unused Permit2 unordered nonce exists at or after the requested start nonce. */
|
|
243
|
+
export declare class NoUnusedPermit2NonceError extends Error {
|
|
244
|
+
readonly owner: Address;
|
|
245
|
+
readonly startNonce: bigint;
|
|
246
|
+
/**
|
|
247
|
+
* @param owner - Permit2 token owner scanned for a free nonce.
|
|
248
|
+
* @param startNonce - Lowest nonce that was considered.
|
|
249
|
+
*/
|
|
250
|
+
constructor(owner: Address, startNonce: bigint);
|
|
251
|
+
}
|
|
252
|
+
/** Thrown when native funding does not exactly match the contract's gross token pull. */
|
|
253
|
+
export declare class NativeFundingAmountMismatchError extends Error {
|
|
254
|
+
readonly nativeAmount: bigint;
|
|
255
|
+
readonly requiredAmount: bigint;
|
|
256
|
+
/**
|
|
257
|
+
* @param nativeAmount - Native value supplied with the transaction.
|
|
258
|
+
* @param requiredAmount - Gross amount the BlueBundlesV1 entrypoint funds.
|
|
259
|
+
*/
|
|
260
|
+
constructor(nativeAmount: bigint, requiredAmount: bigint);
|
|
261
|
+
}
|
|
262
|
+
/** Thrown when a positive referral fee has no recipient. */
|
|
263
|
+
export declare class MissingReferralFeeRecipientError extends Error {
|
|
264
|
+
constructor();
|
|
265
|
+
}
|
|
266
|
+
/** Thrown when a BlueBundlesV1 reallocation source uses another loan token. */
|
|
267
|
+
export declare class ReallocationLoanTokenMismatchError extends Error {
|
|
268
|
+
readonly expected: Address;
|
|
269
|
+
readonly actual: Address;
|
|
270
|
+
/**
|
|
271
|
+
* @param expected - Loan token of the operation's target market.
|
|
272
|
+
* @param actual - Loan token found in the reallocation source market.
|
|
273
|
+
*/
|
|
274
|
+
constructor(expected: Address, actual: Address);
|
|
275
|
+
}
|
|
276
|
+
/**
|
|
277
|
+
* Thrown when a Blue authorization operator is not one of the chain's registered Morpho operators
|
|
278
|
+
* (GeneralAdapter1 or BlueBundlesV1). Guards the exported authorization builder so a misconfigured
|
|
279
|
+
* `authorized` cannot grant an arbitrary address control over the user's Morpho positions.
|
|
280
|
+
*/
|
|
281
|
+
export declare class UnsupportedAuthorizationOperatorError extends Error {
|
|
282
|
+
readonly authorized: Address;
|
|
283
|
+
readonly chainId: number;
|
|
284
|
+
/**
|
|
285
|
+
* @param authorized - The operator address rejected as unsupported.
|
|
286
|
+
* @param chainId - Chain whose registry was consulted for the supported operators.
|
|
287
|
+
*/
|
|
288
|
+
constructor(authorized: Address, chainId: number);
|
|
289
|
+
}
|
|
290
|
+
/** Thrown when reallocations are attached to a combined call with no borrow leg. */
|
|
291
|
+
export declare class ReallocationsRequireBorrowError extends Error {
|
|
292
|
+
constructor();
|
|
293
|
+
}
|
|
294
|
+
/** Thrown when repay funding cannot cover the requested assets and referral fee. */
|
|
295
|
+
export declare class MaxRepayAssetsBelowRepayAssetsError extends Error {
|
|
296
|
+
readonly maxRepayAssets: bigint;
|
|
297
|
+
readonly repayAssets: bigint;
|
|
298
|
+
/**
|
|
299
|
+
* @param maxRepayAssets - Maximum loan-token funding supplied to the bundle.
|
|
300
|
+
* @param repayAssets - Minimum funding required for the repayment and referral fee.
|
|
301
|
+
*/
|
|
302
|
+
constructor(maxRepayAssets: bigint, repayAssets: bigint);
|
|
303
|
+
}
|
|
206
304
|
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
207
305
|
export declare const NonPositiveAssetAmountError: typeof NonPositiveInputError;
|
|
208
306
|
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
@@ -375,7 +473,7 @@ export declare namespace BundlerErrors {
|
|
|
375
473
|
}
|
|
376
474
|
}
|
|
377
475
|
/** Requirement signature kind accepted by action-output transaction builders. */
|
|
378
|
-
export type RequirementSignatureKind = "permit" | "authorization" | "midnightOfferRootSignature";
|
|
476
|
+
export type RequirementSignatureKind = "permit" | "permit2TransferFrom" | "authorization" | "midnightOfferRootSignature";
|
|
379
477
|
/**
|
|
380
478
|
* Thrown when `buildTx` receives more than one requirement signature of the same kind.
|
|
381
479
|
*
|
|
@@ -537,11 +635,10 @@ export declare class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
|
537
635
|
constructor(vault: string, marketId: string);
|
|
538
636
|
}
|
|
539
637
|
/**
|
|
540
|
-
* Thrown when a
|
|
541
|
-
*
|
|
638
|
+
* Thrown when a reallocation entry passed to a high-level Blue write is not a valid
|
|
639
|
+
* {@link VaultV2BlueReallocation}: a non-object entry, or an entry carrying Vault V1
|
|
640
|
+
* `withdrawals`/`fee` fields that high-level Blue writes no longer accept.
|
|
542
641
|
*
|
|
543
|
-
* @deprecated Vault V1/V2 reallocation-shape dispatch will be removed in the next major. Use Vault
|
|
544
|
-
* V2 reallocations.
|
|
545
642
|
* @example
|
|
546
643
|
* ```ts
|
|
547
644
|
* import { InvalidReallocationShapeError } from "@morpho-org/morpho-sdk";
|
|
@@ -1038,10 +1135,6 @@ export declare class ReallocationWithdrawExceedsMarketSupplyError extends Error
|
|
|
1038
1135
|
export declare class VaultAssetMismatchError extends Error {
|
|
1039
1136
|
constructor(sourceAsset: Address, targetAsset: Address);
|
|
1040
1137
|
}
|
|
1041
|
-
/** Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive). */
|
|
1042
|
-
export declare class BorrowAmountAndSharesExclusiveError extends Error {
|
|
1043
|
-
constructor(market: string);
|
|
1044
|
-
}
|
|
1045
1138
|
/** Thrown when a refinance has identical source and target market ids (a refinance to the same market is a costly no-op). */
|
|
1046
1139
|
export declare class RefinanceSameMarketError extends Error {
|
|
1047
1140
|
constructor(market: string);
|
|
@@ -1050,7 +1143,23 @@ export declare class RefinanceSameMarketError extends Error {
|
|
|
1050
1143
|
export declare class RefinanceTokenMismatchError extends Error {
|
|
1051
1144
|
constructor(sourceMarket: string, targetMarket: string);
|
|
1052
1145
|
}
|
|
1053
|
-
/**
|
|
1146
|
+
/**
|
|
1147
|
+
* Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive).
|
|
1148
|
+
*
|
|
1149
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1150
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1151
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1152
|
+
*/
|
|
1153
|
+
export declare class BorrowAmountAndSharesExclusiveError extends Error {
|
|
1154
|
+
constructor(market: string);
|
|
1155
|
+
}
|
|
1156
|
+
/**
|
|
1157
|
+
* Thrown when a refinance's `collateralAmount` exceeds the source position's available collateral.
|
|
1158
|
+
*
|
|
1159
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1160
|
+
* partial collateral inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1161
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1162
|
+
*/
|
|
1054
1163
|
export declare class RefinanceExceedsCollateralError extends Error {
|
|
1055
1164
|
readonly market: string;
|
|
1056
1165
|
readonly requested: bigint;
|
|
@@ -1061,7 +1170,13 @@ export declare class RefinanceExceedsCollateralError extends Error {
|
|
|
1061
1170
|
available: bigint;
|
|
1062
1171
|
});
|
|
1063
1172
|
}
|
|
1064
|
-
/**
|
|
1173
|
+
/**
|
|
1174
|
+
* Thrown when a refinance's `borrowShares` exceeds the source position's outstanding borrow shares.
|
|
1175
|
+
*
|
|
1176
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1177
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1178
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1179
|
+
*/
|
|
1065
1180
|
export declare class RefinanceExceedsBorrowSharesError extends Error {
|
|
1066
1181
|
readonly market: string;
|
|
1067
1182
|
readonly requested: bigint;
|
|
@@ -1072,7 +1187,13 @@ export declare class RefinanceExceedsBorrowSharesError extends Error {
|
|
|
1072
1187
|
available: bigint;
|
|
1073
1188
|
});
|
|
1074
1189
|
}
|
|
1075
|
-
/**
|
|
1190
|
+
/**
|
|
1191
|
+
* Thrown when a refinance's `borrowAssets` exceeds the source position's outstanding debt assets.
|
|
1192
|
+
*
|
|
1193
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1194
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1195
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1196
|
+
*/
|
|
1076
1197
|
export declare class RefinanceExceedsBorrowAssetsError extends Error {
|
|
1077
1198
|
readonly market: string;
|
|
1078
1199
|
readonly requested: bigint;
|
|
@@ -1083,7 +1204,13 @@ export declare class RefinanceExceedsBorrowAssetsError extends Error {
|
|
|
1083
1204
|
available: bigint;
|
|
1084
1205
|
});
|
|
1085
1206
|
}
|
|
1086
|
-
/**
|
|
1207
|
+
/**
|
|
1208
|
+
* Thrown when a refinance in shares mode (`borrowShares > 0n`) omits the `borrowAssets` overshoot for the target borrow leg.
|
|
1209
|
+
*
|
|
1210
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1211
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1212
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1213
|
+
*/
|
|
1087
1214
|
export declare class RefinanceSharesMissingBorrowAssetsError extends Error {
|
|
1088
1215
|
constructor(market: string);
|
|
1089
1216
|
}
|
package/lib/esm/types/error.js
CHANGED
|
@@ -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";
|
|
@@ -250,6 +250,144 @@ export class VaultExitBundlesV1PermitMismatchError extends Error {
|
|
|
250
250
|
this.name = "VaultExitBundlesV1PermitMismatchError";
|
|
251
251
|
}
|
|
252
252
|
}
|
|
253
|
+
/** Thrown when a signed requirement cannot be safely encoded for BlueBundlesV1. */
|
|
254
|
+
export class BlueBundlesV1RequirementSignatureMismatchError extends Error {
|
|
255
|
+
/** Field whose signed value or encoding is invalid for the direct BlueBundlesV1 call. */
|
|
256
|
+
field;
|
|
257
|
+
/** Value required by BlueBundlesV1. */
|
|
258
|
+
expected;
|
|
259
|
+
/** Value supplied by the signed requirement. */
|
|
260
|
+
actual;
|
|
261
|
+
/**
|
|
262
|
+
* @param params - Signature mismatch details.
|
|
263
|
+
* @param params.field - Field rejected by the converter.
|
|
264
|
+
* @param params.expected - Value required by the direct route.
|
|
265
|
+
* @param params.actual - Value supplied by the requirement.
|
|
266
|
+
* @param params.cause - Original signature parser failure, when applicable.
|
|
267
|
+
*/
|
|
268
|
+
constructor(params) {
|
|
269
|
+
super(`BlueBundlesV1 requirement ${params.field} mismatch: expected "${params.expected}", got "${params.actual}". Resolve and sign the requirements returned by this Blue action.`, { cause: params.cause });
|
|
270
|
+
this.field = params.field;
|
|
271
|
+
this.expected = params.expected;
|
|
272
|
+
this.actual = params.actual;
|
|
273
|
+
this.name = "BlueBundlesV1RequirementSignatureMismatchError";
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
/** Thrown when Permit2 SignatureTransfer is selected without an explicit unordered nonce. */
|
|
277
|
+
export class MissingPermit2TransferFromNonceError extends Error {
|
|
278
|
+
constructor() {
|
|
279
|
+
super("Permit2 SignatureTransfer requires an explicit unused permit2Nonce. Generate a unique uint256 nonce, pass it to getRequirements(), and resolve the requirements again.");
|
|
280
|
+
this.name = "MissingPermit2TransferFromNonceError";
|
|
281
|
+
}
|
|
282
|
+
}
|
|
283
|
+
/** Thrown when an explicit Permit2 SignatureTransfer unordered nonce is already consumed. */
|
|
284
|
+
export class Permit2TransferFromNonceAlreadyUsedError extends Error {
|
|
285
|
+
owner;
|
|
286
|
+
nonce;
|
|
287
|
+
/**
|
|
288
|
+
* @param owner - Permit2 token owner whose nonce is unavailable.
|
|
289
|
+
* @param nonce - Explicit unordered nonce that has already been consumed.
|
|
290
|
+
*/
|
|
291
|
+
constructor(owner, nonce) {
|
|
292
|
+
super(`Permit2 nonce "${nonce}" is already used for owner "${owner}". Generate a different uint256 permit2Nonce and resolve the requirements again.`);
|
|
293
|
+
this.owner = owner;
|
|
294
|
+
this.nonce = nonce;
|
|
295
|
+
this.name = "Permit2TransferFromNonceAlreadyUsedError";
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
/** Thrown when no unused Permit2 unordered nonce exists at or after the requested start nonce. */
|
|
299
|
+
export class NoUnusedPermit2NonceError extends Error {
|
|
300
|
+
owner;
|
|
301
|
+
startNonce;
|
|
302
|
+
/**
|
|
303
|
+
* @param owner - Permit2 token owner scanned for a free nonce.
|
|
304
|
+
* @param startNonce - Lowest nonce that was considered.
|
|
305
|
+
*/
|
|
306
|
+
constructor(owner, startNonce) {
|
|
307
|
+
super(`No unused Permit2 nonce found for owner "${owner}" at or after "${startNonce}". Pass a lower startNonce.`);
|
|
308
|
+
this.owner = owner;
|
|
309
|
+
this.startNonce = startNonce;
|
|
310
|
+
this.name = "NoUnusedPermit2NonceError";
|
|
311
|
+
}
|
|
312
|
+
}
|
|
313
|
+
/** Thrown when native funding does not exactly match the contract's gross token pull. */
|
|
314
|
+
export class NativeFundingAmountMismatchError extends Error {
|
|
315
|
+
nativeAmount;
|
|
316
|
+
requiredAmount;
|
|
317
|
+
/**
|
|
318
|
+
* @param nativeAmount - Native value supplied with the transaction.
|
|
319
|
+
* @param requiredAmount - Gross amount the BlueBundlesV1 entrypoint funds.
|
|
320
|
+
*/
|
|
321
|
+
constructor(nativeAmount, requiredAmount) {
|
|
322
|
+
super(`Native funding must equal the full funded amount: expected "${requiredAmount}", got "${nativeAmount}". Use either native funding or ERC-20 funding, not both.`);
|
|
323
|
+
this.nativeAmount = nativeAmount;
|
|
324
|
+
this.requiredAmount = requiredAmount;
|
|
325
|
+
this.name = "NativeFundingAmountMismatchError";
|
|
326
|
+
}
|
|
327
|
+
}
|
|
328
|
+
/** Thrown when a positive referral fee has no recipient. */
|
|
329
|
+
export class MissingReferralFeeRecipientError extends Error {
|
|
330
|
+
constructor() {
|
|
331
|
+
super("A positive referralFeePct requires referralFeeRecipient. Provide the recipient or set referralFeePct to zero.");
|
|
332
|
+
this.name = "MissingReferralFeeRecipientError";
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
/** Thrown when a BlueBundlesV1 reallocation source uses another loan token. */
|
|
336
|
+
export class ReallocationLoanTokenMismatchError extends Error {
|
|
337
|
+
expected;
|
|
338
|
+
actual;
|
|
339
|
+
/**
|
|
340
|
+
* @param expected - Loan token of the operation's target market.
|
|
341
|
+
* @param actual - Loan token found in the reallocation source market.
|
|
342
|
+
*/
|
|
343
|
+
constructor(expected, actual) {
|
|
344
|
+
super(`Reallocation source loan token "${actual}" does not match target loan token "${expected}". Recompute reallocations for the target market.`);
|
|
345
|
+
this.expected = expected;
|
|
346
|
+
this.actual = actual;
|
|
347
|
+
this.name = "ReallocationLoanTokenMismatchError";
|
|
348
|
+
}
|
|
349
|
+
}
|
|
350
|
+
/**
|
|
351
|
+
* Thrown when a Blue authorization operator is not one of the chain's registered Morpho operators
|
|
352
|
+
* (GeneralAdapter1 or BlueBundlesV1). Guards the exported authorization builder so a misconfigured
|
|
353
|
+
* `authorized` cannot grant an arbitrary address control over the user's Morpho positions.
|
|
354
|
+
*/
|
|
355
|
+
export class UnsupportedAuthorizationOperatorError extends Error {
|
|
356
|
+
authorized;
|
|
357
|
+
chainId;
|
|
358
|
+
/**
|
|
359
|
+
* @param authorized - The operator address rejected as unsupported.
|
|
360
|
+
* @param chainId - Chain whose registry was consulted for the supported operators.
|
|
361
|
+
*/
|
|
362
|
+
constructor(authorized, chainId) {
|
|
363
|
+
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.`);
|
|
364
|
+
this.authorized = authorized;
|
|
365
|
+
this.chainId = chainId;
|
|
366
|
+
this.name = "UnsupportedAuthorizationOperatorError";
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
/** Thrown when reallocations are attached to a combined call with no borrow leg. */
|
|
370
|
+
export class ReallocationsRequireBorrowError extends Error {
|
|
371
|
+
constructor() {
|
|
372
|
+
super("BlueBundlesV1 reallocations require a positive borrowAssets value. Remove the reallocations or add a borrow leg.");
|
|
373
|
+
this.name = "ReallocationsRequireBorrowError";
|
|
374
|
+
}
|
|
375
|
+
}
|
|
376
|
+
/** Thrown when repay funding cannot cover the requested assets and referral fee. */
|
|
377
|
+
export class MaxRepayAssetsBelowRepayAssetsError extends Error {
|
|
378
|
+
maxRepayAssets;
|
|
379
|
+
repayAssets;
|
|
380
|
+
/**
|
|
381
|
+
* @param maxRepayAssets - Maximum loan-token funding supplied to the bundle.
|
|
382
|
+
* @param repayAssets - Minimum funding required for the repayment and referral fee.
|
|
383
|
+
*/
|
|
384
|
+
constructor(maxRepayAssets, repayAssets) {
|
|
385
|
+
super(`maxRepayAssets "${maxRepayAssets}" cannot cover required repay funding "${repayAssets}". Increase maxRepayAssets to include the repayment and referral fee.`);
|
|
386
|
+
this.maxRepayAssets = maxRepayAssets;
|
|
387
|
+
this.repayAssets = repayAssets;
|
|
388
|
+
this.name = "MaxRepayAssetsBelowRepayAssetsError";
|
|
389
|
+
}
|
|
390
|
+
}
|
|
253
391
|
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
254
392
|
export const NonPositiveAssetAmountError = NonPositiveInputError;
|
|
255
393
|
/** @deprecated Use {@link NonPositiveInputError}. */
|
|
@@ -604,11 +742,10 @@ export class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
|
604
742
|
}
|
|
605
743
|
}
|
|
606
744
|
/**
|
|
607
|
-
* Thrown when a
|
|
608
|
-
*
|
|
745
|
+
* Thrown when a reallocation entry passed to a high-level Blue write is not a valid
|
|
746
|
+
* {@link VaultV2BlueReallocation}: a non-object entry, or an entry carrying Vault V1
|
|
747
|
+
* `withdrawals`/`fee` fields that high-level Blue writes no longer accept.
|
|
609
748
|
*
|
|
610
|
-
* @deprecated Vault V1/V2 reallocation-shape dispatch will be removed in the next major. Use Vault
|
|
611
|
-
* V2 reallocations.
|
|
612
749
|
* @example
|
|
613
750
|
* ```ts
|
|
614
751
|
* import { InvalidReallocationShapeError } from "@morpho-org/morpho-sdk";
|
|
@@ -618,7 +755,7 @@ export class ReallocationWithdrawalOnTargetMarketError extends Error {
|
|
|
618
755
|
*/
|
|
619
756
|
export class InvalidReallocationShapeError extends Error {
|
|
620
757
|
constructor() {
|
|
621
|
-
super(
|
|
758
|
+
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
759
|
this.name = "InvalidReallocationShapeError";
|
|
623
760
|
}
|
|
624
761
|
}
|
|
@@ -1119,12 +1256,6 @@ export class VaultAssetMismatchError extends Error {
|
|
|
1119
1256
|
super(`Source vault asset ${sourceAsset} does not match target vault asset ${targetAsset}`);
|
|
1120
1257
|
}
|
|
1121
1258
|
}
|
|
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
1259
|
/** Thrown when a refinance has identical source and target market ids (a refinance to the same market is a costly no-op). */
|
|
1129
1260
|
export class RefinanceSameMarketError extends Error {
|
|
1130
1261
|
constructor(market) {
|
|
@@ -1137,7 +1268,25 @@ export class RefinanceTokenMismatchError extends Error {
|
|
|
1137
1268
|
super(`Refinance source market ${sourceMarket} and target market ${targetMarket} must share the same loanToken and collateralToken.`);
|
|
1138
1269
|
}
|
|
1139
1270
|
}
|
|
1140
|
-
/**
|
|
1271
|
+
/**
|
|
1272
|
+
* Thrown when a refinance specifies both `borrowAssets` and `borrowShares` as non-zero (modes are mutually exclusive).
|
|
1273
|
+
*
|
|
1274
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1275
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1276
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1277
|
+
*/
|
|
1278
|
+
export class BorrowAmountAndSharesExclusiveError extends Error {
|
|
1279
|
+
constructor(market) {
|
|
1280
|
+
super(`Exactly one of borrowAssets or borrowShares must be non-zero for market: ${market}. Both were provided.`);
|
|
1281
|
+
}
|
|
1282
|
+
}
|
|
1283
|
+
/**
|
|
1284
|
+
* Thrown when a refinance's `collateralAmount` exceeds the source position's available collateral.
|
|
1285
|
+
*
|
|
1286
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1287
|
+
* partial collateral inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1288
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1289
|
+
*/
|
|
1141
1290
|
export class RefinanceExceedsCollateralError extends Error {
|
|
1142
1291
|
market;
|
|
1143
1292
|
requested;
|
|
@@ -1149,7 +1298,13 @@ export class RefinanceExceedsCollateralError extends Error {
|
|
|
1149
1298
|
this.available = params.available;
|
|
1150
1299
|
}
|
|
1151
1300
|
}
|
|
1152
|
-
/**
|
|
1301
|
+
/**
|
|
1302
|
+
* Thrown when a refinance's `borrowShares` exceeds the source position's outstanding borrow shares.
|
|
1303
|
+
*
|
|
1304
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1305
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1306
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1307
|
+
*/
|
|
1153
1308
|
export class RefinanceExceedsBorrowSharesError extends Error {
|
|
1154
1309
|
market;
|
|
1155
1310
|
requested;
|
|
@@ -1161,7 +1316,13 @@ export class RefinanceExceedsBorrowSharesError extends Error {
|
|
|
1161
1316
|
this.available = params.available;
|
|
1162
1317
|
}
|
|
1163
1318
|
}
|
|
1164
|
-
/**
|
|
1319
|
+
/**
|
|
1320
|
+
* Thrown when a refinance's `borrowAssets` exceeds the source position's outstanding debt assets.
|
|
1321
|
+
*
|
|
1322
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1323
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1324
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1325
|
+
*/
|
|
1165
1326
|
export class RefinanceExceedsBorrowAssetsError extends Error {
|
|
1166
1327
|
market;
|
|
1167
1328
|
requested;
|
|
@@ -1173,7 +1334,13 @@ export class RefinanceExceedsBorrowAssetsError extends Error {
|
|
|
1173
1334
|
this.available = params.available;
|
|
1174
1335
|
}
|
|
1175
1336
|
}
|
|
1176
|
-
/**
|
|
1337
|
+
/**
|
|
1338
|
+
* Thrown when a refinance in shares mode (`borrowShares > 0n`) omits the `borrowAssets` overshoot for the target borrow leg.
|
|
1339
|
+
*
|
|
1340
|
+
* @deprecated The BlueBundlesV1 refinance route migrates the full live position and no longer accepts
|
|
1341
|
+
* partial borrow inputs, so this error is never thrown by `morpho-sdk` v6. It remains exported as a
|
|
1342
|
+
* compatibility shim for consumers pattern-matching on the v5 surface and will be removed in the next major.
|
|
1343
|
+
*/
|
|
1177
1344
|
export class RefinanceSharesMissingBorrowAssetsError extends Error {
|
|
1178
1345
|
constructor(market) {
|
|
1179
1346
|
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.0",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"contributors": [
|
|
7
7
|
"Foulks-Plb <https://x.com/FoulkPlb>"
|
|
@@ -157,7 +157,8 @@
|
|
|
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",
|
|
@@ -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;
|