@strkfarm/sdk 1.1.17 → 1.1.20

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "1.1.17",
3
+ "version": "1.1.20",
4
4
  "description": "STRKFarm TS SDK (Meant for our internal use, but feel free to use it)",
5
5
  "typings": "dist/index.d.ts",
6
6
  "types": "dist/index.d.ts",
@@ -62,6 +62,7 @@
62
62
  "@noble/curves": "^1.0.0",
63
63
  "@noble/hashes": "^2.0.0",
64
64
  "@scure/starknet": "^2.0.0",
65
+ "@strkfarm/sdk": "link:",
65
66
  "bignumber.js": "4.0.4",
66
67
  "browser-assert": "^1.2.1",
67
68
  "chalk": "^4.1.2",
@@ -10,27 +10,42 @@ export class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
10
10
  }
11
11
 
12
12
  toWei() {
13
- return this.mul(10 ** this.decimals).toFixed(0);
13
+ return super.mul(10 ** this.decimals).toFixed(0);
14
14
  }
15
15
 
16
16
  multipliedBy(value: string | number | T): T {
17
17
  const _value = this.getStandardString(value);
18
- return this.construct(this.mul(_value).toString(), this.decimals);
18
+ return this.construct(super.mul(_value).toString(), this.decimals);
19
19
  }
20
20
 
21
21
  dividedBy(value: string | number | T): T {
22
22
  const _value = this.getStandardString(value);
23
- return this.construct(this.div(_value).toString(), this.decimals);
23
+ return this.construct(super.dividedBy(_value).toString(), this.decimals);
24
24
  }
25
25
 
26
26
  plus(value: string | number | T): T {
27
- const _value = this.getStandardString(value);
28
- return this.construct(this.add(_value).toString(), this.decimals);
27
+ // Convert to raw number/string to avoid calling overridden methods
28
+ const rawValue = this.getStandardString(value);
29
+
30
+ // Create a fresh BigNumber instance to do the math
31
+ const thisBN = new BigNumber(this.toString());
32
+ const result = thisBN.plus(rawValue);
33
+
34
+ return this.construct(result.toString(), this.decimals);
35
+ // const _value = this.getStandardString(value);
36
+ // return this.construct(super.plus(_value).toString(), this.decimals);
29
37
  }
30
38
 
31
39
  minus(n: number | string | T, base?: number): T {
32
- const _value = this.getStandardString(n);
33
- return this.construct(super.minus(_value, base).toString(), this.decimals);
40
+ const rawValue = this.getStandardString(n);
41
+
42
+ // Create a fresh BigNumber instance to do the math
43
+ const thisBN = new BigNumber(this.toString());
44
+ const result = thisBN.minus(rawValue, base);
45
+
46
+ return this.construct(result.toString(), this.decimals);
47
+ // const _value = this.getStandardString(n);
48
+ // return this.construct(super.minus(_value, base).toString(), this.decimals);
34
49
  }
35
50
 
36
51
  protected construct(value: string | number, decimals: number): T {
@@ -56,10 +71,15 @@ export class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
56
71
  }
57
72
 
58
73
  private getStandardString(value: string | number | T): string {
59
- if (typeof value == "string") {
74
+ if (typeof value === "string") {
60
75
  return value;
61
76
  }
62
- return value.toFixed(this.maxToFixedDecimals());
77
+ if (typeof value === "number") {
78
+ return value.toString();
79
+ }
80
+ // For _Web3Number instances, use the parent BigNumber's toString
81
+ // to avoid triggering our overridden methods
82
+ return BigNumber.prototype.toString.call(value);
63
83
  }
64
84
 
65
85
  minimum(value: string | number | T): T {
@@ -72,13 +92,11 @@ export class _Web3Number<T extends _Web3Number<T>> extends BigNumber {
72
92
  maximum(value: string | number | T): T {
73
93
  const _value = new BigNumber(value);
74
94
  const _valueMe = new BigNumber(this.toString());
75
- console.warn(`maximum: _value: ${_value.toString()}, _valueMe: ${_valueMe.toString()}`);
76
95
  const answer = _value.greaterThanOrEqualTo(_valueMe) ? _value : _valueMe;
77
96
  return this.construct(answer.toString(), this.decimals);
78
97
  }
79
98
 
80
99
  abs(): T {
81
- console.warn(`abs: this: ${this}`);
82
100
  return this.construct(Math.abs(this.toNumber()).toFixed(12), this.decimals);
83
101
  }
84
102
 
@@ -42,7 +42,7 @@ export class PricerFromApi extends PricerBase {
42
42
 
43
43
  async getPriceFromMyAPI(tokenSymbol: string) {
44
44
  logger.verbose(`getPrice from redis: ${tokenSymbol}`);
45
- const endpoint = 'https://cache-server-t2me.onrender.com'
45
+ const endpoint = 'https://proxy.api.troves.fi'
46
46
  const url = `${endpoint}/api/price/${tokenSymbol}`;
47
47
  const priceInfoRes = await fetch(url);
48
48
  const priceInfo = await priceInfoRes.json();
@@ -1,5 +1,5 @@
1
1
  import { ContractAddr, Web3Number } from "@/dataTypes";
2
- import { IConfig, TokenInfo } from "@/interfaces";
2
+ import { IConfig, TokenInfo, VaultPosition } from "@/interfaces";
3
3
  import { CacheClass } from "@/utils/cacheClass";
4
4
  import { Call } from "starknet";
5
5
 
@@ -51,4 +51,8 @@ export class BaseStrategy<TVLInfo, ActionInfo> extends CacheClass {
51
51
  async withdrawCall(amountInfo: ActionInfo, receiver: ContractAddr, owner: ContractAddr): Promise<Call[]> {
52
52
  throw new Error("Not implemented");
53
53
  }
54
+
55
+ async getVaultPositions(): Promise<VaultPosition[]> {
56
+ throw new Error("Not implemented");
57
+ }
54
58
  }
@@ -7,5 +7,5 @@ export const COMMON_CONTRACTS = [{
7
7
  }];
8
8
 
9
9
  export const ENDPOINTS = {
10
- VESU_BASE: "https://cache-server-t2me.onrender.com/vesu"
10
+ VESU_BASE: "https://proxy.api.troves.fi/vesu-staging"
11
11
  }
@@ -11,6 +11,7 @@ import {
11
11
  RiskFactor,
12
12
  RiskType,
13
13
  TokenInfo,
14
+ VaultPosition,
14
15
  } from "@/interfaces";
15
16
  import { PricerBase } from "@/modules/pricerBase";
16
17
  import { assert } from "@/utils";
@@ -634,6 +635,50 @@ export class EkuboCLVault extends BaseStrategy<
634
635
  return this.tickToi129(tick);
635
636
  }
636
637
 
638
+ async getVaultPositions(): Promise<VaultPosition[]> {
639
+ const tvlInfo = await this.getTVL();
640
+ const fees = await this.getUncollectedFees();
641
+ const unusedBalance = await this.unusedBalances();
642
+ return [
643
+ {
644
+ amount: tvlInfo.token0.amount,
645
+ usdValue: tvlInfo.token0.usdValue,
646
+ token: tvlInfo.token0.tokenInfo,
647
+ remarks: `Liquidity in Ekubo`
648
+ },
649
+ {
650
+ amount: fees.token0.amount,
651
+ usdValue: fees.token0.usdValue,
652
+ token: fees.token0.tokenInfo,
653
+ remarks: "Uncollected Fees in Ekubo"
654
+ },
655
+ {
656
+ amount: unusedBalance.token0.amount,
657
+ usdValue: unusedBalance.token0.usdValue,
658
+ token: unusedBalance.token0.tokenInfo,
659
+ remarks: "Unused Balance in the Vault"
660
+ },
661
+ {
662
+ amount: tvlInfo.token1.amount,
663
+ usdValue: tvlInfo.token1.usdValue,
664
+ token: tvlInfo.token1.tokenInfo,
665
+ remarks: "Liquidity in Ekubo"
666
+ },
667
+ {
668
+ amount: fees.token1.amount,
669
+ usdValue: fees.token1.usdValue,
670
+ token: fees.token1.tokenInfo,
671
+ remarks: "Uncollected Fees in Ekubo"
672
+ },
673
+ {
674
+ amount: unusedBalance.token1.amount,
675
+ usdValue: unusedBalance.token1.usdValue,
676
+ token: unusedBalance.token1.tokenInfo,
677
+ remarks: "Unused Balance in the Vault"
678
+ }
679
+ ];
680
+ }
681
+
637
682
  async getPoolKey(
638
683
  blockIdentifier: BlockIdentifier = "latest"
639
684
  ): Promise<EkuboPoolKey> {
@@ -3,10 +3,12 @@ import { ContractAddr } from "@/dataTypes";
3
3
  // Zellic audited
4
4
  export const SIMPLE_SANITIZER = ContractAddr.from('0x5a2e3ceb3da368b983a8717898427ab7b6daf04014b70f321e777f9aad940b4');
5
5
  // Without flashloan options
6
- export const SIMPLE_SANITIZER_V2 = ContractAddr.from('0x5643d54da70a471cd2b6fa37f52ea7a13cc3f3910689a839f8490a663d2208a');
6
+ export const SIMPLE_SANITIZER_V2 = ContractAddr.from('0x7b6f98311af8aa425278570e62abf523e6462eaa01a38c1feab9b2f416492e2');
7
+ export const SIMPLE_SANITIZER_VESU_V1_DELEGATIONS = ContractAddr.from('0x5643d54da70a471cd2b6fa37f52ea7a13cc3f3910689a839f8490a663d2208a');
7
8
  export const PRICE_ROUTER = ContractAddr.from('0x05e83Fa38D791d2dba8E6f487758A9687FfEe191A6Cf8a6c5761ab0a110DB837');
8
9
  export const AVNU_MIDDLEWARE = ContractAddr.from('0x4a7972ed3f5d1e74a6d6c4a8f467666953d081c8f2270390cc169d50d17cb0d');
9
10
 
11
+ export const VESU_SINGLETON = ContractAddr.from('0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160');
10
12
  export function toBigInt(value: string | number): bigint {
11
13
  if (typeof value === 'string') {
12
14
  return BigInt(value);
@@ -1,3 +1,4 @@
1
1
  export * from "./baseAdapter";
2
2
  export * from "./common-adapter";
3
3
  export * from "./vesu-adapter";
4
+ export * from "./adapter-utils";
@@ -1,10 +1,10 @@
1
1
  import { LeafData, logger } from "@/utils"
2
2
  import { CairoCustomEnum, Contract, hash, num, RpcProvider, shortString, uint256, Uint256 } from "starknet";
3
- import { SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, toBigInt } from "./adapter-utils";
3
+ import { SIMPLE_SANITIZER, SIMPLE_SANITIZER_V2, SIMPLE_SANITIZER_VESU_V1_DELEGATIONS, toBigInt, VESU_SINGLETON } from "./adapter-utils";
4
4
  import { ContractAddr, Web3Number } from "@/dataTypes";
5
5
  import { AdapterLeafType, BaseAdapter, GenerateCallFn, LeafAdapterFn, ManageCall } from "./baseAdapter";
6
6
  import VesuSingletonAbi from '../../data/vesu-singleton.abi.json';
7
- import { IConfig, TokenInfo, VaultPosition } from "@/interfaces";
7
+ import { getMainnetConfig, IConfig, TokenInfo, VaultPosition } from "@/interfaces";
8
8
  import { PricerBase } from "@/modules/pricerBase";
9
9
  import VesuPoolIDs from "@/data/vesu_pools.json";
10
10
  import { getAPIUsingHeadlessBrowser } from "@/node/headless";
@@ -13,6 +13,7 @@ import { VESU_REWARDS_CONTRACT } from "@/modules/harvests";
13
13
  import { ENDPOINTS } from "../constants";
14
14
  import VesuMultiplyAbi from '@/data/vesu-multiple.abi.json';
15
15
  import { EkuboPoolKey } from "../ekubo-cl-vault";
16
+ import VesuPoolV2Abi from '@/data/vesu-pool-v2.abi.json';
16
17
 
17
18
  interface VesuPoolsInfo { pools: any[]; isErrorPoolsAPI: boolean };
18
19
 
@@ -212,12 +213,21 @@ function getVesuMultiplyParams(isIncrease: boolean, params: IncreaseLeverParams
212
213
 
213
214
  export const VesuPools = {
214
215
  Genesis: ContractAddr.from('0x4dc4f0ca6ea4961e4c8373265bfd5317678f4fe374d76f3fd7135f57763bf28'),
215
- Re7xSTRK: ContractAddr.from('0x052fb52363939c3aa848f8f4ac28f0a51379f8d1b971d8444de25fbd77d8f161')
216
+ Re7xSTRK: ContractAddr.from('0x052fb52363939c3aa848f8f4ac28f0a51379f8d1b971d8444de25fbd77d8f161'),
217
+ Re7xBTC: ContractAddr.from('0x3a8416bf20d036df5b1cf3447630a2e1cb04685f6b0c3a70ed7fb1473548ecf')
218
+ }
219
+
220
+ export function getVesuSingletonAddress(vesuPool: ContractAddr) {
221
+ if (vesuPool.eq(VesuPools.Genesis) ||
222
+ vesuPool.eq(VesuPools.Re7xSTRK)) {
223
+ return {addr: VESU_SINGLETON, isV2: false};
224
+ }
225
+ return {addr: vesuPool, isV2: true}; // Vesu v2
216
226
  }
217
227
 
218
228
  export class VesuAdapter extends BaseAdapter {
219
- VESU_SINGLETON = ContractAddr.from("0x000d8d6dfec4d33bfb6895de9f3852143a17c6f92fd2a21da3d6924d34870160");
220
- VESU_MULTIPLY = ContractAddr.from('0x3630f1f8e5b8f5c4c4ae9b6620f8a570ae55cddebc0276c37550e7c118edf67');
229
+ VESU_MULTIPLY_V1 = ContractAddr.from('0x3630f1f8e5b8f5c4c4ae9b6620f8a570ae55cddebc0276c37550e7c118edf67');
230
+ VESU_MULTIPLY = ContractAddr.from('0x027fef272d0a9a3844767c851a64b36fe4f0115141d81134baade95d2b27b781');
221
231
  config: VesuAdapterConfig;
222
232
  networkConfig: IConfig | undefined;
223
233
  pricer: PricerBase | undefined;
@@ -239,7 +249,7 @@ export class VesuAdapter extends BaseAdapter {
239
249
  ];
240
250
  const output = this.constructSimpleLeafData({
241
251
  id: this.config.id,
242
- target: this.VESU_SINGLETON,
252
+ target: getVesuSingletonAddress(this.config.poolId).addr,
243
253
  method: 'modify_position',
244
254
  packedArguments
245
255
  });
@@ -299,9 +309,15 @@ export class VesuAdapter extends BaseAdapter {
299
309
  }
300
310
  };
301
311
  logger.verbose(`VesuAdapter::ConstructingModify::Debt::${JSON.stringify(_debt)}`)
302
- const singletonContract = new Contract({abi: VesuSingletonAbi, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider({nodeUrl: ''})});
303
- const call = singletonContract.populate('modify_position', {
304
- params: {
312
+ const { contract, isV2 } = this.getVesuSingletonContract(getMainnetConfig(), this.config.poolId);
313
+ const call = contract.populate('modify_position', {
314
+ params: isV2 ? {
315
+ collateral_asset: this.config.collateral.address.toBigInt(),
316
+ debt_asset: this.config.debt.address.toBigInt(),
317
+ user: this.config.vaultAllocator.toBigInt(),
318
+ collateral: _collateral,
319
+ debt: _debt,
320
+ } : {
305
321
  pool_id: this.config.poolId.toBigInt(),
306
322
  collateral_asset: this.config.collateral.address.toBigInt(),
307
323
  debt_asset: this.config.debt.address.toBigInt(),
@@ -314,7 +330,7 @@ export class VesuAdapter extends BaseAdapter {
314
330
  return {
315
331
  sanitizer: SIMPLE_SANITIZER,
316
332
  call: {
317
- contractAddress: this.VESU_SINGLETON,
333
+ contractAddress: ContractAddr.from(contract.address),
318
334
  selector: hash.getSelectorFromName('modify_position'),
319
335
  calldata: [
320
336
  ...call.calldata as bigint[]
@@ -330,9 +346,10 @@ export class VesuAdapter extends BaseAdapter {
330
346
  toBigInt(this.config.debt.address.toString()), // debt
331
347
  toBigInt(this.config.vaultAllocator.toString()), // vault allocator
332
348
  ];
349
+ const { isV2 } = getVesuSingletonAddress(this.config.poolId);
333
350
  const output = this.constructSimpleLeafData({
334
351
  id: this.config.id,
335
- target: this.VESU_MULTIPLY,
352
+ target: isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1,
336
353
  method: 'modify_lever',
337
354
  packedArguments
338
355
  }, SIMPLE_SANITIZER_V2);
@@ -346,7 +363,9 @@ export class VesuAdapter extends BaseAdapter {
346
363
  if (!multiplyParams) {
347
364
  throw new Error('Multiply params are not provided');
348
365
  }
349
- const multiplyContract = new Contract({abi: VesuMultiplyAbi, address: this.VESU_MULTIPLY.toString(), providerOrAccount: new RpcProvider({nodeUrl: ''})});
366
+ const { isV2 } = getVesuSingletonAddress(this.config.poolId);
367
+ const VESU_MULTIPLY = isV2 ? this.VESU_MULTIPLY : this.VESU_MULTIPLY_V1;
368
+ const multiplyContract = new Contract({abi: VesuMultiplyAbi, address: VESU_MULTIPLY.toString(), providerOrAccount: new RpcProvider({nodeUrl: ''})});
350
369
  const call = multiplyContract.populate('modify_lever', {
351
370
  modify_lever_params: getVesuMultiplyParams(isIncrease, {
352
371
  ...multiplyParams,
@@ -360,7 +379,7 @@ export class VesuAdapter extends BaseAdapter {
360
379
  return {
361
380
  sanitizer: SIMPLE_SANITIZER_V2,
362
381
  call: {
363
- contractAddress: this.VESU_MULTIPLY,
382
+ contractAddress: VESU_MULTIPLY,
364
383
  selector: hash.getSelectorFromName('modify_lever'),
365
384
  calldata: [
366
385
  ...call.calldata as bigint[]
@@ -371,32 +390,39 @@ export class VesuAdapter extends BaseAdapter {
371
390
 
372
391
  getVesuModifyDelegationAdapter = (id: string): LeafAdapterFn<VesuModifyDelegationCallParams> => {
373
392
  return () => {
374
- const packedArguments: bigint[] = [
375
- toBigInt(this.config.poolId.toString()), // pool id
376
- toBigInt(this.VESU_MULTIPLY.toString()), // vault allocator
393
+ const { addr: VESU_SINGLETON, isV2 } = getVesuSingletonAddress(this.config.poolId);
394
+ const packedArguments: bigint[] = isV2 ? [
395
+ toBigInt(this.VESU_MULTIPLY.toString()), // v2
396
+ ] : [
397
+ this.config.poolId.toBigInt(),
398
+ toBigInt(this.VESU_MULTIPLY_V1.toString()), // v1
377
399
  ];
378
400
  const output = this.constructSimpleLeafData({
379
401
  id: id,
380
- target: this.VESU_SINGLETON,
402
+ target: VESU_SINGLETON,
381
403
  method: 'modify_delegation',
382
404
  packedArguments
383
- }, SIMPLE_SANITIZER_V2);
405
+ }, isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS);
384
406
 
385
407
  return { leaf: output, callConstructor: this.getVesuModifyDelegationCall.bind(this) };
386
408
  }
387
409
  }
388
410
 
389
411
  getVesuModifyDelegationCall = (params: VesuModifyDelegationCallParams): ManageCall => {
390
- const singletonContract = new Contract({abi: VesuSingletonAbi, address: this.VESU_SINGLETON.toString(), providerOrAccount: new RpcProvider({nodeUrl: ''})});
391
- const call = singletonContract.populate('modify_delegation', {
392
- pool_id: this.config.poolId.toBigInt(),
412
+ const VESU_SINGLETON = getVesuSingletonAddress(this.config.poolId).addr;
413
+ const { contract, isV2 } = this.getVesuSingletonContract(getMainnetConfig(), this.config.poolId);
414
+ const call = contract.populate('modify_delegation', isV2 ? {
393
415
  delegatee: this.VESU_MULTIPLY.toBigInt(),
394
416
  delegation: params.delegation,
417
+ } : {
418
+ pool_id: this.config.poolId.toBigInt(),
419
+ delegatee: this.VESU_MULTIPLY_V1.toBigInt(),
420
+ delegation: params.delegation,
395
421
  });
396
422
  return {
397
- sanitizer: SIMPLE_SANITIZER_V2,
423
+ sanitizer: isV2 ? SIMPLE_SANITIZER_V2 : SIMPLE_SANITIZER_VESU_V1_DELEGATIONS,
398
424
  call: {
399
- contractAddress: this.VESU_SINGLETON,
425
+ contractAddress: VESU_SINGLETON,
400
426
  selector: hash.getSelectorFromName('modify_delegation'),
401
427
  calldata: [
402
428
  ...call.calldata as bigint[]
@@ -458,8 +484,13 @@ export class VesuAdapter extends BaseAdapter {
458
484
  throw new Error(`Unknown VesuAmountDenomination: ${denomination}`);
459
485
  }
460
486
 
461
- getVesuSingletonContract(config: IConfig) {
462
- return new Contract({abi: VesuSingletonAbi, address: this.VESU_SINGLETON.address, providerOrAccount: config.provider});
487
+ getVesuSingletonContract(config: IConfig, poolId: ContractAddr) {
488
+ const { addr: VESU_SINGLETON, isV2 } = getVesuSingletonAddress(poolId);
489
+ const ABI = isV2 ? VesuPoolV2Abi : VesuSingletonAbi;
490
+ return {
491
+ contract: new Contract({abi: ABI, address: VESU_SINGLETON.address, providerOrAccount: config.provider}),
492
+ isV2
493
+ }
463
494
  }
464
495
 
465
496
  async getLTVConfig(config: IConfig) {
@@ -468,9 +499,16 @@ export class VesuAdapter extends BaseAdapter {
468
499
  if (cacheData) {
469
500
  return cacheData as number;
470
501
  }
471
- const output: any = await this.getVesuSingletonContract(config)
472
- .call('ltv_config', [this.config.poolId.address, this.config.collateral.address.address, this.config.debt.address.address])
473
- this.setCache(CACHE_KEY, Number(output.max_ltv) / 1e18, 300000); // ttl: 5min
502
+ const { contract, isV2 } = await this.getVesuSingletonContract(config, this.config.poolId);
503
+ let ltv = 0;
504
+ if (isV2) {
505
+ const output: any = await contract.call('pair_config', [this.config.collateral.address.address, this.config.debt.address.address]);
506
+ ltv = Number(output.max_ltv) / 1e18;
507
+ } else {
508
+ const output: any = await contract.call('ltv_config', [this.config.poolId.address, this.config.collateral.address.address, this.config.debt.address.address]);
509
+ ltv = Number(output.max_ltv) / 1e18;
510
+ }
511
+ this.setCache(CACHE_KEY, ltv, 300000); // ttl: 5min
474
512
  return this.getCache<number>(CACHE_KEY) as number;
475
513
  }
476
514
 
@@ -484,9 +522,11 @@ export class VesuAdapter extends BaseAdapter {
484
522
  if (cacheData) {
485
523
  return cacheData;
486
524
  }
487
- const output: any = await this.getVesuSingletonContract(config)
488
- .call('position_unsafe', [
489
- this.config.poolId.address,
525
+
526
+ const { contract, isV2} = this.getVesuSingletonContract(config, this.config.poolId);
527
+ const output: any = await contract
528
+ .call(isV2 ? 'position' : 'position_unsafe', [...(isV2 ?
529
+ []: [this.config.poolId.address]), // exclude pool id in v2
490
530
  this.config.collateral.address.address,
491
531
  this.config.debt.address.address,
492
532
  this.config.vaultAllocator.address
@@ -494,7 +534,8 @@ export class VesuAdapter extends BaseAdapter {
494
534
 
495
535
  const token1Price = await this.pricer.getPrice(this.config.collateral.symbol);
496
536
  const token2Price = await this.pricer.getPrice(this.config.debt.symbol);
497
-
537
+ logger.verbose(`VesuAdapter::getPositions token1Price: ${token1Price.price}, token2Price: ${token2Price.price}`);
538
+
498
539
  const collateralAmount = Web3Number.fromWei(output['1'].toString(), this.config.collateral.decimals);
499
540
  const debtAmount = Web3Number.fromWei(output['2'].toString(), this.config.debt.decimals);
500
541
  const value = [{
@@ -522,9 +563,11 @@ export class VesuAdapter extends BaseAdapter {
522
563
  if (cacheData) {
523
564
  return cacheData;
524
565
  }
525
- const output: any = await this.getVesuSingletonContract(config)
526
- .call('check_collateralization_unsafe', [
527
- this.config.poolId.address,
566
+ const { contract, isV2 } = this.getVesuSingletonContract(config, this.config.poolId);
567
+ const output: any = await contract
568
+ .call(isV2 ? 'check_collateralization' : 'check_collateralization_unsafe', [
569
+ ...(isV2 ?
570
+ []: [this.config.poolId.address]), // exclude pool id in v2
528
571
  this.config.collateral.address.address,
529
572
  this.config.debt.address.address,
530
573
  this.config.vaultAllocator.address
@@ -598,7 +641,7 @@ export class VesuAdapter extends BaseAdapter {
598
641
 
599
642
  // Vesu API is unstable sometimes, some Pools may be missing sometimes
600
643
  for (const pool of VesuPoolIDs.data) {
601
- const found = pools.find((d: any) => d.id === pool.id);
644
+ const found = pools.find((d: any) => ContractAddr.from(d.id).eqString(pool.id));
602
645
  if (!found) {
603
646
  logger.verbose(`VesuRebalance: pools: ${JSON.stringify(pools)}`);
604
647
  logger.verbose(