@morpho-org/morpho-sdk 5.8.0 → 6.0.0-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/MIGRATION-v5-to-v6.md +201 -0
- package/README.md +62 -40
- package/lib/cjs/abis.d.ts +543 -0
- package/lib/cjs/abis.js +738 -0
- package/lib/cjs/actions/blue/borrow.d.ts +62 -58
- package/lib/cjs/actions/blue/borrow.js +48 -80
- package/lib/cjs/actions/blue/common.d.ts +99 -0
- package/lib/cjs/actions/blue/common.js +318 -0
- package/lib/cjs/actions/blue/refinance.d.ts +72 -107
- package/lib/cjs/actions/blue/refinance.js +97 -197
- package/lib/cjs/actions/blue/repay.d.ts +72 -68
- package/lib/cjs/actions/blue/repay.js +56 -118
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +85 -90
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +148 -137
- package/lib/cjs/actions/blue/supply.d.ts +62 -45
- package/lib/cjs/actions/blue/supply.js +94 -70
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +63 -40
- package/lib/cjs/actions/blue/supplyCollateral.js +52 -69
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +82 -86
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +133 -119
- package/lib/cjs/actions/blue/withdraw.d.ts +68 -78
- package/lib/cjs/actions/blue/withdraw.js +101 -97
- package/lib/cjs/actions/blue/withdrawCollateral.d.ts +56 -28
- package/lib/cjs/actions/blue/withdrawCollateral.js +45 -50
- package/lib/cjs/actions/index.d.ts +1 -1
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +29 -17
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +60 -19
- package/lib/cjs/actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts +80 -0
- package/lib/cjs/actions/requirements/blue/getBlueBundlesV1TokenRequirements.js +207 -0
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
- package/lib/cjs/actions/requirements/blue/getUnusedPermit2Nonce.js +72 -0
- package/lib/cjs/actions/requirements/blue/index.d.ts +2 -0
- package/lib/cjs/actions/requirements/blue/index.js +2 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +30 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +7 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +33 -6
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts +61 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit2TransferFrom.js +123 -0
- package/lib/cjs/actions/requirements/encode/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/encode/index.js +1 -0
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +5 -4
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +5 -4
- package/lib/cjs/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/cjs/actions/signatures/getTokenRequirementActions.js +4 -0
- package/lib/cjs/blue/types.d.ts +3 -1
- package/lib/cjs/blue/utils.d.ts +3 -1
- package/lib/cjs/blue/utils.js +1 -0
- package/lib/cjs/bundler/actions.d.ts +6 -4
- package/lib/cjs/bundler/actions.js +6 -4
- package/lib/cjs/bundler/types.d.ts +10 -1
- package/lib/cjs/client/morphoViemExtension.d.ts +2 -1
- package/lib/cjs/client/morphoViemExtension.js +2 -1
- package/lib/cjs/entities/blue/blue.d.ts +817 -360
- package/lib/cjs/entities/blue/blue.js +455 -698
- package/lib/cjs/entities/index.d.ts +1 -0
- package/lib/cjs/entities/vaultV1/vaultV1.js +4 -12
- package/lib/cjs/entities/vaultV1ReallocationData.d.ts +18 -3
- package/lib/cjs/entities/vaultV1ReallocationData.js +11 -1
- package/lib/cjs/entities/vaultV2/vaultV2.js +6 -18
- package/lib/cjs/helpers/computeVaultV1Reallocations.d.ts +7 -10
- package/lib/cjs/helpers/computeVaultV1Reallocations.js +7 -10
- package/lib/cjs/helpers/validate.d.ts +16 -23
- package/lib/cjs/helpers/validate.js +32 -48
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/cjs/helpers/validateRequirementSpender.js +2 -0
- package/lib/cjs/types/action.d.ts +146 -162
- package/lib/cjs/types/action.js +29 -2
- package/lib/cjs/types/client.d.ts +9 -0
- package/lib/cjs/types/error.d.ts +173 -18
- package/lib/cjs/types/error.js +230 -25
- package/lib/cjs/types/sharedLiquidity.d.ts +20 -4
- package/lib/cjs/types.d.ts +3 -1
- package/lib/cjs/utils.d.ts +3 -1
- package/lib/cjs/utils.js +1 -0
- package/lib/esm/abis.d.ts +543 -0
- package/lib/esm/abis.js +737 -0
- package/lib/esm/actions/blue/borrow.d.ts +62 -58
- package/lib/esm/actions/blue/borrow.js +48 -80
- package/lib/esm/actions/blue/common.d.ts +99 -0
- package/lib/esm/actions/blue/common.js +306 -0
- package/lib/esm/actions/blue/refinance.d.ts +72 -107
- package/lib/esm/actions/blue/refinance.js +98 -198
- package/lib/esm/actions/blue/repay.d.ts +72 -68
- package/lib/esm/actions/blue/repay.js +56 -118
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +85 -90
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +149 -138
- package/lib/esm/actions/blue/supply.d.ts +62 -45
- package/lib/esm/actions/blue/supply.js +94 -70
- package/lib/esm/actions/blue/supplyCollateral.d.ts +63 -40
- package/lib/esm/actions/blue/supplyCollateral.js +52 -69
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +82 -86
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +134 -120
- package/lib/esm/actions/blue/withdraw.d.ts +68 -78
- package/lib/esm/actions/blue/withdraw.js +100 -96
- package/lib/esm/actions/blue/withdrawCollateral.d.ts +56 -28
- package/lib/esm/actions/blue/withdrawCollateral.js +45 -50
- package/lib/esm/actions/index.d.ts +1 -1
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +29 -17
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +63 -22
- package/lib/esm/actions/requirements/blue/getBlueBundlesV1TokenRequirements.d.ts +80 -0
- package/lib/esm/actions/requirements/blue/getBlueBundlesV1TokenRequirements.js +203 -0
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.d.ts +48 -0
- package/lib/esm/actions/requirements/blue/getUnusedPermit2Nonce.js +68 -0
- package/lib/esm/actions/requirements/blue/index.d.ts +2 -0
- package/lib/esm/actions/requirements/blue/index.js +2 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +10 -7
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +31 -6
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +8 -3
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +16 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +34 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.d.ts +61 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Permit2TransferFrom.js +119 -0
- package/lib/esm/actions/requirements/encode/index.d.ts +1 -0
- package/lib/esm/actions/requirements/encode/index.js +1 -0
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts +1 -1
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +5 -4
- package/lib/esm/actions/requirements/getRequirementsApproval.js +5 -4
- package/lib/esm/actions/signatures/getTokenRequirementActions.d.ts +1 -0
- package/lib/esm/actions/signatures/getTokenRequirementActions.js +5 -1
- package/lib/esm/blue/types.d.ts +3 -1
- package/lib/esm/blue/utils.d.ts +3 -1
- package/lib/esm/blue/utils.js +3 -1
- package/lib/esm/bundler/actions.d.ts +6 -4
- package/lib/esm/bundler/actions.js +6 -4
- package/lib/esm/bundler/types.d.ts +10 -1
- package/lib/esm/client/morphoViemExtension.d.ts +2 -1
- package/lib/esm/client/morphoViemExtension.js +2 -1
- package/lib/esm/entities/blue/blue.d.ts +817 -360
- package/lib/esm/entities/blue/blue.js +461 -704
- package/lib/esm/entities/index.d.ts +1 -0
- package/lib/esm/entities/vaultV1/vaultV1.js +4 -12
- package/lib/esm/entities/vaultV1ReallocationData.d.ts +18 -3
- package/lib/esm/entities/vaultV1ReallocationData.js +13 -2
- package/lib/esm/entities/vaultV2/vaultV2.js +7 -19
- package/lib/esm/helpers/computeVaultV1Reallocations.d.ts +7 -10
- package/lib/esm/helpers/computeVaultV1Reallocations.js +7 -10
- package/lib/esm/helpers/validate.d.ts +16 -23
- package/lib/esm/helpers/validate.js +32 -48
- package/lib/esm/helpers/validateRequirementSpender.d.ts +2 -1
- package/lib/esm/helpers/validateRequirementSpender.js +2 -0
- package/lib/esm/types/action.d.ts +146 -162
- package/lib/esm/types/action.js +28 -2
- package/lib/esm/types/client.d.ts +9 -0
- package/lib/esm/types/error.d.ts +173 -18
- package/lib/esm/types/error.js +216 -21
- package/lib/esm/types/sharedLiquidity.d.ts +20 -4
- package/lib/esm/types.d.ts +3 -1
- package/lib/esm/utils.d.ts +3 -1
- package/lib/esm/utils.js +3 -1
- package/package.json +7 -6
- package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +0 -47
- package/lib/cjs/actions/blue/buildAssetFundingActions.js +0 -63
- package/lib/cjs/actions/blue/buildReallocationActions.d.ts +0 -69
- package/lib/cjs/actions/blue/buildReallocationActions.js +0 -141
- package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +0 -66
- package/lib/cjs/actions/blue/resolveRepayFunding.js +0 -85
- package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +0 -47
- package/lib/esm/actions/blue/buildAssetFundingActions.js +0 -59
- package/lib/esm/actions/blue/buildReallocationActions.d.ts +0 -69
- package/lib/esm/actions/blue/buildReallocationActions.js +0 -135
- package/lib/esm/actions/blue/resolveRepayFunding.d.ts +0 -66
- package/lib/esm/actions/blue/resolveRepayFunding.js +0 -81
|
@@ -1,100 +1,124 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blueSupply = void 0;
|
|
4
|
-
const
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
const buildAssetFundingActions_js_1 = require("./buildAssetFundingActions.js");
|
|
4
|
+
const viem_1 = require("viem");
|
|
5
|
+
const abis_js_1 = require("../../abis.js");
|
|
6
|
+
const index_js_1 = require("../../types/index.js");
|
|
7
|
+
const common_js_1 = require("./common.js");
|
|
9
8
|
/**
|
|
10
|
-
*
|
|
9
|
+
* Encodes a direct BlueBundlesV1 loan-asset supply transaction.
|
|
11
10
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* wNative for that path. Uses `maxSharePrice` to protect against share-price inflation between
|
|
15
|
-
* transaction construction and execution.
|
|
11
|
+
* `assets` is the gross funded amount; BlueBundlesV1 deducts the referral fee before supplying.
|
|
12
|
+
* This route has no Bundler3 share-price bound or `slippageTolerance` input.
|
|
16
13
|
*
|
|
17
|
-
*
|
|
18
|
-
*
|
|
19
|
-
* @param params.market.
|
|
20
|
-
* @param params.
|
|
21
|
-
* @param params.args.
|
|
22
|
-
*
|
|
23
|
-
* @param params.args.
|
|
24
|
-
* @param params.args.
|
|
25
|
-
*
|
|
26
|
-
* @param params.args.
|
|
27
|
-
*
|
|
28
|
-
* @
|
|
29
|
-
*
|
|
30
|
-
* @
|
|
31
|
-
*
|
|
32
|
-
* @throws {
|
|
33
|
-
* @throws {
|
|
34
|
-
* @throws {
|
|
35
|
-
* @throws {
|
|
36
|
-
*
|
|
37
|
-
* @throws {
|
|
38
|
-
*
|
|
39
|
-
* @throws {
|
|
40
|
-
*
|
|
14
|
+
* @param params - Supply encoding parameters.
|
|
15
|
+
* @param params.market.chainId - Chain containing the BlueBundlesV1 deployment.
|
|
16
|
+
* @param params.market.marketParams - Scoped Morpho Blue market parameters.
|
|
17
|
+
* @param params.args.userAddress - User funding and receiving the position.
|
|
18
|
+
* @param params.args.assets - Gross loan-token funding amount.
|
|
19
|
+
* @param params.args.nativeAmount - Exclusive native funding; must equal `assets`.
|
|
20
|
+
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
21
|
+
* @param params.args.referralFeePct - Optional WAD-scaled fee below 100%.
|
|
22
|
+
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
23
|
+
* @param params.args.requirementSignature - Optional ERC-2612 or Permit2 SignatureTransfer result.
|
|
24
|
+
* @param params.metadata - Optional transaction metadata.
|
|
25
|
+
* @returns A deep-frozen `Readonly<Transaction<BlueSupplyAction>>` whose `to` address is
|
|
26
|
+
* BlueBundlesV1 and whose `action` records the normalized supply inputs.
|
|
27
|
+
* @throws {NonPositiveInputError} when `assets` or `deadline` is not positive.
|
|
28
|
+
* @throws {NegativeInputError} when `nativeAmount` or `referralFeePct` is negative.
|
|
29
|
+
* @throws {InputExceedsMaxError} when `assets` exceeds `uint256` or `referralFeePct` is at least WAD.
|
|
30
|
+
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
31
|
+
* @throws {NativeFundingAmountMismatchError} when native funding does not equal `assets`.
|
|
32
|
+
* @throws {ChainWNativeMissingError} when native funding is requested on a chain without wNative.
|
|
33
|
+
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another token.
|
|
34
|
+
* @throws {UnexpectedRequirementSignatureError} when native funding also supplies a token signature.
|
|
35
|
+
* @throws {DepositOwnerMismatchError} when the signed owner differs from `userAddress`.
|
|
36
|
+
* @throws {DepositAssetMismatchError} when the signed asset differs from the loan token.
|
|
37
|
+
* @throws {DepositAmountMismatchError} when the signed amount differs from `assets`.
|
|
38
|
+
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
39
|
+
* @throws {BlueBundlesV1RequirementSignatureMismatchError} when the signature kind or encoding is invalid.
|
|
40
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the address registry.
|
|
41
|
+
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
41
42
|
* @example
|
|
42
43
|
* ```ts
|
|
44
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
43
45
|
* import { blueSupply } from "@morpho-org/morpho-sdk";
|
|
46
|
+
* import { zeroAddress } from "viem";
|
|
47
|
+
* import { mainnet } from "viem/chains";
|
|
44
48
|
*
|
|
49
|
+
* const marketParams = markets[mainnet.id].usdc_wbtc;
|
|
45
50
|
* const tx = blueSupply({
|
|
46
|
-
* market: { chainId:
|
|
51
|
+
* market: { chainId: mainnet.id, marketParams },
|
|
47
52
|
* args: {
|
|
48
|
-
*
|
|
49
|
-
*
|
|
50
|
-
*
|
|
53
|
+
* userAddress: zeroAddress,
|
|
54
|
+
* assets: 1_000_000n,
|
|
55
|
+
* deadline: 1_900_000_000n,
|
|
51
56
|
* },
|
|
52
57
|
* });
|
|
53
58
|
* // tx satisfies Readonly<Transaction<BlueSupplyAction>>
|
|
54
59
|
* ```
|
|
55
60
|
*/
|
|
56
|
-
const blueSupply = (
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
throw new index_js_3.NegativeInputError("nativeAmount", nativeAmount);
|
|
62
|
-
}
|
|
63
|
-
if (maxSharePrice < 0n) {
|
|
64
|
-
throw new index_js_3.NegativeInputError("maxSharePrice", maxSharePrice);
|
|
61
|
+
const blueSupply = (params) => {
|
|
62
|
+
const { chainId, marketParams } = params.market;
|
|
63
|
+
const { assets, userAddress, requirementSignature } = params.args;
|
|
64
|
+
if (assets <= 0n) {
|
|
65
|
+
throw new index_js_1.NonPositiveInputError("assets", assets);
|
|
65
66
|
}
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
67
|
+
if (assets > viem_1.maxUint256) {
|
|
68
|
+
throw new index_js_1.InputExceedsMaxError({
|
|
69
|
+
field: "assets",
|
|
70
|
+
value: assets,
|
|
71
|
+
max: viem_1.maxUint256,
|
|
72
|
+
});
|
|
69
73
|
}
|
|
70
|
-
const
|
|
74
|
+
const common = {
|
|
75
|
+
chainId,
|
|
76
|
+
userAddress,
|
|
77
|
+
deadline: params.args.deadline,
|
|
78
|
+
referralFeePct: params.args.referralFeePct,
|
|
79
|
+
referralFeeRecipient: params.args.referralFeeRecipient,
|
|
80
|
+
metadata: params.metadata,
|
|
81
|
+
};
|
|
82
|
+
const { referralFeePct, referralFeeRecipient } = (0, common_js_1.normalizeBlueBundlesV1CommonParams)(common);
|
|
83
|
+
const value = (0, common_js_1.validateBlueBundlesV1NativeFunding)({
|
|
71
84
|
chainId,
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
nativeAmount: nativeAmount
|
|
85
|
+
token: marketParams.loanToken,
|
|
86
|
+
fundedAmount: assets,
|
|
87
|
+
nativeAmount: params.args.nativeAmount,
|
|
75
88
|
requirementSignature,
|
|
76
89
|
});
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
90
|
+
const tokenPermit = (0, common_js_1.getBlueBundlesV1TokenPermit)({
|
|
91
|
+
chainId,
|
|
92
|
+
userAddress,
|
|
93
|
+
token: marketParams.loanToken,
|
|
94
|
+
amount: assets,
|
|
95
|
+
requirementSignature,
|
|
80
96
|
});
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
value
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
97
|
+
return (0, common_js_1.finalizeBlueBundlesV1Transaction)({
|
|
98
|
+
common,
|
|
99
|
+
value,
|
|
100
|
+
data: (0, viem_1.encodeFunctionData)({
|
|
101
|
+
abi: abis_js_1.blueBundlesV1Abi,
|
|
102
|
+
functionName: "blueBundlesV1Supply",
|
|
103
|
+
args: [
|
|
104
|
+
marketParams,
|
|
105
|
+
assets,
|
|
106
|
+
tokenPermit,
|
|
107
|
+
referralFeePct,
|
|
108
|
+
referralFeeRecipient,
|
|
109
|
+
params.args.deadline,
|
|
110
|
+
],
|
|
111
|
+
}),
|
|
90
112
|
action: {
|
|
91
113
|
type: "blueSupply",
|
|
92
114
|
args: {
|
|
93
115
|
market: marketParams.id,
|
|
94
|
-
|
|
95
|
-
onBehalf,
|
|
96
|
-
|
|
97
|
-
|
|
116
|
+
assets,
|
|
117
|
+
onBehalf: userAddress,
|
|
118
|
+
nativeAmount: value > 0n ? value : undefined,
|
|
119
|
+
referralFeePct,
|
|
120
|
+
referralFeeRecipient,
|
|
121
|
+
deadline: params.args.deadline,
|
|
98
122
|
},
|
|
99
123
|
},
|
|
100
124
|
});
|
|
@@ -1,60 +1,83 @@
|
|
|
1
1
|
import type { MarketParams } from "@morpho-org/blue-sdk";
|
|
2
|
-
import type
|
|
3
|
-
import {
|
|
2
|
+
import { type Address } from "viem";
|
|
3
|
+
import type { BlueBundlesV1TokenRequirementSignature, BlueSupplyCollateralAction, Metadata, Transaction } from "../../types/index.js";
|
|
4
4
|
/** Parameters for {@link blueSupplyCollateral}. */
|
|
5
5
|
export interface BlueSupplyCollateralParams {
|
|
6
|
-
market
|
|
6
|
+
/** Chain and scoped Morpho Blue market. */
|
|
7
|
+
readonly market: {
|
|
7
8
|
readonly chainId: number;
|
|
8
9
|
readonly marketParams: MarketParams;
|
|
9
10
|
};
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
11
|
+
/** Direct BlueBundlesV1 collateral-supply arguments. */
|
|
12
|
+
readonly args: {
|
|
13
|
+
/** User whose collateral position is credited. */
|
|
14
|
+
readonly userAddress: Address;
|
|
15
|
+
/** Gross collateral assets supplied. */
|
|
16
|
+
readonly collateralAssets: bigint;
|
|
17
|
+
/** Full native collateral funding; must equal `collateralAssets`. */
|
|
18
|
+
readonly nativeAmount?: bigint;
|
|
19
|
+
/** Final call deadline in Unix seconds. */
|
|
20
|
+
readonly deadline: bigint;
|
|
21
|
+
/** Optional WAD-scaled referral fee, strictly below 100%. */
|
|
22
|
+
readonly referralFeePct?: bigint;
|
|
23
|
+
/** Recipient required when `referralFeePct` is positive. */
|
|
24
|
+
readonly referralFeeRecipient?: Address;
|
|
25
|
+
/** Optional collateral ERC-2612 or Permit2 SignatureTransfer result. */
|
|
26
|
+
readonly requirementSignature?: BlueBundlesV1TokenRequirementSignature;
|
|
15
27
|
};
|
|
16
|
-
metadata
|
|
28
|
+
/** Optional transaction metadata suffix. */
|
|
29
|
+
readonly metadata?: Metadata;
|
|
17
30
|
}
|
|
18
31
|
/**
|
|
19
|
-
*
|
|
32
|
+
* Encodes a pure collateral supply through BlueBundlesV1.
|
|
20
33
|
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* the chain's wNative for that path.
|
|
34
|
+
* Delegates to {@link blueSupplyCollateralBorrow} with a zero borrow leg and an unrestricted LTV
|
|
35
|
+
* cap. Native funding is exclusive with ERC-20 funding and no Bundler3 action is encoded.
|
|
24
36
|
*
|
|
25
|
-
*
|
|
26
|
-
*
|
|
27
|
-
* @param params.market.
|
|
28
|
-
* @param params.
|
|
29
|
-
* @param params.args.
|
|
30
|
-
*
|
|
31
|
-
* @param params.args.
|
|
32
|
-
* @param params.args.
|
|
33
|
-
* @param params.args.
|
|
34
|
-
*
|
|
35
|
-
* @param params.metadata - Optional
|
|
36
|
-
* @returns A deep-frozen `Transaction<BlueSupplyCollateralAction
|
|
37
|
-
*
|
|
38
|
-
* @throws {NegativeInputError} when
|
|
39
|
-
* @throws {NonPositiveInputError} when
|
|
40
|
-
* @throws {
|
|
41
|
-
* @throws {
|
|
42
|
-
*
|
|
43
|
-
* @throws {
|
|
44
|
-
*
|
|
45
|
-
* @throws {
|
|
46
|
-
*
|
|
47
|
-
* @throws {
|
|
48
|
-
*
|
|
37
|
+
* @param params - Collateral-supply encoding parameters.
|
|
38
|
+
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
39
|
+
* @param params.market.marketParams - Scoped Morpho Blue market parameters.
|
|
40
|
+
* @param params.args.userAddress - User whose collateral position is credited.
|
|
41
|
+
* @param params.args.collateralAssets - Gross collateral assets supplied.
|
|
42
|
+
* @param params.args.nativeAmount - Exclusive native collateral funding.
|
|
43
|
+
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
44
|
+
* @param params.args.referralFeePct - Optional WAD-scaled referral fee.
|
|
45
|
+
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
46
|
+
* @param params.args.requirementSignature - Optional collateral-token signature.
|
|
47
|
+
* @param params.metadata - Optional transaction metadata.
|
|
48
|
+
* @returns A deep-frozen `Readonly<Transaction<BlueSupplyCollateralAction>>` whose calldata
|
|
49
|
+
* invokes the combined BlueBundlesV1 entrypoint with a zero borrow leg.
|
|
50
|
+
* @throws {NegativeInputError} when an amount or fee is negative.
|
|
51
|
+
* @throws {NonPositiveInputError} when collateral or deadline is not positive.
|
|
52
|
+
* @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
|
|
53
|
+
* @throws {ChainWNativeMissingError} when native funding is requested without a registered wNative.
|
|
54
|
+
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another collateral token.
|
|
55
|
+
* @throws {UnexpectedRequirementSignatureError} when native funding also supplies a token signature.
|
|
56
|
+
* @throws {DepositOwnerMismatchError} when the signed owner differs from `userAddress`.
|
|
57
|
+
* @throws {DepositAssetMismatchError} when the signed asset differs from the collateral token.
|
|
58
|
+
* @throws {DepositAmountMismatchError} when the signed amount differs from `collateralAssets`.
|
|
59
|
+
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
60
|
+
* @throws {BlueBundlesV1RequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
61
|
+
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
62
|
+
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
63
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
64
|
+
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
49
65
|
* @example
|
|
50
66
|
* ```ts
|
|
67
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
51
68
|
* import { blueSupplyCollateral } from "@morpho-org/morpho-sdk";
|
|
69
|
+
* import { zeroAddress } from "viem";
|
|
70
|
+
* import { mainnet } from "viem/chains";
|
|
52
71
|
*
|
|
53
72
|
* const tx = blueSupplyCollateral({
|
|
54
|
-
* market: { chainId:
|
|
55
|
-
* args: {
|
|
73
|
+
* market: { chainId: mainnet.id, marketParams: markets[mainnet.id].usdc_wbtc },
|
|
74
|
+
* args: {
|
|
75
|
+
* userAddress: zeroAddress,
|
|
76
|
+
* collateralAssets: 1_000_000_000_000_000_000n,
|
|
77
|
+
* deadline: 1_900_000_000n,
|
|
78
|
+
* },
|
|
56
79
|
* });
|
|
57
80
|
* // tx satisfies Readonly<Transaction<BlueSupplyCollateralAction>>
|
|
58
81
|
* ```
|
|
59
82
|
*/
|
|
60
|
-
export declare const blueSupplyCollateral: (
|
|
83
|
+
export declare const blueSupplyCollateral: (params: BlueSupplyCollateralParams) => Readonly<Transaction<BlueSupplyCollateralAction>>;
|
|
@@ -2,89 +2,72 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.blueSupplyCollateral = void 0;
|
|
4
4
|
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
5
|
-
const
|
|
6
|
-
const
|
|
7
|
-
const index_js_3 = require("../../types/index.js");
|
|
8
|
-
const buildAssetFundingActions_js_1 = require("./buildAssetFundingActions.js");
|
|
5
|
+
const viem_1 = require("viem");
|
|
6
|
+
const supplyCollateralBorrow_js_1 = require("./supplyCollateralBorrow.js");
|
|
9
7
|
/**
|
|
10
|
-
*
|
|
8
|
+
* Encodes a pure collateral supply through BlueBundlesV1.
|
|
11
9
|
*
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
* the chain's wNative for that path.
|
|
10
|
+
* Delegates to {@link blueSupplyCollateralBorrow} with a zero borrow leg and an unrestricted LTV
|
|
11
|
+
* cap. Native funding is exclusive with ERC-20 funding and no Bundler3 action is encoded.
|
|
15
12
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
18
|
-
* @param params.market.
|
|
19
|
-
* @param params.
|
|
20
|
-
* @param params.args.
|
|
21
|
-
*
|
|
22
|
-
* @param params.args.
|
|
23
|
-
* @param params.args.
|
|
24
|
-
* @param params.args.
|
|
25
|
-
*
|
|
26
|
-
* @param params.metadata - Optional
|
|
27
|
-
* @returns A deep-frozen `Transaction<BlueSupplyCollateralAction
|
|
28
|
-
*
|
|
29
|
-
* @throws {NegativeInputError} when
|
|
30
|
-
* @throws {NonPositiveInputError} when
|
|
31
|
-
* @throws {
|
|
32
|
-
* @throws {
|
|
33
|
-
*
|
|
34
|
-
* @throws {
|
|
35
|
-
*
|
|
36
|
-
* @throws {
|
|
37
|
-
*
|
|
38
|
-
* @throws {
|
|
39
|
-
*
|
|
13
|
+
* @param params - Collateral-supply encoding parameters.
|
|
14
|
+
* @param params.market.chainId - Chain containing BlueBundlesV1.
|
|
15
|
+
* @param params.market.marketParams - Scoped Morpho Blue market parameters.
|
|
16
|
+
* @param params.args.userAddress - User whose collateral position is credited.
|
|
17
|
+
* @param params.args.collateralAssets - Gross collateral assets supplied.
|
|
18
|
+
* @param params.args.nativeAmount - Exclusive native collateral funding.
|
|
19
|
+
* @param params.args.deadline - Final call deadline in Unix seconds.
|
|
20
|
+
* @param params.args.referralFeePct - Optional WAD-scaled referral fee.
|
|
21
|
+
* @param params.args.referralFeeRecipient - Recipient required for a positive fee.
|
|
22
|
+
* @param params.args.requirementSignature - Optional collateral-token signature.
|
|
23
|
+
* @param params.metadata - Optional transaction metadata.
|
|
24
|
+
* @returns A deep-frozen `Readonly<Transaction<BlueSupplyCollateralAction>>` whose calldata
|
|
25
|
+
* invokes the combined BlueBundlesV1 entrypoint with a zero borrow leg.
|
|
26
|
+
* @throws {NegativeInputError} when an amount or fee is negative.
|
|
27
|
+
* @throws {NonPositiveInputError} when collateral or deadline is not positive.
|
|
28
|
+
* @throws {NativeFundingAmountMismatchError} when native funding is partial or mixed.
|
|
29
|
+
* @throws {ChainWNativeMissingError} when native funding is requested without a registered wNative.
|
|
30
|
+
* @throws {NativeAmountOnNonWNativeAssetError} when native funding targets another collateral token.
|
|
31
|
+
* @throws {UnexpectedRequirementSignatureError} when native funding also supplies a token signature.
|
|
32
|
+
* @throws {DepositOwnerMismatchError} when the signed owner differs from `userAddress`.
|
|
33
|
+
* @throws {DepositAssetMismatchError} when the signed asset differs from the collateral token.
|
|
34
|
+
* @throws {DepositAmountMismatchError} when the signed amount differs from `collateralAssets`.
|
|
35
|
+
* @throws {DepositSpenderMismatchError} when the signed spender is not BlueBundlesV1.
|
|
36
|
+
* @throws {BlueBundlesV1RequirementSignatureMismatchError} when a signature cannot be encoded safely.
|
|
37
|
+
* @throws {InputExceedsMaxError} when the referral fee is at least WAD.
|
|
38
|
+
* @throws {MissingReferralFeeRecipientError} when a positive fee has no recipient.
|
|
39
|
+
* @throws {UnsupportedChainIdError} when the chain is absent from the registry.
|
|
40
|
+
* @throws {UnknownAddressError} when BlueBundlesV1 is not registered.
|
|
40
41
|
* @example
|
|
41
42
|
* ```ts
|
|
43
|
+
* import { markets } from "@morpho-org/morpho-test";
|
|
42
44
|
* import { blueSupplyCollateral } from "@morpho-org/morpho-sdk";
|
|
45
|
+
* import { zeroAddress } from "viem";
|
|
46
|
+
* import { mainnet } from "viem/chains";
|
|
43
47
|
*
|
|
44
48
|
* const tx = blueSupplyCollateral({
|
|
45
|
-
* market: { chainId:
|
|
46
|
-
* args: {
|
|
49
|
+
* market: { chainId: mainnet.id, marketParams: markets[mainnet.id].usdc_wbtc },
|
|
50
|
+
* args: {
|
|
51
|
+
* userAddress: zeroAddress,
|
|
52
|
+
* collateralAssets: 1_000_000_000_000_000_000n,
|
|
53
|
+
* deadline: 1_900_000_000n,
|
|
54
|
+
* },
|
|
47
55
|
* });
|
|
48
56
|
* // tx satisfies Readonly<Transaction<BlueSupplyCollateralAction>>
|
|
49
57
|
* ```
|
|
50
58
|
*/
|
|
51
|
-
const blueSupplyCollateral = (
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
if (totalCollateral === 0n) {
|
|
60
|
-
throw new index_js_3.NonPositiveInputError("totalCollateral", totalCollateral);
|
|
61
|
-
}
|
|
62
|
-
const actions = (0, buildAssetFundingActions_js_1.buildAssetFundingActions)({
|
|
63
|
-
chainId,
|
|
64
|
-
asset: marketParams.collateralToken,
|
|
65
|
-
erc20Amount: amount,
|
|
66
|
-
nativeAmount: nativeAmount ?? 0n,
|
|
67
|
-
requirementSignature,
|
|
68
|
-
});
|
|
69
|
-
actions.push({
|
|
70
|
-
type: "morphoSupplyCollateral",
|
|
71
|
-
args: [marketParams, totalCollateral, onBehalf, [], false],
|
|
59
|
+
const blueSupplyCollateral = (params) => {
|
|
60
|
+
const transaction = (0, supplyCollateralBorrow_js_1.blueSupplyCollateralBorrow)({
|
|
61
|
+
...params,
|
|
62
|
+
args: {
|
|
63
|
+
...params.args,
|
|
64
|
+
borrowAssets: 0n,
|
|
65
|
+
maxLtv: viem_1.maxUint256,
|
|
66
|
+
},
|
|
72
67
|
});
|
|
73
|
-
let tx = index_js_1.BundlerAction.encodeBundle(chainId, actions);
|
|
74
|
-
if (metadata) {
|
|
75
|
-
tx = (0, index_js_2.addTransactionMetadata)(tx, metadata);
|
|
76
|
-
}
|
|
77
68
|
return (0, morpho_ts_1.deepFreeze)({
|
|
78
|
-
...
|
|
79
|
-
action: {
|
|
80
|
-
type: "blueSupplyCollateral",
|
|
81
|
-
args: {
|
|
82
|
-
market: marketParams.id,
|
|
83
|
-
amount: totalCollateral,
|
|
84
|
-
onBehalf,
|
|
85
|
-
nativeAmount,
|
|
86
|
-
},
|
|
87
|
-
},
|
|
69
|
+
...transaction,
|
|
70
|
+
action: { ...transaction.action, type: "blueSupplyCollateral" },
|
|
88
71
|
});
|
|
89
72
|
};
|
|
90
73
|
exports.blueSupplyCollateral = blueSupplyCollateral;
|