@gearbox-protocol/sdk 13.0.0-next.26 → 13.0.0-next.28
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.
|
@@ -600,7 +600,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
600
600
|
async changeDebt({
|
|
601
601
|
creditAccount,
|
|
602
602
|
amount,
|
|
603
|
-
|
|
603
|
+
collateral
|
|
604
604
|
}) {
|
|
605
605
|
if (amount === 0n) {
|
|
606
606
|
throw new Error("debt increase or decrease must be non-zero");
|
|
@@ -614,21 +614,31 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
614
614
|
creditManager: creditAccount.creditManager,
|
|
615
615
|
creditAccount
|
|
616
616
|
});
|
|
617
|
-
const addCollateralCalls =
|
|
617
|
+
const addCollateralCalls = collateral && isDecrease ? this.prepareAddCollateral(
|
|
618
618
|
creditAccount.creditFacade,
|
|
619
619
|
[
|
|
620
620
|
{
|
|
621
|
-
token:
|
|
622
|
-
balance:
|
|
621
|
+
token: collateral[0].token,
|
|
622
|
+
balance: collateral[0].balance
|
|
623
623
|
}
|
|
624
624
|
],
|
|
625
625
|
{}
|
|
626
626
|
) : [];
|
|
627
|
+
const unwrapCalls = collateral && isDecrease ? await this.getKYCWrapCalls(
|
|
628
|
+
collateral[0].balance,
|
|
629
|
+
creditAccount.creditManager
|
|
630
|
+
) || [] : [];
|
|
631
|
+
if (addCollateralCalls.length > 0 && unwrapCalls.length === 0 && collateral && collateral?.[0].token !== creditAccount.underlying) {
|
|
632
|
+
throw new Error(
|
|
633
|
+
"Can't use collateral other than underlying for non KYC market"
|
|
634
|
+
);
|
|
635
|
+
}
|
|
627
636
|
const underlyingEnabled = (creditAccount.enabledTokensMask & 1n) === 1n;
|
|
628
637
|
const shouldEnable = !isDecrease && !underlyingEnabled;
|
|
629
638
|
const calls = [
|
|
630
639
|
...priceUpdatesCalls,
|
|
631
640
|
...addCollateralCalls,
|
|
641
|
+
...unwrapCalls,
|
|
632
642
|
...shouldEnable ? this.#prepareEnableTokens(creditAccount.creditFacade, [
|
|
633
643
|
creditAccount.underlying
|
|
634
644
|
]) : [],
|
|
@@ -590,7 +590,7 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
590
590
|
async changeDebt({
|
|
591
591
|
creditAccount,
|
|
592
592
|
amount,
|
|
593
|
-
|
|
593
|
+
collateral
|
|
594
594
|
}) {
|
|
595
595
|
if (amount === 0n) {
|
|
596
596
|
throw new Error("debt increase or decrease must be non-zero");
|
|
@@ -604,21 +604,31 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
604
604
|
creditManager: creditAccount.creditManager,
|
|
605
605
|
creditAccount
|
|
606
606
|
});
|
|
607
|
-
const addCollateralCalls =
|
|
607
|
+
const addCollateralCalls = collateral && isDecrease ? this.prepareAddCollateral(
|
|
608
608
|
creditAccount.creditFacade,
|
|
609
609
|
[
|
|
610
610
|
{
|
|
611
|
-
token:
|
|
612
|
-
balance:
|
|
611
|
+
token: collateral[0].token,
|
|
612
|
+
balance: collateral[0].balance
|
|
613
613
|
}
|
|
614
614
|
],
|
|
615
615
|
{}
|
|
616
616
|
) : [];
|
|
617
|
+
const unwrapCalls = collateral && isDecrease ? await this.getKYCWrapCalls(
|
|
618
|
+
collateral[0].balance,
|
|
619
|
+
creditAccount.creditManager
|
|
620
|
+
) || [] : [];
|
|
621
|
+
if (addCollateralCalls.length > 0 && unwrapCalls.length === 0 && collateral && collateral?.[0].token !== creditAccount.underlying) {
|
|
622
|
+
throw new Error(
|
|
623
|
+
"Can't use collateral other than underlying for non KYC market"
|
|
624
|
+
);
|
|
625
|
+
}
|
|
617
626
|
const underlyingEnabled = (creditAccount.enabledTokensMask & 1n) === 1n;
|
|
618
627
|
const shouldEnable = !isDecrease && !underlyingEnabled;
|
|
619
628
|
const calls = [
|
|
620
629
|
...priceUpdatesCalls,
|
|
621
630
|
...addCollateralCalls,
|
|
631
|
+
...unwrapCalls,
|
|
622
632
|
...shouldEnable ? this.#prepareEnableTokens(creditAccount.creditFacade, [
|
|
623
633
|
creditAccount.underlying
|
|
624
634
|
]) : [],
|
|
@@ -136,7 +136,7 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
136
136
|
positive value for debt increase.
|
|
137
137
|
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
138
138
|
*/
|
|
139
|
-
changeDebt({ creditAccount, amount,
|
|
139
|
+
changeDebt({ creditAccount, amount, collateral, }: ChangeDeptProps): Promise<CreditAccountOperationResult>;
|
|
140
140
|
/**
|
|
141
141
|
* Executes swap specified by given calls, update quotas of affected tokens
|
|
142
142
|
- Swap is executed in the following order: price update -> execute swap path -> update quotas
|
|
@@ -326,9 +326,9 @@ export interface ChangeDeptProps {
|
|
|
326
326
|
*/
|
|
327
327
|
amount: bigint;
|
|
328
328
|
/**
|
|
329
|
-
*
|
|
329
|
+
* Assets to add as collateral
|
|
330
330
|
*/
|
|
331
|
-
|
|
331
|
+
collateral?: [Asset];
|
|
332
332
|
}
|
|
333
333
|
export interface FullyLiquidateProps {
|
|
334
334
|
/**
|