@gearbox-protocol/sdk 12.6.5 → 12.6.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.
@@ -21,7 +21,6 @@ __export(CreditAccountsServiceV300_exports, {
21
21
  CreditAccountServiceV300: () => CreditAccountServiceV300
22
22
  });
23
23
  module.exports = __toCommonJS(CreditAccountsServiceV300_exports);
24
- var import_integrations_v3 = require("@gearbox-protocol/integrations-v3");
25
24
  var import_abitype = require("abitype");
26
25
  var import_viem = require("viem");
27
26
  var import_iBaseRewardPool = require("../../abi/iBaseRewardPool.js");
@@ -185,106 +184,24 @@ class CreditAccountServiceV300 extends import_AbstractCreditAccountsService.Abst
185
184
  llamathena
186
185
  }) {
187
186
  const LLAMATHENA_CURVE_POOL = "0xd29f8980852c2c76fc3f6e96a7aa06e0bedcc1b1".toLowerCase();
188
- const SCRVUSD = "0x0655977FEb2f289A4aB78af67BAB0d17aAb84367".toLowerCase();
189
- const SUSDE = "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497".toLowerCase();
190
187
  const llamathenaBalance = llamathena.balance;
191
- if (llamathenaBalance === 0n)
188
+ if (llamathenaBalance === 0n) {
192
189
  return {
193
- scrvusdDelta: 0n,
194
- scrvusdAddress: SCRVUSD,
195
- susdeDelta: 0n,
196
- susdeAddress: SUSDE,
197
- llamathena: [llamathena],
190
+ stkLlamathena: [llamathena],
198
191
  assets: [
199
192
  {
200
- token: SCRVUSD,
201
- balance: 0n
202
- },
203
- {
204
- token: SUSDE,
193
+ token: LLAMATHENA_CURVE_POOL,
205
194
  balance: 0n
206
195
  }
207
196
  ]
208
197
  };
209
- const llamathenaAbi = [
210
- {
211
- type: "function",
212
- inputs: [],
213
- name: "get_balances",
214
- outputs: [
215
- {
216
- name: "",
217
- internalType: "uint256[]",
218
- type: "uint256[]"
219
- }
220
- ],
221
- stateMutability: "view"
222
- },
223
- {
224
- type: "function",
225
- inputs: [],
226
- name: "totalSupply",
227
- outputs: [
228
- {
229
- name: "",
230
- internalType: "uint256",
231
- type: "uint256"
232
- }
233
- ],
234
- stateMutability: "view"
235
- }
236
- ];
237
- const [poolBalances, totalSupply] = await this.client.multicall({
238
- batchSize: 0,
239
- allowFailure: false,
240
- contracts: [
241
- {
242
- address: LLAMATHENA_CURVE_POOL,
243
- abi: llamathenaAbi,
244
- functionName: "get_balances"
245
- },
246
- {
247
- address: LLAMATHENA_CURVE_POOL,
248
- abi: llamathenaAbi,
249
- functionName: "totalSupply"
250
- }
251
- ]
252
- });
253
- if (totalSupply === 0n)
254
- return {
255
- scrvusdDelta: 0n,
256
- scrvusdAddress: SCRVUSD,
257
- susdeDelta: 0n,
258
- susdeAddress: SUSDE,
259
- llamathena: [llamathena],
260
- assets: [
261
- {
262
- token: SCRVUSD,
263
- balance: 0n
264
- },
265
- {
266
- token: SUSDE,
267
- balance: 0n
268
- }
269
- ]
270
- };
271
- const [scrvusdBalance = 0n, susdeBalance = 0n] = poolBalances;
272
- const scrvusdDelta = scrvusdBalance * llamathenaBalance / totalSupply;
273
- const susdeDelta = susdeBalance * llamathenaBalance / totalSupply;
198
+ }
274
199
  return {
275
- scrvusdDelta,
276
- scrvusdAddress: SCRVUSD,
277
- susdeDelta,
278
- susdeAddress: SUSDE,
279
- llamathena: [llamathena],
200
+ stkLlamathena: [llamathena],
280
201
  assets: [
281
202
  {
282
- token: SCRVUSD,
283
- balance: scrvusdDelta
284
- },
285
- {
286
- token: SUSDE,
287
- balance: susdeDelta
203
+ token: LLAMATHENA_CURVE_POOL,
204
+ balance: llamathenaBalance
288
205
  }
289
206
  ]
290
207
  };
@@ -296,7 +213,6 @@ class CreditAccountServiceV300 extends import_AbstractCreditAccountsService.Abst
296
213
  averageQuota
297
214
  }) {
298
215
  const LLAMATHENA_BASE_REWARD_POOL = "0x11fd8801a051b296e337a3e1168839fb346d5940";
299
- const LLAMATHENA_POOL = "0xd29f8980852c2c76fc3f6e96a7aa06e0bedcc1b1";
300
216
  const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
301
217
  const priceUpdatesCalls = await this.getPriceUpdatesForFacade({
302
218
  creditManager: ca.creditManager,
@@ -309,10 +225,6 @@ class CreditAccountServiceV300 extends import_AbstractCreditAccountsService.Abst
309
225
  if (!baseRewardPoolAdapter) {
310
226
  throw new Error("BaseRewardPool adapter for llamathena is missing");
311
227
  }
312
- const curvePoolAdapter = cm.creditManager.adapters.get(LLAMATHENA_POOL);
313
- if (!curvePoolAdapter) {
314
- throw new Error("Curve pool adapter for llamathena is missing");
315
- }
316
228
  const storeExpectedBalances = {
317
229
  target: cm.creditFacade.address,
318
230
  callData: (0, import_viem.encodeFunctionData)({
@@ -320,8 +232,10 @@ class CreditAccountServiceV300 extends import_AbstractCreditAccountsService.Abst
320
232
  functionName: "storeExpectedBalances",
321
233
  args: [
322
234
  [
323
- { token: preview.scrvusdAddress, amount: preview.scrvusdDelta },
324
- { token: preview.susdeAddress, amount: preview.susdeDelta }
235
+ {
236
+ token: preview.assets[0].token,
237
+ amount: preview.assets[0].balance
238
+ }
325
239
  ]
326
240
  ]
327
241
  })
@@ -331,15 +245,7 @@ class CreditAccountServiceV300 extends import_AbstractCreditAccountsService.Abst
331
245
  callData: (0, import_viem.encodeFunctionData)({
332
246
  abi: import_iBaseRewardPool.iBaseRewardPoolAbi,
333
247
  functionName: "withdrawAndUnwrap",
334
- args: [preview.llamathena[0].balance, false]
335
- })
336
- };
337
- const removeLiquidityCall = {
338
- target: curvePoolAdapter.address,
339
- callData: (0, import_viem.encodeFunctionData)({
340
- abi: import_integrations_v3.iCurveV1_2AssetsAdapterAbi,
341
- functionName: "remove_liquidity",
342
- args: [preview.llamathena[0].balance, [0n, 0n]]
248
+ args: [preview.stkLlamathena[0].balance, false]
343
249
  })
344
250
  };
345
251
  const compareBalances = {
@@ -353,7 +259,6 @@ class CreditAccountServiceV300 extends import_AbstractCreditAccountsService.Abst
353
259
  const swapCalls = [
354
260
  storeExpectedBalances,
355
261
  withdrawAndUnwrapCall,
356
- removeLiquidityCall,
357
262
  compareBalances
358
263
  ];
359
264
  const calls = [
@@ -32,7 +32,7 @@ module.exports = __toCommonJS(chains_exports);
32
32
  var import_viem = require("viem");
33
33
  var import_chains = require("viem/chains");
34
34
  var import_v4 = require("zod/v4");
35
- var import_utils = require("../utils/index.js");
35
+ var import_mappers = require("../utils/mappers.js");
36
36
  const SUPPORTED_NETWORKS = [
37
37
  "Mainnet",
38
38
  "Arbitrum",
@@ -162,16 +162,13 @@ const chains = {
162
162
  "sonic-rpc"
163
163
  ),
164
164
  MegaETH: (0, import_viem.defineChain)({
165
- ...import_chains.megaethTestnet,
165
+ ...import_chains.megaeth,
166
166
  network: "MegaETH",
167
- defaultMarketConfigurators: {
168
- "0x59Db4A2241BFe5Ba9023d47A012a6c7A039139A6": "Chaos Labs"
169
- },
167
+ defaultMarketConfigurators: {},
170
168
  isPublic: false,
171
- // TODO: has no block explorer API
172
169
  wellKnownToken: {
173
- address: "0x4eB2Bd7beE16F38B1F4a0A5796Fffd028b6040e9",
174
- symbol: "WETH"
170
+ address: "0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7",
171
+ symbol: "USDm"
175
172
  }
176
173
  }),
177
174
  // NOTE: Monad chain configs should be updated once the public mainnet is available
@@ -311,8 +308,8 @@ const chains = {
311
308
  },
312
309
  isPublic: true,
313
310
  wellKnownToken: {
314
- address: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb",
315
- symbol: "USDT0"
311
+ address: "0x5d72a9d9a9510cd8cbdba12ac62593a58930a948",
312
+ symbol: "aPlaUSDT0"
316
313
  },
317
314
  contracts: {
318
315
  multicall3: {
@@ -389,7 +386,7 @@ function isPublicNetwork(networkOrChainId) {
389
386
  function getCuratorName(marketConfigurator, network) {
390
387
  const chainz = network ? [chains[network]] : Object.values(chains);
391
388
  for (const c of chainz) {
392
- for (const [a, curator] of import_utils.TypedObjectUtils.entries({
389
+ for (const [a, curator] of import_mappers.TypedObjectUtils.entries({
393
390
  ...c.defaultMarketConfigurators,
394
391
  ...c.testMarketConfigurators
395
392
  })) {
@@ -403,7 +400,7 @@ function getCuratorName(marketConfigurator, network) {
403
400
  function findCuratorMarketConfigurator(curator, network) {
404
401
  const { defaultMarketConfigurators, testMarketConfigurators } = chains[network];
405
402
  const all = { ...defaultMarketConfigurators, ...testMarketConfigurators };
406
- for (const [a, c] of import_utils.TypedObjectUtils.entries(all)) {
403
+ for (const [a, c] of import_mappers.TypedObjectUtils.entries(all)) {
407
404
  if (c === curator) {
408
405
  return a;
409
406
  }
@@ -1,4 +1,3 @@
1
- import { iCurveV1_2AssetsAdapterAbi } from "@gearbox-protocol/integrations-v3";
2
1
  import { parseAbi } from "abitype";
3
2
  import { encodeFunctionData } from "viem";
4
3
  import { iBaseRewardPoolAbi } from "../../abi/iBaseRewardPool.js";
@@ -174,106 +173,24 @@ class CreditAccountServiceV300 extends AbstractCreditAccountService {
174
173
  llamathena
175
174
  }) {
176
175
  const LLAMATHENA_CURVE_POOL = "0xd29f8980852c2c76fc3f6e96a7aa06e0bedcc1b1".toLowerCase();
177
- const SCRVUSD = "0x0655977FEb2f289A4aB78af67BAB0d17aAb84367".toLowerCase();
178
- const SUSDE = "0x9D39A5DE30e57443BfF2A8307A4256c8797A3497".toLowerCase();
179
176
  const llamathenaBalance = llamathena.balance;
180
- if (llamathenaBalance === 0n)
177
+ if (llamathenaBalance === 0n) {
181
178
  return {
182
- scrvusdDelta: 0n,
183
- scrvusdAddress: SCRVUSD,
184
- susdeDelta: 0n,
185
- susdeAddress: SUSDE,
186
- llamathena: [llamathena],
179
+ stkLlamathena: [llamathena],
187
180
  assets: [
188
181
  {
189
- token: SCRVUSD,
190
- balance: 0n
191
- },
192
- {
193
- token: SUSDE,
182
+ token: LLAMATHENA_CURVE_POOL,
194
183
  balance: 0n
195
184
  }
196
185
  ]
197
186
  };
198
- const llamathenaAbi = [
199
- {
200
- type: "function",
201
- inputs: [],
202
- name: "get_balances",
203
- outputs: [
204
- {
205
- name: "",
206
- internalType: "uint256[]",
207
- type: "uint256[]"
208
- }
209
- ],
210
- stateMutability: "view"
211
- },
212
- {
213
- type: "function",
214
- inputs: [],
215
- name: "totalSupply",
216
- outputs: [
217
- {
218
- name: "",
219
- internalType: "uint256",
220
- type: "uint256"
221
- }
222
- ],
223
- stateMutability: "view"
224
- }
225
- ];
226
- const [poolBalances, totalSupply] = await this.client.multicall({
227
- batchSize: 0,
228
- allowFailure: false,
229
- contracts: [
230
- {
231
- address: LLAMATHENA_CURVE_POOL,
232
- abi: llamathenaAbi,
233
- functionName: "get_balances"
234
- },
235
- {
236
- address: LLAMATHENA_CURVE_POOL,
237
- abi: llamathenaAbi,
238
- functionName: "totalSupply"
239
- }
240
- ]
241
- });
242
- if (totalSupply === 0n)
243
- return {
244
- scrvusdDelta: 0n,
245
- scrvusdAddress: SCRVUSD,
246
- susdeDelta: 0n,
247
- susdeAddress: SUSDE,
248
- llamathena: [llamathena],
249
- assets: [
250
- {
251
- token: SCRVUSD,
252
- balance: 0n
253
- },
254
- {
255
- token: SUSDE,
256
- balance: 0n
257
- }
258
- ]
259
- };
260
- const [scrvusdBalance = 0n, susdeBalance = 0n] = poolBalances;
261
- const scrvusdDelta = scrvusdBalance * llamathenaBalance / totalSupply;
262
- const susdeDelta = susdeBalance * llamathenaBalance / totalSupply;
187
+ }
263
188
  return {
264
- scrvusdDelta,
265
- scrvusdAddress: SCRVUSD,
266
- susdeDelta,
267
- susdeAddress: SUSDE,
268
- llamathena: [llamathena],
189
+ stkLlamathena: [llamathena],
269
190
  assets: [
270
191
  {
271
- token: SCRVUSD,
272
- balance: scrvusdDelta
273
- },
274
- {
275
- token: SUSDE,
276
- balance: susdeDelta
192
+ token: LLAMATHENA_CURVE_POOL,
193
+ balance: llamathenaBalance
277
194
  }
278
195
  ]
279
196
  };
@@ -285,7 +202,6 @@ class CreditAccountServiceV300 extends AbstractCreditAccountService {
285
202
  averageQuota
286
203
  }) {
287
204
  const LLAMATHENA_BASE_REWARD_POOL = "0x11fd8801a051b296e337a3e1168839fb346d5940";
288
- const LLAMATHENA_POOL = "0xd29f8980852c2c76fc3f6e96a7aa06e0bedcc1b1";
289
205
  const cm = this.sdk.marketRegister.findCreditManager(ca.creditManager);
290
206
  const priceUpdatesCalls = await this.getPriceUpdatesForFacade({
291
207
  creditManager: ca.creditManager,
@@ -298,10 +214,6 @@ class CreditAccountServiceV300 extends AbstractCreditAccountService {
298
214
  if (!baseRewardPoolAdapter) {
299
215
  throw new Error("BaseRewardPool adapter for llamathena is missing");
300
216
  }
301
- const curvePoolAdapter = cm.creditManager.adapters.get(LLAMATHENA_POOL);
302
- if (!curvePoolAdapter) {
303
- throw new Error("Curve pool adapter for llamathena is missing");
304
- }
305
217
  const storeExpectedBalances = {
306
218
  target: cm.creditFacade.address,
307
219
  callData: encodeFunctionData({
@@ -309,8 +221,10 @@ class CreditAccountServiceV300 extends AbstractCreditAccountService {
309
221
  functionName: "storeExpectedBalances",
310
222
  args: [
311
223
  [
312
- { token: preview.scrvusdAddress, amount: preview.scrvusdDelta },
313
- { token: preview.susdeAddress, amount: preview.susdeDelta }
224
+ {
225
+ token: preview.assets[0].token,
226
+ amount: preview.assets[0].balance
227
+ }
314
228
  ]
315
229
  ]
316
230
  })
@@ -320,15 +234,7 @@ class CreditAccountServiceV300 extends AbstractCreditAccountService {
320
234
  callData: encodeFunctionData({
321
235
  abi: iBaseRewardPoolAbi,
322
236
  functionName: "withdrawAndUnwrap",
323
- args: [preview.llamathena[0].balance, false]
324
- })
325
- };
326
- const removeLiquidityCall = {
327
- target: curvePoolAdapter.address,
328
- callData: encodeFunctionData({
329
- abi: iCurveV1_2AssetsAdapterAbi,
330
- functionName: "remove_liquidity",
331
- args: [preview.llamathena[0].balance, [0n, 0n]]
237
+ args: [preview.stkLlamathena[0].balance, false]
332
238
  })
333
239
  };
334
240
  const compareBalances = {
@@ -342,7 +248,6 @@ class CreditAccountServiceV300 extends AbstractCreditAccountService {
342
248
  const swapCalls = [
343
249
  storeExpectedBalances,
344
250
  withdrawAndUnwrapCall,
345
- removeLiquidityCall,
346
251
  compareBalances
347
252
  ];
348
253
  const calls = [
@@ -9,7 +9,7 @@ import {
9
9
  hemi,
10
10
  lisk,
11
11
  mainnet,
12
- megaethTestnet,
12
+ megaeth,
13
13
  monad,
14
14
  optimism,
15
15
  plasma,
@@ -17,7 +17,7 @@ import {
17
17
  worldchain
18
18
  } from "viem/chains";
19
19
  import { z } from "zod/v4";
20
- import { TypedObjectUtils } from "../utils/index.js";
20
+ import { TypedObjectUtils } from "../utils/mappers.js";
21
21
  const SUPPORTED_NETWORKS = [
22
22
  "Mainnet",
23
23
  "Arbitrum",
@@ -147,16 +147,13 @@ const chains = {
147
147
  "sonic-rpc"
148
148
  ),
149
149
  MegaETH: defineChain({
150
- ...megaethTestnet,
150
+ ...megaeth,
151
151
  network: "MegaETH",
152
- defaultMarketConfigurators: {
153
- "0x59Db4A2241BFe5Ba9023d47A012a6c7A039139A6": "Chaos Labs"
154
- },
152
+ defaultMarketConfigurators: {},
155
153
  isPublic: false,
156
- // TODO: has no block explorer API
157
154
  wellKnownToken: {
158
- address: "0x4eB2Bd7beE16F38B1F4a0A5796Fffd028b6040e9",
159
- symbol: "WETH"
155
+ address: "0xFAfDdbb3FC7688494971a79cc65DCa3EF82079E7",
156
+ symbol: "USDm"
160
157
  }
161
158
  }),
162
159
  // NOTE: Monad chain configs should be updated once the public mainnet is available
@@ -296,8 +293,8 @@ const chains = {
296
293
  },
297
294
  isPublic: true,
298
295
  wellKnownToken: {
299
- address: "0xB8CE59FC3717ada4C02eaDF9682A9e934F625ebb",
300
- symbol: "USDT0"
296
+ address: "0x5d72a9d9a9510cd8cbdba12ac62593a58930a948",
297
+ symbol: "aPlaUSDT0"
301
298
  },
302
299
  contracts: {
303
300
  multicall3: {
@@ -418,27 +418,11 @@ export interface PreviewWithdrawLlamathenaProportionallyResult {
418
418
  /**
419
419
  * Assets to get
420
420
  */
421
- assets: Array<Asset>;
422
- /**
423
- * Address of SCRVUSD token
424
- */
425
- scrvusdAddress: Address;
426
- /**
427
- * Address of SUSDE token
428
- */
429
- susdeAddress: Address;
421
+ assets: [Asset];
430
422
  /**
431
423
  * Llamathena asset
432
424
  */
433
- llamathena: [Asset];
434
- /**
435
- * Amount of SCRVUSD to get
436
- */
437
- scrvusdDelta: bigint;
438
- /**
439
- * Amount of SUSDE to get
440
- */
441
- susdeDelta: bigint;
425
+ stkLlamathena: [Asset];
442
426
  }
443
427
  export interface LlamathenaProportionalWithdrawProps extends PrepareUpdateQuotasProps {
444
428
  /**
@@ -123,8 +123,8 @@ export declare class CreditAccountData_Legacy {
123
123
  constructor(payload: CreditAccountDataPayload);
124
124
  static sortBalances(balances: Record<Address, bigint>, prices: Record<Address, bigint>, tokens: Record<Address, TokenData>): Array<[Address, bigint]>;
125
125
  static sortAssets<T extends Asset>(balances: Array<T>, prices: Record<Address, bigint>, tokens: Record<Address, TokenData>): T[];
126
- static assetComparator<T extends Asset>(t1: T, t2: T, prices1: Record<Address, bigint> | undefined, prices2: Record<Address, bigint> | undefined, tokens1: Record<Address, TokenData> | undefined, tokens2: Record<Address, TokenData> | undefined): 1 | -1 | 0;
127
- static tokensAbcComparator(t1?: TokenData, t2?: TokenData): 1 | -1 | 0;
126
+ static assetComparator<T extends Asset>(t1: T, t2: T, prices1: Record<Address, bigint> | undefined, prices2: Record<Address, bigint> | undefined, tokens1: Record<Address, TokenData> | undefined, tokens2: Record<Address, TokenData> | undefined): 1 | 0 | -1;
127
+ static tokensAbcComparator(t1?: TokenData, t2?: TokenData): 1 | 0 | -1;
128
128
  static amountAbcComparator(t1: bigint, t2: bigint): 1 | -1;
129
129
  isForbidden(token: Address): boolean;
130
130
  isQuoted(token: Address): boolean;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "12.6.5",
3
+ "version": "12.6.7",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",
@@ -66,12 +66,12 @@
66
66
  "zod": "^4.3.6"
67
67
  },
68
68
  "devDependencies": {
69
- "@biomejs/biome": "^2.3.13",
70
- "@commitlint/cli": "^20.3.1",
71
- "@commitlint/config-conventional": "^20.3.1",
72
- "@gearbox-protocol/biome-config": "^1.0.19",
69
+ "@biomejs/biome": "^2.3.14",
70
+ "@commitlint/cli": "^20.4.1",
71
+ "@commitlint/config-conventional": "^20.4.1",
72
+ "@gearbox-protocol/biome-config": "^1.0.20",
73
73
  "@types/cross-spawn": "^6.0.6",
74
- "axios": "^1.13.3",
74
+ "axios": "^1.13.5",
75
75
  "cross-spawn": "^7.0.6",
76
76
  "husky": "^9.1.7",
77
77
  "lint-staged": "^16.2.7",