@gearbox-protocol/sdk 8.20.0 → 8.22.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/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +243 -0
- package/dist/cjs/sdk/chain/chains.js +2 -3
- package/dist/cjs/sdk/sdk-legacy/core/transactions.js +53 -2
- package/dist/cjs/sdk/sdk-legacy/tokens/tokenData.js +2 -1
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +244 -1
- package/dist/esm/sdk/chain/chains.js +2 -3
- package/dist/esm/sdk/sdk-legacy/core/transactions.js +52 -2
- package/dist/esm/sdk/sdk-legacy/tokens/tokenData.js +2 -1
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +15 -1
- package/dist/types/sdk/accounts/types.d.ts +54 -0
- package/dist/types/sdk/sdk-legacy/core/transactions.d.ts +17 -1
- package/package.json +1 -1
|
@@ -432,6 +432,163 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
432
432
|
const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
|
|
433
433
|
return { tx, calls, creditFacade: cm.creditFacade };
|
|
434
434
|
}
|
|
435
|
+
/**
|
|
436
|
+
* Start delayed withdrawal for given token
|
|
437
|
+
- Withdrawal is executed in the following order: price update -> execute withdraw calls -> update quotas
|
|
438
|
+
* @param props - {@link StartDelayedWithdrawalProps}
|
|
439
|
+
* @returns
|
|
440
|
+
*/
|
|
441
|
+
async startDelayedWithdrawal_Mellow({
|
|
442
|
+
creditAccount,
|
|
443
|
+
minQuota,
|
|
444
|
+
averageQuota,
|
|
445
|
+
instantWithdrawals,
|
|
446
|
+
delayedWithdrawals,
|
|
447
|
+
sourceAmount,
|
|
448
|
+
sourceToken
|
|
449
|
+
}) {
|
|
450
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
451
|
+
creditAccount.creditManager
|
|
452
|
+
);
|
|
453
|
+
const balances = [...instantWithdrawals, ...delayedWithdrawals].filter(
|
|
454
|
+
(a) => a.balance > 0
|
|
455
|
+
);
|
|
456
|
+
const storeExpectedBalances = {
|
|
457
|
+
target: cm.creditFacade.address,
|
|
458
|
+
callData: (0, import_viem.encodeFunctionData)({
|
|
459
|
+
abi: import_v300.iCreditFacadeV300MulticallAbi,
|
|
460
|
+
functionName: "storeExpectedBalances",
|
|
461
|
+
args: [
|
|
462
|
+
balances.map((a) => ({ token: a.token, amount: a.balance - 10n }))
|
|
463
|
+
]
|
|
464
|
+
})
|
|
465
|
+
};
|
|
466
|
+
const compareBalances = {
|
|
467
|
+
target: cm.creditFacade.address,
|
|
468
|
+
callData: (0, import_viem.encodeFunctionData)({
|
|
469
|
+
abi: import_v300.iCreditFacadeV300MulticallAbi,
|
|
470
|
+
functionName: "compareBalances",
|
|
471
|
+
args: []
|
|
472
|
+
})
|
|
473
|
+
};
|
|
474
|
+
const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
|
|
475
|
+
creditAccount.creditManager,
|
|
476
|
+
creditAccount,
|
|
477
|
+
averageQuota
|
|
478
|
+
);
|
|
479
|
+
const mellowAdapter = cm.creditManager.adapters.mustGet(sourceToken);
|
|
480
|
+
const redeem = {
|
|
481
|
+
target: mellowAdapter.address,
|
|
482
|
+
callData: (0, import_viem.encodeFunctionData)({
|
|
483
|
+
abi: ierc4626AdapterAbi,
|
|
484
|
+
functionName: "redeem",
|
|
485
|
+
args: [sourceAmount, import_constants.ADDRESS_0X0, import_constants.ADDRESS_0X0]
|
|
486
|
+
})
|
|
487
|
+
};
|
|
488
|
+
const CLAIMER = "0x25024a3017B8da7161d8c5DCcF768F8678fB5802";
|
|
489
|
+
const mellowClaimerAdapter = cm.creditManager.adapters.mustGet(CLAIMER);
|
|
490
|
+
const multiAcceptContract = (0, import_viem.getContract)({
|
|
491
|
+
address: mellowClaimerAdapter.address,
|
|
492
|
+
abi: iMellowClaimerAdapterAbi,
|
|
493
|
+
client: this.sdk.provider.publicClient
|
|
494
|
+
});
|
|
495
|
+
const indices = await multiAcceptContract.read.getMultiVaultSubvaultIndices(
|
|
496
|
+
[sourceToken]
|
|
497
|
+
);
|
|
498
|
+
const multiaccept = {
|
|
499
|
+
target: mellowClaimerAdapter.address,
|
|
500
|
+
callData: (0, import_viem.encodeFunctionData)({
|
|
501
|
+
abi: iMellowClaimerAdapterAbi,
|
|
502
|
+
functionName: "multiAccept",
|
|
503
|
+
args: [sourceToken, ...indices]
|
|
504
|
+
})
|
|
505
|
+
};
|
|
506
|
+
const calls = [
|
|
507
|
+
...priceUpdatesCalls,
|
|
508
|
+
storeExpectedBalances,
|
|
509
|
+
redeem,
|
|
510
|
+
multiaccept,
|
|
511
|
+
compareBalances,
|
|
512
|
+
...this.prepareUpdateQuotas(creditAccount.creditFacade, {
|
|
513
|
+
minQuota,
|
|
514
|
+
averageQuota
|
|
515
|
+
})
|
|
516
|
+
];
|
|
517
|
+
const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
|
|
518
|
+
return { tx, calls, creditFacade: cm.creditFacade };
|
|
519
|
+
}
|
|
520
|
+
/**
|
|
521
|
+
* Claim tokens with delayed withdrawal
|
|
522
|
+
- Claim is executed in the following order: price update -> execute claim calls -> update quotas
|
|
523
|
+
* @param props - {@link ClaimDelayedProps}
|
|
524
|
+
* @returns
|
|
525
|
+
*/
|
|
526
|
+
async claimDelayed_Mellow({
|
|
527
|
+
creditAccount,
|
|
528
|
+
minQuota,
|
|
529
|
+
averageQuota,
|
|
530
|
+
sourceToken,
|
|
531
|
+
phantom,
|
|
532
|
+
target
|
|
533
|
+
}) {
|
|
534
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
535
|
+
creditAccount.creditManager
|
|
536
|
+
);
|
|
537
|
+
const storeExpectedBalances = {
|
|
538
|
+
target: cm.creditFacade.address,
|
|
539
|
+
callData: (0, import_viem.encodeFunctionData)({
|
|
540
|
+
abi: import_v300.iCreditFacadeV300MulticallAbi,
|
|
541
|
+
functionName: "storeExpectedBalances",
|
|
542
|
+
args: [
|
|
543
|
+
[target].map((a) => ({ token: a.token, amount: a.balance - 10n }))
|
|
544
|
+
]
|
|
545
|
+
})
|
|
546
|
+
};
|
|
547
|
+
const compareBalances = {
|
|
548
|
+
target: cm.creditFacade.address,
|
|
549
|
+
callData: (0, import_viem.encodeFunctionData)({
|
|
550
|
+
abi: import_v300.iCreditFacadeV300MulticallAbi,
|
|
551
|
+
functionName: "compareBalances",
|
|
552
|
+
args: []
|
|
553
|
+
})
|
|
554
|
+
};
|
|
555
|
+
const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
|
|
556
|
+
creditAccount.creditManager,
|
|
557
|
+
creditAccount,
|
|
558
|
+
averageQuota
|
|
559
|
+
);
|
|
560
|
+
const CLAIMER = "0x25024a3017B8da7161d8c5DCcF768F8678fB5802";
|
|
561
|
+
const mellowClaimerAdapter = cm.creditManager.adapters.mustGet(CLAIMER);
|
|
562
|
+
const multiAcceptContract = (0, import_viem.getContract)({
|
|
563
|
+
address: mellowClaimerAdapter.address,
|
|
564
|
+
abi: iMellowClaimerAdapterAbi,
|
|
565
|
+
client: this.sdk.provider.publicClient
|
|
566
|
+
});
|
|
567
|
+
const indices = await multiAcceptContract.read.getUserSubvaultIndices([
|
|
568
|
+
sourceToken,
|
|
569
|
+
creditAccount.creditAccount
|
|
570
|
+
]);
|
|
571
|
+
const multiaccept = {
|
|
572
|
+
target: mellowClaimerAdapter.address,
|
|
573
|
+
callData: (0, import_viem.encodeFunctionData)({
|
|
574
|
+
abi: iMellowClaimerAdapterAbi,
|
|
575
|
+
functionName: "multiAcceptAndClaim",
|
|
576
|
+
args: [sourceToken, ...indices, import_constants.ADDRESS_0X0, phantom.balance]
|
|
577
|
+
})
|
|
578
|
+
};
|
|
579
|
+
const calls = [
|
|
580
|
+
...priceUpdatesCalls,
|
|
581
|
+
storeExpectedBalances,
|
|
582
|
+
multiaccept,
|
|
583
|
+
compareBalances,
|
|
584
|
+
...this.prepareUpdateQuotas(creditAccount.creditFacade, {
|
|
585
|
+
minQuota,
|
|
586
|
+
averageQuota
|
|
587
|
+
})
|
|
588
|
+
];
|
|
589
|
+
const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
|
|
590
|
+
return { tx, calls, creditFacade: cm.creditFacade };
|
|
591
|
+
}
|
|
435
592
|
/**
|
|
436
593
|
* Executes enable/disable tokens specified by given tokens lists and token prices
|
|
437
594
|
* @param {RouterCASlice} creditAccount - minimal credit account data {@link RouterCASlice} on which operation is performed
|
|
@@ -864,6 +1021,92 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
864
1021
|
)[0];
|
|
865
1022
|
}
|
|
866
1023
|
}
|
|
1024
|
+
const iMellowClaimerAdapterAbi = [
|
|
1025
|
+
{
|
|
1026
|
+
type: "function",
|
|
1027
|
+
name: "getMultiVaultSubvaultIndices",
|
|
1028
|
+
inputs: [{ name: "multiVault", type: "address", internalType: "address" }],
|
|
1029
|
+
outputs: [
|
|
1030
|
+
{
|
|
1031
|
+
name: "subvaultIndices",
|
|
1032
|
+
type: "uint256[]",
|
|
1033
|
+
internalType: "uint256[]"
|
|
1034
|
+
},
|
|
1035
|
+
{
|
|
1036
|
+
name: "withdrawalIndices",
|
|
1037
|
+
type: "uint256[][]",
|
|
1038
|
+
internalType: "uint256[][]"
|
|
1039
|
+
}
|
|
1040
|
+
],
|
|
1041
|
+
stateMutability: "view"
|
|
1042
|
+
},
|
|
1043
|
+
{
|
|
1044
|
+
type: "function",
|
|
1045
|
+
name: "getUserSubvaultIndices",
|
|
1046
|
+
inputs: [
|
|
1047
|
+
{ name: "multiVault", type: "address", internalType: "address" },
|
|
1048
|
+
{ name: "user", type: "address", internalType: "address" }
|
|
1049
|
+
],
|
|
1050
|
+
outputs: [
|
|
1051
|
+
{
|
|
1052
|
+
name: "subvaultIndices",
|
|
1053
|
+
type: "uint256[]",
|
|
1054
|
+
internalType: "uint256[]"
|
|
1055
|
+
},
|
|
1056
|
+
{
|
|
1057
|
+
name: "withdrawalIndices",
|
|
1058
|
+
type: "uint256[][]",
|
|
1059
|
+
internalType: "uint256[][]"
|
|
1060
|
+
}
|
|
1061
|
+
],
|
|
1062
|
+
stateMutability: "view"
|
|
1063
|
+
},
|
|
1064
|
+
{
|
|
1065
|
+
type: "function",
|
|
1066
|
+
name: "multiAccept",
|
|
1067
|
+
inputs: [
|
|
1068
|
+
{ name: "multiVault", type: "address", internalType: "address" },
|
|
1069
|
+
{
|
|
1070
|
+
name: "subvaultIndices",
|
|
1071
|
+
type: "uint256[]",
|
|
1072
|
+
internalType: "uint256[]"
|
|
1073
|
+
},
|
|
1074
|
+
{ name: "indices", type: "uint256[][]", internalType: "uint256[][]" }
|
|
1075
|
+
],
|
|
1076
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
1077
|
+
stateMutability: "nonpayable"
|
|
1078
|
+
},
|
|
1079
|
+
{
|
|
1080
|
+
type: "function",
|
|
1081
|
+
name: "multiAcceptAndClaim",
|
|
1082
|
+
inputs: [
|
|
1083
|
+
{ name: "multiVault", type: "address", internalType: "address" },
|
|
1084
|
+
{
|
|
1085
|
+
name: "subvaultIndices",
|
|
1086
|
+
type: "uint256[]",
|
|
1087
|
+
internalType: "uint256[]"
|
|
1088
|
+
},
|
|
1089
|
+
{ name: "indices", type: "uint256[][]", internalType: "uint256[][]" },
|
|
1090
|
+
{ name: "", type: "address", internalType: "address" },
|
|
1091
|
+
{ name: "maxAssets", type: "uint256", internalType: "uint256" }
|
|
1092
|
+
],
|
|
1093
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
1094
|
+
stateMutability: "nonpayable"
|
|
1095
|
+
}
|
|
1096
|
+
];
|
|
1097
|
+
const ierc4626AdapterAbi = [
|
|
1098
|
+
{
|
|
1099
|
+
type: "function",
|
|
1100
|
+
inputs: [
|
|
1101
|
+
{ name: "shares", internalType: "uint256", type: "uint256" },
|
|
1102
|
+
{ name: "", internalType: "address", type: "address" },
|
|
1103
|
+
{ name: "", internalType: "address", type: "address" }
|
|
1104
|
+
],
|
|
1105
|
+
name: "redeem",
|
|
1106
|
+
outputs: [{ name: "useSafePrices", internalType: "bool", type: "bool" }],
|
|
1107
|
+
stateMutability: "nonpayable"
|
|
1108
|
+
}
|
|
1109
|
+
];
|
|
867
1110
|
// Annotate the CommonJS export names for ESM import in node:
|
|
868
1111
|
0 && (module.exports = {
|
|
869
1112
|
AbstractCreditAccountService
|
|
@@ -70,11 +70,10 @@ const chains = {
|
|
|
70
70
|
"0x4d427D418342d8CE89a7634c3a402851978B680A": "K3",
|
|
71
71
|
"0xc168343c791d56dd1da4b4b8b0cc1c1ec1a16e6b": "cp0x",
|
|
72
72
|
"0x3b56538833fc02f4f0e75609390f26ded0c32e42": "Re7",
|
|
73
|
-
"0x7a133fbd01736fd076158307c9476cc3877f1af5": "Invariant Group"
|
|
74
|
-
},
|
|
75
|
-
testMarketConfigurators: {
|
|
73
|
+
"0x7a133fbd01736fd076158307c9476cc3877f1af5": "Invariant Group",
|
|
76
74
|
"0x09d8305F49374AEA6A78aF6C996df2913e8f3b19": "Tulipa"
|
|
77
75
|
},
|
|
76
|
+
testMarketConfigurators: {},
|
|
78
77
|
isPublic: true,
|
|
79
78
|
wellKnownToken: {
|
|
80
79
|
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
@@ -41,6 +41,7 @@ __export(transactions_exports, {
|
|
|
41
41
|
TxRepayAccount: () => TxRepayAccount,
|
|
42
42
|
TxSerializer: () => TxSerializer,
|
|
43
43
|
TxStakeDiesel: () => TxStakeDiesel,
|
|
44
|
+
TxStartDelayedWithdrawal: () => TxStartDelayedWithdrawal,
|
|
44
45
|
TxUnstakeDiesel: () => TxUnstakeDiesel,
|
|
45
46
|
TxUpdateQuota: () => TxUpdateQuota,
|
|
46
47
|
TxWithdrawCollateral: () => TxWithdrawCollateral
|
|
@@ -108,6 +109,8 @@ class TxSerializer {
|
|
|
108
109
|
return new TxEnableTokens(params);
|
|
109
110
|
case "TxFillOrder":
|
|
110
111
|
return new TxFillOrder(params);
|
|
112
|
+
case "TxStartDelayedWithdrawal":
|
|
113
|
+
return new TxStartDelayedWithdrawal(params);
|
|
111
114
|
default:
|
|
112
115
|
throw new Error(`Unknown transaction for parsing: ${e.type}`);
|
|
113
116
|
}
|
|
@@ -389,7 +392,7 @@ class TxClaimRewards extends import_eventOrTx.EVMTx {
|
|
|
389
392
|
const { title } = token;
|
|
390
393
|
return title;
|
|
391
394
|
}).join(", ");
|
|
392
|
-
return `
|
|
395
|
+
return `Claimed: ${rewardsString}`;
|
|
393
396
|
}
|
|
394
397
|
serialize() {
|
|
395
398
|
return {
|
|
@@ -398,6 +401,51 @@ class TxClaimRewards extends import_eventOrTx.EVMTx {
|
|
|
398
401
|
};
|
|
399
402
|
}
|
|
400
403
|
}
|
|
404
|
+
class TxStartDelayedWithdrawal extends import_eventOrTx.EVMTx {
|
|
405
|
+
instantWithdrawals;
|
|
406
|
+
delayedWithdrawals;
|
|
407
|
+
constructor(opts) {
|
|
408
|
+
super(opts);
|
|
409
|
+
this.instantWithdrawals = opts.instantWithdrawals.map(
|
|
410
|
+
({ token, balance }) => ({
|
|
411
|
+
token: opts.tokensList[token],
|
|
412
|
+
balance
|
|
413
|
+
})
|
|
414
|
+
);
|
|
415
|
+
this.delayedWithdrawals = opts.delayedWithdrawals.map(
|
|
416
|
+
({ token, balance }) => ({
|
|
417
|
+
token: opts.tokensList[token],
|
|
418
|
+
balance
|
|
419
|
+
})
|
|
420
|
+
);
|
|
421
|
+
}
|
|
422
|
+
toString() {
|
|
423
|
+
const total = this.instantWithdrawals.length + this.delayedWithdrawals.length;
|
|
424
|
+
const instantString = total <= 2 ? this.instantWithdrawals.map(({ token, balance }) => {
|
|
425
|
+
const { title, decimals = 18 } = token;
|
|
426
|
+
return `${(0, import_utils.formatBN)(balance, decimals)} ${title}`;
|
|
427
|
+
}).join(", ") : this.instantWithdrawals.map(({ token }) => {
|
|
428
|
+
const { title } = token;
|
|
429
|
+
return title;
|
|
430
|
+
}).join(", ");
|
|
431
|
+
const delayedString = total <= 2 ? this.delayedWithdrawals.map(({ token, balance }) => {
|
|
432
|
+
const { title, decimals = 18 } = token;
|
|
433
|
+
return `${(0, import_utils.formatBN)(balance, decimals)} ${title}`;
|
|
434
|
+
}).join(", ") : this.delayedWithdrawals.map(({ token }) => {
|
|
435
|
+
const { title } = token;
|
|
436
|
+
return title;
|
|
437
|
+
}).join(", ");
|
|
438
|
+
const instant = this.instantWithdrawals.length > 0 ? `Tokens obtained: ${instantString}` : void 0;
|
|
439
|
+
const delayed = this.delayedWithdrawals.length > 0 ? `Tokens withdrawal started: ${delayedString}` : void 0;
|
|
440
|
+
return [instant, delayed].filter((s) => s).join("; ");
|
|
441
|
+
}
|
|
442
|
+
serialize() {
|
|
443
|
+
return {
|
|
444
|
+
type: "TxStartDelayedWithdrawal",
|
|
445
|
+
content: JSON.stringify(this)
|
|
446
|
+
};
|
|
447
|
+
}
|
|
448
|
+
}
|
|
401
449
|
class TxRepayAccount extends import_eventOrTx.EVMTx {
|
|
402
450
|
creditManagerName;
|
|
403
451
|
constructor(opts) {
|
|
@@ -635,7 +683,9 @@ class TxEnableTokens extends import_eventOrTx.EVMTx {
|
|
|
635
683
|
enabledSymbols.length > 0 ? `enabled: ${enabledSymbols.join(", ")}` : "",
|
|
636
684
|
disabledSymbols.length > 0 ? `disabled: ${disabledSymbols.join(", ")}` : ""
|
|
637
685
|
].filter((s) => !!s);
|
|
638
|
-
return `Credit Account ${this.creditManagerName}: ${currentSentences.join(
|
|
686
|
+
return `Credit Account ${this.creditManagerName}: ${currentSentences.join(
|
|
687
|
+
"; "
|
|
688
|
+
)}`;
|
|
639
689
|
}
|
|
640
690
|
serialize() {
|
|
641
691
|
return {
|
|
@@ -693,6 +743,7 @@ class TxFillOrder extends import_eventOrTx.EVMTx {
|
|
|
693
743
|
TxRepayAccount,
|
|
694
744
|
TxSerializer,
|
|
695
745
|
TxStakeDiesel,
|
|
746
|
+
TxStartDelayedWithdrawal,
|
|
696
747
|
TxUnstakeDiesel,
|
|
697
748
|
TxUpdateQuota,
|
|
698
749
|
TxWithdrawCollateral
|
|
@@ -43,7 +43,8 @@ const HUMAN_READABLE_SYMBOLS = {
|
|
|
43
43
|
PT_sUSDX_1SEP2025: "pt.sUSDX(1.09.25)",
|
|
44
44
|
PT_sUSDf_25SEP2025: "pt.sUSDf(1.09.25)",
|
|
45
45
|
PT_USDf_29JAN2026: "pt.USDf(29.01.26)",
|
|
46
|
-
["PT-wstUSR-25SEP2025"]: "pt.wstUSR(25.09.25)"
|
|
46
|
+
["PT-wstUSR-25SEP2025"]: "pt.wstUSR(25.09.25)",
|
|
47
|
+
wdwstETH: "rstETH\xA0\u2192\xA0wstETH"
|
|
47
48
|
};
|
|
48
49
|
class TokenData {
|
|
49
50
|
address;
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { encodeFunctionData, getAddress } from "viem";
|
|
1
|
+
import { encodeFunctionData, getAddress, getContract } from "viem";
|
|
2
2
|
import {
|
|
3
3
|
iCreditAccountCompressorAbi,
|
|
4
4
|
iPeripheryCompressorAbi,
|
|
@@ -423,6 +423,163 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
423
423
|
const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
|
|
424
424
|
return { tx, calls, creditFacade: cm.creditFacade };
|
|
425
425
|
}
|
|
426
|
+
/**
|
|
427
|
+
* Start delayed withdrawal for given token
|
|
428
|
+
- Withdrawal is executed in the following order: price update -> execute withdraw calls -> update quotas
|
|
429
|
+
* @param props - {@link StartDelayedWithdrawalProps}
|
|
430
|
+
* @returns
|
|
431
|
+
*/
|
|
432
|
+
async startDelayedWithdrawal_Mellow({
|
|
433
|
+
creditAccount,
|
|
434
|
+
minQuota,
|
|
435
|
+
averageQuota,
|
|
436
|
+
instantWithdrawals,
|
|
437
|
+
delayedWithdrawals,
|
|
438
|
+
sourceAmount,
|
|
439
|
+
sourceToken
|
|
440
|
+
}) {
|
|
441
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
442
|
+
creditAccount.creditManager
|
|
443
|
+
);
|
|
444
|
+
const balances = [...instantWithdrawals, ...delayedWithdrawals].filter(
|
|
445
|
+
(a) => a.balance > 0
|
|
446
|
+
);
|
|
447
|
+
const storeExpectedBalances = {
|
|
448
|
+
target: cm.creditFacade.address,
|
|
449
|
+
callData: encodeFunctionData({
|
|
450
|
+
abi: iCreditFacadeV300MulticallAbi,
|
|
451
|
+
functionName: "storeExpectedBalances",
|
|
452
|
+
args: [
|
|
453
|
+
balances.map((a) => ({ token: a.token, amount: a.balance - 10n }))
|
|
454
|
+
]
|
|
455
|
+
})
|
|
456
|
+
};
|
|
457
|
+
const compareBalances = {
|
|
458
|
+
target: cm.creditFacade.address,
|
|
459
|
+
callData: encodeFunctionData({
|
|
460
|
+
abi: iCreditFacadeV300MulticallAbi,
|
|
461
|
+
functionName: "compareBalances",
|
|
462
|
+
args: []
|
|
463
|
+
})
|
|
464
|
+
};
|
|
465
|
+
const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
|
|
466
|
+
creditAccount.creditManager,
|
|
467
|
+
creditAccount,
|
|
468
|
+
averageQuota
|
|
469
|
+
);
|
|
470
|
+
const mellowAdapter = cm.creditManager.adapters.mustGet(sourceToken);
|
|
471
|
+
const redeem = {
|
|
472
|
+
target: mellowAdapter.address,
|
|
473
|
+
callData: encodeFunctionData({
|
|
474
|
+
abi: ierc4626AdapterAbi,
|
|
475
|
+
functionName: "redeem",
|
|
476
|
+
args: [sourceAmount, ADDRESS_0X0, ADDRESS_0X0]
|
|
477
|
+
})
|
|
478
|
+
};
|
|
479
|
+
const CLAIMER = "0x25024a3017B8da7161d8c5DCcF768F8678fB5802";
|
|
480
|
+
const mellowClaimerAdapter = cm.creditManager.adapters.mustGet(CLAIMER);
|
|
481
|
+
const multiAcceptContract = getContract({
|
|
482
|
+
address: mellowClaimerAdapter.address,
|
|
483
|
+
abi: iMellowClaimerAdapterAbi,
|
|
484
|
+
client: this.sdk.provider.publicClient
|
|
485
|
+
});
|
|
486
|
+
const indices = await multiAcceptContract.read.getMultiVaultSubvaultIndices(
|
|
487
|
+
[sourceToken]
|
|
488
|
+
);
|
|
489
|
+
const multiaccept = {
|
|
490
|
+
target: mellowClaimerAdapter.address,
|
|
491
|
+
callData: encodeFunctionData({
|
|
492
|
+
abi: iMellowClaimerAdapterAbi,
|
|
493
|
+
functionName: "multiAccept",
|
|
494
|
+
args: [sourceToken, ...indices]
|
|
495
|
+
})
|
|
496
|
+
};
|
|
497
|
+
const calls = [
|
|
498
|
+
...priceUpdatesCalls,
|
|
499
|
+
storeExpectedBalances,
|
|
500
|
+
redeem,
|
|
501
|
+
multiaccept,
|
|
502
|
+
compareBalances,
|
|
503
|
+
...this.prepareUpdateQuotas(creditAccount.creditFacade, {
|
|
504
|
+
minQuota,
|
|
505
|
+
averageQuota
|
|
506
|
+
})
|
|
507
|
+
];
|
|
508
|
+
const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
|
|
509
|
+
return { tx, calls, creditFacade: cm.creditFacade };
|
|
510
|
+
}
|
|
511
|
+
/**
|
|
512
|
+
* Claim tokens with delayed withdrawal
|
|
513
|
+
- Claim is executed in the following order: price update -> execute claim calls -> update quotas
|
|
514
|
+
* @param props - {@link ClaimDelayedProps}
|
|
515
|
+
* @returns
|
|
516
|
+
*/
|
|
517
|
+
async claimDelayed_Mellow({
|
|
518
|
+
creditAccount,
|
|
519
|
+
minQuota,
|
|
520
|
+
averageQuota,
|
|
521
|
+
sourceToken,
|
|
522
|
+
phantom,
|
|
523
|
+
target
|
|
524
|
+
}) {
|
|
525
|
+
const cm = this.sdk.marketRegister.findCreditManager(
|
|
526
|
+
creditAccount.creditManager
|
|
527
|
+
);
|
|
528
|
+
const storeExpectedBalances = {
|
|
529
|
+
target: cm.creditFacade.address,
|
|
530
|
+
callData: encodeFunctionData({
|
|
531
|
+
abi: iCreditFacadeV300MulticallAbi,
|
|
532
|
+
functionName: "storeExpectedBalances",
|
|
533
|
+
args: [
|
|
534
|
+
[target].map((a) => ({ token: a.token, amount: a.balance - 10n }))
|
|
535
|
+
]
|
|
536
|
+
})
|
|
537
|
+
};
|
|
538
|
+
const compareBalances = {
|
|
539
|
+
target: cm.creditFacade.address,
|
|
540
|
+
callData: encodeFunctionData({
|
|
541
|
+
abi: iCreditFacadeV300MulticallAbi,
|
|
542
|
+
functionName: "compareBalances",
|
|
543
|
+
args: []
|
|
544
|
+
})
|
|
545
|
+
};
|
|
546
|
+
const priceUpdatesCalls = await this.getPriceUpdatesForFacade(
|
|
547
|
+
creditAccount.creditManager,
|
|
548
|
+
creditAccount,
|
|
549
|
+
averageQuota
|
|
550
|
+
);
|
|
551
|
+
const CLAIMER = "0x25024a3017B8da7161d8c5DCcF768F8678fB5802";
|
|
552
|
+
const mellowClaimerAdapter = cm.creditManager.adapters.mustGet(CLAIMER);
|
|
553
|
+
const multiAcceptContract = getContract({
|
|
554
|
+
address: mellowClaimerAdapter.address,
|
|
555
|
+
abi: iMellowClaimerAdapterAbi,
|
|
556
|
+
client: this.sdk.provider.publicClient
|
|
557
|
+
});
|
|
558
|
+
const indices = await multiAcceptContract.read.getUserSubvaultIndices([
|
|
559
|
+
sourceToken,
|
|
560
|
+
creditAccount.creditAccount
|
|
561
|
+
]);
|
|
562
|
+
const multiaccept = {
|
|
563
|
+
target: mellowClaimerAdapter.address,
|
|
564
|
+
callData: encodeFunctionData({
|
|
565
|
+
abi: iMellowClaimerAdapterAbi,
|
|
566
|
+
functionName: "multiAcceptAndClaim",
|
|
567
|
+
args: [sourceToken, ...indices, ADDRESS_0X0, phantom.balance]
|
|
568
|
+
})
|
|
569
|
+
};
|
|
570
|
+
const calls = [
|
|
571
|
+
...priceUpdatesCalls,
|
|
572
|
+
storeExpectedBalances,
|
|
573
|
+
multiaccept,
|
|
574
|
+
compareBalances,
|
|
575
|
+
...this.prepareUpdateQuotas(creditAccount.creditFacade, {
|
|
576
|
+
minQuota,
|
|
577
|
+
averageQuota
|
|
578
|
+
})
|
|
579
|
+
];
|
|
580
|
+
const tx = cm.creditFacade.multicall(creditAccount.creditAccount, calls);
|
|
581
|
+
return { tx, calls, creditFacade: cm.creditFacade };
|
|
582
|
+
}
|
|
426
583
|
/**
|
|
427
584
|
* Executes enable/disable tokens specified by given tokens lists and token prices
|
|
428
585
|
* @param {RouterCASlice} creditAccount - minimal credit account data {@link RouterCASlice} on which operation is performed
|
|
@@ -855,6 +1012,92 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
855
1012
|
)[0];
|
|
856
1013
|
}
|
|
857
1014
|
}
|
|
1015
|
+
const iMellowClaimerAdapterAbi = [
|
|
1016
|
+
{
|
|
1017
|
+
type: "function",
|
|
1018
|
+
name: "getMultiVaultSubvaultIndices",
|
|
1019
|
+
inputs: [{ name: "multiVault", type: "address", internalType: "address" }],
|
|
1020
|
+
outputs: [
|
|
1021
|
+
{
|
|
1022
|
+
name: "subvaultIndices",
|
|
1023
|
+
type: "uint256[]",
|
|
1024
|
+
internalType: "uint256[]"
|
|
1025
|
+
},
|
|
1026
|
+
{
|
|
1027
|
+
name: "withdrawalIndices",
|
|
1028
|
+
type: "uint256[][]",
|
|
1029
|
+
internalType: "uint256[][]"
|
|
1030
|
+
}
|
|
1031
|
+
],
|
|
1032
|
+
stateMutability: "view"
|
|
1033
|
+
},
|
|
1034
|
+
{
|
|
1035
|
+
type: "function",
|
|
1036
|
+
name: "getUserSubvaultIndices",
|
|
1037
|
+
inputs: [
|
|
1038
|
+
{ name: "multiVault", type: "address", internalType: "address" },
|
|
1039
|
+
{ name: "user", type: "address", internalType: "address" }
|
|
1040
|
+
],
|
|
1041
|
+
outputs: [
|
|
1042
|
+
{
|
|
1043
|
+
name: "subvaultIndices",
|
|
1044
|
+
type: "uint256[]",
|
|
1045
|
+
internalType: "uint256[]"
|
|
1046
|
+
},
|
|
1047
|
+
{
|
|
1048
|
+
name: "withdrawalIndices",
|
|
1049
|
+
type: "uint256[][]",
|
|
1050
|
+
internalType: "uint256[][]"
|
|
1051
|
+
}
|
|
1052
|
+
],
|
|
1053
|
+
stateMutability: "view"
|
|
1054
|
+
},
|
|
1055
|
+
{
|
|
1056
|
+
type: "function",
|
|
1057
|
+
name: "multiAccept",
|
|
1058
|
+
inputs: [
|
|
1059
|
+
{ name: "multiVault", type: "address", internalType: "address" },
|
|
1060
|
+
{
|
|
1061
|
+
name: "subvaultIndices",
|
|
1062
|
+
type: "uint256[]",
|
|
1063
|
+
internalType: "uint256[]"
|
|
1064
|
+
},
|
|
1065
|
+
{ name: "indices", type: "uint256[][]", internalType: "uint256[][]" }
|
|
1066
|
+
],
|
|
1067
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
1068
|
+
stateMutability: "nonpayable"
|
|
1069
|
+
},
|
|
1070
|
+
{
|
|
1071
|
+
type: "function",
|
|
1072
|
+
name: "multiAcceptAndClaim",
|
|
1073
|
+
inputs: [
|
|
1074
|
+
{ name: "multiVault", type: "address", internalType: "address" },
|
|
1075
|
+
{
|
|
1076
|
+
name: "subvaultIndices",
|
|
1077
|
+
type: "uint256[]",
|
|
1078
|
+
internalType: "uint256[]"
|
|
1079
|
+
},
|
|
1080
|
+
{ name: "indices", type: "uint256[][]", internalType: "uint256[][]" },
|
|
1081
|
+
{ name: "", type: "address", internalType: "address" },
|
|
1082
|
+
{ name: "maxAssets", type: "uint256", internalType: "uint256" }
|
|
1083
|
+
],
|
|
1084
|
+
outputs: [{ name: "", type: "bool", internalType: "bool" }],
|
|
1085
|
+
stateMutability: "nonpayable"
|
|
1086
|
+
}
|
|
1087
|
+
];
|
|
1088
|
+
const ierc4626AdapterAbi = [
|
|
1089
|
+
{
|
|
1090
|
+
type: "function",
|
|
1091
|
+
inputs: [
|
|
1092
|
+
{ name: "shares", internalType: "uint256", type: "uint256" },
|
|
1093
|
+
{ name: "", internalType: "address", type: "address" },
|
|
1094
|
+
{ name: "", internalType: "address", type: "address" }
|
|
1095
|
+
],
|
|
1096
|
+
name: "redeem",
|
|
1097
|
+
outputs: [{ name: "useSafePrices", internalType: "bool", type: "bool" }],
|
|
1098
|
+
stateMutability: "nonpayable"
|
|
1099
|
+
}
|
|
1100
|
+
];
|
|
858
1101
|
export {
|
|
859
1102
|
AbstractCreditAccountService
|
|
860
1103
|
};
|
|
@@ -55,11 +55,10 @@ const chains = {
|
|
|
55
55
|
"0x4d427D418342d8CE89a7634c3a402851978B680A": "K3",
|
|
56
56
|
"0xc168343c791d56dd1da4b4b8b0cc1c1ec1a16e6b": "cp0x",
|
|
57
57
|
"0x3b56538833fc02f4f0e75609390f26ded0c32e42": "Re7",
|
|
58
|
-
"0x7a133fbd01736fd076158307c9476cc3877f1af5": "Invariant Group"
|
|
59
|
-
},
|
|
60
|
-
testMarketConfigurators: {
|
|
58
|
+
"0x7a133fbd01736fd076158307c9476cc3877f1af5": "Invariant Group",
|
|
61
59
|
"0x09d8305F49374AEA6A78aF6C996df2913e8f3b19": "Tulipa"
|
|
62
60
|
},
|
|
61
|
+
testMarketConfigurators: {},
|
|
63
62
|
isPublic: true,
|
|
64
63
|
wellKnownToken: {
|
|
65
64
|
address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
|
|
@@ -60,6 +60,8 @@ class TxSerializer {
|
|
|
60
60
|
return new TxEnableTokens(params);
|
|
61
61
|
case "TxFillOrder":
|
|
62
62
|
return new TxFillOrder(params);
|
|
63
|
+
case "TxStartDelayedWithdrawal":
|
|
64
|
+
return new TxStartDelayedWithdrawal(params);
|
|
63
65
|
default:
|
|
64
66
|
throw new Error(`Unknown transaction for parsing: ${e.type}`);
|
|
65
67
|
}
|
|
@@ -341,7 +343,7 @@ class TxClaimRewards extends EVMTx {
|
|
|
341
343
|
const { title } = token;
|
|
342
344
|
return title;
|
|
343
345
|
}).join(", ");
|
|
344
|
-
return `
|
|
346
|
+
return `Claimed: ${rewardsString}`;
|
|
345
347
|
}
|
|
346
348
|
serialize() {
|
|
347
349
|
return {
|
|
@@ -350,6 +352,51 @@ class TxClaimRewards extends EVMTx {
|
|
|
350
352
|
};
|
|
351
353
|
}
|
|
352
354
|
}
|
|
355
|
+
class TxStartDelayedWithdrawal extends EVMTx {
|
|
356
|
+
instantWithdrawals;
|
|
357
|
+
delayedWithdrawals;
|
|
358
|
+
constructor(opts) {
|
|
359
|
+
super(opts);
|
|
360
|
+
this.instantWithdrawals = opts.instantWithdrawals.map(
|
|
361
|
+
({ token, balance }) => ({
|
|
362
|
+
token: opts.tokensList[token],
|
|
363
|
+
balance
|
|
364
|
+
})
|
|
365
|
+
);
|
|
366
|
+
this.delayedWithdrawals = opts.delayedWithdrawals.map(
|
|
367
|
+
({ token, balance }) => ({
|
|
368
|
+
token: opts.tokensList[token],
|
|
369
|
+
balance
|
|
370
|
+
})
|
|
371
|
+
);
|
|
372
|
+
}
|
|
373
|
+
toString() {
|
|
374
|
+
const total = this.instantWithdrawals.length + this.delayedWithdrawals.length;
|
|
375
|
+
const instantString = total <= 2 ? this.instantWithdrawals.map(({ token, balance }) => {
|
|
376
|
+
const { title, decimals = 18 } = token;
|
|
377
|
+
return `${formatBN(balance, decimals)} ${title}`;
|
|
378
|
+
}).join(", ") : this.instantWithdrawals.map(({ token }) => {
|
|
379
|
+
const { title } = token;
|
|
380
|
+
return title;
|
|
381
|
+
}).join(", ");
|
|
382
|
+
const delayedString = total <= 2 ? this.delayedWithdrawals.map(({ token, balance }) => {
|
|
383
|
+
const { title, decimals = 18 } = token;
|
|
384
|
+
return `${formatBN(balance, decimals)} ${title}`;
|
|
385
|
+
}).join(", ") : this.delayedWithdrawals.map(({ token }) => {
|
|
386
|
+
const { title } = token;
|
|
387
|
+
return title;
|
|
388
|
+
}).join(", ");
|
|
389
|
+
const instant = this.instantWithdrawals.length > 0 ? `Tokens obtained: ${instantString}` : void 0;
|
|
390
|
+
const delayed = this.delayedWithdrawals.length > 0 ? `Tokens withdrawal started: ${delayedString}` : void 0;
|
|
391
|
+
return [instant, delayed].filter((s) => s).join("; ");
|
|
392
|
+
}
|
|
393
|
+
serialize() {
|
|
394
|
+
return {
|
|
395
|
+
type: "TxStartDelayedWithdrawal",
|
|
396
|
+
content: JSON.stringify(this)
|
|
397
|
+
};
|
|
398
|
+
}
|
|
399
|
+
}
|
|
353
400
|
class TxRepayAccount extends EVMTx {
|
|
354
401
|
creditManagerName;
|
|
355
402
|
constructor(opts) {
|
|
@@ -587,7 +634,9 @@ class TxEnableTokens extends EVMTx {
|
|
|
587
634
|
enabledSymbols.length > 0 ? `enabled: ${enabledSymbols.join(", ")}` : "",
|
|
588
635
|
disabledSymbols.length > 0 ? `disabled: ${disabledSymbols.join(", ")}` : ""
|
|
589
636
|
].filter((s) => !!s);
|
|
590
|
-
return `Credit Account ${this.creditManagerName}: ${currentSentences.join(
|
|
637
|
+
return `Credit Account ${this.creditManagerName}: ${currentSentences.join(
|
|
638
|
+
"; "
|
|
639
|
+
)}`;
|
|
591
640
|
}
|
|
592
641
|
serialize() {
|
|
593
642
|
return {
|
|
@@ -644,6 +693,7 @@ export {
|
|
|
644
693
|
TxRepayAccount,
|
|
645
694
|
TxSerializer,
|
|
646
695
|
TxStakeDiesel,
|
|
696
|
+
TxStartDelayedWithdrawal,
|
|
647
697
|
TxUnstakeDiesel,
|
|
648
698
|
TxUpdateQuota,
|
|
649
699
|
TxWithdrawCollateral
|
|
@@ -20,7 +20,8 @@ const HUMAN_READABLE_SYMBOLS = {
|
|
|
20
20
|
PT_sUSDX_1SEP2025: "pt.sUSDX(1.09.25)",
|
|
21
21
|
PT_sUSDf_25SEP2025: "pt.sUSDf(1.09.25)",
|
|
22
22
|
PT_USDf_29JAN2026: "pt.USDf(29.01.26)",
|
|
23
|
-
["PT-wstUSR-25SEP2025"]: "pt.wstUSR(25.09.25)"
|
|
23
|
+
["PT-wstUSR-25SEP2025"]: "pt.wstUSR(25.09.25)",
|
|
24
|
+
wdwstETH: "rstETH\xA0\u2192\xA0wstETH"
|
|
24
25
|
};
|
|
25
26
|
class TokenData {
|
|
26
27
|
address;
|
|
@@ -5,7 +5,7 @@ import type { GearboxSDK } from "../GearboxSDK.js";
|
|
|
5
5
|
import type { OnDemandPriceUpdate, UpdatePriceFeedsResult } from "../market/index.js";
|
|
6
6
|
import { type Asset, type RouterCASlice } from "../router/index.js";
|
|
7
7
|
import type { MultiCall } from "../types/index.js";
|
|
8
|
-
import type { FullyLiquidateProps, GetConnectedBotsResult } from "./types";
|
|
8
|
+
import type { ClaimDelayedProps, FullyLiquidateProps, GetConnectedBotsResult, StartDelayedWithdrawalProps } from "./types";
|
|
9
9
|
import type { AddCollateralProps, ChangeDeptProps, CloseCreditAccountProps, CloseCreditAccountResult, CreditAccountOperationResult, EnableTokensProps, ExecuteSwapProps, GetCreditAccountsOptions, OpenCAProps, PermitResult, PrepareUpdateQuotasProps, Rewards, UpdateQuotasProps } from "./types.js";
|
|
10
10
|
export interface CreditAccountServiceOptions {
|
|
11
11
|
batchSize?: number;
|
|
@@ -112,6 +112,20 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
112
112
|
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
113
113
|
*/
|
|
114
114
|
executeSwap({ creditAccount, calls: swapCalls, minQuota, averageQuota, }: ExecuteSwapProps): Promise<CreditAccountOperationResult>;
|
|
115
|
+
/**
|
|
116
|
+
* Start delayed withdrawal for given token
|
|
117
|
+
- Withdrawal is executed in the following order: price update -> execute withdraw calls -> update quotas
|
|
118
|
+
* @param props - {@link StartDelayedWithdrawalProps}
|
|
119
|
+
* @returns
|
|
120
|
+
*/
|
|
121
|
+
startDelayedWithdrawal_Mellow({ creditAccount, minQuota, averageQuota, instantWithdrawals, delayedWithdrawals, sourceAmount, sourceToken, }: StartDelayedWithdrawalProps): Promise<CreditAccountOperationResult>;
|
|
122
|
+
/**
|
|
123
|
+
* Claim tokens with delayed withdrawal
|
|
124
|
+
- Claim is executed in the following order: price update -> execute claim calls -> update quotas
|
|
125
|
+
* @param props - {@link ClaimDelayedProps}
|
|
126
|
+
* @returns
|
|
127
|
+
*/
|
|
128
|
+
claimDelayed_Mellow({ creditAccount, minQuota, averageQuota, sourceToken, phantom, target, }: ClaimDelayedProps): Promise<CreditAccountOperationResult>;
|
|
115
129
|
/**
|
|
116
130
|
* Executes enable/disable tokens specified by given tokens lists and token prices
|
|
117
131
|
* @param {RouterCASlice} creditAccount - minimal credit account data {@link RouterCASlice} on which operation is performed
|
|
@@ -156,6 +156,46 @@ export interface ExecuteSwapProps extends PrepareUpdateQuotasProps {
|
|
|
156
156
|
*/
|
|
157
157
|
creditAccount: RouterCASlice;
|
|
158
158
|
}
|
|
159
|
+
export interface StartDelayedWithdrawalProps extends PrepareUpdateQuotasProps {
|
|
160
|
+
/**
|
|
161
|
+
* Amount of source token (ex. sp0xlrt)
|
|
162
|
+
*/
|
|
163
|
+
sourceAmount: bigint;
|
|
164
|
+
/**
|
|
165
|
+
* Address of source token (ex. sp0xlrt)
|
|
166
|
+
*/
|
|
167
|
+
sourceToken: Address;
|
|
168
|
+
/**
|
|
169
|
+
* Array of token which can be instantly withdrawn
|
|
170
|
+
*/
|
|
171
|
+
instantWithdrawals: Array<Asset>;
|
|
172
|
+
/**
|
|
173
|
+
* Array of token which will be withdrawn with a delay
|
|
174
|
+
*/
|
|
175
|
+
delayedWithdrawals: Array<Asset>;
|
|
176
|
+
/**
|
|
177
|
+
* Minimal credit account data on which operation is performed
|
|
178
|
+
*/
|
|
179
|
+
creditAccount: RouterCASlice;
|
|
180
|
+
}
|
|
181
|
+
export interface ClaimDelayedProps extends PrepareUpdateQuotasProps {
|
|
182
|
+
/**
|
|
183
|
+
* Address of source token (ex. sp0xlrt)
|
|
184
|
+
*/
|
|
185
|
+
sourceToken: Address;
|
|
186
|
+
/**
|
|
187
|
+
* Amount of phantom token
|
|
188
|
+
*/
|
|
189
|
+
phantom: Asset;
|
|
190
|
+
/**
|
|
191
|
+
* Amount of target token
|
|
192
|
+
*/
|
|
193
|
+
target: Asset;
|
|
194
|
+
/**
|
|
195
|
+
* Minimal credit account data on which operation is performed
|
|
196
|
+
*/
|
|
197
|
+
creditAccount: RouterCASlice;
|
|
198
|
+
}
|
|
159
199
|
export interface ClaimFarmRewardsProps extends PrepareUpdateQuotasProps {
|
|
160
200
|
/**
|
|
161
201
|
* Legacy property, v3.1 only enables token when quota is bought and when quota is bought token cannot be disabled.
|
|
@@ -400,6 +440,20 @@ export interface ICreditAccountsService extends SDKConstruct {
|
|
|
400
440
|
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
401
441
|
*/
|
|
402
442
|
executeSwap(props: ExecuteSwapProps): Promise<CreditAccountOperationResult>;
|
|
443
|
+
/**
|
|
444
|
+
* Start delayed withdrawal for given token
|
|
445
|
+
- Withdrawal is executed in the following order: price update -> execute withdraw calls -> update quotas
|
|
446
|
+
* @param props - {@link StartDelayedWithdrawalProps}
|
|
447
|
+
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
448
|
+
*/
|
|
449
|
+
startDelayedWithdrawal_Mellow(props: StartDelayedWithdrawalProps): Promise<CreditAccountOperationResult>;
|
|
450
|
+
/**
|
|
451
|
+
* Claim tokens with delayed withdrawal
|
|
452
|
+
- Claim is executed in the following order: price update -> execute claim calls -> update quotas
|
|
453
|
+
* @param props - {@link ClaimDelayedProps}
|
|
454
|
+
* @returns
|
|
455
|
+
*/
|
|
456
|
+
claimDelayed_Mellow(props: ClaimDelayedProps): Promise<CreditAccountOperationResult>;
|
|
403
457
|
/**
|
|
404
458
|
* Executes enable/disable tokens specified by given tokens lists and token prices
|
|
405
459
|
* @param props - {@link EnableTokensProps}
|
|
@@ -4,7 +4,7 @@ import type { TokenData } from "../tokens/tokenData.js";
|
|
|
4
4
|
import type { EVMTxProps } from "./eventOrTx.js";
|
|
5
5
|
import { EVMTx } from "./eventOrTx.js";
|
|
6
6
|
export interface TxSerialized {
|
|
7
|
-
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimNFT" | "TxClaimRewards" | "TxUpdateQuota" | "TxGaugeStake" | "TxGaugeUnstake" | "TxGaugeClaim" | "TxGaugeVote" | "TxWithdrawCollateral" | "TxAddBot" | "TxRemoveBot" | "TxLiquidateAccount" | "TxStakeDiesel" | "TxUnstakeDiesel" | "TxEnableTokens" | "TxFillOrder";
|
|
7
|
+
type: "TxAddLiquidity" | "TxRemoveLiquidity" | "TxSwap" | "TxAddCollateral" | "TxIncreaseBorrowAmount" | "TxDecreaseBorrowAmount" | "TxRepayAccount" | "TxCloseAccount" | "TxApprove" | "TxOpenMultitokenAccount" | "TxClaimNFT" | "TxClaimRewards" | "TxUpdateQuota" | "TxGaugeStake" | "TxGaugeUnstake" | "TxGaugeClaim" | "TxGaugeVote" | "TxWithdrawCollateral" | "TxAddBot" | "TxRemoveBot" | "TxLiquidateAccount" | "TxStakeDiesel" | "TxUnstakeDiesel" | "TxEnableTokens" | "TxFillOrder" | "TxStartDelayedWithdrawal";
|
|
8
8
|
content: string;
|
|
9
9
|
}
|
|
10
10
|
export declare class TxSerializer {
|
|
@@ -160,6 +160,22 @@ export declare class TxClaimRewards extends EVMTx {
|
|
|
160
160
|
toString(): string;
|
|
161
161
|
serialize(): TxSerialized;
|
|
162
162
|
}
|
|
163
|
+
interface TxStartDelayedWithdrawalProps extends EVMTxProps {
|
|
164
|
+
instantWithdrawals: Array<Asset>;
|
|
165
|
+
delayedWithdrawals: Array<Asset>;
|
|
166
|
+
tokensList: Record<Address, TokenData>;
|
|
167
|
+
}
|
|
168
|
+
export declare class TxStartDelayedWithdrawal extends EVMTx {
|
|
169
|
+
readonly instantWithdrawals: Array<Omit<Asset, "token"> & {
|
|
170
|
+
token: TokenData;
|
|
171
|
+
}>;
|
|
172
|
+
readonly delayedWithdrawals: Array<Omit<Asset, "token"> & {
|
|
173
|
+
token: TokenData;
|
|
174
|
+
}>;
|
|
175
|
+
constructor(opts: TxStartDelayedWithdrawalProps);
|
|
176
|
+
toString(): string;
|
|
177
|
+
serialize(): TxSerialized;
|
|
178
|
+
}
|
|
163
179
|
interface RepayAccountProps extends EVMTxProps {
|
|
164
180
|
creditManagerName: string;
|
|
165
181
|
}
|