@morpho-org/morpho-sdk 6.0.0-next.0 → 6.0.0-next.2
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 +329 -15
- package/README.md +93 -47
- package/lib/cjs/abis.d.ts +227 -2
- package/lib/cjs/abis.js +156 -3
- 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 +28 -162
- 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 +3 -8
- 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 +230 -0
- package/lib/cjs/actions/bundles/common.js +507 -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/getBlueAuthorizationRequirement.d.ts +3 -0
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +6 -10
- package/lib/cjs/actions/requirements/blue/index.d.ts +0 -2
- package/lib/cjs/actions/requirements/blue/index.js +0 -2
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +21 -21
- 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 +19 -10
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +43 -31
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
- package/lib/{esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → cjs/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +16 -14
- package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +27 -22
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.d.ts +12 -9
- package/lib/cjs/actions/requirements/encode/encodeVaultSharesPermit.js +27 -21
- 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/generalAdapter/getGeneralAdapterRequirements.js +1 -0
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
- 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 +28 -30
- package/lib/cjs/actions/signatures/getVaultExitBundlesV1PermitStruct.js +20 -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/inKindRedeem.d.ts +1 -0
- package/lib/cjs/actions/vaultV1/inKindRedeem.js +3 -2
- 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/forceWithdraw.d.ts +58 -39
- package/lib/cjs/actions/vaultV2/forceWithdraw.js +87 -60
- package/lib/cjs/actions/vaultV2/inKindRedeem.d.ts +1 -0
- package/lib/cjs/actions/vaultV2/inKindRedeem.js +3 -2
- 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/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
- package/lib/cjs/blue/abis.d.ts +5 -1
- package/lib/cjs/blue/abis.js +2 -0
- package/lib/cjs/blue/entities.d.ts +8 -2
- package/lib/cjs/blue/entities.js +1 -0
- package/lib/cjs/blue/errors.d.ts +1 -1
- package/lib/cjs/blue/errors.js +2 -1
- package/lib/cjs/blue/fetch.d.ts +3 -1
- package/lib/cjs/blue/fetch.js +1 -0
- package/lib/cjs/entities/blue/blue.d.ts +29 -20
- package/lib/cjs/entities/blue/blue.js +6 -1
- package/lib/cjs/entities/index.d.ts +9 -2
- package/lib/cjs/entities/index.js +16 -0
- package/lib/cjs/entities/midnight/midnight.d.ts +2 -2
- package/lib/cjs/entities/midnight/midnight.js +20 -24
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +27 -19
- package/lib/cjs/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +76 -75
- package/lib/{esm/actions/requirements/blue → cjs/entities/requirements}/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/cjs/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +4 -4
- 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 +2 -0
- package/lib/cjs/entities/requirements/index.js +18 -0
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +356 -101
- package/lib/cjs/entities/vaultV1/vaultV1.js +334 -120
- package/lib/cjs/entities/vaultV1ReallocationData.d.ts +6 -0
- package/lib/cjs/entities/vaultV1ReallocationData.js +20 -5
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +359 -100
- package/lib/cjs/entities/vaultV2/vaultV2.js +448 -93
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +8 -1
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +46 -13
- package/lib/cjs/errors.d.ts +1 -1
- package/lib/cjs/errors.js +3 -2
- package/lib/cjs/fetch.d.ts +3 -1
- package/lib/cjs/fetch.js +1 -0
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +2 -0
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +2 -0
- package/lib/cjs/helpers/index.d.ts +4 -1
- package/lib/cjs/helpers/index.js +14 -1
- package/lib/cjs/helpers/metadata.d.ts +3 -5
- package/lib/cjs/helpers/metadata.js +4 -6
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
- package/lib/cjs/helpers/previewVaultV2ForceWithdraw.js +164 -0
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
- package/lib/cjs/helpers/previewVaultV2InKindRedeem.js +2 -0
- package/lib/cjs/helpers/referralFee.d.ts +21 -0
- package/lib/cjs/helpers/referralFee.js +35 -0
- package/lib/cjs/helpers/slippage.d.ts +136 -1
- package/lib/cjs/helpers/slippage.js +188 -0
- package/lib/cjs/helpers/validate.d.ts +67 -8
- package/lib/cjs/helpers/validate.js +94 -9
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +1 -0
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
- package/lib/cjs/helpers/vaultV2ForceWithdrawPlan.js +369 -0
- package/lib/cjs/index.d.ts +1 -0
- package/lib/cjs/index.js +1 -0
- package/lib/cjs/types/action.d.ts +273 -82
- package/lib/cjs/types/action.js +12 -12
- package/lib/cjs/types/error.d.ts +349 -23
- package/lib/cjs/types/error.js +393 -39
- package/lib/cjs/types/sharedLiquidity.d.ts +2 -2
- package/lib/cjs/utils.d.ts +3 -1
- package/lib/cjs/utils.js +10 -1
- package/lib/esm/abis.d.ts +227 -2
- package/lib/esm/abis.js +157 -2
- 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 +30 -164
- 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 +5 -10
- 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 +230 -0
- package/lib/esm/actions/bundles/common.js +494 -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/getBlueAuthorizationRequirement.d.ts +3 -0
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +8 -12
- package/lib/esm/actions/requirements/blue/index.d.ts +0 -2
- package/lib/esm/actions/requirements/blue/index.js +0 -2
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +15 -8
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +22 -22
- 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 +19 -10
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +44 -32
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.d.ts +4 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2Approve.js +15 -10
- package/lib/{cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts → esm/actions/requirements/encode/encodeErc20Permit2SignatureTransfer.d.ts} +16 -14
- package/lib/esm/actions/requirements/encode/{encodeErc20Permit2TransferFrom.js → encodeErc20Permit2SignatureTransfer.js} +25 -20
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.d.ts +12 -9
- package/lib/esm/actions/requirements/encode/encodeVaultSharesPermit.js +27 -21
- 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/generalAdapter/getGeneralAdapterRequirements.js +1 -0
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +4 -1
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +5 -2
- 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 +28 -30
- package/lib/esm/actions/signatures/getVaultExitBundlesV1PermitStruct.js +21 -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/inKindRedeem.d.ts +1 -0
- package/lib/esm/actions/vaultV1/inKindRedeem.js +3 -2
- 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/forceWithdraw.d.ts +58 -39
- package/lib/esm/actions/vaultV2/forceWithdraw.js +89 -62
- package/lib/esm/actions/vaultV2/inKindRedeem.d.ts +1 -0
- package/lib/esm/actions/vaultV2/inKindRedeem.js +3 -2
- 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/augment/VaultMarketPublicAllocatorConfig.d.ts +4 -1
- package/lib/esm/augment/VaultMarketPublicAllocatorConfig.js +3 -1
- package/lib/esm/blue/abis.d.ts +5 -1
- package/lib/esm/blue/abis.js +5 -1
- package/lib/esm/blue/entities.d.ts +8 -2
- package/lib/esm/blue/entities.js +3 -1
- package/lib/esm/blue/errors.d.ts +1 -1
- package/lib/esm/blue/errors.js +1 -1
- package/lib/esm/blue/fetch.d.ts +3 -1
- package/lib/esm/blue/fetch.js +3 -1
- package/lib/esm/entities/blue/blue.d.ts +29 -20
- package/lib/esm/entities/blue/blue.js +7 -2
- package/lib/esm/entities/index.d.ts +9 -2
- package/lib/esm/entities/index.js +4 -1
- package/lib/esm/entities/midnight/midnight.d.ts +2 -2
- package/lib/esm/entities/midnight/midnight.js +20 -24
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts → entities/requirements/getBundlesTokenRequirements.d.ts} +27 -19
- package/lib/esm/{actions/requirements/blue/getBlueBundlesV1TokenRequirements.js → entities/requirements/getBundlesTokenRequirements.js} +67 -66
- package/lib/{cjs/actions/requirements/blue → esm/entities/requirements}/getUnusedPermit2Nonce.d.ts +1 -1
- package/lib/esm/{actions/requirements/blue → entities/requirements}/getUnusedPermit2Nonce.js +4 -4
- 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 +2 -0
- package/lib/esm/entities/requirements/index.js +2 -0
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +356 -101
- package/lib/esm/entities/vaultV1/vaultV1.js +338 -124
- package/lib/esm/entities/vaultV1ReallocationData.d.ts +6 -0
- package/lib/esm/entities/vaultV1ReallocationData.js +20 -5
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +359 -100
- package/lib/esm/entities/vaultV2/vaultV2.js +452 -97
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +8 -1
- package/lib/esm/entities/vaultV2BlueReallocationData.js +46 -13
- package/lib/esm/errors.d.ts +1 -1
- package/lib/esm/errors.js +1 -1
- package/lib/esm/fetch.d.ts +3 -1
- package/lib/esm/fetch.js +3 -1
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +2 -0
- package/lib/esm/helpers/computeVaultV1Reallocations.js +2 -0
- package/lib/esm/helpers/index.d.ts +4 -1
- package/lib/esm/helpers/index.js +4 -1
- package/lib/esm/helpers/metadata.d.ts +3 -5
- package/lib/esm/helpers/metadata.js +4 -6
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.d.ts +107 -0
- package/lib/esm/helpers/previewVaultV2ForceWithdraw.js +161 -0
- package/lib/esm/helpers/previewVaultV2InKindRedeem.d.ts +1 -0
- package/lib/esm/helpers/previewVaultV2InKindRedeem.js +2 -0
- package/lib/esm/helpers/referralFee.d.ts +21 -0
- package/lib/esm/helpers/referralFee.js +31 -0
- package/lib/esm/helpers/slippage.d.ts +136 -1
- package/lib/esm/helpers/slippage.js +186 -2
- package/lib/esm/helpers/validate.d.ts +67 -8
- package/lib/esm/helpers/validate.js +92 -10
- package/lib/esm/helpers/validateRequirementSpender.d.ts +1 -1
- package/lib/esm/helpers/validateRequirementSpender.js +1 -0
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.d.ts +274 -0
- package/lib/esm/helpers/vaultV2ForceWithdrawPlan.js +362 -0
- package/lib/esm/index.d.ts +1 -0
- package/lib/esm/index.js +1 -0
- package/lib/esm/types/action.d.ts +273 -82
- package/lib/esm/types/action.js +11 -11
- package/lib/esm/types/error.d.ts +349 -23
- package/lib/esm/types/error.js +377 -31
- package/lib/esm/types/sharedLiquidity.d.ts +2 -2
- package/lib/esm/utils.d.ts +3 -1
- package/lib/esm/utils.js +3 -1
- package/package.json +7 -7
|
@@ -7,21 +7,8 @@ const viem_1 = require("viem");
|
|
|
7
7
|
const index_js_1 = require("../../helpers/index.js");
|
|
8
8
|
const validate_js_1 = require("../../helpers/validate.js");
|
|
9
9
|
const index_js_2 = require("../../types/index.js");
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
* the pull, `erc2612` (1) is an ERC-2612 permit, `permit2TransferFrom` (2) is a Permit2
|
|
13
|
-
* SignatureTransfer. Named so a transposed literal can't silently route a permit to the wrong branch.
|
|
14
|
-
* @internal
|
|
15
|
-
*/
|
|
16
|
-
const BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND = {
|
|
17
|
-
none: 0,
|
|
18
|
-
erc2612: 1,
|
|
19
|
-
permit2TransferFrom: 2,
|
|
20
|
-
};
|
|
21
|
-
const EMPTY_TOKEN_PERMIT = {
|
|
22
|
-
kind: BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND.none,
|
|
23
|
-
data: "0x",
|
|
24
|
-
};
|
|
10
|
+
const common_js_1 = require("../bundles/common.js");
|
|
11
|
+
const index_js_3 = require("../bundles/index.js");
|
|
25
12
|
const EMPTY_SIGNED_AUTHORIZATION = {
|
|
26
13
|
signature: { v: 0, r: viem_1.zeroHash, s: viem_1.zeroHash },
|
|
27
14
|
nonce: 0n,
|
|
@@ -29,35 +16,10 @@ const EMPTY_SIGNED_AUTHORIZATION = {
|
|
|
29
16
|
};
|
|
30
17
|
/** @internal */
|
|
31
18
|
const normalizeBlueBundlesV1CommonParams = (params) => {
|
|
32
|
-
|
|
33
|
-
throw new index_js_2.NonPositiveInputError("deadline", params.deadline);
|
|
34
|
-
}
|
|
35
|
-
if (params.deadline > viem_1.maxUint256) {
|
|
36
|
-
throw new index_js_2.InputExceedsMaxError({
|
|
37
|
-
field: "deadline",
|
|
38
|
-
value: params.deadline,
|
|
39
|
-
max: viem_1.maxUint256,
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
const referralFeePct = params.referralFeePct ?? 0n;
|
|
43
|
-
if (referralFeePct < 0n) {
|
|
44
|
-
throw new index_js_2.NegativeInputError("referralFeePct", referralFeePct);
|
|
45
|
-
}
|
|
46
|
-
if (referralFeePct >= blue_sdk_1.MathLib.WAD) {
|
|
47
|
-
throw new index_js_2.InputExceedsMaxError({
|
|
48
|
-
field: "referralFeePct",
|
|
49
|
-
value: referralFeePct,
|
|
50
|
-
max: blue_sdk_1.MathLib.WAD - 1n,
|
|
51
|
-
});
|
|
52
|
-
}
|
|
53
|
-
if (referralFeePct > 0n &&
|
|
54
|
-
(params.referralFeeRecipient == null ||
|
|
55
|
-
(0, viem_1.isAddressEqual)(params.referralFeeRecipient, viem_1.zeroAddress))) {
|
|
56
|
-
throw new index_js_2.MissingReferralFeeRecipientError();
|
|
57
|
-
}
|
|
19
|
+
const normalized = (0, common_js_1.normalizeBundlesCommonParams)(params);
|
|
58
20
|
return {
|
|
59
|
-
referralFeePct,
|
|
60
|
-
referralFeeRecipient:
|
|
21
|
+
referralFeePct: normalized.referralFeePct,
|
|
22
|
+
referralFeeRecipient: normalized.referralFeeRecipient,
|
|
61
23
|
};
|
|
62
24
|
};
|
|
63
25
|
exports.normalizeBlueBundlesV1CommonParams = normalizeBlueBundlesV1CommonParams;
|
|
@@ -81,88 +43,13 @@ const validateBlueBundlesV1NativeFunding = (params) => {
|
|
|
81
43
|
exports.validateBlueBundlesV1NativeFunding = validateBlueBundlesV1NativeFunding;
|
|
82
44
|
/** @internal */
|
|
83
45
|
const getBlueBundlesV1TokenPermit = (params) => {
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
}
|
|
91
|
-
if (!(0, viem_1.isAddressEqual)(requirementSignature.args.asset, params.token)) {
|
|
92
|
-
throw new index_js_2.DepositAssetMismatchError(params.token, requirementSignature.args.asset);
|
|
93
|
-
}
|
|
94
|
-
if (requirementSignature.args.amount !== params.amount) {
|
|
95
|
-
throw new index_js_2.DepositAmountMismatchError(params.amount, requirementSignature.args.amount);
|
|
96
|
-
}
|
|
97
|
-
if (!(0, viem_1.isAddressEqual)(requirementSignature.action.args.spender, spender)) {
|
|
98
|
-
throw new index_js_2.DepositSpenderMismatchError(spender, requirementSignature.action.args.spender);
|
|
99
|
-
}
|
|
100
|
-
if (requirementSignature.action.args.amount !== params.amount) {
|
|
101
|
-
throw new index_js_2.DepositAmountMismatchError(params.amount, requirementSignature.action.args.amount);
|
|
102
|
-
}
|
|
103
|
-
if (requirementSignature.action.args.deadline !==
|
|
104
|
-
requirementSignature.args.deadline) {
|
|
105
|
-
throw new index_js_2.BlueBundlesV1RequirementSignatureMismatchError({
|
|
106
|
-
field: "deadline",
|
|
107
|
-
expected: String(requirementSignature.args.deadline),
|
|
108
|
-
actual: String(requirementSignature.action.args.deadline),
|
|
109
|
-
});
|
|
110
|
-
}
|
|
111
|
-
if (requirementSignature.action.type === "permit2TransferFrom") {
|
|
112
|
-
return {
|
|
113
|
-
kind: BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND.permit2TransferFrom,
|
|
114
|
-
data: (0, viem_1.encodeAbiParameters)([
|
|
115
|
-
{ type: "uint256", name: "nonce" },
|
|
116
|
-
{ type: "uint256", name: "deadline" },
|
|
117
|
-
{ type: "bytes", name: "signature" },
|
|
118
|
-
], [
|
|
119
|
-
requirementSignature.args.nonce,
|
|
120
|
-
requirementSignature.args.deadline,
|
|
121
|
-
requirementSignature.args.signature,
|
|
122
|
-
]),
|
|
123
|
-
};
|
|
124
|
-
}
|
|
125
|
-
if (requirementSignature.action.type !== "permit") {
|
|
126
|
-
throw new index_js_2.BlueBundlesV1RequirementSignatureMismatchError({
|
|
127
|
-
field: "type",
|
|
128
|
-
expected: "permit or permit2TransferFrom",
|
|
129
|
-
actual: requirementSignature.action.type,
|
|
130
|
-
});
|
|
131
|
-
}
|
|
132
|
-
const serializedSignature = requirementSignature.args.signature;
|
|
133
|
-
let parsed;
|
|
134
|
-
try {
|
|
135
|
-
parsed =
|
|
136
|
-
(0, viem_1.size)(serializedSignature) === 64
|
|
137
|
-
? (0, viem_1.compactSignatureToSignature)((0, viem_1.parseCompactSignature)(serializedSignature))
|
|
138
|
-
: (0, viem_1.parseSignature)(serializedSignature);
|
|
139
|
-
}
|
|
140
|
-
catch (cause) {
|
|
141
|
-
throw new index_js_2.BlueBundlesV1RequirementSignatureMismatchError({
|
|
142
|
-
field: "signature",
|
|
143
|
-
expected: "a 64-byte compact or 65-byte serialized ECDSA signature",
|
|
144
|
-
actual: serializedSignature,
|
|
145
|
-
cause,
|
|
146
|
-
});
|
|
147
|
-
}
|
|
148
|
-
const v = parsed.v ??
|
|
149
|
-
(parsed.yParity == null ? undefined : BigInt(parsed.yParity + 27));
|
|
150
|
-
if (v == null) {
|
|
151
|
-
throw new index_js_2.BlueBundlesV1RequirementSignatureMismatchError({
|
|
152
|
-
field: "signature",
|
|
153
|
-
expected: "a signature containing v or yParity",
|
|
154
|
-
actual: serializedSignature,
|
|
155
|
-
});
|
|
156
|
-
}
|
|
157
|
-
return {
|
|
158
|
-
kind: BLUE_BUNDLES_V1_TOKEN_PERMIT_KIND.erc2612,
|
|
159
|
-
data: (0, viem_1.encodeAbiParameters)([
|
|
160
|
-
{ type: "uint256", name: "deadline" },
|
|
161
|
-
{ type: "uint8", name: "v" },
|
|
162
|
-
{ type: "bytes32", name: "r" },
|
|
163
|
-
{ type: "bytes32", name: "s" },
|
|
164
|
-
], [requirementSignature.args.deadline, Number(v), parsed.r, parsed.s]),
|
|
165
|
-
};
|
|
46
|
+
return (0, index_js_3.getBundlesTokenPermit)({
|
|
47
|
+
userAddress: params.userAddress,
|
|
48
|
+
token: params.token,
|
|
49
|
+
spender: (0, morpho_ts_1.getChainAddress)(params.chainId, "bundles.blueBundlesV1"),
|
|
50
|
+
amount: params.amount,
|
|
51
|
+
requirementSignature: params.requirementSignature,
|
|
52
|
+
});
|
|
166
53
|
};
|
|
167
54
|
exports.getBlueBundlesV1TokenPermit = getBlueBundlesV1TokenPermit;
|
|
168
55
|
/** @internal */
|
|
@@ -175,28 +62,28 @@ const getBlueBundlesV1SignedAuthorization = (params) => {
|
|
|
175
62
|
throw new index_js_2.DepositOwnerMismatchError(params.userAddress, authorizationSignature.args.owner);
|
|
176
63
|
}
|
|
177
64
|
if (!(0, viem_1.isAddressEqual)(authorizationSignature.args.authorized, authorized)) {
|
|
178
|
-
throw new index_js_2.
|
|
65
|
+
throw new index_js_2.BundlesRequirementSignatureMismatchError({
|
|
179
66
|
field: "authorized",
|
|
180
67
|
expected: authorized,
|
|
181
68
|
actual: authorizationSignature.args.authorized,
|
|
182
69
|
});
|
|
183
70
|
}
|
|
184
71
|
if (!(0, viem_1.isAddressEqual)(authorizationSignature.action.args.authorized, authorized)) {
|
|
185
|
-
throw new index_js_2.
|
|
72
|
+
throw new index_js_2.BundlesRequirementSignatureMismatchError({
|
|
186
73
|
field: "authorized",
|
|
187
74
|
expected: authorized,
|
|
188
75
|
actual: authorizationSignature.action.args.authorized,
|
|
189
76
|
});
|
|
190
77
|
}
|
|
191
78
|
if (!authorizationSignature.args.isAuthorized) {
|
|
192
|
-
throw new index_js_2.
|
|
79
|
+
throw new index_js_2.BundlesRequirementSignatureMismatchError({
|
|
193
80
|
field: "isAuthorized",
|
|
194
81
|
expected: "true",
|
|
195
82
|
actual: String(authorizationSignature.args.isAuthorized),
|
|
196
83
|
});
|
|
197
84
|
}
|
|
198
85
|
if (!authorizationSignature.action.args.isAuthorized) {
|
|
199
|
-
throw new index_js_2.
|
|
86
|
+
throw new index_js_2.BundlesRequirementSignatureMismatchError({
|
|
200
87
|
field: "isAuthorized",
|
|
201
88
|
expected: "true",
|
|
202
89
|
actual: String(authorizationSignature.action.args.isAuthorized),
|
|
@@ -204,39 +91,18 @@ const getBlueBundlesV1SignedAuthorization = (params) => {
|
|
|
204
91
|
}
|
|
205
92
|
if (authorizationSignature.action.args.deadline !==
|
|
206
93
|
authorizationSignature.args.deadline) {
|
|
207
|
-
throw new index_js_2.
|
|
94
|
+
throw new index_js_2.BundlesRequirementSignatureMismatchError({
|
|
208
95
|
field: "deadline",
|
|
209
96
|
expected: String(authorizationSignature.args.deadline),
|
|
210
97
|
actual: String(authorizationSignature.action.args.deadline),
|
|
211
98
|
});
|
|
212
99
|
}
|
|
213
|
-
const
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
(0, viem_1.size)(serializedSignature) === 64
|
|
218
|
-
? (0, viem_1.compactSignatureToSignature)((0, viem_1.parseCompactSignature)(serializedSignature))
|
|
219
|
-
: (0, viem_1.parseSignature)(serializedSignature);
|
|
220
|
-
}
|
|
221
|
-
catch (cause) {
|
|
222
|
-
throw new index_js_2.BlueBundlesV1RequirementSignatureMismatchError({
|
|
223
|
-
field: "signature",
|
|
224
|
-
expected: "a 64-byte compact or 65-byte serialized ECDSA signature",
|
|
225
|
-
actual: serializedSignature,
|
|
226
|
-
cause,
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
const v = parsed.v ??
|
|
230
|
-
(parsed.yParity == null ? undefined : BigInt(parsed.yParity + 27));
|
|
231
|
-
if (v == null) {
|
|
232
|
-
throw new index_js_2.BlueBundlesV1RequirementSignatureMismatchError({
|
|
233
|
-
field: "signature",
|
|
234
|
-
expected: "a signature containing v or yParity",
|
|
235
|
-
actual: serializedSignature,
|
|
236
|
-
});
|
|
237
|
-
}
|
|
100
|
+
const signature = (0, common_js_1.normalizeBundlesSignature)(authorizationSignature.args.signature, (details) => new index_js_2.BundlesRequirementSignatureMismatchError({
|
|
101
|
+
field: "signature",
|
|
102
|
+
...details,
|
|
103
|
+
}));
|
|
238
104
|
return {
|
|
239
|
-
signature
|
|
105
|
+
signature,
|
|
240
106
|
nonce: authorizationSignature.args.nonce,
|
|
241
107
|
deadline: authorizationSignature.args.deadline,
|
|
242
108
|
};
|
|
@@ -281,24 +147,24 @@ const getBlueBundlesV1ReferralFeeAssets = (assets, referralFeePct) => referralFe
|
|
|
281
147
|
exports.getBlueBundlesV1ReferralFeeAssets = getBlueBundlesV1ReferralFeeAssets;
|
|
282
148
|
/** @internal */
|
|
283
149
|
const selectBlueBundlesV1RequirementSignatures = (signatures, accepts) => {
|
|
284
|
-
const { permit,
|
|
150
|
+
const { permit, permit2SignatureTransfer, authorization } = (0, index_js_2.selectRequirementSignatures)(signatures, {
|
|
285
151
|
permit: accepts.token,
|
|
286
|
-
|
|
152
|
+
permit2SignatureTransfer: accepts.token,
|
|
287
153
|
authorization: accepts.authorization,
|
|
288
154
|
});
|
|
289
155
|
if (permit?.action.type === "permit2") {
|
|
290
|
-
throw new index_js_2.
|
|
156
|
+
throw new index_js_2.BundlesRequirementSignatureMismatchError({
|
|
291
157
|
field: "type",
|
|
292
|
-
expected: "permit or
|
|
158
|
+
expected: "permit or permit2SignatureTransfer",
|
|
293
159
|
actual: permit.action.type,
|
|
294
160
|
});
|
|
295
161
|
}
|
|
296
|
-
if (permit != null &&
|
|
162
|
+
if (permit != null && permit2SignatureTransfer != null) {
|
|
297
163
|
throw new index_js_2.AmbiguousRequirementSignaturesError("permit", 2);
|
|
298
164
|
}
|
|
299
165
|
return {
|
|
300
166
|
token: permit ??
|
|
301
|
-
|
|
167
|
+
permit2SignatureTransfer,
|
|
302
168
|
authorization,
|
|
303
169
|
};
|
|
304
170
|
};
|
|
@@ -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
|
|
@@ -42,7 +42,7 @@ const common_js_1 = require("./common.js");
|
|
|
42
42
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the destination market.
|
|
43
43
|
* @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
|
|
44
44
|
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
45
|
-
* @throws {
|
|
45
|
+
* @throws {BundlesRequirementSignatureMismatchError} when authorization 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 { 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.
|
|
@@ -37,7 +37,7 @@ const repayWithdrawCollateral_js_1 = require("./repayWithdrawCollateral.js");
|
|
|
37
37
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
|
|
38
38
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `maxRepayAssets`.
|
|
39
39
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
40
|
-
* @throws {
|
|
40
|
+
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
41
41
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
42
42
|
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
43
43
|
* @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
|
|
@@ -45,7 +45,7 @@ const common_js_1 = require("./common.js");
|
|
|
45
45
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
|
|
46
46
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `maxRepayAssets`.
|
|
47
47
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
48
|
-
* @throws {
|
|
48
|
+
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be bound safely.
|
|
49
49
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
50
50
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
51
51
|
* @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
|
|
@@ -3,6 +3,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.blueSupply = void 0;
|
|
4
4
|
const viem_1 = require("viem");
|
|
5
5
|
const abis_js_1 = require("../../abis.js");
|
|
6
|
+
const validate_js_1 = require("../../helpers/validate.js");
|
|
6
7
|
const index_js_1 = require("../../types/index.js");
|
|
7
8
|
const common_js_1 = require("./common.js");
|
|
8
9
|
/**
|
|
@@ -36,7 +37,7 @@ const common_js_1 = require("./common.js");
|
|
|
36
37
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
|
|
37
38
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `assets`.
|
|
38
39
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
39
|
-
* @throws {
|
|
40
|
+
* @throws {BundlesRequirementSignatureMismatchError} when the signature kind or encoding is invalid.
|
|
40
41
|
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
41
42
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
42
43
|
* @example
|
|
@@ -64,13 +65,7 @@ const blueSupply = (params) => {
|
|
|
64
65
|
if (assets <= 0n) {
|
|
65
66
|
throw new index_js_1.NonPositiveInputError("assets", assets);
|
|
66
67
|
}
|
|
67
|
-
|
|
68
|
-
throw new index_js_1.InputExceedsMaxError({
|
|
69
|
-
field: "assets",
|
|
70
|
-
value: assets,
|
|
71
|
-
max: viem_1.maxUint256,
|
|
72
|
-
});
|
|
73
|
-
}
|
|
68
|
+
(0, validate_js_1.validateUint256Field)("assets", assets);
|
|
74
69
|
const common = {
|
|
75
70
|
chainId,
|
|
76
71
|
userAddress,
|
|
@@ -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.
|
|
@@ -33,7 +33,7 @@ const supplyCollateralBorrow_js_1 = require("./supplyCollateralBorrow.js");
|
|
|
33
33
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the collateral token.
|
|
34
34
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `collateralAssets`.
|
|
35
35
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
36
|
-
* @throws {
|
|
36
|
+
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
37
37
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
38
38
|
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
39
39
|
* @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 BlueSupplyCollateralBorrowAction, type BundlesTokenRequirementSignature, type Metadata, type Transaction, type VaultV2BlueReallocation } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueSupplyCollateralBorrow}. */
|
|
5
5
|
export interface BlueSupplyCollateralBorrowParams {
|
|
6
6
|
/** Chain and scoped Morpho Blue market. */
|
|
@@ -29,7 +29,7 @@ export interface BlueSupplyCollateralBorrowParams {
|
|
|
29
29
|
/** Recipient required when `referralFeePct` is positive. */
|
|
30
30
|
readonly referralFeeRecipient?: Address;
|
|
31
31
|
/** Optional collateral ERC-2612 or Permit2 SignatureTransfer result. */
|
|
32
|
-
readonly requirementSignature?:
|
|
32
|
+
readonly requirementSignature?: BundlesTokenRequirementSignature;
|
|
33
33
|
/** Optional Morpho authorization signature for BlueBundlesV1. */
|
|
34
34
|
readonly authorizationSignature?: AuthorizationRequirementSignature;
|
|
35
35
|
};
|
|
@@ -78,7 +78,7 @@ export interface BlueSupplyCollateralBorrowParams {
|
|
|
78
78
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the collateral token.
|
|
79
79
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `collateralAssets`.
|
|
80
80
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
81
|
-
* @throws {
|
|
81
|
+
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be bound safely.
|
|
82
82
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
83
83
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
84
84
|
* @example
|
|
@@ -48,7 +48,7 @@ const common_js_1 = require("./common.js");
|
|
|
48
48
|
* @throws {DepositAssetMismatchError} when the signed asset differs from the collateral token.
|
|
49
49
|
* @throws {DepositAmountMismatchError} when the signed amount differs from `collateralAssets`.
|
|
50
50
|
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
51
|
-
* @throws {
|
|
51
|
+
* @throws {BundlesRequirementSignatureMismatchError} when a signature cannot be bound safely.
|
|
52
52
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
53
53
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
54
54
|
* @example
|
|
@@ -64,7 +64,7 @@ export interface BlueWithdrawParams {
|
|
|
64
64
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
|
|
65
65
|
* @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
|
|
66
66
|
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
67
|
-
* @throws {
|
|
67
|
+
* @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
68
68
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
69
69
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
70
70
|
* @example
|
|
@@ -40,7 +40,7 @@ const common_js_1 = require("./common.js");
|
|
|
40
40
|
* @throws {ReallocationWithdrawalOnTargetMarketError} when a source is the target market.
|
|
41
41
|
* @throws {ReallocationLoanTokenMismatchError} when a source market uses another loan token.
|
|
42
42
|
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
43
|
-
* @throws {
|
|
43
|
+
* @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
44
44
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
45
45
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
46
46
|
* @example
|
|
@@ -52,7 +52,7 @@ export interface BlueWithdrawCollateralParams {
|
|
|
52
52
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
53
53
|
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
54
54
|
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
55
|
-
* @throws {
|
|
55
|
+
* @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
56
56
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
57
57
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
58
58
|
* @example
|
|
@@ -27,7 +27,7 @@ const repayWithdrawCollateral_js_1 = require("./repayWithdrawCollateral.js");
|
|
|
27
27
|
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
28
28
|
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
29
29
|
* @throws {DepositOwnerMismatchError} when the signed authorization owner differs from `userAddress`.
|
|
30
|
-
* @throws {
|
|
30
|
+
* @throws {BundlesRequirementSignatureMismatchError} when authorization cannot be bound safely.
|
|
31
31
|
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
32
32
|
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
33
33
|
* @example
|