@gearbox-protocol/deploy-tools 5.3.10 → 5.3.11

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.
Files changed (2) hide show
  1. package/dist/index.mjs +19 -32
  2. package/package.json +2 -2
package/dist/index.mjs CHANGED
@@ -383761,11 +383761,11 @@ var RouterV3Contract = class extends BaseContract {
383761
383761
  return {
383762
383762
  balances: {
383763
383763
  ...balancesAfter,
383764
- [target]: (expectedMap.get(target) ?? 0n) + result.amount
383764
+ [target.toLowerCase()]: (expectedMap.get(target) ?? 0n) + result.amount
383765
383765
  },
383766
383766
  minBalances: {
383767
383767
  ...balancesAfter,
383768
- [target]: (expectedMap.get(target) ?? 0n) + result.minAmount
383768
+ [target.toLowerCase()]: (expectedMap.get(target) ?? 0n) + result.minAmount
383769
383769
  },
383770
383770
  amount: result.amount,
383771
383771
  minAmount: result.minAmount,
@@ -409245,29 +409245,24 @@ var AccountOpener = class {
409245
409245
  * Tries to open account with underlying only in each CM
409246
409246
  */
409247
409247
  async openCreditAccounts(targets) {
409248
- const borrower = await this.#prepareBorrower(targets);
409248
+ await this.#prepareBorrower(targets);
409249
409249
  for (const c of targets) {
409250
409250
  const cm = this.sdk.marketRegister.findCreditManager(c.creditManager);
409251
409251
  await this.#approve(c.collateral, cm);
409252
409252
  }
409253
- for (const target of targets) {
409253
+ for (let i = 0; i < targets.length; i++) {
409254
+ const target = targets[i];
409254
409255
  try {
409255
- await this.#openAccount(target);
409256
+ await this.#openAccount(target, i + 1, targets.length);
409256
409257
  } catch (e) {
409257
409258
  this.#logger?.error(e);
409258
409259
  }
409259
409260
  }
409260
- const accounts = await this.#service.getCreditAccounts({
409261
- owner: borrower.address
409262
- });
409261
+ const accounts = await this.getOpenedAccounts();
409263
409262
  this.#logger?.info(`opened ${accounts.length} accounts`);
409263
+ return accounts;
409264
409264
  }
409265
- async #openAccount({
409266
- creditManager,
409267
- collateral,
409268
- leverage = 4,
409269
- slippage = 50
409270
- }) {
409265
+ async #openAccount({ creditManager, collateral, leverage = 4, slippage = 50 }, index2, total) {
409271
409266
  const borrower = await this.#getBorrower();
409272
409267
  const cm = this.sdk.marketRegister.findCreditManager(creditManager);
409273
409268
  const symbol = this.sdk.tokensMeta.symbol(collateral);
@@ -409275,6 +409270,7 @@ var AccountOpener = class {
409275
409270
  creditManager: cm.name,
409276
409271
  collateral: symbol
409277
409272
  });
409273
+ logger2?.debug(`opening account #${index2}/${total}`);
409278
409274
  const { minDebt, underlying } = cm.creditFacade;
409279
409275
  const expectedBalances = [];
409280
409276
  const leftoverBalances = [];
@@ -409299,26 +409295,20 @@ var AccountOpener = class {
409299
409295
  });
409300
409296
  logger2?.debug(strategy, "found open strategy");
409301
409297
  const debt = minDebt * BigInt(leverage - 1);
409298
+ const collateralLT = BigInt(cm.collateralTokens[collateral]);
409299
+ const inUnderlying = collateral.toLowerCase() === underlying.toLowerCase();
409302
409300
  const { tx, calls } = await this.#service.openCA({
409303
409301
  creditManager: cm.creditManager.address,
409304
- averageQuota: [
409302
+ averageQuota: inUnderlying ? [] : [
409305
409303
  {
409306
409304
  token: collateral,
409307
- balance: this.#calcQuota(
409308
- strategy.amount,
409309
- debt,
409310
- BigInt(cm.collateralTokens[collateral])
409311
- )
409305
+ balance: this.#calcQuota(strategy.amount, debt, collateralLT)
409312
409306
  }
409313
409307
  ],
409314
- minQuota: [
409308
+ minQuota: inUnderlying ? [] : [
409315
409309
  {
409316
409310
  token: collateral,
409317
- balance: this.#calcQuota(
409318
- strategy.minAmount,
409319
- debt,
409320
- BigInt(cm.collateralTokens[collateral])
409321
- )
409311
+ balance: this.#calcQuota(strategy.minAmount, debt, collateralLT)
409322
409312
  }
409323
409313
  ],
409324
409314
  collateral: [{ token: underlying, balance: minDebt }],
@@ -409345,10 +409335,7 @@ var AccountOpener = class {
409345
409335
  if (receipt.status === "reverted") {
409346
409336
  throw new Error(`open credit account tx ${hash2} reverted`);
409347
409337
  }
409348
- logger2?.debug(
409349
- `opened credit account in ${cm.name} with collateral ${symbol}`
409350
- );
409351
- return this.getOpenedAccounts();
409338
+ logger2?.debug(`opened credit account ${index2}/${total}`);
409352
409339
  }
409353
409340
  async getOpenedAccounts() {
409354
409341
  return await this.#service.getCreditAccounts({
@@ -418001,7 +417988,7 @@ function getRenderer(opts) {
418001
417988
  var package_default = {
418002
417989
  name: "@gearbox-protocol/deploy-tools",
418003
417990
  description: "Gearbox deploy tools",
418004
- version: "5.3.10",
417991
+ version: "5.3.11",
418005
417992
  homepage: "https://gearbox.fi",
418006
417993
  keywords: [
418007
417994
  "gearbox"
@@ -418044,7 +418031,7 @@ var package_default = {
418044
418031
  "@gearbox-protocol/deploy-tools-node": "0.0.0",
418045
418032
  "@gearbox-protocol/deploy-tools-shared": "0.0.0",
418046
418033
  "@gearbox-protocol/deploy-tools-types": "0.0.0",
418047
- "@gearbox-protocol/sdk": "^3.0.0-vfour.161",
418034
+ "@gearbox-protocol/sdk": "^3.0.0-vfour.162",
418048
418035
  "@gearbox-protocol/sdk-gov": "^2.33.2",
418049
418036
  "@types/lodash-es": "^4.17.12",
418050
418037
  "@types/node": "^22.10.5",
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/deploy-tools",
3
3
  "description": "Gearbox deploy tools",
4
- "version": "5.3.10",
4
+ "version": "5.3.11",
5
5
  "homepage": "https://gearbox.fi",
6
6
  "keywords": [
7
7
  "gearbox"
@@ -44,7 +44,7 @@
44
44
  "@gearbox-protocol/deploy-tools-node": "0.0.0",
45
45
  "@gearbox-protocol/deploy-tools-shared": "0.0.0",
46
46
  "@gearbox-protocol/deploy-tools-types": "0.0.0",
47
- "@gearbox-protocol/sdk": "^3.0.0-vfour.161",
47
+ "@gearbox-protocol/sdk": "^3.0.0-vfour.162",
48
48
  "@gearbox-protocol/sdk-gov": "^2.33.2",
49
49
  "@types/lodash-es": "^4.17.12",
50
50
  "@types/node": "^22.10.5",