@gearbox-protocol/sdk 8.19.0 → 8.19.2

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.
@@ -286,11 +286,16 @@ class AccountOpener extends import_sdk.SDKConstruct {
286
286
  async #depositIntoPools(targets) {
287
287
  this.#logger?.debug("checking and topping up pools if necessary");
288
288
  const minAvailableByPool = {};
289
- for (const t of targets) {
289
+ for (let i = 0; i < targets.length; i++) {
290
+ const t = targets[i];
290
291
  const leverage = this.#getLeverage(t);
291
292
  const cm = this.sdk.marketRegister.findCreditManager(t.creditManager);
292
293
  const minDebt = this.#minDebtMultiplier * cm.creditFacade.minDebt / import_sdk.PERCENTAGE_FACTOR;
293
- minAvailableByPool[cm.pool] = (minAvailableByPool[cm.pool] ?? 0n) + minDebt * (leverage - import_sdk.PERCENTAGE_FACTOR) / import_sdk.PERCENTAGE_FACTOR * this.#poolDepositMultiplier / import_sdk.PERCENTAGE_FACTOR;
294
+ const amount = minDebt * (leverage - import_sdk.PERCENTAGE_FACTOR) / import_sdk.PERCENTAGE_FACTOR * this.#poolDepositMultiplier / import_sdk.PERCENTAGE_FACTOR;
295
+ minAvailableByPool[cm.pool] = (minAvailableByPool[cm.pool] ?? 0n) + amount;
296
+ this.#logger?.debug(
297
+ `target #${i + 1} (${this.labelAddress(t.target)}) needs ${this.sdk.tokensMeta.formatBN(cm.underlying, amount)} ${this.sdk.tokensMeta.symbol(cm.underlying)} in pool (leverage: ${Number(leverage / import_sdk.PERCENTAGE_FACTOR)}%)`
298
+ );
294
299
  }
295
300
  let totalUSD = 0n;
296
301
  const deposits = [];
@@ -99,6 +99,14 @@ class AddressMap {
99
99
  }
100
100
  return this.#map.get(key);
101
101
  }
102
+ /**
103
+ * Deletes address from map
104
+ * @param address
105
+ */
106
+ delete(address) {
107
+ const key = (0, import_viem.getAddress)(address);
108
+ this.#map.delete(key);
109
+ }
102
110
  clear() {
103
111
  this.#map.clear();
104
112
  }
@@ -278,11 +278,16 @@ class AccountOpener extends SDKConstruct {
278
278
  async #depositIntoPools(targets) {
279
279
  this.#logger?.debug("checking and topping up pools if necessary");
280
280
  const minAvailableByPool = {};
281
- for (const t of targets) {
281
+ for (let i = 0; i < targets.length; i++) {
282
+ const t = targets[i];
282
283
  const leverage = this.#getLeverage(t);
283
284
  const cm = this.sdk.marketRegister.findCreditManager(t.creditManager);
284
285
  const minDebt = this.#minDebtMultiplier * cm.creditFacade.minDebt / PERCENTAGE_FACTOR;
285
- minAvailableByPool[cm.pool] = (minAvailableByPool[cm.pool] ?? 0n) + minDebt * (leverage - PERCENTAGE_FACTOR) / PERCENTAGE_FACTOR * this.#poolDepositMultiplier / PERCENTAGE_FACTOR;
286
+ const amount = minDebt * (leverage - PERCENTAGE_FACTOR) / PERCENTAGE_FACTOR * this.#poolDepositMultiplier / PERCENTAGE_FACTOR;
287
+ minAvailableByPool[cm.pool] = (minAvailableByPool[cm.pool] ?? 0n) + amount;
288
+ this.#logger?.debug(
289
+ `target #${i + 1} (${this.labelAddress(t.target)}) needs ${this.sdk.tokensMeta.formatBN(cm.underlying, amount)} ${this.sdk.tokensMeta.symbol(cm.underlying)} in pool (leverage: ${Number(leverage / PERCENTAGE_FACTOR)}%)`
290
+ );
286
291
  }
287
292
  let totalUSD = 0n;
288
293
  const deposits = [];
@@ -76,6 +76,14 @@ class AddressMap {
76
76
  }
77
77
  return this.#map.get(key);
78
78
  }
79
+ /**
80
+ * Deletes address from map
81
+ * @param address
82
+ */
83
+ delete(address) {
84
+ const key = getAddress(address);
85
+ this.#map.delete(key);
86
+ }
79
87
  clear() {
80
88
  this.#map.clear();
81
89
  }
@@ -32,6 +32,11 @@ export declare class AddressMap<T> {
32
32
  * @returns
33
33
  */
34
34
  mustGet(address: string): T;
35
+ /**
36
+ * Deletes address from map
37
+ * @param address
38
+ */
39
+ delete(address: string): void;
35
40
  clear(): void;
36
41
  entries(): Array<[Address, T]>;
37
42
  values(): T[];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "8.19.0",
3
+ "version": "8.19.2",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",