@gearbox-protocol/sdk 3.0.0-vfour.377 → 3.0.0-vfour.378
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.
|
@@ -104,7 +104,7 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
104
104
|
return results;
|
|
105
105
|
}
|
|
106
106
|
async #openAccount(input, index, total) {
|
|
107
|
-
const { creditManager, collateral } = input;
|
|
107
|
+
const { creditManager, target: collateral } = input;
|
|
108
108
|
const cm = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
109
109
|
const symbol = this.sdk.tokensMeta.symbol(collateral);
|
|
110
110
|
const logger = this.#logger?.child?.({
|
|
@@ -167,16 +167,16 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
167
167
|
async prepareOpen(input) {
|
|
168
168
|
const {
|
|
169
169
|
creditManager,
|
|
170
|
-
|
|
170
|
+
target,
|
|
171
171
|
leverage = DEFAULT_LEVERAGE,
|
|
172
172
|
slippage = 50
|
|
173
173
|
} = input;
|
|
174
174
|
const borrower = await this.#getBorrower();
|
|
175
175
|
const cm = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
176
|
-
const symbol = this.sdk.tokensMeta.symbol(
|
|
176
|
+
const symbol = this.sdk.tokensMeta.symbol(target);
|
|
177
177
|
const logger = this.#logger?.child?.({
|
|
178
178
|
creditManager: cm.name,
|
|
179
|
-
|
|
179
|
+
target: symbol
|
|
180
180
|
});
|
|
181
181
|
const { minDebt, underlying } = cm.creditFacade;
|
|
182
182
|
const expectedBalances = [];
|
|
@@ -198,19 +198,19 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
198
198
|
expectedBalances,
|
|
199
199
|
leftoverBalances,
|
|
200
200
|
slippage,
|
|
201
|
-
target
|
|
201
|
+
target
|
|
202
202
|
});
|
|
203
203
|
logger?.debug(strategy, "found open strategy");
|
|
204
204
|
const debt = minDebt * BigInt(leverage - 1);
|
|
205
205
|
const averageQuota = this.#getCollateralQuota(
|
|
206
206
|
cm,
|
|
207
|
-
|
|
207
|
+
target,
|
|
208
208
|
strategy.amount,
|
|
209
209
|
debt
|
|
210
210
|
);
|
|
211
211
|
const minQuota = this.#getCollateralQuota(
|
|
212
212
|
cm,
|
|
213
|
-
|
|
213
|
+
target,
|
|
214
214
|
strategy.minAmount,
|
|
215
215
|
debt
|
|
216
216
|
);
|
|
@@ -90,7 +90,7 @@ class AccountOpener extends SDKConstruct {
|
|
|
90
90
|
return results;
|
|
91
91
|
}
|
|
92
92
|
async #openAccount(input, index, total) {
|
|
93
|
-
const { creditManager, collateral } = input;
|
|
93
|
+
const { creditManager, target: collateral } = input;
|
|
94
94
|
const cm = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
95
95
|
const symbol = this.sdk.tokensMeta.symbol(collateral);
|
|
96
96
|
const logger = this.#logger?.child?.({
|
|
@@ -153,16 +153,16 @@ class AccountOpener extends SDKConstruct {
|
|
|
153
153
|
async prepareOpen(input) {
|
|
154
154
|
const {
|
|
155
155
|
creditManager,
|
|
156
|
-
|
|
156
|
+
target,
|
|
157
157
|
leverage = DEFAULT_LEVERAGE,
|
|
158
158
|
slippage = 50
|
|
159
159
|
} = input;
|
|
160
160
|
const borrower = await this.#getBorrower();
|
|
161
161
|
const cm = this.sdk.marketRegister.findCreditManager(creditManager);
|
|
162
|
-
const symbol = this.sdk.tokensMeta.symbol(
|
|
162
|
+
const symbol = this.sdk.tokensMeta.symbol(target);
|
|
163
163
|
const logger = this.#logger?.child?.({
|
|
164
164
|
creditManager: cm.name,
|
|
165
|
-
|
|
165
|
+
target: symbol
|
|
166
166
|
});
|
|
167
167
|
const { minDebt, underlying } = cm.creditFacade;
|
|
168
168
|
const expectedBalances = [];
|
|
@@ -184,19 +184,19 @@ class AccountOpener extends SDKConstruct {
|
|
|
184
184
|
expectedBalances,
|
|
185
185
|
leftoverBalances,
|
|
186
186
|
slippage,
|
|
187
|
-
target
|
|
187
|
+
target
|
|
188
188
|
});
|
|
189
189
|
logger?.debug(strategy, "found open strategy");
|
|
190
190
|
const debt = minDebt * BigInt(leverage - 1);
|
|
191
191
|
const averageQuota = this.#getCollateralQuota(
|
|
192
192
|
cm,
|
|
193
|
-
|
|
193
|
+
target,
|
|
194
194
|
strategy.amount,
|
|
195
195
|
debt
|
|
196
196
|
);
|
|
197
197
|
const minQuota = this.#getCollateralQuota(
|
|
198
198
|
cm,
|
|
199
|
-
|
|
199
|
+
target,
|
|
200
200
|
strategy.minAmount,
|
|
201
201
|
debt
|
|
202
202
|
);
|
|
@@ -8,7 +8,18 @@ export interface AccountOpenerOptions {
|
|
|
8
8
|
}
|
|
9
9
|
export interface TargetAccount {
|
|
10
10
|
creditManager: Address;
|
|
11
|
-
|
|
11
|
+
/**
|
|
12
|
+
* Everything will be swapped into this token in the end
|
|
13
|
+
*/
|
|
14
|
+
target: Address;
|
|
15
|
+
/**
|
|
16
|
+
* This token will be provided as collateral, defaults to underlying token
|
|
17
|
+
* Expected to be found on borrower's address before opening the account
|
|
18
|
+
* Can be claimed from faucet
|
|
19
|
+
*
|
|
20
|
+
* TODO: not implemented
|
|
21
|
+
*/
|
|
22
|
+
collateral?: Address;
|
|
12
23
|
leverage?: number;
|
|
13
24
|
slippage?: number;
|
|
14
25
|
}
|