@morpho-org/morpho-sdk 6.5.0 → 7.0.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-v6-to-v7.md +291 -0
- package/README.md +26 -12
- package/lib/cjs/abis.d.ts +1 -1
- package/lib/cjs/abis.js +3 -2
- package/lib/cjs/actions/bundles/common.d.ts +9 -5
- package/lib/cjs/actions/bundles/common.js +22 -13
- package/lib/cjs/actions/midnight/authorization.d.ts +3 -2
- package/lib/cjs/actions/midnight/authorization.js +3 -2
- package/lib/cjs/actions/midnight/cancelAndMake.d.ts +153 -0
- package/lib/cjs/actions/midnight/cancelAndMake.js +292 -0
- package/lib/cjs/actions/midnight/index.d.ts +3 -3
- package/lib/cjs/actions/midnight/index.js +3 -3
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.d.ts +40 -23
- package/lib/cjs/actions/midnight/repayWithdrawCollateral.js +105 -69
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.d.ts +52 -27
- package/lib/cjs/actions/midnight/supplyCollateralTakeBorrow.js +128 -71
- package/lib/cjs/actions/midnight/takeBorrow.d.ts +40 -28
- package/lib/cjs/actions/midnight/takeBorrow.js +95 -54
- package/lib/cjs/actions/midnight/takeLend.d.ts +51 -27
- package/lib/cjs/actions/midnight/takeLend.js +111 -54
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.d.ts +97 -0
- package/lib/cjs/actions/midnight/takeRepayWithdrawCollateral.js +201 -0
- package/lib/cjs/actions/midnight/takeWithdraw.d.ts +69 -0
- package/lib/cjs/actions/midnight/takeWithdraw.js +153 -0
- package/lib/cjs/actions/midnight/types.d.ts +7 -26
- package/lib/cjs/actions/midnight/types.js +0 -13
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/cjs/actions/requirements/encode/encodeErc20Approval.js +3 -2
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.d.ts +4 -4
- package/lib/cjs/actions/requirements/encode/encodeErc20Permit.js +5 -5
- package/lib/cjs/actions/requirements/getRequirementsApproval.d.ts +2 -2
- package/lib/cjs/actions/requirements/getRequirementsApproval.js +2 -2
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +24 -8
- package/lib/cjs/actions/requirements/midnight/getMidnightApprovalRequirements.js +24 -13
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -7
- package/lib/cjs/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +11 -7
- package/lib/cjs/actions/requirements/midnight/index.d.ts +0 -1
- package/lib/cjs/actions/requirements/midnight/index.js +0 -1
- package/lib/cjs/constants.d.ts +1 -1
- package/lib/cjs/constants.js +3 -1
- package/lib/cjs/entities/blue/blue.d.ts +10 -6
- package/lib/cjs/entities/blue/blue.js +5 -3
- package/lib/cjs/entities/index.d.ts +2 -2
- package/lib/cjs/entities/midnight/midnight.d.ts +582 -108
- package/lib/cjs/entities/midnight/midnight.js +981 -509
- package/lib/cjs/entities/midnight/types.d.ts +142 -60
- package/lib/cjs/entities/vaultV1/vaultV1.d.ts +2 -1
- package/lib/cjs/entities/vaultV1/vaultV1.js +1 -0
- package/lib/cjs/entities/vaultV2/vaultV2.d.ts +2 -1
- package/lib/cjs/entities/vaultV2/vaultV2.js +1 -0
- package/lib/cjs/entities/vaultV2BlueReallocationData.d.ts +11 -3
- package/lib/cjs/entities/vaultV2BlueReallocationData.js +119 -43
- package/lib/cjs/helpers/callback.d.ts +54 -0
- package/lib/cjs/helpers/callback.js +73 -0
- package/lib/cjs/helpers/constant.d.ts +10 -0
- package/lib/cjs/helpers/constant.js +11 -1
- package/lib/cjs/helpers/index.d.ts +3 -2
- package/lib/cjs/helpers/index.js +7 -1
- package/lib/cjs/helpers/signAndVerifyTypedData.d.ts +3 -3
- package/lib/cjs/helpers/signAndVerifyTypedData.js +3 -3
- package/lib/cjs/helpers/utilization.d.ts +13 -0
- package/lib/cjs/helpers/utilization.js +26 -1
- package/lib/cjs/helpers/validate.d.ts +43 -2
- package/lib/cjs/helpers/validate.js +60 -3
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
- package/lib/cjs/helpers/validateMidnightAuthorizationTarget.js +3 -7
- package/lib/cjs/helpers/validateRequirementSpender.d.ts +3 -3
- package/lib/cjs/helpers/validateRequirementSpender.js +4 -5
- package/lib/cjs/midnight/abis.d.ts +1 -1
- package/lib/cjs/midnight/abis.js +3 -2
- package/lib/cjs/midnight/types.d.ts +1 -1
- package/lib/cjs/types/action.d.ts +117 -89
- package/lib/cjs/types/action.js +1 -19
- package/lib/cjs/types/error.d.ts +126 -40
- package/lib/cjs/types/error.js +154 -49
- package/lib/cjs/types/sharedLiquidity.d.ts +17 -0
- package/lib/esm/abis.d.ts +1 -1
- package/lib/esm/abis.js +1 -1
- package/lib/esm/actions/bundles/common.d.ts +9 -5
- package/lib/esm/actions/bundles/common.js +22 -13
- package/lib/esm/actions/midnight/authorization.d.ts +3 -2
- package/lib/esm/actions/midnight/authorization.js +3 -2
- package/lib/esm/actions/midnight/cancelAndMake.d.ts +153 -0
- package/lib/esm/actions/midnight/cancelAndMake.js +288 -0
- package/lib/esm/actions/midnight/index.d.ts +3 -3
- package/lib/esm/actions/midnight/index.js +3 -3
- package/lib/esm/actions/midnight/repayWithdrawCollateral.d.ts +40 -23
- package/lib/esm/actions/midnight/repayWithdrawCollateral.js +108 -72
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.d.ts +52 -27
- package/lib/esm/actions/midnight/supplyCollateralTakeBorrow.js +131 -74
- package/lib/esm/actions/midnight/takeBorrow.d.ts +40 -28
- package/lib/esm/actions/midnight/takeBorrow.js +98 -57
- package/lib/esm/actions/midnight/takeLend.d.ts +51 -27
- package/lib/esm/actions/midnight/takeLend.js +114 -57
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.d.ts +97 -0
- package/lib/esm/actions/midnight/takeRepayWithdrawCollateral.js +197 -0
- package/lib/esm/actions/midnight/takeWithdraw.d.ts +69 -0
- package/lib/esm/actions/midnight/takeWithdraw.js +149 -0
- package/lib/esm/actions/midnight/types.d.ts +7 -26
- package/lib/esm/actions/midnight/types.js +1 -12
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.d.ts +2 -1
- package/lib/esm/actions/requirements/encode/encodeErc20Approval.js +3 -2
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.d.ts +4 -4
- package/lib/esm/actions/requirements/encode/encodeErc20Permit.js +5 -5
- package/lib/esm/actions/requirements/getRequirementsApproval.d.ts +2 -2
- package/lib/esm/actions/requirements/getRequirementsApproval.js +2 -2
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.d.ts +24 -8
- package/lib/esm/actions/requirements/midnight/getMidnightApprovalRequirements.js +25 -14
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.d.ts +11 -7
- package/lib/esm/actions/requirements/midnight/getMidnightAuthorizationRequirement.js +11 -7
- package/lib/esm/actions/requirements/midnight/index.d.ts +0 -1
- package/lib/esm/actions/requirements/midnight/index.js +0 -1
- package/lib/esm/constants.d.ts +1 -1
- package/lib/esm/constants.js +1 -1
- package/lib/esm/entities/blue/blue.d.ts +10 -6
- package/lib/esm/entities/blue/blue.js +5 -3
- package/lib/esm/entities/index.d.ts +2 -2
- package/lib/esm/entities/midnight/midnight.d.ts +582 -108
- package/lib/esm/entities/midnight/midnight.js +987 -515
- package/lib/esm/entities/midnight/types.d.ts +142 -60
- package/lib/esm/entities/vaultV1/vaultV1.d.ts +2 -1
- package/lib/esm/entities/vaultV1/vaultV1.js +1 -0
- package/lib/esm/entities/vaultV2/vaultV2.d.ts +2 -1
- package/lib/esm/entities/vaultV2/vaultV2.js +1 -0
- package/lib/esm/entities/vaultV2BlueReallocationData.d.ts +11 -3
- package/lib/esm/entities/vaultV2BlueReallocationData.js +120 -44
- package/lib/esm/helpers/callback.d.ts +54 -0
- package/lib/esm/helpers/callback.js +68 -0
- package/lib/esm/helpers/constant.d.ts +10 -0
- package/lib/esm/helpers/constant.js +10 -0
- package/lib/esm/helpers/index.d.ts +3 -2
- package/lib/esm/helpers/index.js +3 -2
- package/lib/esm/helpers/signAndVerifyTypedData.d.ts +3 -3
- package/lib/esm/helpers/signAndVerifyTypedData.js +3 -3
- package/lib/esm/helpers/utilization.d.ts +13 -0
- package/lib/esm/helpers/utilization.js +25 -1
- package/lib/esm/helpers/validate.d.ts +43 -2
- package/lib/esm/helpers/validate.js +58 -2
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.d.ts +1 -1
- package/lib/esm/helpers/validateMidnightAuthorizationTarget.js +3 -7
- package/lib/esm/helpers/validateRequirementSpender.d.ts +3 -3
- package/lib/esm/helpers/validateRequirementSpender.js +4 -5
- package/lib/esm/midnight/abis.d.ts +1 -1
- package/lib/esm/midnight/abis.js +1 -1
- package/lib/esm/midnight/types.d.ts +1 -1
- package/lib/esm/types/action.d.ts +117 -89
- package/lib/esm/types/action.js +1 -18
- package/lib/esm/types/error.d.ts +126 -40
- package/lib/esm/types/error.js +135 -38
- package/lib/esm/types/sharedLiquidity.d.ts +17 -0
- package/package.json +9 -8
- package/lib/cjs/actions/midnight/cancelOffer.d.ts +0 -38
- package/lib/cjs/actions/midnight/cancelOffer.js +0 -73
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
- package/lib/cjs/actions/midnight/mempoolSubmitOffers.js +0 -72
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
- package/lib/cjs/actions/midnight/setterRatifierRatifyRoot.js +0 -59
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
- package/lib/cjs/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -70
- package/lib/esm/actions/midnight/cancelOffer.d.ts +0 -38
- package/lib/esm/actions/midnight/cancelOffer.js +0 -69
- package/lib/esm/actions/midnight/mempoolSubmitOffers.d.ts +0 -52
- package/lib/esm/actions/midnight/mempoolSubmitOffers.js +0 -68
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.d.ts +0 -40
- package/lib/esm/actions/midnight/setterRatifierRatifyRoot.js +0 -55
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.d.ts +0 -42
- package/lib/esm/actions/requirements/midnight/getSetterRatifierRatifyRootRequirement.js +0 -66
package/lib/esm/types/error.js
CHANGED
|
@@ -559,7 +559,8 @@ export class BundlesPermitMismatchError extends Error {
|
|
|
559
559
|
/**
|
|
560
560
|
* @param params - Permit mismatch values used to explain the rejection.
|
|
561
561
|
* @param params.field - Permit field that does not match the exit.
|
|
562
|
-
* @param params.expected - Value required by the exit.
|
|
562
|
+
* @param params.expected - Value required by the exit. For `field: "amount"` on an
|
|
563
|
+
* operation that accepts a range of permit amounts, an inclusive `"[min, max]"` range.
|
|
563
564
|
* @param params.actual - Value supplied by the signature.
|
|
564
565
|
* @param params.cause - Original parser failure when signature decoding is wrapped.
|
|
565
566
|
*/
|
|
@@ -836,17 +837,13 @@ export class ApprovalAmountLessThanSpendAmountError extends Error {
|
|
|
836
837
|
/** Thrown when a requirement encoder targets an unsupported spender. */
|
|
837
838
|
export class UnsupportedErc20ApprovalSpenderError extends Error {
|
|
838
839
|
constructor(params) {
|
|
839
|
-
const supported = (params.supportedSpenders ?? [
|
|
840
|
-
params.permit2,
|
|
841
|
-
params.midnight,
|
|
842
|
-
params.midnightBundles,
|
|
843
|
-
])
|
|
840
|
+
const supported = (params.supportedSpenders ?? [params.permit2, params.midnight])
|
|
844
841
|
.filter((address) => address != null)
|
|
845
842
|
.join('", "');
|
|
846
843
|
super(`Requirement spender "${params.spender}" is not supported on chain "${params.chainId}". Use "${supported}".`);
|
|
847
844
|
}
|
|
848
845
|
}
|
|
849
|
-
/** Thrown when a Midnight authorization requirement
|
|
846
|
+
/** Thrown when a Midnight authorization target (a requirement operator, or the ratifier that `midnightCancelAndMake` activates and MidnightBundlesV2 authorizes) is not registered for the chain. */
|
|
850
847
|
export class UnsupportedMidnightAuthorizationTargetError extends Error {
|
|
851
848
|
constructor(params) {
|
|
852
849
|
super(`Midnight authorization target "${params.authorized}" is not supported on chain "${params.chainId}". Use "${params.supportedTargets.join('", "')}".`);
|
|
@@ -1209,10 +1206,22 @@ export class ReallocationAdapterSupplySharesUnderflowError extends Error {
|
|
|
1209
1206
|
this.params = params;
|
|
1210
1207
|
}
|
|
1211
1208
|
}
|
|
1212
|
-
/** Thrown when a Midnight
|
|
1213
|
-
export class
|
|
1209
|
+
/** Thrown when a Midnight batch cancellation has no offer groups. */
|
|
1210
|
+
export class EmptyMidnightGroupCancellationsError extends Error {
|
|
1211
|
+
constructor() {
|
|
1212
|
+
super("Midnight group cancellations cannot be empty. Pass at least one offer group to cancel.");
|
|
1213
|
+
}
|
|
1214
|
+
}
|
|
1215
|
+
/** Thrown when a Midnight flow passes a collateral market with no collateral supplies. */
|
|
1216
|
+
export class EmptyMidnightCollateralSuppliesError extends Error {
|
|
1217
|
+
constructor() {
|
|
1218
|
+
super("Midnight collateral supplies cannot be empty. Pass at least one collateral supply, or use `makeBorrow` to publish without collateral.");
|
|
1219
|
+
}
|
|
1220
|
+
}
|
|
1221
|
+
/** Thrown when a Midnight batch cancellation lists the same offer group twice. */
|
|
1222
|
+
export class DuplicateMidnightGroupCancellationError extends Error {
|
|
1214
1223
|
constructor(params) {
|
|
1215
|
-
super(`Midnight
|
|
1224
|
+
super(`Midnight group cancellation "${params.index}" repeats group "${params.group}". Pass each offer group once.`);
|
|
1216
1225
|
}
|
|
1217
1226
|
}
|
|
1218
1227
|
/** Thrown when a Midnight flow needs at least one takeable offer. */
|
|
@@ -1227,12 +1236,100 @@ export class MidnightOfferSideMismatchError extends Error {
|
|
|
1227
1236
|
super(`Midnight offer "${params.index}" has buy="${params.actualBuy}", expected "${params.expectedBuy}". Use the matching flow or rebuild the offer list.`);
|
|
1228
1237
|
}
|
|
1229
1238
|
}
|
|
1239
|
+
/** Thrown when a Midnight maker method that is not a limit exit receives a reduce-only offer. */
|
|
1240
|
+
export class MidnightOfferReduceOnlyError extends Error {
|
|
1241
|
+
constructor(params) {
|
|
1242
|
+
super(`Midnight offer "${params.index}" is reduce-only. Rebuild the offer with reduceOnly=false; reduce-only exits need a dedicated exit flow.`);
|
|
1243
|
+
}
|
|
1244
|
+
}
|
|
1230
1245
|
/** Thrown when a Midnight maker offer belongs to a different account than the action flow. */
|
|
1231
1246
|
export class MidnightOfferMakerMismatchError extends Error {
|
|
1232
1247
|
constructor(params) {
|
|
1233
1248
|
super(`Midnight offer "${params.index}" belongs to maker "${params.actualMaker}", expected "${params.expectedMaker}". Rebuild the offer set for the active account.`);
|
|
1234
1249
|
}
|
|
1235
1250
|
}
|
|
1251
|
+
/** Thrown when a Midnight maker offer sets a nonzero continuous fee cap. */
|
|
1252
|
+
export class MidnightOfferContinuousFeeCapError extends Error {
|
|
1253
|
+
/** Offer index in the maker tree. */
|
|
1254
|
+
index;
|
|
1255
|
+
/** Continuous fee cap supplied on the offer. */
|
|
1256
|
+
continuousFeeCap;
|
|
1257
|
+
/**
|
|
1258
|
+
* @param params - Offer index and rejected fee cap.
|
|
1259
|
+
* @param params.index - Offer index in the maker tree.
|
|
1260
|
+
* @param params.continuousFeeCap - Continuous fee cap supplied on the offer.
|
|
1261
|
+
*/
|
|
1262
|
+
constructor(params) {
|
|
1263
|
+
super(`Midnight offer "${params.index}" has continuous fee cap "${params.continuousFeeCap}". Maker offers must use 0n; rebuild the offer with its fee cap set to zero.`);
|
|
1264
|
+
this.index = params.index;
|
|
1265
|
+
this.continuousFeeCap = params.continuousFeeCap;
|
|
1266
|
+
this.name = "MidnightOfferContinuousFeeCapError";
|
|
1267
|
+
}
|
|
1268
|
+
}
|
|
1269
|
+
/** Thrown when a Midnight sell offer routes its seller proceeds to another address. */
|
|
1270
|
+
export class MidnightOfferSellerReceiverMismatchError extends Error {
|
|
1271
|
+
/** Offer index in the maker tree. */
|
|
1272
|
+
index;
|
|
1273
|
+
/** Offer maker, which must receive seller proceeds. */
|
|
1274
|
+
expectedReceiver;
|
|
1275
|
+
/** Seller receiver supplied on the offer. */
|
|
1276
|
+
actualReceiver;
|
|
1277
|
+
/**
|
|
1278
|
+
* @param params - Offer index and expected and actual seller receivers.
|
|
1279
|
+
* @param params.index - Offer index in the maker tree.
|
|
1280
|
+
* @param params.expectedReceiver - Offer maker, which must receive seller proceeds.
|
|
1281
|
+
* @param params.actualReceiver - Seller receiver supplied on the offer.
|
|
1282
|
+
*/
|
|
1283
|
+
constructor(params) {
|
|
1284
|
+
super(`Midnight sell offer "${params.index}" routes seller proceeds to "${params.actualReceiver}", expected its maker "${params.expectedReceiver}". Set receiverIfMakerIsSeller to the maker address.`);
|
|
1285
|
+
this.index = params.index;
|
|
1286
|
+
this.expectedReceiver = params.expectedReceiver;
|
|
1287
|
+
this.actualReceiver = params.actualReceiver;
|
|
1288
|
+
this.name = "MidnightOfferSellerReceiverMismatchError";
|
|
1289
|
+
}
|
|
1290
|
+
}
|
|
1291
|
+
/** Thrown when a Midnight taker flow uses an unbounded target or deadline. */
|
|
1292
|
+
export class UnboundedMidnightTakeInputError extends Error {
|
|
1293
|
+
field;
|
|
1294
|
+
/**
|
|
1295
|
+
* @param field - Target or deadline input set to `maxUint256`.
|
|
1296
|
+
*/
|
|
1297
|
+
constructor(field) {
|
|
1298
|
+
super(`Midnight "${field}" cannot be maxUint256. Provide an explicit bounded value.`);
|
|
1299
|
+
this.field = field;
|
|
1300
|
+
this.name = "UnboundedMidnightTakeInputError";
|
|
1301
|
+
}
|
|
1302
|
+
}
|
|
1303
|
+
/** Thrown when a Midnight taker flow uses a zero address as its receiver. */
|
|
1304
|
+
export class MidnightZeroReceiverError extends Error {
|
|
1305
|
+
field;
|
|
1306
|
+
/**
|
|
1307
|
+
* @param field - Receiver field containing the zero address.
|
|
1308
|
+
*/
|
|
1309
|
+
constructor(field) {
|
|
1310
|
+
super(`Midnight "${field}" cannot be the zero address. Provide a valid recipient.`);
|
|
1311
|
+
this.field = field;
|
|
1312
|
+
this.name = "MidnightZeroReceiverError";
|
|
1313
|
+
}
|
|
1314
|
+
}
|
|
1315
|
+
/** Thrown when a Midnight take deadline is more than one hour from the current time. */
|
|
1316
|
+
export class MidnightTakeDeadlineTooFarError extends Error {
|
|
1317
|
+
/** Deadline supplied by the caller. */
|
|
1318
|
+
deadline;
|
|
1319
|
+
/** Accepted maximum deadline. */
|
|
1320
|
+
maxDeadline;
|
|
1321
|
+
/**
|
|
1322
|
+
* @param params - Supplied deadline and accepted maximum.
|
|
1323
|
+
* @param params.deadline - Deadline supplied by the caller.
|
|
1324
|
+
* @param params.maxDeadline - Latest accepted deadline.
|
|
1325
|
+
*/
|
|
1326
|
+
constructor(params) {
|
|
1327
|
+
super(`Midnight take deadline "${params.deadline}" is later than the one-hour limit "${params.maxDeadline}". Choose a deadline within the next hour.`);
|
|
1328
|
+
this.deadline = params.deadline;
|
|
1329
|
+
this.maxDeadline = params.maxDeadline;
|
|
1330
|
+
this.name = "MidnightTakeDeadlineTooFarError";
|
|
1331
|
+
}
|
|
1332
|
+
}
|
|
1236
1333
|
/** Thrown when a Midnight maker offer targets a different chain than the action flow. */
|
|
1237
1334
|
export class MidnightOfferMarketChainMismatchError extends Error {
|
|
1238
1335
|
constructor(params) {
|
|
@@ -1257,52 +1354,46 @@ export class MidnightOfferMarketLoanTokenMismatchError extends Error {
|
|
|
1257
1354
|
super(`Midnight offer "${params.index}" uses loan token "${params.actualLoanToken}", expected "${params.expectedLoanToken}". Rebuild the lend offer set for the approved loan token.`);
|
|
1258
1355
|
}
|
|
1259
1356
|
}
|
|
1260
|
-
/** Thrown when a
|
|
1261
|
-
export class
|
|
1357
|
+
/** Thrown when a Blue-funded Midnight lend offer does not use the maker's derived `BlueBuyCallback`. */
|
|
1358
|
+
export class MidnightOfferCallbackMismatchError extends Error {
|
|
1262
1359
|
constructor(params) {
|
|
1263
|
-
super(`Midnight
|
|
1360
|
+
super(`Midnight offer "${params.index}" uses callback "${params.actualCallback}", expected the maker's BlueBuyCallback "${params.expectedCallback}". Rebuild the offer with the derived callback.`);
|
|
1264
1361
|
}
|
|
1265
1362
|
}
|
|
1266
|
-
/** Thrown when a Midnight offer
|
|
1267
|
-
export class
|
|
1363
|
+
/** Thrown when a Blue-funded Midnight lend offer's callback data is not the ABI-encoded Blue market. */
|
|
1364
|
+
export class MidnightOfferCallbackDataMismatchError extends Error {
|
|
1268
1365
|
constructor(params) {
|
|
1269
|
-
super(`Midnight offer
|
|
1270
|
-
}
|
|
1271
|
-
}
|
|
1272
|
-
/** Thrown when a Midnight Ecrecover maker flow builds the submit transaction before signing. */
|
|
1273
|
-
export class MissingMidnightOfferRootSignatureError extends Error {
|
|
1274
|
-
constructor() {
|
|
1275
|
-
super("Midnight offer root signature is missing. Sign the offer-root requirement before building the submit transaction.");
|
|
1366
|
+
super(`Midnight offer "${params.index}" uses callback data "${params.actualCallbackData}", expected "${params.expectedCallbackData}". Set the callback data to the ABI-encoded Blue market the assets are parked in.`);
|
|
1276
1367
|
}
|
|
1277
1368
|
}
|
|
1278
|
-
/** Thrown when
|
|
1279
|
-
export class
|
|
1369
|
+
/** Thrown when loan assets would be parked in a Morpho Blue market with no existing supply. */
|
|
1370
|
+
export class EmptyBlueParkingMarketError extends Error {
|
|
1280
1371
|
constructor(params) {
|
|
1281
|
-
super(`
|
|
1372
|
+
super(`Morpho Blue market "${params.marketId}" has no supply shares. Parking assets in an empty market is exposed to supply-share-price inflation; choose a market with existing supply.`);
|
|
1282
1373
|
}
|
|
1283
1374
|
}
|
|
1284
|
-
/** Thrown when
|
|
1285
|
-
export class
|
|
1375
|
+
/** Thrown when parked assets would mint no Morpho Blue supply shares. */
|
|
1376
|
+
export class ZeroBlueParkingSharesError extends Error {
|
|
1286
1377
|
constructor(params) {
|
|
1287
|
-
super(`
|
|
1378
|
+
super(`Supplying "${params.assets}" assets to Morpho Blue market "${params.marketId}" mints zero supply shares at its current share price; park more assets or choose another market.`);
|
|
1288
1379
|
}
|
|
1289
1380
|
}
|
|
1290
|
-
/** Thrown when a Midnight offer
|
|
1291
|
-
export class
|
|
1381
|
+
/** Thrown when a quoted Midnight takeable offer belongs to a different market than the requested flow. */
|
|
1382
|
+
export class MidnightTakeableOfferMarketMismatchError extends Error {
|
|
1292
1383
|
constructor(params) {
|
|
1293
|
-
super(`Midnight offer
|
|
1384
|
+
super(`Midnight takeable offer "${params.index}" belongs to market "${params.actualMarket}", expected "${params.expectedMarket}". Refresh the quote and try again.`);
|
|
1294
1385
|
}
|
|
1295
1386
|
}
|
|
1296
|
-
/** Thrown when a Midnight offer
|
|
1297
|
-
export class
|
|
1387
|
+
/** Thrown when a Midnight offer's ratifier does not match its tree's ratifier route. */
|
|
1388
|
+
export class MidnightOfferRatifierMismatchError extends Error {
|
|
1298
1389
|
constructor(params) {
|
|
1299
|
-
super(`Midnight offer
|
|
1390
|
+
super(`Midnight offer "${params.index}" uses ratifier "${params.actualRatifier}", expected "${params.expectedRatifier}" for its tree type. Rebuild the offer with the tree's ratifier.`);
|
|
1300
1391
|
}
|
|
1301
1392
|
}
|
|
1302
|
-
/** Thrown when a Midnight
|
|
1303
|
-
export class
|
|
1304
|
-
constructor() {
|
|
1305
|
-
super(
|
|
1393
|
+
/** Thrown when a Midnight repost cancels a group it also publishes. */
|
|
1394
|
+
export class MidnightReplacementGroupCancelledError extends Error {
|
|
1395
|
+
constructor(params) {
|
|
1396
|
+
super(`Midnight offer group "${params.group}" is both published and cancelled. Give replacement offers a fresh group.`);
|
|
1306
1397
|
}
|
|
1307
1398
|
}
|
|
1308
1399
|
/** Thrown when a Midnight redeem flow finds no credit units for the user. */
|
|
@@ -1373,3 +1464,9 @@ export class RefinanceTokenMismatchError extends Error {
|
|
|
1373
1464
|
super(`Refinance source market ${sourceMarket} and target market ${targetMarket} must share the same loanToken and collateralToken.`);
|
|
1374
1465
|
}
|
|
1375
1466
|
}
|
|
1467
|
+
/** Thrown when a maker limit-exit offer can increase or open a position. */
|
|
1468
|
+
export class MidnightOfferNotReduceOnlyError extends Error {
|
|
1469
|
+
constructor(params) {
|
|
1470
|
+
super(`Midnight exit offer "${params.index}" must have reduceOnly=true. Rebuild the offer tree for the exit intent.`);
|
|
1471
|
+
}
|
|
1472
|
+
}
|
|
@@ -24,6 +24,23 @@ export interface VaultV2BluePublicAllocatorOptions {
|
|
|
24
24
|
* @default DEFAULT_CAP_ACCRUAL_BUFFER (2h)
|
|
25
25
|
*/
|
|
26
26
|
readonly capAccrualBuffer?: BigIntish;
|
|
27
|
+
/**
|
|
28
|
+
* Share of each target-market BluePublicAllocator cap, scaled by WAD, that
|
|
29
|
+
* operation planning keeps free. When a reallocation toward the utilization
|
|
30
|
+
* target would come within this headroom of the cap, the plan is reduced to
|
|
31
|
+
* the larger of the operation's absolute shortfall and what vaults below
|
|
32
|
+
* their cap were already moving. A plan of only the shortfall leaves the
|
|
33
|
+
* market fully utilized, so a competing borrow or withdraw landing first can
|
|
34
|
+
* still make it revert. If the shortfall cannot be covered while keeping the
|
|
35
|
+
* headroom, the plan uses the full cap, first for the shortfall only and
|
|
36
|
+
* then toward the utilization target if that is still short.
|
|
37
|
+
* Discovery plans, `getPublicReallocationLiquidity` and
|
|
38
|
+
* `getAvailableLiquidityToUtilization` ignore it and use the full cap.
|
|
39
|
+
* Must not exceed WAD (100%). Set to `0n` to disable.
|
|
40
|
+
*
|
|
41
|
+
* @default DEFAULT_ALLOCATOR_CAP_HEADROOM (1%)
|
|
42
|
+
*/
|
|
43
|
+
readonly allocatorCapHeadroom?: bigint;
|
|
27
44
|
/**
|
|
28
45
|
* Vault V2 addresses to consider. Arrays, readonly arrays, sets, and other
|
|
29
46
|
* iterables are accepted. Defaults to every vault in the reallocation data.
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@morpho-org/morpho-sdk",
|
|
3
3
|
"description": "Abstraction layer for Morpho's complexity.",
|
|
4
|
-
"version": "
|
|
4
|
+
"version": "7.0.0",
|
|
5
5
|
"author": "Morpho Association <contact@morpho.org>",
|
|
6
6
|
"repository": {
|
|
7
7
|
"type": "git",
|
|
@@ -147,25 +147,26 @@
|
|
|
147
147
|
],
|
|
148
148
|
"files": [
|
|
149
149
|
"lib",
|
|
150
|
-
"MIGRATION-v5-to-v6.md"
|
|
150
|
+
"MIGRATION-v5-to-v6.md",
|
|
151
|
+
"MIGRATION-v6-to-v7.md"
|
|
151
152
|
],
|
|
152
153
|
"dependencies": {
|
|
153
|
-
"@morpho-org/blue-sdk": "^
|
|
154
|
-
"@morpho-org/blue-sdk-viem": "^6.2.
|
|
155
|
-
"@morpho-org/midnight-sdk": "^
|
|
156
|
-
"@morpho-org/morpho-ts": "^
|
|
154
|
+
"@morpho-org/blue-sdk": "^8.0.0",
|
|
155
|
+
"@morpho-org/blue-sdk-viem": "^6.2.1",
|
|
156
|
+
"@morpho-org/midnight-sdk": "^2.0.0",
|
|
157
|
+
"@morpho-org/morpho-ts": "^4.0.0"
|
|
157
158
|
},
|
|
158
159
|
"peerDependencies": {
|
|
159
160
|
"viem": "^2.0.0"
|
|
160
161
|
},
|
|
161
162
|
"devDependencies": {
|
|
162
|
-
"@morpho-org/test": "^2.10.
|
|
163
|
+
"@morpho-org/test": "^2.10.1",
|
|
163
164
|
"dotenv": "^17.4.2",
|
|
164
165
|
"fast-check": "^4.9.0",
|
|
165
166
|
"typescript": "7.0.2",
|
|
166
167
|
"viem": "^2.55.10",
|
|
167
168
|
"vitest": "^4.1.11",
|
|
168
|
-
"zod": "^4.
|
|
169
|
+
"zod": "^4.6.5"
|
|
169
170
|
},
|
|
170
171
|
"scripts": {
|
|
171
172
|
"prepublish": "pnpm build",
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { type Address, type Hex } from "viem";
|
|
2
|
-
import type { Metadata, MidnightCancelOfferAction, Transaction } from "../../types/index.js";
|
|
3
|
-
/** Parameters for encoding a Midnight group consumption update. */
|
|
4
|
-
export interface MidnightCancelOfferParams {
|
|
5
|
-
readonly chainId: number;
|
|
6
|
-
readonly group: Hex;
|
|
7
|
-
readonly onBehalf: Address;
|
|
8
|
-
readonly amount?: bigint;
|
|
9
|
-
readonly metadata?: Metadata;
|
|
10
|
-
}
|
|
11
|
-
/**
|
|
12
|
-
* Encodes `Midnight.setConsumed` to cancel or partially consume an offer group.
|
|
13
|
-
*
|
|
14
|
-
* App flows should usually call `client.morpho.midnight(chainId).cancelOffer(...)`.
|
|
15
|
-
* Use this builder directly when the group id is already known and no
|
|
16
|
-
* additional requirements are needed. Omitting `amount` fully cancels the group
|
|
17
|
-
* by setting consumption to {@link MAX_OFFER_CAP}.
|
|
18
|
-
*
|
|
19
|
-
* @param params.chainId - Chain id used to resolve `Midnight`.
|
|
20
|
-
* @param params.group - Offer group id to mark consumed.
|
|
21
|
-
* @param params.onBehalf - Maker whose group consumption is updated.
|
|
22
|
-
* @param params.amount - Optional consumed amount; defaults to {@link MAX_OFFER_CAP} for full cancellation.
|
|
23
|
-
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
24
|
-
* @returns A deep-frozen `Transaction<MidnightCancelOfferAction>` targeting `Midnight`.
|
|
25
|
-
* @throws {NegativeInputError} when `amount` is negative.
|
|
26
|
-
* @throws {MidnightAmountExceedsMaxOfferCapError} when `amount` exceeds {@link MAX_OFFER_CAP}.
|
|
27
|
-
* @example
|
|
28
|
-
* ```ts
|
|
29
|
-
* import { midnightCancelOffer } from "@morpho-org/morpho-sdk";
|
|
30
|
-
*
|
|
31
|
-
* const tx = midnightCancelOffer({
|
|
32
|
-
* chainId: 8453,
|
|
33
|
-
* group,
|
|
34
|
-
* onBehalf: maker,
|
|
35
|
-
* });
|
|
36
|
-
* ```
|
|
37
|
-
*/
|
|
38
|
-
export declare const midnightCancelOffer: (params: MidnightCancelOfferParams) => Readonly<Transaction<MidnightCancelOfferAction>>;
|
|
@@ -1,73 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.midnightCancelOffer = void 0;
|
|
4
|
-
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const viem_1 = require("viem");
|
|
7
|
-
const index_js_1 = require("../../helpers/index.js");
|
|
8
|
-
const index_js_2 = require("../../types/index.js");
|
|
9
|
-
/**
|
|
10
|
-
* Encodes `Midnight.setConsumed` to cancel or partially consume an offer group.
|
|
11
|
-
*
|
|
12
|
-
* App flows should usually call `client.morpho.midnight(chainId).cancelOffer(...)`.
|
|
13
|
-
* Use this builder directly when the group id is already known and no
|
|
14
|
-
* additional requirements are needed. Omitting `amount` fully cancels the group
|
|
15
|
-
* by setting consumption to {@link MAX_OFFER_CAP}.
|
|
16
|
-
*
|
|
17
|
-
* @param params.chainId - Chain id used to resolve `Midnight`.
|
|
18
|
-
* @param params.group - Offer group id to mark consumed.
|
|
19
|
-
* @param params.onBehalf - Maker whose group consumption is updated.
|
|
20
|
-
* @param params.amount - Optional consumed amount; defaults to {@link MAX_OFFER_CAP} for full cancellation.
|
|
21
|
-
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
22
|
-
* @returns A deep-frozen `Transaction<MidnightCancelOfferAction>` targeting `Midnight`.
|
|
23
|
-
* @throws {NegativeInputError} when `amount` is negative.
|
|
24
|
-
* @throws {MidnightAmountExceedsMaxOfferCapError} when `amount` exceeds {@link MAX_OFFER_CAP}.
|
|
25
|
-
* @example
|
|
26
|
-
* ```ts
|
|
27
|
-
* import { midnightCancelOffer } from "@morpho-org/morpho-sdk";
|
|
28
|
-
*
|
|
29
|
-
* const tx = midnightCancelOffer({
|
|
30
|
-
* chainId: 8453,
|
|
31
|
-
* group,
|
|
32
|
-
* onBehalf: maker,
|
|
33
|
-
* });
|
|
34
|
-
* ```
|
|
35
|
-
*/
|
|
36
|
-
const midnightCancelOffer = (params) => {
|
|
37
|
-
const midnight = (0, morpho_ts_1.getChainAddress)(params.chainId, "midnight");
|
|
38
|
-
const amount = params.amount ?? midnight_sdk_1.MAX_OFFER_CAP;
|
|
39
|
-
if (amount < 0n) {
|
|
40
|
-
throw new index_js_2.NegativeInputError("amount", amount);
|
|
41
|
-
}
|
|
42
|
-
if (amount > midnight_sdk_1.MAX_OFFER_CAP) {
|
|
43
|
-
throw new index_js_2.MidnightAmountExceedsMaxOfferCapError({
|
|
44
|
-
label: "cancel amount",
|
|
45
|
-
amount,
|
|
46
|
-
maxOfferCap: midnight_sdk_1.MAX_OFFER_CAP,
|
|
47
|
-
});
|
|
48
|
-
}
|
|
49
|
-
let tx = {
|
|
50
|
-
to: midnight,
|
|
51
|
-
value: 0n,
|
|
52
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
53
|
-
abi: midnight_sdk_1.midnightAbi,
|
|
54
|
-
functionName: "setConsumed",
|
|
55
|
-
args: [params.group, amount, params.onBehalf],
|
|
56
|
-
}),
|
|
57
|
-
};
|
|
58
|
-
if (params.metadata) {
|
|
59
|
-
tx = (0, index_js_1.addTransactionMetadata)(tx, params.metadata);
|
|
60
|
-
}
|
|
61
|
-
return (0, morpho_ts_1.deepFreeze)({
|
|
62
|
-
...tx,
|
|
63
|
-
action: {
|
|
64
|
-
type: "midnightCancelOffer",
|
|
65
|
-
args: {
|
|
66
|
-
group: params.group,
|
|
67
|
-
amount,
|
|
68
|
-
onBehalf: params.onBehalf,
|
|
69
|
-
},
|
|
70
|
-
},
|
|
71
|
-
});
|
|
72
|
-
};
|
|
73
|
-
exports.midnightCancelOffer = midnightCancelOffer;
|
|
@@ -1,52 +0,0 @@
|
|
|
1
|
-
import type { Address, Hex } from "viem";
|
|
2
|
-
import type { MempoolSubmitOffersAction, Metadata, Transaction } from "../../types/index.js";
|
|
3
|
-
/** Parameters for publishing an already ratified Midnight offer payload. */
|
|
4
|
-
export interface MempoolSubmitOffersParams {
|
|
5
|
-
readonly chainId: number;
|
|
6
|
-
readonly groups: readonly Hex[];
|
|
7
|
-
readonly root: Hex;
|
|
8
|
-
readonly maker: Address;
|
|
9
|
-
readonly ratifier: Address;
|
|
10
|
-
readonly ratifierType: "ecrecover" | "setter";
|
|
11
|
-
readonly offers: number;
|
|
12
|
-
readonly payload: Hex;
|
|
13
|
-
readonly metadata?: Metadata;
|
|
14
|
-
}
|
|
15
|
-
/**
|
|
16
|
-
* Encodes a Midnight mempool payload submission transaction.
|
|
17
|
-
*
|
|
18
|
-
* App make-offer flows should call `getOffersData`, gather the returned
|
|
19
|
-
* requirements, then call the output `buildTx(signatures)`. Use this builder
|
|
20
|
-
* directly only when the payload has already been encoded with ratifier data
|
|
21
|
-
* and the caller wants to submit those bytes to the mempool contract.
|
|
22
|
-
*
|
|
23
|
-
* @param params.chainId - Chain id used to resolve `MidnightMempool`.
|
|
24
|
-
* @param params.groups - Group ids included in the payload.
|
|
25
|
-
* @param params.root - Offer tree root committed by the maker.
|
|
26
|
-
* @param params.maker - Maker whose offers are submitted.
|
|
27
|
-
* @param params.ratifier - Ratifier address shared by the offer tree.
|
|
28
|
-
* @param params.ratifierType - Ratifier route used to build the payload.
|
|
29
|
-
* @param params.offers - Number of non-padding offers in the payload.
|
|
30
|
-
* @param params.payload - Encoded mempool payload bytes.
|
|
31
|
-
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
32
|
-
* @returns A deep-frozen `Transaction<MempoolSubmitOffersAction>` targeting `MidnightMempool`.
|
|
33
|
-
* @throws {InvalidTreeError} when `offers <= 0`.
|
|
34
|
-
* @example
|
|
35
|
-
* ```ts
|
|
36
|
-
* import { MidnightPayload } from "@morpho-org/morpho-sdk/utils";
|
|
37
|
-
* import { mempoolSubmitOffers } from "@morpho-org/morpho-sdk";
|
|
38
|
-
*
|
|
39
|
-
* const payload = await MidnightPayload.encode(items);
|
|
40
|
-
* const tx = mempoolSubmitOffers({
|
|
41
|
-
* chainId: 8453,
|
|
42
|
-
* groups,
|
|
43
|
-
* root: tree.root,
|
|
44
|
-
* maker,
|
|
45
|
-
* ratifier,
|
|
46
|
-
* ratifierType: "ecrecover",
|
|
47
|
-
* offers: tree.offers.length,
|
|
48
|
-
* payload,
|
|
49
|
-
* });
|
|
50
|
-
* ```
|
|
51
|
-
*/
|
|
52
|
-
export declare const mempoolSubmitOffers: (params: MempoolSubmitOffersParams) => Readonly<Transaction<MempoolSubmitOffersAction>>;
|
|
@@ -1,72 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.mempoolSubmitOffers = void 0;
|
|
4
|
-
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const index_js_1 = require("../../helpers/index.js");
|
|
7
|
-
/**
|
|
8
|
-
* Encodes a Midnight mempool payload submission transaction.
|
|
9
|
-
*
|
|
10
|
-
* App make-offer flows should call `getOffersData`, gather the returned
|
|
11
|
-
* requirements, then call the output `buildTx(signatures)`. Use this builder
|
|
12
|
-
* directly only when the payload has already been encoded with ratifier data
|
|
13
|
-
* and the caller wants to submit those bytes to the mempool contract.
|
|
14
|
-
*
|
|
15
|
-
* @param params.chainId - Chain id used to resolve `MidnightMempool`.
|
|
16
|
-
* @param params.groups - Group ids included in the payload.
|
|
17
|
-
* @param params.root - Offer tree root committed by the maker.
|
|
18
|
-
* @param params.maker - Maker whose offers are submitted.
|
|
19
|
-
* @param params.ratifier - Ratifier address shared by the offer tree.
|
|
20
|
-
* @param params.ratifierType - Ratifier route used to build the payload.
|
|
21
|
-
* @param params.offers - Number of non-padding offers in the payload.
|
|
22
|
-
* @param params.payload - Encoded mempool payload bytes.
|
|
23
|
-
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
24
|
-
* @returns A deep-frozen `Transaction<MempoolSubmitOffersAction>` targeting `MidnightMempool`.
|
|
25
|
-
* @throws {InvalidTreeError} when `offers <= 0`.
|
|
26
|
-
* @example
|
|
27
|
-
* ```ts
|
|
28
|
-
* import { MidnightPayload } from "@morpho-org/morpho-sdk/utils";
|
|
29
|
-
* import { mempoolSubmitOffers } from "@morpho-org/morpho-sdk";
|
|
30
|
-
*
|
|
31
|
-
* const payload = await MidnightPayload.encode(items);
|
|
32
|
-
* const tx = mempoolSubmitOffers({
|
|
33
|
-
* chainId: 8453,
|
|
34
|
-
* groups,
|
|
35
|
-
* root: tree.root,
|
|
36
|
-
* maker,
|
|
37
|
-
* ratifier,
|
|
38
|
-
* ratifierType: "ecrecover",
|
|
39
|
-
* offers: tree.offers.length,
|
|
40
|
-
* payload,
|
|
41
|
-
* });
|
|
42
|
-
* ```
|
|
43
|
-
*/
|
|
44
|
-
const mempoolSubmitOffers = (params) => {
|
|
45
|
-
if (params.offers <= 0) {
|
|
46
|
-
throw new midnight_sdk_1.InvalidTreeError("Tree must contain at least one offer.");
|
|
47
|
-
}
|
|
48
|
-
const midnightMempool = (0, morpho_ts_1.getChainAddress)(params.chainId, "midnightMempool");
|
|
49
|
-
let tx = {
|
|
50
|
-
to: midnightMempool,
|
|
51
|
-
value: 0n,
|
|
52
|
-
data: params.payload,
|
|
53
|
-
};
|
|
54
|
-
if (params.metadata) {
|
|
55
|
-
tx = (0, index_js_1.addTransactionMetadata)(tx, params.metadata);
|
|
56
|
-
}
|
|
57
|
-
return (0, morpho_ts_1.deepFreeze)({
|
|
58
|
-
...tx,
|
|
59
|
-
action: {
|
|
60
|
-
type: "mempoolSubmitOffers",
|
|
61
|
-
args: {
|
|
62
|
-
groups: [...params.groups],
|
|
63
|
-
root: params.root,
|
|
64
|
-
maker: params.maker,
|
|
65
|
-
ratifier: params.ratifier,
|
|
66
|
-
ratifierType: params.ratifierType,
|
|
67
|
-
offers: params.offers,
|
|
68
|
-
},
|
|
69
|
-
},
|
|
70
|
-
});
|
|
71
|
-
};
|
|
72
|
-
exports.mempoolSubmitOffers = mempoolSubmitOffers;
|
|
@@ -1,40 +0,0 @@
|
|
|
1
|
-
import { type Address, type Hex } from "viem";
|
|
2
|
-
import type { Metadata, SetterRatifierRatifyRootAction, Transaction } from "../../types/index.js";
|
|
3
|
-
/** Parameters for {@link setterRatifierRatifyRoot}. */
|
|
4
|
-
export interface SetterRatifierRatifyRootParams {
|
|
5
|
-
/** Chain id used to resolve the SetterRatifier deployment. */
|
|
6
|
-
readonly chainId: number;
|
|
7
|
-
/** Maker whose offer-tree root is being ratified. */
|
|
8
|
-
readonly maker: Address;
|
|
9
|
-
/** Offer-tree root to ratify or unratify. */
|
|
10
|
-
readonly root: Hex;
|
|
11
|
-
/** Whether the root should be ratified. Defaults to `true`. */
|
|
12
|
-
readonly isRootRatified?: boolean;
|
|
13
|
-
/** Optional metadata appended to the transaction calldata. */
|
|
14
|
-
readonly metadata?: Metadata;
|
|
15
|
-
}
|
|
16
|
-
/**
|
|
17
|
-
* Encodes a SetterRatifier root-ratification transaction.
|
|
18
|
-
*
|
|
19
|
-
* Use this after building a Setter-ratified offer tree and before submitting
|
|
20
|
-
* its mempool payload. Entity make-offer flows expose the same transaction
|
|
21
|
-
* through `getRequirements()` when the root is not already approved.
|
|
22
|
-
*
|
|
23
|
-
* @param params.chainId - Chain id used to resolve `SetterRatifier`.
|
|
24
|
-
* @param params.maker - Maker whose root approval is updated.
|
|
25
|
-
* @param params.root - Offer-tree root to approve or revoke.
|
|
26
|
-
* @param params.isRootRatified - Optional target state; defaults to `true`.
|
|
27
|
-
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
28
|
-
* @returns A deep-frozen `Transaction<SetterRatifierRatifyRootAction>` targeting `SetterRatifier`.
|
|
29
|
-
* @example
|
|
30
|
-
* ```ts
|
|
31
|
-
* import { setterRatifierRatifyRoot } from "@morpho-org/morpho-sdk";
|
|
32
|
-
*
|
|
33
|
-
* const tx = setterRatifierRatifyRoot({
|
|
34
|
-
* chainId: 8453,
|
|
35
|
-
* maker,
|
|
36
|
-
* root,
|
|
37
|
-
* });
|
|
38
|
-
* ```
|
|
39
|
-
*/
|
|
40
|
-
export declare const setterRatifierRatifyRoot: (params: SetterRatifierRatifyRootParams) => Readonly<Transaction<SetterRatifierRatifyRootAction>>;
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.setterRatifierRatifyRoot = void 0;
|
|
4
|
-
const midnight_sdk_1 = require("@morpho-org/midnight-sdk");
|
|
5
|
-
const morpho_ts_1 = require("@morpho-org/morpho-ts");
|
|
6
|
-
const viem_1 = require("viem");
|
|
7
|
-
const index_js_1 = require("../../helpers/index.js");
|
|
8
|
-
/**
|
|
9
|
-
* Encodes a SetterRatifier root-ratification transaction.
|
|
10
|
-
*
|
|
11
|
-
* Use this after building a Setter-ratified offer tree and before submitting
|
|
12
|
-
* its mempool payload. Entity make-offer flows expose the same transaction
|
|
13
|
-
* through `getRequirements()` when the root is not already approved.
|
|
14
|
-
*
|
|
15
|
-
* @param params.chainId - Chain id used to resolve `SetterRatifier`.
|
|
16
|
-
* @param params.maker - Maker whose root approval is updated.
|
|
17
|
-
* @param params.root - Offer-tree root to approve or revoke.
|
|
18
|
-
* @param params.isRootRatified - Optional target state; defaults to `true`.
|
|
19
|
-
* @param params.metadata - Optional analytics metadata appended to calldata.
|
|
20
|
-
* @returns A deep-frozen `Transaction<SetterRatifierRatifyRootAction>` targeting `SetterRatifier`.
|
|
21
|
-
* @example
|
|
22
|
-
* ```ts
|
|
23
|
-
* import { setterRatifierRatifyRoot } from "@morpho-org/morpho-sdk";
|
|
24
|
-
*
|
|
25
|
-
* const tx = setterRatifierRatifyRoot({
|
|
26
|
-
* chainId: 8453,
|
|
27
|
-
* maker,
|
|
28
|
-
* root,
|
|
29
|
-
* });
|
|
30
|
-
* ```
|
|
31
|
-
*/
|
|
32
|
-
const setterRatifierRatifyRoot = (params) => {
|
|
33
|
-
const isRootRatified = params.isRootRatified ?? true;
|
|
34
|
-
const setterRatifier = (0, morpho_ts_1.getChainAddress)(params.chainId, "setterRatifier");
|
|
35
|
-
let tx = {
|
|
36
|
-
to: setterRatifier,
|
|
37
|
-
value: 0n,
|
|
38
|
-
data: (0, viem_1.encodeFunctionData)({
|
|
39
|
-
abi: midnight_sdk_1.setterRatifierAbi,
|
|
40
|
-
functionName: "setIsRootRatified",
|
|
41
|
-
args: [params.maker, params.root, isRootRatified],
|
|
42
|
-
}),
|
|
43
|
-
};
|
|
44
|
-
if (params.metadata) {
|
|
45
|
-
tx = (0, index_js_1.addTransactionMetadata)(tx, params.metadata);
|
|
46
|
-
}
|
|
47
|
-
return (0, morpho_ts_1.deepFreeze)({
|
|
48
|
-
...tx,
|
|
49
|
-
action: {
|
|
50
|
-
type: "setterRatifierRatifyRoot",
|
|
51
|
-
args: {
|
|
52
|
-
maker: params.maker,
|
|
53
|
-
root: params.root,
|
|
54
|
-
isRootRatified,
|
|
55
|
-
},
|
|
56
|
-
},
|
|
57
|
-
});
|
|
58
|
-
};
|
|
59
|
-
exports.setterRatifierRatifyRoot = setterRatifierRatifyRoot;
|