@gearbox-protocol/sdk 12.6.4 → 12.6.6

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 = [
@@ -124,11 +124,13 @@ class TxAddLiquidity extends import_eventOrTx.EVMTx {
124
124
  amount;
125
125
  token;
126
126
  poolName;
127
+ address;
127
128
  constructor(opts) {
128
129
  super(opts);
129
130
  this.amount = opts.amount;
130
131
  this.token = opts.tokensList[opts.token];
131
132
  this.poolName = opts.poolName;
133
+ this.address = opts.address;
132
134
  }
133
135
  _toString() {
134
136
  const { title, decimals = 18 } = this.token;
@@ -148,11 +150,13 @@ class TxRemoveLiquidity extends import_eventOrTx.EVMTx {
148
150
  amount;
149
151
  token;
150
152
  poolName;
153
+ address;
151
154
  constructor(opts) {
152
155
  super(opts);
153
156
  this.amount = opts.amount;
154
157
  this.token = opts.tokensList[opts.token];
155
158
  this.poolName = opts.poolName;
159
+ this.address = opts.address;
156
160
  }
157
161
  _toString() {
158
162
  const { title, decimals = 18 } = this.token;
@@ -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 = [
@@ -74,11 +74,13 @@ class TxAddLiquidity extends EVMTx {
74
74
  amount;
75
75
  token;
76
76
  poolName;
77
+ address;
77
78
  constructor(opts) {
78
79
  super(opts);
79
80
  this.amount = opts.amount;
80
81
  this.token = opts.tokensList[opts.token];
81
82
  this.poolName = opts.poolName;
83
+ this.address = opts.address;
82
84
  }
83
85
  _toString() {
84
86
  const { title, decimals = 18 } = this.token;
@@ -98,11 +100,13 @@ class TxRemoveLiquidity extends EVMTx {
98
100
  amount;
99
101
  token;
100
102
  poolName;
103
+ address;
101
104
  constructor(opts) {
102
105
  super(opts);
103
106
  this.amount = opts.amount;
104
107
  this.token = opts.tokensList[opts.token];
105
108
  this.poolName = opts.poolName;
109
+ this.address = opts.address;
106
110
  }
107
111
  _toString() {
108
112
  const { title, decimals = 18 } = this.token;
@@ -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
  /**
@@ -16,12 +16,14 @@ interface AddLiquidityProps extends EVMTxProps {
16
16
  amount: bigint;
17
17
  token: Address;
18
18
  poolName: string;
19
+ address: Address;
19
20
  tokensList: Record<Address, TokenData>;
20
21
  }
21
22
  export declare class TxAddLiquidity extends EVMTx {
22
23
  readonly amount: bigint;
23
24
  readonly token: TokenData;
24
25
  readonly poolName: string;
26
+ readonly address: Address;
25
27
  constructor(opts: AddLiquidityProps);
26
28
  _toString(): string;
27
29
  serialize(): TxSerialized;
@@ -30,12 +32,14 @@ interface RemoveLiquidityProps extends EVMTxProps {
30
32
  amount: bigint;
31
33
  token: Address;
32
34
  poolName: string;
35
+ address: Address;
33
36
  tokensList: Record<Address, TokenData>;
34
37
  }
35
38
  export declare class TxRemoveLiquidity extends EVMTx {
36
39
  readonly amount: bigint;
37
40
  readonly token: TokenData;
38
41
  readonly poolName: string;
42
+ readonly address: Address;
39
43
  constructor(opts: RemoveLiquidityProps);
40
44
  _toString(): string;
41
45
  serialize(): TxSerialized;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@gearbox-protocol/sdk",
3
- "version": "12.6.4",
3
+ "version": "12.6.6",
4
4
  "description": "Gearbox SDK",
5
5
  "license": "MIT",
6
6
  "main": "./dist/cjs/sdk/index.js",