@gearbox-protocol/sdk 13.0.0-next.17 → 13.0.0-next.18
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.
|
@@ -809,41 +809,30 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
809
809
|
}
|
|
810
810
|
/**
|
|
811
811
|
* Executes swap specified by given calls, update quotas of affected tokens
|
|
812
|
-
|
|
813
|
-
|
|
814
|
-
|
|
815
|
-
|
|
816
|
-
|
|
817
|
-
|
|
818
|
-
|
|
819
|
-
* @param {bigint} ethAmount - native token amount to attach to tx
|
|
820
|
-
* @param {Address} creditManager - address of credit manager to open credit account on
|
|
821
|
-
* @param {Array<Asset>} collateral - array of collateral which can be just directly added or swapped using the path {@link Asset}
|
|
822
|
-
* @param {Record<Address, PermitResult>} permits - permits of collateral tokens (in any permittable token is present) {@link PermitResult}
|
|
823
|
-
* @param {bigint} debt - debt to open credit account with
|
|
824
|
-
* @param {boolean} withdrawDebt - flag to withdraw debt to wallet after opening credit account;
|
|
825
|
-
used for borrowing functionality
|
|
826
|
-
* @param {bigint} referralCode - referral code to open credit account with
|
|
827
|
-
* @param {Address} to - wallet address to transfer credit account to
|
|
828
|
-
* @param {Array<MultiCall>} calls - array of MultiCall from router methods findOpenStrategyPath {@link MultiCall}.
|
|
829
|
-
Used for trading and strategy functionality
|
|
830
|
-
* @param {Array<Asset>} averageQuota - average quota for tokens after open {@link Asset}
|
|
831
|
-
* @param {Array<Asset>} minQuota - minimum quota for tokens after open {@link Asset}
|
|
812
|
+
* - Open credit account is executed in the following order: price update -> increase debt -> add collateral ->
|
|
813
|
+
* -> update quotas -> (optionally: execute swap path for trading/strategy) ->
|
|
814
|
+
* -> (optionally: withdraw debt for lending)
|
|
815
|
+
*- Basic open credit account: price update -> increase debt -> add collateral -> update quotas
|
|
816
|
+
*- Lending: price update -> increase debt -> add collateral -> update quotas -> withdraw debt
|
|
817
|
+
*- Strategy/trading: price update -> increase debt -> add collateral -> update quotas -> execute swap path
|
|
818
|
+
*- In strategy is possible situation when collateral is added, but not swapped; the only swapped value in this case will be debt
|
|
832
819
|
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
833
|
-
|
|
834
|
-
async openCA({
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
839
|
-
|
|
840
|
-
|
|
841
|
-
|
|
842
|
-
|
|
843
|
-
|
|
844
|
-
|
|
845
|
-
|
|
846
|
-
|
|
820
|
+
**/
|
|
821
|
+
async openCA(props) {
|
|
822
|
+
const {
|
|
823
|
+
ethAmount,
|
|
824
|
+
creditManager,
|
|
825
|
+
reopenCreditAccount,
|
|
826
|
+
collateral,
|
|
827
|
+
permits,
|
|
828
|
+
debt,
|
|
829
|
+
withdrawToken,
|
|
830
|
+
referralCode,
|
|
831
|
+
to,
|
|
832
|
+
calls: openPathCalls,
|
|
833
|
+
minQuota,
|
|
834
|
+
averageQuota
|
|
835
|
+
} = props;
|
|
847
836
|
const cmSuite = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
848
837
|
const cm = cmSuite.creditManager;
|
|
849
838
|
let tokenToWithdraw;
|
|
@@ -875,7 +864,12 @@ class AbstractCreditAccountService extends import_base.SDKConstruct {
|
|
|
875
864
|
averageQuota
|
|
876
865
|
})
|
|
877
866
|
];
|
|
878
|
-
|
|
867
|
+
let tx;
|
|
868
|
+
if (reopenCreditAccount) {
|
|
869
|
+
tx = await this.multicallTx(cmSuite, reopenCreditAccount, calls);
|
|
870
|
+
} else {
|
|
871
|
+
tx = await this.openCreditAccountTx(cmSuite, to, calls, referralCode);
|
|
872
|
+
}
|
|
879
873
|
tx.value = ethAmount.toString(10);
|
|
880
874
|
return { calls, tx, creditFacade: cmSuite.creditFacade };
|
|
881
875
|
}
|
|
@@ -801,41 +801,30 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
801
801
|
}
|
|
802
802
|
/**
|
|
803
803
|
* Executes swap specified by given calls, update quotas of affected tokens
|
|
804
|
-
|
|
805
|
-
|
|
806
|
-
|
|
807
|
-
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
|
|
811
|
-
* @param {bigint} ethAmount - native token amount to attach to tx
|
|
812
|
-
* @param {Address} creditManager - address of credit manager to open credit account on
|
|
813
|
-
* @param {Array<Asset>} collateral - array of collateral which can be just directly added or swapped using the path {@link Asset}
|
|
814
|
-
* @param {Record<Address, PermitResult>} permits - permits of collateral tokens (in any permittable token is present) {@link PermitResult}
|
|
815
|
-
* @param {bigint} debt - debt to open credit account with
|
|
816
|
-
* @param {boolean} withdrawDebt - flag to withdraw debt to wallet after opening credit account;
|
|
817
|
-
used for borrowing functionality
|
|
818
|
-
* @param {bigint} referralCode - referral code to open credit account with
|
|
819
|
-
* @param {Address} to - wallet address to transfer credit account to
|
|
820
|
-
* @param {Array<MultiCall>} calls - array of MultiCall from router methods findOpenStrategyPath {@link MultiCall}.
|
|
821
|
-
Used for trading and strategy functionality
|
|
822
|
-
* @param {Array<Asset>} averageQuota - average quota for tokens after open {@link Asset}
|
|
823
|
-
* @param {Array<Asset>} minQuota - minimum quota for tokens after open {@link Asset}
|
|
804
|
+
* - Open credit account is executed in the following order: price update -> increase debt -> add collateral ->
|
|
805
|
+
* -> update quotas -> (optionally: execute swap path for trading/strategy) ->
|
|
806
|
+
* -> (optionally: withdraw debt for lending)
|
|
807
|
+
*- Basic open credit account: price update -> increase debt -> add collateral -> update quotas
|
|
808
|
+
*- Lending: price update -> increase debt -> add collateral -> update quotas -> withdraw debt
|
|
809
|
+
*- Strategy/trading: price update -> increase debt -> add collateral -> update quotas -> execute swap path
|
|
810
|
+
*- In strategy is possible situation when collateral is added, but not swapped; the only swapped value in this case will be debt
|
|
824
811
|
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
825
|
-
|
|
826
|
-
async openCA({
|
|
827
|
-
|
|
828
|
-
|
|
829
|
-
|
|
830
|
-
|
|
831
|
-
|
|
832
|
-
|
|
833
|
-
|
|
834
|
-
|
|
835
|
-
|
|
836
|
-
|
|
837
|
-
|
|
838
|
-
|
|
812
|
+
**/
|
|
813
|
+
async openCA(props) {
|
|
814
|
+
const {
|
|
815
|
+
ethAmount,
|
|
816
|
+
creditManager,
|
|
817
|
+
reopenCreditAccount,
|
|
818
|
+
collateral,
|
|
819
|
+
permits,
|
|
820
|
+
debt,
|
|
821
|
+
withdrawToken,
|
|
822
|
+
referralCode,
|
|
823
|
+
to,
|
|
824
|
+
calls: openPathCalls,
|
|
825
|
+
minQuota,
|
|
826
|
+
averageQuota
|
|
827
|
+
} = props;
|
|
839
828
|
const cmSuite = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
840
829
|
const cm = cmSuite.creditManager;
|
|
841
830
|
let tokenToWithdraw;
|
|
@@ -867,7 +856,12 @@ class AbstractCreditAccountService extends SDKConstruct {
|
|
|
867
856
|
averageQuota
|
|
868
857
|
})
|
|
869
858
|
];
|
|
870
|
-
|
|
859
|
+
let tx;
|
|
860
|
+
if (reopenCreditAccount) {
|
|
861
|
+
tx = await this.multicallTx(cmSuite, reopenCreditAccount, calls);
|
|
862
|
+
} else {
|
|
863
|
+
tx = await this.openCreditAccountTx(cmSuite, to, calls, referralCode);
|
|
864
|
+
}
|
|
871
865
|
tx.value = ethAmount.toString(10);
|
|
872
866
|
return { calls, tx, creditFacade: cmSuite.creditFacade };
|
|
873
867
|
}
|
|
@@ -158,29 +158,16 @@ export declare abstract class AbstractCreditAccountService extends SDKConstruct
|
|
|
158
158
|
getApprovalAddress(options: GetApprovalAddressProps): Promise<Address>;
|
|
159
159
|
/**
|
|
160
160
|
* Executes swap specified by given calls, update quotas of affected tokens
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
* @param {bigint} ethAmount - native token amount to attach to tx
|
|
169
|
-
* @param {Address} creditManager - address of credit manager to open credit account on
|
|
170
|
-
* @param {Array<Asset>} collateral - array of collateral which can be just directly added or swapped using the path {@link Asset}
|
|
171
|
-
* @param {Record<Address, PermitResult>} permits - permits of collateral tokens (in any permittable token is present) {@link PermitResult}
|
|
172
|
-
* @param {bigint} debt - debt to open credit account with
|
|
173
|
-
* @param {boolean} withdrawDebt - flag to withdraw debt to wallet after opening credit account;
|
|
174
|
-
used for borrowing functionality
|
|
175
|
-
* @param {bigint} referralCode - referral code to open credit account with
|
|
176
|
-
* @param {Address} to - wallet address to transfer credit account to
|
|
177
|
-
* @param {Array<MultiCall>} calls - array of MultiCall from router methods findOpenStrategyPath {@link MultiCall}.
|
|
178
|
-
Used for trading and strategy functionality
|
|
179
|
-
* @param {Array<Asset>} averageQuota - average quota for tokens after open {@link Asset}
|
|
180
|
-
* @param {Array<Asset>} minQuota - minimum quota for tokens after open {@link Asset}
|
|
161
|
+
* - Open credit account is executed in the following order: price update -> increase debt -> add collateral ->
|
|
162
|
+
* -> update quotas -> (optionally: execute swap path for trading/strategy) ->
|
|
163
|
+
* -> (optionally: withdraw debt for lending)
|
|
164
|
+
*- Basic open credit account: price update -> increase debt -> add collateral -> update quotas
|
|
165
|
+
*- Lending: price update -> increase debt -> add collateral -> update quotas -> withdraw debt
|
|
166
|
+
*- Strategy/trading: price update -> increase debt -> add collateral -> update quotas -> execute swap path
|
|
167
|
+
*- In strategy is possible situation when collateral is added, but not swapped; the only swapped value in this case will be debt
|
|
181
168
|
* @returns All necessary data to execute the transaction (call, credit facade)
|
|
182
|
-
|
|
183
|
-
openCA(
|
|
169
|
+
**/
|
|
170
|
+
openCA(props: OpenCAProps): Promise<CreditAccountOperationResult>;
|
|
184
171
|
/**
|
|
185
172
|
* Returns borrow rate with 4 digits precision (10000 = 100%)
|
|
186
173
|
* @param ca
|
|
@@ -291,6 +291,10 @@ export interface OpenCAProps extends PrepareUpdateQuotasProps {
|
|
|
291
291
|
* Address of credit manager to open credit account on
|
|
292
292
|
*/
|
|
293
293
|
creditManager: Address;
|
|
294
|
+
/**
|
|
295
|
+
* Optional address of credit account to reopen
|
|
296
|
+
*/
|
|
297
|
+
reopenCreditAccount?: Address;
|
|
294
298
|
/**
|
|
295
299
|
* Wallet address to transfer credit account to
|
|
296
300
|
*/
|