@gearbox-protocol/sdk 4.1.5 → 4.1.7
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.
|
@@ -173,22 +173,32 @@ class AccountOpener extends import_sdk.SDKConstruct {
|
|
|
173
173
|
target: symbol
|
|
174
174
|
});
|
|
175
175
|
const leverage = this.#getLeverage(input);
|
|
176
|
-
logger?.debug(`using leverage ${leverage}`);
|
|
177
176
|
const { minDebt, underlying } = cm.creditFacade;
|
|
177
|
+
const expectedUnderlyingBalance = minDebt * leverage / import_sdk.PERCENTAGE_FACTOR;
|
|
178
178
|
const expectedBalances = [];
|
|
179
179
|
const leftoverBalances = [];
|
|
180
180
|
for (const t of cm.creditManager.collateralTokens) {
|
|
181
181
|
const token = t;
|
|
182
182
|
expectedBalances.push({
|
|
183
183
|
token,
|
|
184
|
-
balance: token === underlying ?
|
|
184
|
+
balance: token === underlying ? expectedUnderlyingBalance : 1n
|
|
185
185
|
});
|
|
186
186
|
leftoverBalances.push({
|
|
187
187
|
token,
|
|
188
188
|
balance: 1n
|
|
189
189
|
});
|
|
190
190
|
}
|
|
191
|
-
logger?.debug(
|
|
191
|
+
logger?.debug(
|
|
192
|
+
{
|
|
193
|
+
minDebt: this.sdk.tokensMeta.formatBN(underlying, minDebt),
|
|
194
|
+
leverage: leverage.toString(),
|
|
195
|
+
expectedUnderlyingBalance: this.sdk.tokensMeta.formatBN(
|
|
196
|
+
underlying,
|
|
197
|
+
expectedUnderlyingBalance
|
|
198
|
+
)
|
|
199
|
+
},
|
|
200
|
+
"looking for open strategy"
|
|
201
|
+
);
|
|
192
202
|
const strategy = await this.sdk.routerFor(cm).findOpenStrategyPath({
|
|
193
203
|
creditManager: cm.creditManager,
|
|
194
204
|
expectedBalances,
|
|
@@ -211,6 +211,9 @@ const chains = {
|
|
|
211
211
|
defaultMarketConfigurators: {
|
|
212
212
|
"0x5BCF14d8470e1a6110916371aacC8E1C947A7D9d": "Chaos Labs"
|
|
213
213
|
},
|
|
214
|
+
testMarketConfigurators: {
|
|
215
|
+
"0x19037a281025b83fa37e3264b77af523ff87a3a4": "Chaos Labs"
|
|
216
|
+
},
|
|
214
217
|
isPublic: false,
|
|
215
218
|
wellKnownToken: {
|
|
216
219
|
address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
|
|
@@ -159,22 +159,32 @@ class AccountOpener extends SDKConstruct {
|
|
|
159
159
|
target: symbol
|
|
160
160
|
});
|
|
161
161
|
const leverage = this.#getLeverage(input);
|
|
162
|
-
logger?.debug(`using leverage ${leverage}`);
|
|
163
162
|
const { minDebt, underlying } = cm.creditFacade;
|
|
163
|
+
const expectedUnderlyingBalance = minDebt * leverage / PERCENTAGE_FACTOR;
|
|
164
164
|
const expectedBalances = [];
|
|
165
165
|
const leftoverBalances = [];
|
|
166
166
|
for (const t of cm.creditManager.collateralTokens) {
|
|
167
167
|
const token = t;
|
|
168
168
|
expectedBalances.push({
|
|
169
169
|
token,
|
|
170
|
-
balance: token === underlying ?
|
|
170
|
+
balance: token === underlying ? expectedUnderlyingBalance : 1n
|
|
171
171
|
});
|
|
172
172
|
leftoverBalances.push({
|
|
173
173
|
token,
|
|
174
174
|
balance: 1n
|
|
175
175
|
});
|
|
176
176
|
}
|
|
177
|
-
logger?.debug(
|
|
177
|
+
logger?.debug(
|
|
178
|
+
{
|
|
179
|
+
minDebt: this.sdk.tokensMeta.formatBN(underlying, minDebt),
|
|
180
|
+
leverage: leverage.toString(),
|
|
181
|
+
expectedUnderlyingBalance: this.sdk.tokensMeta.formatBN(
|
|
182
|
+
underlying,
|
|
183
|
+
expectedUnderlyingBalance
|
|
184
|
+
)
|
|
185
|
+
},
|
|
186
|
+
"looking for open strategy"
|
|
187
|
+
);
|
|
178
188
|
const strategy = await this.sdk.routerFor(cm).findOpenStrategyPath({
|
|
179
189
|
creditManager: cm.creditManager,
|
|
180
190
|
expectedBalances,
|
|
@@ -194,6 +194,9 @@ const chains = {
|
|
|
194
194
|
defaultMarketConfigurators: {
|
|
195
195
|
"0x5BCF14d8470e1a6110916371aacC8E1C947A7D9d": "Chaos Labs"
|
|
196
196
|
},
|
|
197
|
+
testMarketConfigurators: {
|
|
198
|
+
"0x19037a281025b83fa37e3264b77af523ff87a3a4": "Chaos Labs"
|
|
199
|
+
},
|
|
197
200
|
isPublic: false,
|
|
198
201
|
wellKnownToken: {
|
|
199
202
|
address: "0x8ac76a51cc950d9822d68b83fe1ad97b32cd580d",
|