@morpho-org/morpho-sdk 6.0.0-next.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 +206 -3
- package/README.md +81 -41
- package/lib/cjs/abis.d.ts +210 -0
- package/lib/cjs/abis.js +142 -2
- package/lib/cjs/actions/blue/borrow.d.ts +1 -1
- package/lib/cjs/actions/blue/borrow.js +1 -1
- package/lib/cjs/actions/blue/common.d.ts +6 -19
- package/lib/cjs/actions/blue/common.js +25 -138
- package/lib/cjs/actions/blue/refinance.d.ts +1 -1
- package/lib/cjs/actions/blue/refinance.js +1 -1
- package/lib/cjs/actions/blue/repay.d.ts +3 -3
- package/lib/cjs/actions/blue/repay.js +1 -1
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +3 -3
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +1 -1
- package/lib/cjs/actions/blue/supply.d.ts +3 -3
- package/lib/cjs/actions/blue/supply.js +1 -1
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +3 -3
- package/lib/cjs/actions/blue/supplyCollateral.js +1 -1
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +3 -3
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +1 -1
- package/lib/cjs/actions/blue/withdraw.d.ts +1 -1
- package/lib/cjs/actions/blue/withdraw.js +1 -1
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +1 -1
- package/lib/cjs/actions/blue/withdrawCollateral.js +1 -1
- 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 +1 -0
- 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/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.js +1 -1
- package/lib/cjs/actions/requirements/blue/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/blue/index.js +0 -1
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +3 -3
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +10 -4
- package/lib/{esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +12 -12
- package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +13 -13
- 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 -1
- package/lib/cjs/actions/requirements/encode/index.js +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +4 -3
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +4 -3
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +2 -2
- 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/entities/blue/blue.d.ts +19 -19
- package/lib/cjs/entities/blue/blue.js +3 -1
- package/lib/cjs/entities/index.d.ts +1 -0
- package/lib/cjs/entities/index.js +15 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +21 -14
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +61 -65
- 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/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 +2 -0
- package/lib/cjs/helpers/validate.js +12 -1
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +1 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types/action.d.ts +179 -70
- package/lib/cjs/types/action.js +12 -12
- package/lib/cjs/types/error.d.ts +62 -14
- package/lib/cjs/types/error.js +88 -22
- package/lib/esm/abis.d.ts +210 -0
- package/lib/esm/abis.js +140 -0
- package/lib/esm/actions/blue/borrow.d.ts +1 -1
- package/lib/esm/actions/blue/borrow.js +1 -1
- package/lib/esm/actions/blue/common.d.ts +6 -19
- package/lib/esm/actions/blue/common.js +27 -140
- package/lib/esm/actions/blue/refinance.d.ts +1 -1
- package/lib/esm/actions/blue/refinance.js +1 -1
- package/lib/esm/actions/blue/repay.d.ts +3 -3
- package/lib/esm/actions/blue/repay.js +1 -1
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +3 -3
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +1 -1
- package/lib/esm/actions/blue/supply.d.ts +3 -3
- package/lib/esm/actions/blue/supply.js +1 -1
- package/lib/esm/actions/blue/supplyCollateral.d.ts +3 -3
- package/lib/esm/actions/blue/supplyCollateral.js +1 -1
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +3 -3
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +1 -1
- package/lib/esm/actions/blue/withdraw.d.ts +1 -1
- package/lib/esm/actions/blue/withdraw.js +1 -1
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +1 -1
- package/lib/esm/actions/blue/withdrawCollateral.js +1 -1
- 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 +1 -0
- 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/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.js +1 -1
- package/lib/esm/actions/requirements/blue/index.d.ts +0 -1
- package/lib/esm/actions/requirements/blue/index.js +0 -1
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +1 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +1 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +3 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +10 -4
- package/lib/{cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +12 -12
- package/lib/esm/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +11 -11
- 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 -1
- package/lib/esm/actions/requirements/encode/index.js +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +4 -3
- package/lib/esm/actions/requirements/getRequirementsApproval.js +4 -3
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +3 -3
- 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/entities/blue/blue.d.ts +19 -19
- package/lib/esm/entities/blue/blue.js +4 -2
- package/lib/esm/entities/index.d.ts +1 -0
- package/lib/esm/entities/index.js +1 -0
- package/lib/esm/entities/midnight/midnight.d.ts +2 -2
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +21 -14
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +51 -55
- 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/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 +2 -0
- package/lib/esm/helpers/validate.js +11 -1
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +1 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/types/action.d.ts +179 -70
- package/lib/esm/types/action.js +11 -11
- package/lib/esm/types/error.d.ts +62 -14
- package/lib/esm/types/error.js +80 -16
- package/package.json +3 -3
package/lib/esm/abis.js
CHANGED
|
@@ -179,6 +179,146 @@ export const vaultExitBundlesV1Abi = [
|
|
|
179
179
|
stateMutability: "nonpayable",
|
|
180
180
|
},
|
|
181
181
|
];
|
|
182
|
+
/**
|
|
183
|
+
* Pinned ABI for the VaultBundlesV1 entrypoints used by Vault V1 and Vault V2 actions.
|
|
184
|
+
*
|
|
185
|
+
* Sourced from `morpho-org/bundles` commit
|
|
186
|
+
* `f27e7bcf744310303e24faa522b71d702e696686`.
|
|
187
|
+
*/
|
|
188
|
+
export const vaultBundlesV1Abi = [
|
|
189
|
+
{ type: "error", name: "AlreadyInitiated", inputs: [] },
|
|
190
|
+
{ type: "error", name: "DeadlinePassed", inputs: [] },
|
|
191
|
+
{ type: "error", name: "InconsistentAssets", inputs: [] },
|
|
192
|
+
{ type: "error", name: "NotExactlyOneZero", inputs: [] },
|
|
193
|
+
{ type: "error", name: "PctExceeded", inputs: [] },
|
|
194
|
+
{ type: "error", name: "SlippageExceeded", inputs: [] },
|
|
195
|
+
{
|
|
196
|
+
type: "function",
|
|
197
|
+
name: "initiator",
|
|
198
|
+
inputs: [],
|
|
199
|
+
outputs: [{ name: "", type: "address", internalType: "address" }],
|
|
200
|
+
stateMutability: "view",
|
|
201
|
+
},
|
|
202
|
+
{
|
|
203
|
+
type: "function",
|
|
204
|
+
name: "vaultBundlesV1Deposit",
|
|
205
|
+
inputs: [
|
|
206
|
+
{ name: "vault", type: "address", internalType: "address" },
|
|
207
|
+
{ name: "assets", type: "uint256", internalType: "uint256" },
|
|
208
|
+
{
|
|
209
|
+
name: "maxSharePriceE27",
|
|
210
|
+
type: "uint256",
|
|
211
|
+
internalType: "uint256",
|
|
212
|
+
},
|
|
213
|
+
{
|
|
214
|
+
name: "assetPermit",
|
|
215
|
+
type: "tuple",
|
|
216
|
+
internalType: "struct TokenPermit",
|
|
217
|
+
components: [
|
|
218
|
+
{ name: "kind", type: "uint8", internalType: "enum PermitKind" },
|
|
219
|
+
{ name: "data", type: "bytes", internalType: "bytes" },
|
|
220
|
+
],
|
|
221
|
+
},
|
|
222
|
+
{
|
|
223
|
+
name: "referralFeePct",
|
|
224
|
+
type: "uint256",
|
|
225
|
+
internalType: "uint256",
|
|
226
|
+
},
|
|
227
|
+
{
|
|
228
|
+
name: "referralFeeRecipient",
|
|
229
|
+
type: "address",
|
|
230
|
+
internalType: "address",
|
|
231
|
+
},
|
|
232
|
+
{ name: "deadline", type: "uint256", internalType: "uint256" },
|
|
233
|
+
],
|
|
234
|
+
outputs: [],
|
|
235
|
+
stateMutability: "payable",
|
|
236
|
+
},
|
|
237
|
+
{
|
|
238
|
+
type: "function",
|
|
239
|
+
name: "vaultBundlesV1Withdraw",
|
|
240
|
+
inputs: [
|
|
241
|
+
{ name: "vault", type: "address", internalType: "address" },
|
|
242
|
+
{ name: "assets", type: "uint256", internalType: "uint256" },
|
|
243
|
+
{ name: "shares", type: "uint256", internalType: "uint256" },
|
|
244
|
+
{
|
|
245
|
+
name: "sharesPermit",
|
|
246
|
+
type: "tuple",
|
|
247
|
+
internalType: "struct Permit",
|
|
248
|
+
components: [
|
|
249
|
+
{ name: "value", type: "uint256", internalType: "uint256" },
|
|
250
|
+
{ name: "nonce", type: "uint256", internalType: "uint256" },
|
|
251
|
+
{ name: "deadline", type: "uint256", internalType: "uint256" },
|
|
252
|
+
{ name: "v", type: "uint8", internalType: "uint8" },
|
|
253
|
+
{ name: "r", type: "bytes32", internalType: "bytes32" },
|
|
254
|
+
{ name: "s", type: "bytes32", internalType: "bytes32" },
|
|
255
|
+
],
|
|
256
|
+
},
|
|
257
|
+
{
|
|
258
|
+
name: "referralFeePct",
|
|
259
|
+
type: "uint256",
|
|
260
|
+
internalType: "uint256",
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
name: "referralFeeRecipient",
|
|
264
|
+
type: "address",
|
|
265
|
+
internalType: "address",
|
|
266
|
+
},
|
|
267
|
+
{ name: "deadline", type: "uint256", internalType: "uint256" },
|
|
268
|
+
],
|
|
269
|
+
outputs: [],
|
|
270
|
+
stateMutability: "nonpayable",
|
|
271
|
+
},
|
|
272
|
+
{
|
|
273
|
+
type: "function",
|
|
274
|
+
name: "vaultBundlesV1Migrate",
|
|
275
|
+
inputs: [
|
|
276
|
+
{ name: "sourceVault", type: "address", internalType: "address" },
|
|
277
|
+
{ name: "destVault", type: "address", internalType: "address" },
|
|
278
|
+
{
|
|
279
|
+
name: "assetsWithdrawn",
|
|
280
|
+
type: "uint256",
|
|
281
|
+
internalType: "uint256",
|
|
282
|
+
},
|
|
283
|
+
{
|
|
284
|
+
name: "sharesRedeemed",
|
|
285
|
+
type: "uint256",
|
|
286
|
+
internalType: "uint256",
|
|
287
|
+
},
|
|
288
|
+
{
|
|
289
|
+
name: "destMaxSharePriceE27",
|
|
290
|
+
type: "uint256",
|
|
291
|
+
internalType: "uint256",
|
|
292
|
+
},
|
|
293
|
+
{
|
|
294
|
+
name: "sharesPermit",
|
|
295
|
+
type: "tuple",
|
|
296
|
+
internalType: "struct Permit",
|
|
297
|
+
components: [
|
|
298
|
+
{ name: "value", type: "uint256", internalType: "uint256" },
|
|
299
|
+
{ name: "nonce", type: "uint256", internalType: "uint256" },
|
|
300
|
+
{ name: "deadline", type: "uint256", internalType: "uint256" },
|
|
301
|
+
{ name: "v", type: "uint8", internalType: "uint8" },
|
|
302
|
+
{ name: "r", type: "bytes32", internalType: "bytes32" },
|
|
303
|
+
{ name: "s", type: "bytes32", internalType: "bytes32" },
|
|
304
|
+
],
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
name: "referralFeePct",
|
|
308
|
+
type: "uint256",
|
|
309
|
+
internalType: "uint256",
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
name: "referralFeeRecipient",
|
|
313
|
+
type: "address",
|
|
314
|
+
internalType: "address",
|
|
315
|
+
},
|
|
316
|
+
{ name: "deadline", type: "uint256", internalType: "uint256" },
|
|
317
|
+
],
|
|
318
|
+
outputs: [],
|
|
319
|
+
stateMutability: "nonpayable",
|
|
320
|
+
},
|
|
321
|
+
];
|
|
182
322
|
/** ABI for the Bundler3 multicall contract. */
|
|
183
323
|
export const bundler3Abi = [
|
|
184
324
|
{
|
|
@@ -60,7 +60,7 @@ export interface BlueBorrowParams {
|
|
|
60
60
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
|
|
61
61
|
* @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
|
|
62
62
|
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
63
|
-
* @throws {
|
|
63
|
+
* @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
64
64
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
65
65
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
66
66
|
* @example
|
|
@@ -30,7 +30,7 @@ import { blueSupplyCollateralBorrow } from "./supplyCollateralBorrow.js";
|
|
|
30
30
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
|
|
31
31
|
* @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
|
|
32
32
|
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
33
|
-
* @throws {
|
|
33
|
+
* @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
34
34
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
35
35
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
36
36
|
* @example
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { type Address, type Hex } from "viem";
|
|
3
|
-
import { type AuthorizationRequirementSignature, type BaseAction, type
|
|
3
|
+
import { type AuthorizationRequirementSignature, type BaseAction, type BundlesTokenRequirementSignature, type Metadata, type RequirementSignature, type Transaction, type VaultV2BlueReallocation } from "../../types/index.js";
|
|
4
|
+
import { type BundlesTokenPermit } from "../bundles/index.js";
|
|
4
5
|
/** @internal */
|
|
5
6
|
export interface BlueBundlesV1CommonParams {
|
|
6
7
|
chainId: number;
|
|
@@ -15,21 +16,7 @@ export interface NormalizedBlueBundlesV1CommonParams {
|
|
|
15
16
|
referralFeePct: bigint;
|
|
16
17
|
referralFeeRecipient: Address;
|
|
17
18
|
}
|
|
18
|
-
|
|
19
|
-
* BlueBundlesV1 token-permit discriminator carried in the encoded permit struct: `none` (0) skips
|
|
20
|
-
* the pull, `erc2612` (1) is an ERC-2612 permit, `permit2TransferFrom` (2) is a Permit2
|
|
21
|
-
* SignatureTransfer. Named so a transposed literal can't silently route a permit to the wrong branch.
|
|
22
|
-
* @internal
|
|
23
|
-
*/
|
|
24
|
-
declare const BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND: {
|
|
25
|
-
readonly none: 0;
|
|
26
|
-
readonly erc2612: 1;
|
|
27
|
-
readonly permit2TransferFrom: 2;
|
|
28
|
-
};
|
|
29
|
-
interface BlueBundlesV1TokenPermit {
|
|
30
|
-
kind: (typeof BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND)[keyof typeof BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND];
|
|
31
|
-
data: Hex;
|
|
32
|
-
}
|
|
19
|
+
type BlueBundlesV1TokenPermit = BundlesTokenPermit;
|
|
33
20
|
interface BlueBundlesV1SignedAuthorization {
|
|
34
21
|
signature: {
|
|
35
22
|
v: number;
|
|
@@ -47,7 +34,7 @@ export declare const validateBlueBundlesV1NativeFunding: (params: {
|
|
|
47
34
|
token: Address;
|
|
48
35
|
fundedAmount: bigint;
|
|
49
36
|
nativeAmount?: bigint;
|
|
50
|
-
requirementSignature?:
|
|
37
|
+
requirementSignature?: BundlesTokenRequirementSignature;
|
|
51
38
|
}) => bigint;
|
|
52
39
|
/** @internal */
|
|
53
40
|
export declare const getBlueBundlesV1TokenPermit: (params: {
|
|
@@ -55,7 +42,7 @@ export declare const getBlueBundlesV1TokenPermit: (params: {
|
|
|
55
42
|
userAddress: Address;
|
|
56
43
|
token: Address;
|
|
57
44
|
amount: bigint;
|
|
58
|
-
requirementSignature?:
|
|
45
|
+
requirementSignature?: BundlesTokenRequirementSignature;
|
|
59
46
|
}) => BlueBundlesV1TokenPermit;
|
|
60
47
|
/** @internal */
|
|
61
48
|
export declare const getBlueBundlesV1SignedAuthorization: (params: {
|
|
@@ -86,7 +73,7 @@ export declare const selectBlueBundlesV1RequirementSignatures: (signatures: read
|
|
|
86
73
|
token?: boolean;
|
|
87
74
|
authorization?: boolean;
|
|
88
75
|
}) => {
|
|
89
|
-
token?:
|
|
76
|
+
token?: BundlesTokenRequirementSignature;
|
|
90
77
|
authorization?: AuthorizationRequirementSignature;
|
|
91
78
|
};
|
|
92
79
|
/** @internal */
|
|
@@ -1,24 +1,11 @@
|
|
|
1
1
|
import { MarketParams, MathLib, VaultV2BluePublicAllocatorConfigUtils, } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { deepFreeze, getChainAddress } from "@morpho-org/morpho-ts";
|
|
3
|
-
import { compactSignatureToSignature,
|
|
3
|
+
import { compactSignatureToSignature, isAddressEqual, parseCompactSignature, parseSignature, size, zeroAddress, zeroHash, } from "viem";
|
|
4
4
|
import { addTransactionMetadata, validateNativeAsset, } from "../../helpers/index.js";
|
|
5
5
|
import { validateVaultV2BlueReallocations } from "../../helpers/validate.js";
|
|
6
|
-
import { AmbiguousRequirementSignaturesError,
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
* the pull, `erc2612` (1) is an ERC-2612 permit, `permit2TransferFrom` (2) is a Permit2
|
|
10
|
-
* SignatureTransfer. Named so a transposed literal can't silently route a permit to the wrong branch.
|
|
11
|
-
* @internal
|
|
12
|
-
*/
|
|
13
|
-
const BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND = {
|
|
14
|
-
none: 0,
|
|
15
|
-
erc2612: 1,
|
|
16
|
-
permit2TransferFrom: 2,
|
|
17
|
-
};
|
|
18
|
-
const EMPTY_TOKEN_PERMIT = {
|
|
19
|
-
kind: BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND.none,
|
|
20
|
-
data: "0x",
|
|
21
|
-
};
|
|
6
|
+
import { AmbiguousRequirementSignaturesError, BundlesRequirementSignatureMismatchError, DepositOwnerMismatchError, NativeFundingAmountMismatchError, NegativeInputError, ReallocationLoanTokenMismatchError, selectRequirementSignatures, UnexpectedRequirementSignatureError, } from "../../types/index.js";
|
|
7
|
+
import { normalizeBundlesCommonParams } from "../bundles/common.js";
|
|
8
|
+
import { getBundlesTokenPermit, } from "../bundles/index.js";
|
|
22
9
|
const EMPTY_SIGNED_AUTHORIZATION = {
|
|
23
10
|
signature: { v: 0, r: zeroHash, s: zeroHash },
|
|
24
11
|
nonce: 0n,
|
|
@@ -26,35 +13,10 @@ const EMPTY_SIGNED_AUTHORIZATION = {
|
|
|
26
13
|
};
|
|
27
14
|
/** @internal */
|
|
28
15
|
export const normalizeBlueBundlesV1CommonParams = (params) => {
|
|
29
|
-
|
|
30
|
-
throw new NonPositiveInputError("deadline", params.deadline);
|
|
31
|
-
}
|
|
32
|
-
if (params.deadline > maxUint256) {
|
|
33
|
-
throw new InputExceedsMaxError({
|
|
34
|
-
field: "deadline",
|
|
35
|
-
value: params.deadline,
|
|
36
|
-
max: maxUint256,
|
|
37
|
-
});
|
|
38
|
-
}
|
|
39
|
-
const referralFeePct = params.referralFeePct ?? 0n;
|
|
40
|
-
if (referralFeePct < 0n) {
|
|
41
|
-
throw new NegativeInputError("referralFeePct", referralFeePct);
|
|
42
|
-
}
|
|
43
|
-
if (referralFeePct >= MathLib.WAD) {
|
|
44
|
-
throw new InputExceedsMaxError({
|
|
45
|
-
field: "referralFeePct",
|
|
46
|
-
value: referralFeePct,
|
|
47
|
-
max: MathLib.WAD - 1n,
|
|
48
|
-
});
|
|
49
|
-
}
|
|
50
|
-
if (referralFeePct > 0n &&
|
|
51
|
-
(params.referralFeeRecipient == null ||
|
|
52
|
-
isAddressEqual(params.referralFeeRecipient, zeroAddress))) {
|
|
53
|
-
throw new MissingReferralFeeRecipientError();
|
|
54
|
-
}
|
|
16
|
+
const normalized = normalizeBundlesCommonParams(params);
|
|
55
17
|
return {
|
|
56
|
-
referralFeePct,
|
|
57
|
-
referralFeeRecipient:
|
|
18
|
+
referralFeePct: normalized.referralFeePct,
|
|
19
|
+
referralFeeRecipient: normalized.referralFeeRecipient,
|
|
58
20
|
};
|
|
59
21
|
};
|
|
60
22
|
/** @internal */
|
|
@@ -76,88 +38,13 @@ export const validateBlueBundlesV1NativeFunding = (params) => {
|
|
|
76
38
|
};
|
|
77
39
|
/** @internal */
|
|
78
40
|
export const getBlueBundlesV1TokenPermit = (params) => {
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
}
|
|
86
|
-
if (!isAddressEqual(requirementSignature.args.asset, params.token)) {
|
|
87
|
-
throw new DepositAssetMismatchError(params.token, requirementSignature.args.asset);
|
|
88
|
-
}
|
|
89
|
-
if (requirementSignature.args.amount !== params.amount) {
|
|
90
|
-
throw new DepositAmountMismatchError(params.amount, requirementSignature.args.amount);
|
|
91
|
-
}
|
|
92
|
-
if (!isAddressEqual(requirementSignature.action.args.spender, spender)) {
|
|
93
|
-
throw new DepositSpenderMismatchError(spender, requirementSignature.action.args.spender);
|
|
94
|
-
}
|
|
95
|
-
if (requirementSignature.action.args.amount !== params.amount) {
|
|
96
|
-
throw new DepositAmountMismatchError(params.amount, requirementSignature.action.args.amount);
|
|
97
|
-
}
|
|
98
|
-
if (requirementSignature.action.args.deadline !==
|
|
99
|
-
requirementSignature.args.deadline) {
|
|
100
|
-
throw new BlueBundlesV1RequirementSignatureMismatchError({
|
|
101
|
-
field: "deadline",
|
|
102
|
-
expected: String(requirementSignature.args.deadline),
|
|
103
|
-
actual: String(requirementSignature.action.args.deadline),
|
|
104
|
-
});
|
|
105
|
-
}
|
|
106
|
-
if (requirementSignature.action.type === "permit2TransferFrom") {
|
|
107
|
-
return {
|
|
108
|
-
kind: BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND.permit2TransferFrom,
|
|
109
|
-
data: encodeAbiParameters([
|
|
110
|
-
{ type: "uint256", name: "nonce" },
|
|
111
|
-
{ type: "uint256", name: "deadline" },
|
|
112
|
-
{ type: "bytes", name: "signature" },
|
|
113
|
-
], [
|
|
114
|
-
requirementSignature.args.nonce,
|
|
115
|
-
requirementSignature.args.deadline,
|
|
116
|
-
requirementSignature.args.signature,
|
|
117
|
-
]),
|
|
118
|
-
};
|
|
119
|
-
}
|
|
120
|
-
if (requirementSignature.action.type !== "permit") {
|
|
121
|
-
throw new BlueBundlesV1RequirementSignatureMismatchError({
|
|
122
|
-
field: "type",
|
|
123
|
-
expected: "permit or permit2TransferFrom",
|
|
124
|
-
actual: requirementSignature.action.type,
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
const serializedSignature = requirementSignature.args.signature;
|
|
128
|
-
let parsed;
|
|
129
|
-
try {
|
|
130
|
-
parsed =
|
|
131
|
-
size(serializedSignature) === 64
|
|
132
|
-
? compactSignatureToSignature(parseCompactSignature(serializedSignature))
|
|
133
|
-
: parseSignature(serializedSignature);
|
|
134
|
-
}
|
|
135
|
-
catch (cause) {
|
|
136
|
-
throw new BlueBundlesV1RequirementSignatureMismatchError({
|
|
137
|
-
field: "signature",
|
|
138
|
-
expected: "a 64-byte compact or 65-byte serialized ECDSA signature",
|
|
139
|
-
actual: serializedSignature,
|
|
140
|
-
cause,
|
|
141
|
-
});
|
|
142
|
-
}
|
|
143
|
-
const v = parsed.v ??
|
|
144
|
-
(parsed.yParity == null ? undefined : BigInt(parsed.yParity + 27));
|
|
145
|
-
if (v == null) {
|
|
146
|
-
throw new BlueBundlesV1RequirementSignatureMismatchError({
|
|
147
|
-
field: "signature",
|
|
148
|
-
expected: "a signature containing v or yParity",
|
|
149
|
-
actual: serializedSignature,
|
|
150
|
-
});
|
|
151
|
-
}
|
|
152
|
-
return {
|
|
153
|
-
kind: BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND.erc2612,
|
|
154
|
-
data: encodeAbiParameters([
|
|
155
|
-
{ type: "uint256", name: "deadline" },
|
|
156
|
-
{ type: "uint8", name: "v" },
|
|
157
|
-
{ type: "bytes32", name: "r" },
|
|
158
|
-
{ type: "bytes32", name: "s" },
|
|
159
|
-
], [requirementSignature.args.deadline, Number(v), parsed.r, parsed.s]),
|
|
160
|
-
};
|
|
41
|
+
return getBundlesTokenPermit({
|
|
42
|
+
userAddress: params.userAddress,
|
|
43
|
+
token: params.token,
|
|
44
|
+
spender: getChainAddress(params.chainId, "bundles.blueBundlesV1"),
|
|
45
|
+
amount: params.amount,
|
|
46
|
+
requirementSignature: params.requirementSignature,
|
|
47
|
+
});
|
|
161
48
|
};
|
|
162
49
|
/** @internal */
|
|
163
50
|
export const getBlueBundlesV1SignedAuthorization = (params) => {
|
|
@@ -169,28 +56,28 @@ export const getBlueBundlesV1SignedAuthorization = (params) => {
|
|
|
169
56
|
throw new DepositOwnerMismatchError(params.userAddress, authorizationSignature.args.owner);
|
|
170
57
|
}
|
|
171
58
|
if (!isAddressEqual(authorizationSignature.args.authorized, authorized)) {
|
|
172
|
-
throw new
|
|
59
|
+
throw new BundlesRequirementSignatureMismatchError({
|
|
173
60
|
field: "authorized",
|
|
174
61
|
expected: authorized,
|
|
175
62
|
actual: authorizationSignature.args.authorized,
|
|
176
63
|
});
|
|
177
64
|
}
|
|
178
65
|
if (!isAddressEqual(authorizationSignature.action.args.authorized, authorized)) {
|
|
179
|
-
throw new
|
|
66
|
+
throw new BundlesRequirementSignatureMismatchError({
|
|
180
67
|
field: "authorized",
|
|
181
68
|
expected: authorized,
|
|
182
69
|
actual: authorizationSignature.action.args.authorized,
|
|
183
70
|
});
|
|
184
71
|
}
|
|
185
72
|
if (!authorizationSignature.args.isAuthorized) {
|
|
186
|
-
throw new
|
|
73
|
+
throw new BundlesRequirementSignatureMismatchError({
|
|
187
74
|
field: "isAuthorized",
|
|
188
75
|
expected: "true",
|
|
189
76
|
actual: String(authorizationSignature.args.isAuthorized),
|
|
190
77
|
});
|
|
191
78
|
}
|
|
192
79
|
if (!authorizationSignature.action.args.isAuthorized) {
|
|
193
|
-
throw new
|
|
80
|
+
throw new BundlesRequirementSignatureMismatchError({
|
|
194
81
|
field: "isAuthorized",
|
|
195
82
|
expected: "true",
|
|
196
83
|
actual: String(authorizationSignature.action.args.isAuthorized),
|
|
@@ -198,7 +85,7 @@ export const getBlueBundlesV1SignedAuthorization = (params) => {
|
|
|
198
85
|
}
|
|
199
86
|
if (authorizationSignature.action.args.deadline !==
|
|
200
87
|
authorizationSignature.args.deadline) {
|
|
201
|
-
throw new
|
|
88
|
+
throw new BundlesRequirementSignatureMismatchError({
|
|
202
89
|
field: "deadline",
|
|
203
90
|
expected: String(authorizationSignature.args.deadline),
|
|
204
91
|
actual: String(authorizationSignature.action.args.deadline),
|
|
@@ -213,7 +100,7 @@ export const getBlueBundlesV1SignedAuthorization = (params) => {
|
|
|
213
100
|
: parseSignature(serializedSignature);
|
|
214
101
|
}
|
|
215
102
|
catch (cause) {
|
|
216
|
-
throw new
|
|
103
|
+
throw new BundlesRequirementSignatureMismatchError({
|
|
217
104
|
field: "signature",
|
|
218
105
|
expected: "a 64-byte compact or 65-byte serialized ECDSA signature",
|
|
219
106
|
actual: serializedSignature,
|
|
@@ -223,7 +110,7 @@ export const getBlueBundlesV1SignedAuthorization = (params) => {
|
|
|
223
110
|
const v = parsed.v ??
|
|
224
111
|
(parsed.yParity == null ? undefined : BigInt(parsed.yParity + 27));
|
|
225
112
|
if (v == null) {
|
|
226
|
-
throw new
|
|
113
|
+
throw new BundlesRequirementSignatureMismatchError({
|
|
227
114
|
field: "signature",
|
|
228
115
|
expected: "a signature containing v or yParity",
|
|
229
116
|
actual: serializedSignature,
|
|
@@ -271,24 +158,24 @@ export const getBlueBundlesV1ReferralFeeAssets = (assets, referralFeePct) => ref
|
|
|
271
158
|
: MathLib.mulDivDown(assets, referralFeePct, MathLib.WAD - referralFeePct);
|
|
272
159
|
/** @internal */
|
|
273
160
|
export const selectBlueBundlesV1RequirementSignatures = (signatures, accepts) => {
|
|
274
|
-
const { permit,
|
|
161
|
+
const { permit, permit2SignatureTransfer, authorization } = selectRequirementSignatures(signatures, {
|
|
275
162
|
permit: accepts.token,
|
|
276
|
-
|
|
163
|
+
permit2SignatureTransfer: accepts.token,
|
|
277
164
|
authorization: accepts.authorization,
|
|
278
165
|
});
|
|
279
166
|
if (permit?.action.type === "permit2") {
|
|
280
|
-
throw new
|
|
167
|
+
throw new BundlesRequirementSignatureMismatchError({
|
|
281
168
|
field: "type",
|
|
282
|
-
expected: "permit or
|
|
169
|
+
expected: "permit or permit2SignatureTransfer",
|
|
283
170
|
actual: permit.action.type,
|
|
284
171
|
});
|
|
285
172
|
}
|
|
286
|
-
if (permit != null &&
|
|
173
|
+
if (permit != null && permit2SignatureTransfer != null) {
|
|
287
174
|
throw new AmbiguousRequirementSignaturesError("permit", 2);
|
|
288
175
|
}
|
|
289
176
|
return {
|
|
290
177
|
token: permit ??
|
|
291
|
-
|
|
178
|
+
permit2SignatureTransfer,
|
|
292
179
|
authorization,
|
|
293
180
|
};
|
|
294
181
|
};
|
|
@@ -69,7 +69,7 @@ export interface BlueRefinanceParams {
|
|
|
69
69
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the destination market.
|
|
70
70
|
* @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
|
|
71
71
|
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
72
|
-
* @throws {
|
|
72
|
+
* @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
73
73
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
74
74
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
75
75
|
* @example
|
|
@@ -39,7 +39,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1PenaltyAssets, getBlu
|
|
|
39
39
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the destination market.
|
|
40
40
|
* @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
|
|
41
41
|
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
42
|
-
* @throws {
|
|
42
|
+
* @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
43
43
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
44
44
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
45
45
|
* @example
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { type Address } from "viem";
|
|
3
|
-
import type {
|
|
3
|
+
import type { BlueRepayAction, BundlesTokenRequirementSignature, Metadata, Transaction } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueRepay}. */
|
|
5
5
|
export interface BlueRepayParams {
|
|
6
6
|
/** Chain and scoped Morpho Blue market. */
|
|
@@ -27,7 +27,7 @@ export interface BlueRepayParams {
|
|
|
27
27
|
/** Recipient required when `referralFeePct` is positive. */
|
|
28
28
|
readonly referralFeeRecipient?: Address;
|
|
29
29
|
/** Optional loan-token ERC-2612 or Permit2 SignatureTransfer result. */
|
|
30
|
-
readonly requirementSignature?:
|
|
30
|
+
readonly requirementSignature?: BundlesTokenRequirementSignature;
|
|
31
31
|
};
|
|
32
32
|
/** Optional transaction metadata suffix. */
|
|
33
33
|
readonly metadata?: Metadata;
|
|
@@ -65,7 +65,7 @@ export interface BlueRepayParams {
|
|
|
65
65
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
|
|
66
66
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `maxRepayAssets`.
|
|
67
67
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
68
|
-
* @throws {
|
|
68
|
+
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
69
69
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
70
70
|
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
71
71
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
@@ -34,7 +34,7 @@ import { blueRepayWithdrawCollateral } from "./repayWithdrawCollateral.js";
|
|
|
34
34
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
|
|
35
35
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `maxRepayAssets`.
|
|
36
36
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
37
|
-
* @throws {
|
|
37
|
+
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
38
38
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
39
39
|
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
40
40
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { type Address } from "viem";
|
|
3
|
-
import { type AuthorizationRequirementSignature, type
|
|
3
|
+
import { type AuthorizationRequirementSignature, type BlueRepayWithdrawCollateralAction, type BundlesTokenRequirementSignature, type Metadata, type Transaction } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueRepayWithdrawCollateral}. */
|
|
5
5
|
export interface BlueRepayWithdrawCollateralParams {
|
|
6
6
|
/** Chain and scoped Morpho Blue market. */
|
|
@@ -31,7 +31,7 @@ export interface BlueRepayWithdrawCollateralParams {
|
|
|
31
31
|
/** Recipient required when `referralFeePct` is positive. */
|
|
32
32
|
readonly referralFeeRecipient?: Address;
|
|
33
33
|
/** Optional loan-token ERC-2612 or Permit2 SignatureTransfer result. */
|
|
34
|
-
readonly requirementSignature?:
|
|
34
|
+
readonly requirementSignature?: BundlesTokenRequirementSignature;
|
|
35
35
|
/** Optional Morpho authorization signature for BlueBundlesV1. */
|
|
36
36
|
readonly authorizationSignature?: AuthorizationRequirementSignature;
|
|
37
37
|
};
|
|
@@ -77,7 +77,7 @@ export interface BlueRepayWithdrawCollateralParams {
|
|
|
77
77
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
|
|
78
78
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `maxRepayAssets`.
|
|
79
79
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
80
|
-
* @throws {
|
|
80
|
+
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be bound safely.
|
|
81
81
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
82
82
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
83
83
|
* @example
|
|
@@ -42,7 +42,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1ReferralFeeAssets, ge
|
|
|
42
42
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
|
|
43
43
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `maxRepayAssets`.
|
|
44
44
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
45
|
-
* @throws {
|
|
45
|
+
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be bound safely.
|
|
46
46
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
47
47
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
48
48
|
* @example
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { type Address } from "viem";
|
|
3
|
-
import type {
|
|
3
|
+
import type { BlueSupplyAction, BundlesTokenRequirementSignature, Metadata, Transaction } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueSupply}. */
|
|
5
5
|
export interface BlueSupplyParams {
|
|
6
6
|
/** Chain and scoped Morpho Blue market. */
|
|
@@ -23,7 +23,7 @@ export interface BlueSupplyParams {
|
|
|
23
23
|
/** Recipient required when `referralFeePct` is positive. */
|
|
24
24
|
readonly referralFeeRecipient?: Address;
|
|
25
25
|
/** Optional ERC-2612 or Permit2 SignatureTransfer requirement result. */
|
|
26
|
-
readonly requirementSignature?:
|
|
26
|
+
readonly requirementSignature?: BundlesTokenRequirementSignature;
|
|
27
27
|
};
|
|
28
28
|
/** Optional transaction metadata suffix. */
|
|
29
29
|
readonly metadata?: Metadata;
|
|
@@ -59,7 +59,7 @@ export interface BlueSupplyParams {
|
|
|
59
59
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
|
|
60
60
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `assets`.
|
|
61
61
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
62
|
-
* @throws {
|
|
62
|
+
* @throws {BundlesRequirementSignatureMismatchError} when the signature kind or encoding is invalid.
|
|
63
63
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
64
64
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
65
65
|
* @example
|
|
@@ -33,7 +33,7 @@ import { finalizeBlueBundlesV1Transaction, getBlueBundlesV1TokenPermit, normaliz
|
|
|
33
33
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
|
|
34
34
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `assets`.
|
|
35
35
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
36
|
-
* @throws {
|
|
36
|
+
* @throws {BundlesRequirementSignatureMismatchError} when the signature kind or encoding is invalid.
|
|
37
37
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
38
38
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
39
39
|
* @example
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
2
|
import { type Address } from "viem";
|
|
3
|
-
import type {
|
|
3
|
+
import type { BlueSupplyCollateralAction, BundlesTokenRequirementSignature, Metadata, Transaction } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueSupplyCollateral}. */
|
|
5
5
|
export interface BlueSupplyCollateralParams {
|
|
6
6
|
/** Chain and scoped Morpho Blue market. */
|
|
@@ -23,7 +23,7 @@ export interface BlueSupplyCollateralParams {
|
|
|
23
23
|
/** Recipient required when `referralFeePct` is positive. */
|
|
24
24
|
readonly referralFeeRecipient?: Address;
|
|
25
25
|
/** Optional collateral ERC-2612 or Permit2 SignatureTransfer result. */
|
|
26
|
-
readonly requirementSignature?:
|
|
26
|
+
readonly requirementSignature?: BundlesTokenRequirementSignature;
|
|
27
27
|
};
|
|
28
28
|
/** Optional transaction metadata suffix. */
|
|
29
29
|
readonly metadata?: Metadata;
|
|
@@ -57,7 +57,7 @@ export interface BlueSupplyCollateralParams {
|
|
|
57
57
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the collateral token.
|
|
58
58
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `collateralAssets`.
|
|
59
59
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
60
|
-
* @throws {
|
|
60
|
+
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
61
61
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
62
62
|
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
63
63
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
@@ -30,7 +30,7 @@ import { blueSupplyCollateralBorrow } from "./supplyCollateralBorrow.js";
|
|
|
30
30
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the collateral token.
|
|
31
31
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `collateralAssets`.
|
|
32
32
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
33
|
-
* @throws {
|
|
33
|
+
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
34
34
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
35
35
|
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
36
36
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|