@gearbox-protocol/sdk 13.0.0-next.14 → 13.0.0-next.16
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/dev/AccountOpener.js +6 -2
- package/dist/cjs/sdk/accounts/AbstractCreditAccountsService.js +16 -2
- package/dist/cjs/sdk/base/TokensMeta.js +1 -1
- package/dist/esm/dev/AccountOpener.js +6 -2
- package/dist/esm/sdk/accounts/AbstractCreditAccountsService.js +16 -2
- package/dist/esm/sdk/base/TokensMeta.js +1 -1
- package/dist/types/sdk/accounts/AbstractCreditAccountsService.d.ts +1 -1
- package/dist/types/sdk/accounts/types.d.ts +2 -1
- package/package.json +1 -1
|
@@ -475,6 +475,10 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
475
475
|
address,
|
|
476
476
|
underlying
|
|
477
477
|
);
|
|
478
|
+
this.#logger?.debug(
|
|
479
|
+
{ tokensOut: tokensOut.map((t) => this.labelAddress(t)) },
|
|
480
|
+
"deposit tokens out"
|
|
481
|
+
);
|
|
478
482
|
if (tokensOut.length === 0) {
|
|
479
483
|
throw new Error(`no tokens out found for pool ${poolName}`);
|
|
480
484
|
}
|
|
@@ -486,8 +490,8 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
486
490
|
);
|
|
487
491
|
this.logger?.debug(
|
|
488
492
|
{
|
|
489
|
-
underlying,
|
|
490
|
-
tokenOut,
|
|
493
|
+
underlying: this.labelAddress(underlying),
|
|
494
|
+
tokenOut: this.labelAddress(tokenOut),
|
|
491
495
|
...metadata
|
|
492
496
|
},
|
|
493
497
|
"pool deposit metadata"
|
|
@@ -817,7 +817,7 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
817
817
|
collateral,
|
|
818
818
|
permits,
|
|
819
819
|
debt,
|
|
820
|
-
|
|
820
|
+
withdrawToken,
|
|
821
821
|
referralCode,
|
|
822
822
|
to,
|
|
823
823
|
calls: openPathCalls,
|
|
@@ -826,6 +826,12 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
826
826
|
}) {
|
|
827
827
|
const cmSuite = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
828
828
|
const cm = cmSuite.creditManager;
|
|
829
|
+
let tokenToWithdraw;
|
|
830
|
+
if (withdrawToken === true) {
|
|
831
|
+
tokenToWithdraw = cm.underlying;
|
|
832
|
+
} else if (typeof withdrawToken === "string") {
|
|
833
|
+
tokenToWithdraw = withdrawToken;
|
|
834
|
+
}
|
|
829
835
|
const priceUpdatesCalls = await this.getPriceUpdatesForFacade({
|
|
830
836
|
creditManager: cm.address,
|
|
831
837
|
desiredQuotas: averageQuota
|
|
@@ -835,7 +841,15 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
835
841
|
this.#prepareIncreaseDebt(cm.creditFacade, debt),
|
|
836
842
|
...this.prepareAddCollateral(cm.creditFacade, collateral, permits),
|
|
837
843
|
...openPathCalls,
|
|
838
|
-
|
|
844
|
+
// путь из underlying в withdrawal token
|
|
845
|
+
...tokenToWithdraw ? [
|
|
846
|
+
this.prepareWithdrawToken(
|
|
847
|
+
cm.creditFacade,
|
|
848
|
+
tokenToWithdraw,
|
|
849
|
+
import_constants.MAX_UINT256,
|
|
850
|
+
to
|
|
851
|
+
)
|
|
852
|
+
] : [],
|
|
839
853
|
...this.prepareUpdateQuotas(cm.creditFacade, {
|
|
840
854
|
minQuota,
|
|
841
855
|
averageQuota
|
|
@@ -129,7 +129,7 @@ class TokensMeta extends import_utils.AddressMap {
|
|
|
129
129
|
batchSize: 0
|
|
130
130
|
});
|
|
131
131
|
for (let i = 0; i < tokensToLoad.length; i++) {
|
|
132
|
-
this.#overrideTokenMeta(tokensToLoad[i], resp[i], resp[i + 1]);
|
|
132
|
+
this.#overrideTokenMeta(tokensToLoad[i], resp[2 * i], resp[2 * i + 1]);
|
|
133
133
|
this.#tokenDataLoaded.add(tokensToLoad[i]);
|
|
134
134
|
}
|
|
135
135
|
}
|
|
@@ -467,6 +467,10 @@ class AccountOpener extends SDKConstruct {
|
|
|
467
467
|
address,
|
|
468
468
|
underlying
|
|
469
469
|
);
|
|
470
|
+
this.#logger?.debug(
|
|
471
|
+
{ tokensOut: tokensOut.map((t) => this.labelAddress(t)) },
|
|
472
|
+
"deposit tokens out"
|
|
473
|
+
);
|
|
470
474
|
if (tokensOut.length === 0) {
|
|
471
475
|
throw new Error(`no tokens out found for pool ${poolName}`);
|
|
472
476
|
}
|
|
@@ -478,8 +482,8 @@ class AccountOpener extends SDKConstruct {
|
|
|
478
482
|
);
|
|
479
483
|
this.logger?.debug(
|
|
480
484
|
{
|
|
481
|
-
underlying,
|
|
482
|
-
tokenOut,
|
|
485
|
+
underlying: this.labelAddress(underlying),
|
|
486
|
+
tokenOut: this.labelAddress(tokenOut),
|
|
483
487
|
...metadata
|
|
484
488
|
},
|
|
485
489
|
"pool deposit metadata"
|
|
@@ -809,7 +809,7 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
809
809
|
collateral,
|
|
810
810
|
permits,
|
|
811
811
|
debt,
|
|
812
|
-
|
|
812
|
+
withdrawToken,
|
|
813
813
|
referralCode,
|
|
814
814
|
to,
|
|
815
815
|
calls: openPathCalls,
|
|
@@ -818,6 +818,12 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
818
818
|
}) {
|
|
819
819
|
const cmSuite = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
820
820
|
const cm = cmSuite.creditManager;
|
|
821
|
+
let tokenToWithdraw;
|
|
822
|
+
if (withdrawToken === true) {
|
|
823
|
+
tokenToWithdraw = cm.underlying;
|
|
824
|
+
} else if (typeof withdrawToken === "string") {
|
|
825
|
+
tokenToWithdraw = withdrawToken;
|
|
826
|
+
}
|
|
821
827
|
const priceUpdatesCalls = await this.getPriceUpdatesForFacade({
|
|
822
828
|
creditManager: cm.address,
|
|
823
829
|
desiredQuotas: averageQuota
|
|
@@ -827,7 +833,15 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
827
833
|
this.#prepareIncreaseDebt(cm.creditFacade, debt),
|
|
828
834
|
...this.prepareAddCollateral(cm.creditFacade, collateral, permits),
|
|
829
835
|
...openPathCalls,
|
|
830
|
-
|
|
836
|
+
// путь из underlying в withdrawal token
|
|
837
|
+
...tokenToWithdraw ? [
|
|
838
|
+
this.prepareWithdrawToken(
|
|
839
|
+
cm.creditFacade,
|
|
840
|
+
tokenToWithdraw,
|
|
841
|
+
MAX_UINT256,
|
|
842
|
+
to
|
|
843
|
+
)
|
|
844
|
+
] : [],
|
|
831
845
|
...this.prepareUpdateQuotas(cm.creditFacade, {
|
|
832
846
|
minQuota,
|
|
833
847
|
averageQuota
|
|
@@ -112,7 +112,7 @@ class TokensMeta extends AddressMap {
|
|
|
112
112
|
batchSize: 0
|
|
113
113
|
});
|
|
114
114
|
for (let i = 0; i < tokensToLoad.length; i++) {
|
|
115
|
-
this.#overrideTokenMeta(tokensToLoad[i], resp[i], resp[i + 1]);
|
|
115
|
+
this.#overrideTokenMeta(tokensToLoad[i], resp[2 * i], resp[2 * i + 1]);
|
|
116
116
|
this.#tokenDataLoaded.add(tokensToLoad[i]);
|
|
117
117
|
}
|
|
118
118
|
}
|
|
@@ -173,7 +173,7 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
173
173
|
* @param {Array<Asset>} minQuota - minimum quota for tokens after open {@link Asset}
|
|
174
174
|
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
175
175
|
*/
|
|
176
|
-
openCA({ ethAmount, creditManager, collateral, permits, debt,
|
|
176
|
+
openCA({ ethAmount, creditManager, collateral, permits, debt, withdrawToken, referralCode, to, calls: openPathCalls, minQuota, averageQuota, }: OpenCAProps): Promise<CreditAccountOperationResult>;
|
|
177
177
|
/**
|
|
178
178
|
* Returns borrow rate with 4 digits precision (10000 = 100%)
|
|
179
179
|
* @param ca
|
|
@@ -275,8 +275,9 @@ export interface OpenCAProps extends PrepareUpdateQuotasProps {
|
|
|
275
275
|
/**
|
|
276
276
|
* Flag to withdraw debt to wallet after opening credit account;
|
|
277
277
|
* used for borrowing functionality
|
|
278
|
+
* If true, will withdraw underlying token, otherwise will withdraw specified token
|
|
278
279
|
*/
|
|
279
|
-
|
|
280
|
+
withdrawToken?: boolean | Address;
|
|
280
281
|
/**
|
|
281
282
|
* Permits of collateral tokens (in any permittable token is present) {@link PermitResult}
|
|
282
283
|
*/
|