@morpho-org/morpho-sdk 4.2.0 → 5.1.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/README.md +16 -16
- package/lib/cjs/actions/blue/borrow.d.ts +12 -2
- package/lib/cjs/actions/blue/borrow.js +7 -1
- package/lib/cjs/actions/blue/buildAssetFundingActions.d.ts +47 -0
- package/lib/cjs/actions/blue/buildAssetFundingActions.js +63 -0
- package/lib/cjs/actions/blue/refinance.d.ts +13 -3
- package/lib/cjs/actions/blue/refinance.js +8 -2
- package/lib/cjs/actions/blue/repay.d.ts +44 -43
- package/lib/cjs/actions/blue/repay.js +70 -59
- package/lib/cjs/actions/blue/repayWithdrawCollateral.d.ts +50 -41
- package/lib/cjs/actions/blue/repayWithdrawCollateral.js +75 -54
- package/lib/cjs/actions/blue/resolveRepayFunding.d.ts +69 -0
- package/lib/cjs/actions/blue/resolveRepayFunding.js +82 -0
- package/lib/cjs/actions/blue/supply.d.ts +8 -8
- package/lib/cjs/actions/blue/supply.js +11 -35
- package/lib/cjs/actions/blue/supplyCollateral.d.ts +9 -9
- package/lib/cjs/actions/blue/supplyCollateral.js +12 -36
- package/lib/cjs/actions/blue/supplyCollateralBorrow.d.ts +19 -7
- package/lib/cjs/actions/blue/supplyCollateralBorrow.js +17 -32
- package/lib/cjs/actions/blue/withdraw.d.ts +10 -2
- package/lib/cjs/actions/blue/withdraw.js +7 -1
- package/lib/cjs/actions/index.d.ts +1 -0
- package/lib/cjs/actions/index.js +1 -0
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +49 -0
- package/lib/cjs/actions/requirements/blue/getBlueAuthorizationRequirement.js +111 -0
- package/lib/cjs/actions/requirements/blue/index.d.ts +1 -0
- package/lib/cjs/actions/requirements/blue/index.js +17 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +55 -0
- package/lib/cjs/actions/requirements/encode/encodeBlueSignatureAuthorization.js +89 -0
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +6 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +17 -5
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +9 -7
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +18 -4
- package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2.d.ts → encodeErc20Permit2Approve.d.ts} +11 -13
- package/lib/cjs/actions/requirements/encode/{encodeErc20Permit2.js → encodeErc20Permit2Approve.js} +10 -14
- package/lib/cjs/actions/requirements/encode/index.d.ts +2 -1
- package/lib/cjs/actions/requirements/encode/index.js +2 -1
- package/lib/cjs/actions/requirements/{getRequirements.d.ts → generalAdapter/getGeneralAdapterRequirements.d.ts} +34 -20
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +151 -0
- package/lib/{esm/actions/requirements/getRequirementsPermit.d.ts → cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts} +6 -14
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +50 -0
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +57 -0
- package/lib/cjs/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +74 -0
- package/lib/cjs/actions/requirements/generalAdapter/index.d.ts +3 -0
- package/lib/cjs/actions/requirements/generalAdapter/index.js +19 -0
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +3 -2
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +3 -2
- package/lib/cjs/actions/requirements/index.d.ts +2 -5
- package/lib/cjs/actions/requirements/index.js +2 -5
- package/lib/cjs/actions/signatures/getBlueAuthorizationAction.d.ts +29 -0
- package/lib/cjs/actions/signatures/getBlueAuthorizationAction.js +48 -0
- package/lib/{esm/actions/requirements/getRequirementsAction.d.ts → cjs/actions/signatures/getTokenRequirementActions.d.ts} +17 -17
- package/lib/cjs/actions/{requirements/getRequirementsAction.js → signatures/getTokenRequirementActions.js} +26 -13
- package/lib/cjs/actions/signatures/index.d.ts +2 -0
- package/lib/cjs/actions/signatures/index.js +18 -0
- package/lib/cjs/actions/vaultV1/deposit.d.ts +6 -8
- package/lib/cjs/actions/vaultV1/deposit.js +11 -21
- package/lib/cjs/actions/vaultV1/migrateToV2.d.ts +6 -6
- package/lib/cjs/actions/vaultV1/migrateToV2.js +12 -20
- package/lib/cjs/actions/vaultV2/deposit.d.ts +6 -8
- package/lib/cjs/actions/vaultV2/deposit.js +11 -21
- package/lib/cjs/addresses.d.ts +2 -2
- package/lib/cjs/addresses.js +2 -1
- package/lib/cjs/bundler/actions.d.ts +44 -4
- package/lib/cjs/bundler/actions.js +75 -2
- package/lib/cjs/bundler/types.d.ts +6 -0
- package/lib/cjs/constants.d.ts +2 -2
- package/lib/cjs/constants.js +3 -3
- package/lib/cjs/entities/blue/blue.d.ts +58 -33
- package/lib/cjs/entities/blue/blue.js +309 -189
- package/lib/cjs/entities/reallocationData.d.ts +0 -44
- package/lib/cjs/entities/reallocationData.js +3 -50
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +9 -9
- package/lib/cjs/entities/vaultV1/vaultV1.js +44 -34
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +6 -6
- package/lib/cjs/entities/vaultV2/vaultV2.js +21 -16
- package/lib/cjs/errors.d.ts +3 -2
- package/lib/cjs/errors.js +5 -2
- package/lib/cjs/helpers/index.d.ts +1 -1
- package/lib/cjs/helpers/index.js +1 -2
- package/lib/cjs/helpers/validate.d.ts +2 -20
- package/lib/cjs/helpers/validate.js +2 -39
- package/lib/cjs/types/action.d.ts +164 -12
- package/lib/cjs/types/action.js +79 -5
- package/lib/cjs/types/error.d.ts +97 -2
- package/lib/cjs/types/error.js +113 -7
- package/lib/cjs/types.d.ts +2 -1
- package/lib/cjs/utils.d.ts +2 -2
- package/lib/cjs/utils.js +2 -4
- package/lib/esm/actions/blue/borrow.d.ts +12 -2
- package/lib/esm/actions/blue/borrow.js +7 -1
- package/lib/esm/actions/blue/buildAssetFundingActions.d.ts +47 -0
- package/lib/esm/actions/blue/buildAssetFundingActions.js +59 -0
- package/lib/esm/actions/blue/refinance.d.ts +13 -3
- package/lib/esm/actions/blue/refinance.js +8 -2
- package/lib/esm/actions/blue/repay.d.ts +44 -43
- package/lib/esm/actions/blue/repay.js +71 -60
- package/lib/esm/actions/blue/repayWithdrawCollateral.d.ts +50 -41
- package/lib/esm/actions/blue/repayWithdrawCollateral.js +76 -55
- package/lib/esm/actions/blue/resolveRepayFunding.d.ts +69 -0
- package/lib/esm/actions/blue/resolveRepayFunding.js +78 -0
- package/lib/esm/actions/blue/supply.d.ts +8 -8
- package/lib/esm/actions/blue/supply.js +12 -36
- package/lib/esm/actions/blue/supplyCollateral.d.ts +9 -9
- package/lib/esm/actions/blue/supplyCollateral.js +13 -37
- package/lib/esm/actions/blue/supplyCollateralBorrow.d.ts +19 -7
- package/lib/esm/actions/blue/supplyCollateralBorrow.js +18 -33
- package/lib/esm/actions/blue/withdraw.d.ts +10 -2
- package/lib/esm/actions/blue/withdraw.js +7 -1
- package/lib/esm/actions/index.d.ts +1 -0
- package/lib/esm/actions/index.js +1 -0
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.d.ts +49 -0
- package/lib/esm/actions/requirements/blue/getBlueAuthorizationRequirement.js +107 -0
- package/lib/esm/actions/requirements/blue/index.d.ts +1 -0
- package/lib/esm/actions/requirements/blue/index.js +1 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.d.ts +55 -0
- package/lib/esm/actions/requirements/encode/encodeBlueSignatureAuthorization.js +85 -0
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +6 -5
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +19 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +9 -7
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +20 -6
- package/lib/esm/actions/requirements/encode/{encodeErc20Permit2.d.ts → encodeErc20Permit2Approve.d.ts} +11 -13
- package/lib/esm/actions/requirements/encode/{encodeErc20Permit2.js → encodeErc20Permit2Approve.js} +8 -12
- package/lib/esm/actions/requirements/encode/index.d.ts +2 -1
- package/lib/esm/actions/requirements/encode/index.js +2 -1
- package/lib/esm/actions/requirements/{getRequirements.d.ts → generalAdapter/getGeneralAdapterRequirements.d.ts} +34 -20
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirements.js +147 -0
- package/lib/{cjs/actions/requirements/getRequirementsPermit.d.ts → esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.d.ts} +6 -14
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit.js +46 -0
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.d.ts +57 -0
- package/lib/esm/actions/requirements/generalAdapter/getGeneralAdapterRequirementsPermit2.js +70 -0
- package/lib/esm/actions/requirements/generalAdapter/index.d.ts +3 -0
- package/lib/esm/actions/requirements/generalAdapter/index.js +3 -0
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +3 -2
- package/lib/esm/actions/requirements/getRequirementsApproval.js +3 -2
- package/lib/esm/actions/requirements/index.d.ts +2 -5
- package/lib/esm/actions/requirements/index.js +2 -5
- package/lib/esm/actions/signatures/getBlueAuthorizationAction.d.ts +29 -0
- package/lib/esm/actions/signatures/getBlueAuthorizationAction.js +44 -0
- package/lib/{cjs/actions/requirements/getRequirementsAction.d.ts → esm/actions/signatures/getTokenRequirementActions.d.ts} +17 -17
- package/lib/esm/actions/{requirements/getRequirementsAction.js → signatures/getTokenRequirementActions.js} +24 -11
- package/lib/esm/actions/signatures/index.d.ts +2 -0
- package/lib/esm/actions/signatures/index.js +2 -0
- package/lib/esm/actions/vaultV1/deposit.d.ts +6 -8
- package/lib/esm/actions/vaultV1/deposit.js +11 -21
- package/lib/esm/actions/vaultV1/migrateToV2.d.ts +6 -6
- package/lib/esm/actions/vaultV1/migrateToV2.js +12 -20
- package/lib/esm/actions/vaultV2/deposit.d.ts +6 -8
- package/lib/esm/actions/vaultV2/deposit.js +11 -21
- package/lib/esm/addresses.d.ts +2 -2
- package/lib/esm/addresses.js +1 -1
- package/lib/esm/bundler/actions.d.ts +44 -4
- package/lib/esm/bundler/actions.js +77 -4
- package/lib/esm/bundler/types.d.ts +6 -0
- package/lib/esm/constants.d.ts +2 -2
- package/lib/esm/constants.js +2 -2
- package/lib/esm/entities/blue/blue.d.ts +58 -33
- package/lib/esm/entities/blue/blue.js +311 -191
- package/lib/esm/entities/reallocationData.d.ts +0 -44
- package/lib/esm/entities/reallocationData.js +2 -49
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +9 -9
- package/lib/esm/entities/vaultV1/vaultV1.js +46 -36
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +6 -6
- package/lib/esm/entities/vaultV2/vaultV2.js +23 -18
- package/lib/esm/errors.d.ts +3 -2
- package/lib/esm/errors.js +2 -1
- package/lib/esm/helpers/index.d.ts +1 -1
- package/lib/esm/helpers/index.js +1 -1
- package/lib/esm/helpers/validate.d.ts +2 -20
- package/lib/esm/helpers/validate.js +2 -38
- package/lib/esm/types/action.d.ts +164 -12
- package/lib/esm/types/action.js +75 -4
- package/lib/esm/types/error.d.ts +97 -2
- package/lib/esm/types/error.js +107 -5
- package/lib/esm/types.d.ts +2 -1
- package/lib/esm/utils.d.ts +2 -2
- package/lib/esm/utils.js +2 -2
- package/package.json +22 -21
- package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.d.ts +0 -37
- package/lib/cjs/actions/requirements/getMorphoAuthorizationRequirement.js +0 -71
- package/lib/cjs/actions/requirements/getRequirements.js +0 -112
- package/lib/cjs/actions/requirements/getRequirementsPermit.js +0 -57
- package/lib/cjs/actions/requirements/getRequirementsPermit2.d.ts +0 -63
- package/lib/cjs/actions/requirements/getRequirementsPermit2.js +0 -85
- package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.d.ts +0 -37
- package/lib/esm/actions/requirements/getMorphoAuthorizationRequirement.js +0 -67
- package/lib/esm/actions/requirements/getRequirements.js +0 -108
- package/lib/esm/actions/requirements/getRequirementsPermit.js +0 -53
- package/lib/esm/actions/requirements/getRequirementsPermit2.d.ts +0 -63
- package/lib/esm/actions/requirements/getRequirementsPermit2.js +0 -81
- package/src/index.ts +0 -4
|
@@ -2,9 +2,9 @@ import { AccrualPosition, DEFAULT_SLIPPAGE_TOLERANCE, MathLib, } from "@morpho-o
|
|
|
2
2
|
import { fetchAccrualPosition, fetchMarket, fetchPosition, fetchVault, fetchVaultMarketConfig, } from "@morpho-org/blue-sdk-viem";
|
|
3
3
|
import { Time } from "@morpho-org/morpho-ts";
|
|
4
4
|
import { isAddressEqual } from "viem";
|
|
5
|
-
import { blueBorrow, blueRefinance, blueRepay, blueRepayWithdrawCollateral, blueSupply, blueSupplyCollateral, blueSupplyCollateralBorrow, blueWithdraw, blueWithdrawCollateral,
|
|
5
|
+
import { blueBorrow, blueRefinance, blueRepay, blueRepayWithdrawCollateral, blueSupply, blueSupplyCollateral, blueSupplyCollateralBorrow, blueWithdraw, blueWithdrawCollateral, getBlueAuthorizationRequirement, getGeneralAdapterRequirements, } from "../../actions/index.js";
|
|
6
6
|
import { computeMaxRepaySharePrice, computeMaxSupplySharePrice, computeMinBorrowSharePrice, computeMinWithdrawSharePrice, computeReallocations, validateAccrualPosition, validateChainId, validateNativeAsset, validatePositionHealth, validatePositionHealthAfterWithdraw, validateRepayAmount, validateRepayShares, validateSlippageTolerance, validateWithdrawAmount, validateWithdrawShares, } from "../../helpers/index.js";
|
|
7
|
-
import { BorrowAmountAndSharesExclusiveError, MarketIdMismatchError, MissingAccrualPositionError, MutuallyExclusiveRepayAmountsError, MutuallyExclusiveWithdrawAmountsError, NegativeBorrowSharesError, NegativeNativeAmountError, NegativeSupplyAmountError, NonPositiveAssetAmountError, NonPositiveBorrowAmountError, NonPositiveRepayAmountError, NonPositiveWithdrawAmountError, NonPositiveWithdrawCollateralAmountError, RefinanceExceedsBorrowAssetsError, RefinanceExceedsBorrowSharesError, RefinanceExceedsCollateralError, RefinanceSameMarketError, RefinanceTokenMismatchError, WithdrawExceedsCollateralError, ZeroCollateralAmountError, ZeroSupplyAmountError, } from "../../types/index.js";
|
|
7
|
+
import { BorrowAmountAndSharesExclusiveError, MarketIdMismatchError, MissingAccrualPositionError, MutuallyExclusiveRepayAmountsError, MutuallyExclusiveWithdrawAmountsError, NativeAmountExceedsTransferAmountError, NegativeBorrowSharesError, NegativeNativeAmountError, NegativeSupplyAmountError, NonPositiveAssetAmountError, NonPositiveBorrowAmountError, NonPositiveRepayAmountError, NonPositiveWithdrawAmountError, NonPositiveWithdrawCollateralAmountError, RefinanceExceedsBorrowAssetsError, RefinanceExceedsBorrowSharesError, RefinanceExceedsCollateralError, RefinanceSameMarketError, RefinanceTokenMismatchError, selectRequirementSignatures, WithdrawExceedsCollateralError, ZeroCollateralAmountError, ZeroSupplyAmountError, } from "../../types/index.js";
|
|
8
8
|
import { ReallocationData } from "../reallocationData.js";
|
|
9
9
|
export class MorphoBlue {
|
|
10
10
|
client;
|
|
@@ -57,7 +57,7 @@ export class MorphoBlue {
|
|
|
57
57
|
slippageTolerance,
|
|
58
58
|
});
|
|
59
59
|
return {
|
|
60
|
-
getRequirements: (params) =>
|
|
60
|
+
getRequirements: (params) => getGeneralAdapterRequirements(this.client.viemClient, {
|
|
61
61
|
address: this.marketParams.loanToken,
|
|
62
62
|
chainId: this.chainId,
|
|
63
63
|
supportSignature: this.client.options.supportSignature,
|
|
@@ -65,17 +65,22 @@ export class MorphoBlue {
|
|
|
65
65
|
useSimplePermit: params?.useSimplePermit,
|
|
66
66
|
args: { amount, from: userAddress },
|
|
67
67
|
}),
|
|
68
|
-
buildTx: (
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
68
|
+
buildTx: (signatures) => {
|
|
69
|
+
const { permit } = selectRequirementSignatures(signatures, {
|
|
70
|
+
permit: true,
|
|
71
|
+
});
|
|
72
|
+
return blueSupply({
|
|
73
|
+
market: { chainId: this.chainId, marketParams: this.marketParams },
|
|
74
|
+
args: {
|
|
75
|
+
amount,
|
|
76
|
+
nativeAmount,
|
|
77
|
+
onBehalf: userAddress,
|
|
78
|
+
maxSharePrice,
|
|
79
|
+
requirementSignature: permit,
|
|
80
|
+
},
|
|
81
|
+
metadata: this.client.options.metadata,
|
|
82
|
+
});
|
|
83
|
+
},
|
|
79
84
|
};
|
|
80
85
|
}
|
|
81
86
|
withdraw(params) {
|
|
@@ -126,24 +131,31 @@ export class MorphoBlue {
|
|
|
126
131
|
});
|
|
127
132
|
return {
|
|
128
133
|
getRequirements: async () => {
|
|
129
|
-
const authTx = await
|
|
134
|
+
const authTx = await getBlueAuthorizationRequirement({
|
|
130
135
|
viemClient: this.client.viemClient,
|
|
131
136
|
chainId: this.chainId,
|
|
132
137
|
userAddress,
|
|
138
|
+
supportSignature: this.client.options.supportSignature,
|
|
133
139
|
});
|
|
134
140
|
return authTx ? [authTx] : [];
|
|
135
141
|
},
|
|
136
|
-
buildTx: () =>
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
142
|
+
buildTx: (signatures) => {
|
|
143
|
+
const { authorization } = selectRequirementSignatures(signatures, {
|
|
144
|
+
authorization: true,
|
|
145
|
+
});
|
|
146
|
+
return blueWithdraw({
|
|
147
|
+
market: { chainId: this.chainId, marketParams: this.marketParams },
|
|
148
|
+
args: {
|
|
149
|
+
assets,
|
|
150
|
+
shares,
|
|
151
|
+
receiver,
|
|
152
|
+
minSharePrice,
|
|
153
|
+
reallocations,
|
|
154
|
+
authorizationSignature: authorization,
|
|
155
|
+
},
|
|
156
|
+
metadata: this.client.options.metadata,
|
|
157
|
+
});
|
|
158
|
+
},
|
|
147
159
|
};
|
|
148
160
|
}
|
|
149
161
|
supplyCollateral({ amount = 0n, userAddress, nativeAmount, }) {
|
|
@@ -162,7 +174,7 @@ export class MorphoBlue {
|
|
|
162
174
|
validateNativeAsset(this.chainId, this.marketParams.collateralToken);
|
|
163
175
|
}
|
|
164
176
|
return {
|
|
165
|
-
getRequirements: (params) =>
|
|
177
|
+
getRequirements: (params) => getGeneralAdapterRequirements(this.client.viemClient, {
|
|
166
178
|
address: this.marketParams.collateralToken,
|
|
167
179
|
chainId: this.chainId,
|
|
168
180
|
supportSignature: this.client.options.supportSignature,
|
|
@@ -170,19 +182,24 @@ export class MorphoBlue {
|
|
|
170
182
|
useSimplePermit: params?.useSimplePermit,
|
|
171
183
|
args: { amount, from: userAddress },
|
|
172
184
|
}),
|
|
173
|
-
buildTx: (
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
185
|
+
buildTx: (signatures) => {
|
|
186
|
+
const { permit } = selectRequirementSignatures(signatures, {
|
|
187
|
+
permit: true,
|
|
188
|
+
});
|
|
189
|
+
return blueSupplyCollateral({
|
|
190
|
+
market: {
|
|
191
|
+
chainId: this.chainId,
|
|
192
|
+
marketParams: this.marketParams,
|
|
193
|
+
},
|
|
194
|
+
args: {
|
|
195
|
+
amount,
|
|
196
|
+
nativeAmount,
|
|
197
|
+
onBehalf: userAddress,
|
|
198
|
+
requirementSignature: permit,
|
|
199
|
+
},
|
|
200
|
+
metadata: this.client.options.metadata,
|
|
201
|
+
});
|
|
202
|
+
},
|
|
186
203
|
};
|
|
187
204
|
}
|
|
188
205
|
borrow({ amount, userAddress, positionData, slippageTolerance = DEFAULT_SLIPPAGE_TOLERANCE, reallocations, }) {
|
|
@@ -213,44 +230,44 @@ export class MorphoBlue {
|
|
|
213
230
|
});
|
|
214
231
|
return {
|
|
215
232
|
getRequirements: async () => {
|
|
216
|
-
const authTx = await
|
|
233
|
+
const authTx = await getBlueAuthorizationRequirement({
|
|
217
234
|
viemClient: this.client.viemClient,
|
|
218
235
|
chainId: this.chainId,
|
|
219
236
|
userAddress,
|
|
237
|
+
supportSignature: this.client.options.supportSignature,
|
|
220
238
|
});
|
|
221
239
|
return authTx ? [authTx] : [];
|
|
222
240
|
},
|
|
223
|
-
buildTx: () =>
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
241
|
+
buildTx: (signatures) => {
|
|
242
|
+
const { authorization } = selectRequirementSignatures(signatures, {
|
|
243
|
+
authorization: true,
|
|
244
|
+
});
|
|
245
|
+
return blueBorrow({
|
|
246
|
+
market: {
|
|
247
|
+
chainId: this.chainId,
|
|
248
|
+
marketParams: this.marketParams,
|
|
249
|
+
},
|
|
250
|
+
args: {
|
|
251
|
+
amount,
|
|
252
|
+
receiver: userAddress,
|
|
253
|
+
minSharePrice,
|
|
254
|
+
reallocations,
|
|
255
|
+
authorizationSignature: authorization,
|
|
256
|
+
},
|
|
257
|
+
metadata: this.client.options.metadata,
|
|
258
|
+
});
|
|
259
|
+
},
|
|
236
260
|
};
|
|
237
261
|
}
|
|
238
262
|
repay(params) {
|
|
239
263
|
validateChainId(this.client.viemClient.chain?.id, this.chainId);
|
|
240
264
|
const { userAddress, positionData, slippageTolerance = DEFAULT_SLIPPAGE_TOLERANCE, } = params;
|
|
241
|
-
if ("
|
|
265
|
+
if ("amount" in params && "shares" in params) {
|
|
242
266
|
throw new MutuallyExclusiveRepayAmountsError(this.marketParams.id);
|
|
243
267
|
}
|
|
244
|
-
const
|
|
245
|
-
if (
|
|
246
|
-
|
|
247
|
-
throw new NonPositiveRepayAmountError(this.marketParams.id);
|
|
248
|
-
}
|
|
249
|
-
}
|
|
250
|
-
else {
|
|
251
|
-
if (params.assets <= 0n) {
|
|
252
|
-
throw new NonPositiveRepayAmountError(this.marketParams.id);
|
|
253
|
-
}
|
|
268
|
+
const nativeAmount = params.nativeAmount ?? 0n;
|
|
269
|
+
if (nativeAmount < 0n) {
|
|
270
|
+
throw new NegativeNativeAmountError(nativeAmount);
|
|
254
271
|
}
|
|
255
272
|
validateSlippageTolerance(slippageTolerance);
|
|
256
273
|
if (!positionData) {
|
|
@@ -261,67 +278,116 @@ export class MorphoBlue {
|
|
|
261
278
|
expectedMarketId: this.marketParams.id,
|
|
262
279
|
expectedUser: userAddress,
|
|
263
280
|
});
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
281
|
+
if (nativeAmount > 0n) {
|
|
282
|
+
validateNativeAsset(this.chainId, this.marketParams.loanToken);
|
|
283
|
+
}
|
|
284
|
+
let repayAssets;
|
|
285
|
+
let repayShares;
|
|
286
|
+
let erc20Amount;
|
|
267
287
|
let marketForRepay;
|
|
268
|
-
if (
|
|
288
|
+
if ("shares" in params) {
|
|
289
|
+
const shares = params.shares;
|
|
290
|
+
if (shares <= 0n) {
|
|
291
|
+
throw new NonPositiveRepayAmountError(this.marketParams.id);
|
|
292
|
+
}
|
|
269
293
|
validateRepayShares({
|
|
270
294
|
positionData,
|
|
271
|
-
repayShares:
|
|
295
|
+
repayShares: shares,
|
|
272
296
|
marketId: this.marketParams.id,
|
|
273
297
|
});
|
|
274
|
-
|
|
275
|
-
|
|
298
|
+
repayAssets = 0n;
|
|
299
|
+
repayShares = shares;
|
|
276
300
|
// 2h forward accrual upper-bounds the on-chain repay price; bundle
|
|
277
301
|
// skims residual back to the receiver.
|
|
278
302
|
const accrualTimestamp = MathLib.max(Time.timestamp(), positionData.market.lastUpdate) +
|
|
279
303
|
Time.s.from.h(2n);
|
|
280
304
|
marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
281
|
-
|
|
305
|
+
const borrowAssets = marketForRepay.toBorrowAssets(shares, "Up");
|
|
306
|
+
// Native funds part of the transfer; the ERC-20 pulled is the remainder.
|
|
307
|
+
if (nativeAmount > borrowAssets) {
|
|
308
|
+
throw new NativeAmountExceedsTransferAmountError({
|
|
309
|
+
nativeAmount,
|
|
310
|
+
transferAmount: borrowAssets,
|
|
311
|
+
market: this.marketParams.id,
|
|
312
|
+
});
|
|
313
|
+
}
|
|
314
|
+
erc20Amount = borrowAssets - nativeAmount;
|
|
282
315
|
}
|
|
283
316
|
else {
|
|
317
|
+
// Assets mode is additive, like supply: repaid = amount + nativeAmount.
|
|
318
|
+
const amount = params.amount ?? 0n;
|
|
319
|
+
// Reject a negative ERC-20 amount before it can be masked by nativeAmount
|
|
320
|
+
// in the sum below (a negative amount would otherwise yield a negative
|
|
321
|
+
// erc20Amount and a negative approval in getRequirements).
|
|
322
|
+
if (amount < 0n) {
|
|
323
|
+
throw new NonPositiveRepayAmountError(this.marketParams.id);
|
|
324
|
+
}
|
|
325
|
+
repayAssets = amount + nativeAmount;
|
|
326
|
+
if (repayAssets <= 0n) {
|
|
327
|
+
throw new NonPositiveRepayAmountError(this.marketParams.id);
|
|
328
|
+
}
|
|
284
329
|
validateRepayAmount({
|
|
285
330
|
positionData,
|
|
286
|
-
repayAssets
|
|
331
|
+
repayAssets,
|
|
287
332
|
marketId: this.marketParams.id,
|
|
288
333
|
});
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
transferAmount = params.assets;
|
|
334
|
+
repayShares = 0n;
|
|
335
|
+
erc20Amount = amount;
|
|
292
336
|
marketForRepay = positionData.market;
|
|
293
337
|
}
|
|
294
338
|
const maxSharePrice = computeMaxRepaySharePrice({
|
|
295
|
-
repayAssets
|
|
296
|
-
repayShares
|
|
339
|
+
repayAssets,
|
|
340
|
+
repayShares,
|
|
297
341
|
market: marketForRepay,
|
|
298
342
|
slippageTolerance,
|
|
299
343
|
});
|
|
300
344
|
return {
|
|
301
|
-
getRequirements: (reqParams) =>
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
args: { amount: transferAmount, from: userAddress },
|
|
308
|
-
}),
|
|
309
|
-
buildTx: (requirementSignature) => blueRepay({
|
|
310
|
-
market: {
|
|
345
|
+
getRequirements: (reqParams) => {
|
|
346
|
+
// Fully native repay pulls no ERC-20, so it needs no approval/permit.
|
|
347
|
+
if (erc20Amount === 0n)
|
|
348
|
+
return Promise.resolve([]);
|
|
349
|
+
return getGeneralAdapterRequirements(this.client.viemClient, {
|
|
350
|
+
address: this.marketParams.loanToken,
|
|
311
351
|
chainId: this.chainId,
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
324
|
-
|
|
352
|
+
supportSignature: this.client.options.supportSignature,
|
|
353
|
+
supportDeployless: this.client.options.supportDeployless,
|
|
354
|
+
useSimplePermit: reqParams?.useSimplePermit,
|
|
355
|
+
args: { amount: erc20Amount, from: userAddress },
|
|
356
|
+
});
|
|
357
|
+
},
|
|
358
|
+
buildTx: (signatures) => {
|
|
359
|
+
const { permit } = selectRequirementSignatures(signatures, {
|
|
360
|
+
permit: true,
|
|
361
|
+
});
|
|
362
|
+
return blueRepay({
|
|
363
|
+
market: {
|
|
364
|
+
chainId: this.chainId,
|
|
365
|
+
marketParams: this.marketParams,
|
|
366
|
+
},
|
|
367
|
+
// Shares mode: repay `shares`, ERC-20 to pull = `erc20Amount`.
|
|
368
|
+
// Assets mode: repay `repayAssets` (= amount + native), pull `erc20Amount`.
|
|
369
|
+
args: repayShares > 0n
|
|
370
|
+
? {
|
|
371
|
+
shares: repayShares,
|
|
372
|
+
transferAmount: erc20Amount,
|
|
373
|
+
nativeAmount,
|
|
374
|
+
onBehalf: userAddress,
|
|
375
|
+
receiver: userAddress,
|
|
376
|
+
maxSharePrice,
|
|
377
|
+
requirementSignature: permit,
|
|
378
|
+
}
|
|
379
|
+
: {
|
|
380
|
+
amount: erc20Amount,
|
|
381
|
+
transferAmount: repayAssets,
|
|
382
|
+
nativeAmount,
|
|
383
|
+
onBehalf: userAddress,
|
|
384
|
+
receiver: userAddress,
|
|
385
|
+
maxSharePrice,
|
|
386
|
+
requirementSignature: permit,
|
|
387
|
+
},
|
|
388
|
+
metadata: this.client.options.metadata,
|
|
389
|
+
});
|
|
390
|
+
},
|
|
325
391
|
};
|
|
326
392
|
}
|
|
327
393
|
withdrawCollateral({ userAddress, amount, positionData, }) {
|
|
@@ -368,19 +434,12 @@ export class MorphoBlue {
|
|
|
368
434
|
repayWithdrawCollateral(params) {
|
|
369
435
|
validateChainId(this.client.viemClient.chain?.id, this.chainId);
|
|
370
436
|
const { userAddress, withdrawAmount, positionData, slippageTolerance = DEFAULT_SLIPPAGE_TOLERANCE, } = params;
|
|
371
|
-
if ("
|
|
437
|
+
if ("amount" in params && "shares" in params) {
|
|
372
438
|
throw new MutuallyExclusiveRepayAmountsError(this.marketParams.id);
|
|
373
439
|
}
|
|
374
|
-
const
|
|
375
|
-
if (
|
|
376
|
-
|
|
377
|
-
throw new NonPositiveRepayAmountError(this.marketParams.id);
|
|
378
|
-
}
|
|
379
|
-
}
|
|
380
|
-
else {
|
|
381
|
-
if (params.assets <= 0n) {
|
|
382
|
-
throw new NonPositiveRepayAmountError(this.marketParams.id);
|
|
383
|
-
}
|
|
440
|
+
const nativeAmount = params.nativeAmount ?? 0n;
|
|
441
|
+
if (nativeAmount < 0n) {
|
|
442
|
+
throw new NegativeNativeAmountError(nativeAmount);
|
|
384
443
|
}
|
|
385
444
|
if (withdrawAmount <= 0n) {
|
|
386
445
|
throw new NonPositiveWithdrawCollateralAmountError(this.marketParams.id);
|
|
@@ -394,34 +453,61 @@ export class MorphoBlue {
|
|
|
394
453
|
expectedMarketId: this.marketParams.id,
|
|
395
454
|
expectedUser: userAddress,
|
|
396
455
|
});
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
456
|
+
if (nativeAmount > 0n) {
|
|
457
|
+
validateNativeAsset(this.chainId, this.marketParams.loanToken);
|
|
458
|
+
}
|
|
459
|
+
let repayAssets;
|
|
460
|
+
let repayShares;
|
|
461
|
+
let erc20Amount;
|
|
400
462
|
let marketForRepay;
|
|
401
463
|
// 2h forward accrual upper-bounds the on-chain repay price (shares
|
|
402
464
|
// mode) and the post-repay health check; bundle skims residual back.
|
|
403
465
|
const accrualTimestamp = MathLib.max(Time.timestamp(), positionData.market.lastUpdate) +
|
|
404
466
|
Time.s.from.h(2n);
|
|
405
|
-
if (
|
|
467
|
+
if ("shares" in params) {
|
|
468
|
+
const shares = params.shares;
|
|
469
|
+
if (shares <= 0n) {
|
|
470
|
+
throw new NonPositiveRepayAmountError(this.marketParams.id);
|
|
471
|
+
}
|
|
406
472
|
validateRepayShares({
|
|
407
473
|
positionData,
|
|
408
|
-
repayShares:
|
|
474
|
+
repayShares: shares,
|
|
409
475
|
marketId: this.marketParams.id,
|
|
410
476
|
});
|
|
411
|
-
|
|
412
|
-
|
|
477
|
+
repayAssets = 0n;
|
|
478
|
+
repayShares = shares;
|
|
413
479
|
marketForRepay = positionData.market.accrueInterest(accrualTimestamp);
|
|
414
|
-
|
|
480
|
+
const borrowAssets = marketForRepay.toBorrowAssets(shares, "Up");
|
|
481
|
+
// Native funds part of the transfer; the ERC-20 pulled is the remainder.
|
|
482
|
+
if (nativeAmount > borrowAssets) {
|
|
483
|
+
throw new NativeAmountExceedsTransferAmountError({
|
|
484
|
+
nativeAmount,
|
|
485
|
+
transferAmount: borrowAssets,
|
|
486
|
+
market: this.marketParams.id,
|
|
487
|
+
});
|
|
488
|
+
}
|
|
489
|
+
erc20Amount = borrowAssets - nativeAmount;
|
|
415
490
|
}
|
|
416
491
|
else {
|
|
492
|
+
// Assets mode is additive, like supply: repaid = amount + nativeAmount.
|
|
493
|
+
const amount = params.amount ?? 0n;
|
|
494
|
+
// Reject a negative ERC-20 amount before it can be masked by nativeAmount
|
|
495
|
+
// in the sum below (a negative amount would otherwise yield a negative
|
|
496
|
+
// erc20Amount and a negative approval in getRequirements).
|
|
497
|
+
if (amount < 0n) {
|
|
498
|
+
throw new NonPositiveRepayAmountError(this.marketParams.id);
|
|
499
|
+
}
|
|
500
|
+
repayAssets = amount + nativeAmount;
|
|
501
|
+
if (repayAssets <= 0n) {
|
|
502
|
+
throw new NonPositiveRepayAmountError(this.marketParams.id);
|
|
503
|
+
}
|
|
417
504
|
validateRepayAmount({
|
|
418
505
|
positionData,
|
|
419
|
-
repayAssets
|
|
506
|
+
repayAssets,
|
|
420
507
|
marketId: this.marketParams.id,
|
|
421
508
|
});
|
|
422
|
-
|
|
423
|
-
|
|
424
|
-
transferAmount = params.assets;
|
|
509
|
+
repayShares = 0n;
|
|
510
|
+
erc20Amount = amount;
|
|
425
511
|
marketForRepay = positionData.market;
|
|
426
512
|
}
|
|
427
513
|
if (withdrawAmount > positionData.collateral) {
|
|
@@ -431,7 +517,7 @@ export class MorphoBlue {
|
|
|
431
517
|
market: positionData.marketId,
|
|
432
518
|
});
|
|
433
519
|
}
|
|
434
|
-
const { position: positionAfterRepay } = positionData.repay(
|
|
520
|
+
const { position: positionAfterRepay } = positionData.repay(repayAssets, repayShares, accrualTimestamp);
|
|
435
521
|
validatePositionHealthAfterWithdraw({
|
|
436
522
|
positionData: positionAfterRepay,
|
|
437
523
|
withdrawAmount,
|
|
@@ -439,47 +525,69 @@ export class MorphoBlue {
|
|
|
439
525
|
marketId: this.marketParams.id,
|
|
440
526
|
});
|
|
441
527
|
const maxSharePrice = computeMaxRepaySharePrice({
|
|
442
|
-
repayAssets
|
|
443
|
-
repayShares
|
|
528
|
+
repayAssets,
|
|
529
|
+
repayShares,
|
|
444
530
|
market: marketForRepay,
|
|
445
531
|
slippageTolerance,
|
|
446
532
|
});
|
|
447
533
|
return {
|
|
448
534
|
getRequirements: async (reqParams) => {
|
|
449
535
|
const [erc20Requirements, authTx] = await Promise.all([
|
|
450
|
-
|
|
451
|
-
|
|
452
|
-
|
|
453
|
-
|
|
454
|
-
|
|
455
|
-
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
536
|
+
// Fully native repay pulls no ERC-20, so it needs no approval/permit.
|
|
537
|
+
erc20Amount === 0n
|
|
538
|
+
? Promise.resolve([])
|
|
539
|
+
: getGeneralAdapterRequirements(this.client.viemClient, {
|
|
540
|
+
address: this.marketParams.loanToken,
|
|
541
|
+
chainId: this.chainId,
|
|
542
|
+
supportSignature: this.client.options.supportSignature,
|
|
543
|
+
supportDeployless: this.client.options.supportDeployless,
|
|
544
|
+
useSimplePermit: reqParams?.useSimplePermit,
|
|
545
|
+
args: { amount: erc20Amount, from: userAddress },
|
|
546
|
+
}),
|
|
547
|
+
getBlueAuthorizationRequirement({
|
|
459
548
|
viemClient: this.client.viemClient,
|
|
460
549
|
chainId: this.chainId,
|
|
461
550
|
userAddress,
|
|
551
|
+
supportSignature: this.client.options.supportSignature,
|
|
462
552
|
}),
|
|
463
553
|
]);
|
|
464
554
|
return [...erc20Requirements, ...(authTx ? [authTx] : [])];
|
|
465
555
|
},
|
|
466
|
-
buildTx: (
|
|
467
|
-
|
|
468
|
-
|
|
469
|
-
|
|
470
|
-
|
|
471
|
-
|
|
472
|
-
|
|
473
|
-
shares
|
|
474
|
-
|
|
475
|
-
|
|
476
|
-
|
|
477
|
-
|
|
478
|
-
|
|
479
|
-
|
|
480
|
-
|
|
481
|
-
|
|
482
|
-
|
|
556
|
+
buildTx: (signatures) => {
|
|
557
|
+
const { permit, authorization } = selectRequirementSignatures(signatures, { permit: true, authorization: true });
|
|
558
|
+
return blueRepayWithdrawCollateral({
|
|
559
|
+
market: {
|
|
560
|
+
chainId: this.chainId,
|
|
561
|
+
marketParams: this.marketParams,
|
|
562
|
+
},
|
|
563
|
+
// Shares mode: repay `shares`, ERC-20 to pull = `erc20Amount`.
|
|
564
|
+
// Assets mode: repay `repayAssets` (= amount + native), pull `erc20Amount`.
|
|
565
|
+
args: repayShares > 0n
|
|
566
|
+
? {
|
|
567
|
+
shares: repayShares,
|
|
568
|
+
transferAmount: erc20Amount,
|
|
569
|
+
nativeAmount,
|
|
570
|
+
withdrawAmount,
|
|
571
|
+
onBehalf: userAddress,
|
|
572
|
+
receiver: userAddress,
|
|
573
|
+
maxSharePrice,
|
|
574
|
+
requirementSignature: permit,
|
|
575
|
+
authorizationSignature: authorization,
|
|
576
|
+
}
|
|
577
|
+
: {
|
|
578
|
+
amount: erc20Amount,
|
|
579
|
+
transferAmount: repayAssets,
|
|
580
|
+
nativeAmount,
|
|
581
|
+
withdrawAmount,
|
|
582
|
+
onBehalf: userAddress,
|
|
583
|
+
receiver: userAddress,
|
|
584
|
+
maxSharePrice,
|
|
585
|
+
requirementSignature: permit,
|
|
586
|
+
authorizationSignature: authorization,
|
|
587
|
+
},
|
|
588
|
+
metadata: this.client.options.metadata,
|
|
589
|
+
});
|
|
590
|
+
},
|
|
483
591
|
};
|
|
484
592
|
}
|
|
485
593
|
supplyCollateralBorrow({ amount = 0n, userAddress, positionData, borrowAmount, nativeAmount, slippageTolerance = DEFAULT_SLIPPAGE_TOLERANCE, reallocations, }) {
|
|
@@ -524,7 +632,7 @@ export class MorphoBlue {
|
|
|
524
632
|
return {
|
|
525
633
|
getRequirements: async (params) => {
|
|
526
634
|
const [erc20Requirements, authTx] = await Promise.all([
|
|
527
|
-
|
|
635
|
+
getGeneralAdapterRequirements(this.client.viemClient, {
|
|
528
636
|
address: this.marketParams.collateralToken,
|
|
529
637
|
chainId: this.chainId,
|
|
530
638
|
supportSignature: this.client.options.supportSignature,
|
|
@@ -532,31 +640,36 @@ export class MorphoBlue {
|
|
|
532
640
|
useSimplePermit: params?.useSimplePermit,
|
|
533
641
|
args: { amount, from: userAddress },
|
|
534
642
|
}),
|
|
535
|
-
|
|
643
|
+
getBlueAuthorizationRequirement({
|
|
536
644
|
viemClient: this.client.viemClient,
|
|
537
645
|
chainId: this.chainId,
|
|
538
646
|
userAddress,
|
|
647
|
+
supportSignature: this.client.options.supportSignature,
|
|
539
648
|
}),
|
|
540
649
|
]);
|
|
541
650
|
return [...erc20Requirements, ...(authTx ? [authTx] : [])];
|
|
542
651
|
},
|
|
543
|
-
buildTx: (
|
|
544
|
-
|
|
545
|
-
|
|
546
|
-
|
|
547
|
-
|
|
548
|
-
|
|
549
|
-
|
|
550
|
-
|
|
551
|
-
|
|
552
|
-
|
|
553
|
-
|
|
554
|
-
|
|
555
|
-
|
|
556
|
-
|
|
557
|
-
|
|
558
|
-
|
|
559
|
-
|
|
652
|
+
buildTx: (signatures) => {
|
|
653
|
+
const { permit, authorization } = selectRequirementSignatures(signatures, { permit: true, authorization: true });
|
|
654
|
+
return blueSupplyCollateralBorrow({
|
|
655
|
+
market: {
|
|
656
|
+
chainId: this.chainId,
|
|
657
|
+
marketParams: this.marketParams,
|
|
658
|
+
},
|
|
659
|
+
args: {
|
|
660
|
+
amount,
|
|
661
|
+
nativeAmount,
|
|
662
|
+
borrowAmount,
|
|
663
|
+
onBehalf: userAddress,
|
|
664
|
+
receiver: userAddress,
|
|
665
|
+
minSharePrice,
|
|
666
|
+
requirementSignature: permit,
|
|
667
|
+
authorizationSignature: authorization,
|
|
668
|
+
reallocations,
|
|
669
|
+
},
|
|
670
|
+
metadata: this.client.options.metadata,
|
|
671
|
+
});
|
|
672
|
+
},
|
|
560
673
|
};
|
|
561
674
|
}
|
|
562
675
|
refinance({ userAddress, positionData, target, collateralAmount, borrowAssets, borrowShares, slippageTolerance = DEFAULT_SLIPPAGE_TOLERANCE, targetReallocations, }) {
|
|
@@ -690,30 +803,37 @@ export class MorphoBlue {
|
|
|
690
803
|
: 0n;
|
|
691
804
|
return {
|
|
692
805
|
getRequirements: async () => {
|
|
693
|
-
const authTx = await
|
|
806
|
+
const authTx = await getBlueAuthorizationRequirement({
|
|
694
807
|
viemClient: this.client.viemClient,
|
|
695
808
|
chainId: this.chainId,
|
|
696
809
|
userAddress,
|
|
810
|
+
supportSignature: this.client.options.supportSignature,
|
|
697
811
|
});
|
|
698
812
|
return authTx ? [authTx] : [];
|
|
699
813
|
},
|
|
700
|
-
buildTx: () =>
|
|
701
|
-
|
|
702
|
-
|
|
703
|
-
|
|
704
|
-
|
|
705
|
-
|
|
706
|
-
|
|
707
|
-
|
|
708
|
-
|
|
709
|
-
|
|
710
|
-
|
|
711
|
-
|
|
712
|
-
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
|
|
716
|
-
|
|
814
|
+
buildTx: (signatures) => {
|
|
815
|
+
const { authorization } = selectRequirementSignatures(signatures, {
|
|
816
|
+
authorization: true,
|
|
817
|
+
});
|
|
818
|
+
return blueRefinance({
|
|
819
|
+
source: {
|
|
820
|
+
chainId: this.chainId,
|
|
821
|
+
marketParams: this.marketParams,
|
|
822
|
+
},
|
|
823
|
+
target: { marketParams: target.marketParams },
|
|
824
|
+
args: {
|
|
825
|
+
user: userAddress,
|
|
826
|
+
collateralAmount,
|
|
827
|
+
borrowAssets: borrowAssetsAdjusted,
|
|
828
|
+
borrowShares: requestedShares,
|
|
829
|
+
minBorrowSharePrice,
|
|
830
|
+
maxRepaySharePrice,
|
|
831
|
+
targetReallocations,
|
|
832
|
+
authorizationSignature: authorization,
|
|
833
|
+
},
|
|
834
|
+
metadata: this.client.options.metadata,
|
|
835
|
+
});
|
|
836
|
+
},
|
|
717
837
|
};
|
|
718
838
|
}
|
|
719
839
|
/**
|