@strkfarm/sdk 1.0.25 → 1.0.26

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.
@@ -38661,6 +38661,45 @@ var strkfarm_risk_engine = (() => {
38661
38661
  }).filter((p) => p !== null);
38662
38662
  return pools;
38663
38663
  }
38664
+ async getPoolInfo(p, pools, vesuPositions, totalAssets, isErrorPositionsAPI, isErrorPoolsAPI) {
38665
+ const vesuPosition = vesuPositions.find((d) => d.pool.id.toString() === num_exports.getDecimalString(p.pool_id.address.toString()));
38666
+ const _pool = pools.find((d) => {
38667
+ logger.verbose(`pool check: ${d.id == num_exports.getDecimalString(p.pool_id.address.toString())}, id: ${d.id}, pool_id: ${num_exports.getDecimalString(p.pool_id.address.toString())}`);
38668
+ return d.id == num_exports.getDecimalString(p.pool_id.address.toString());
38669
+ });
38670
+ logger.verbose(`pool: ${JSON.stringify(_pool)}`);
38671
+ logger.verbose(typeof _pool);
38672
+ logger.verbose(`name: ${_pool?.name}`);
38673
+ if (!_pool) {
38674
+ throw new Error(`Pool ${p.pool_id.address.toString()} not found`);
38675
+ }
38676
+ const assetInfo = _pool?.assets.find((d) => this.asset().address.eqString(d.address));
38677
+ let vTokenContract = new Contract(vesu_rebalance_abi_default, p.v_token.address, this.config.provider);
38678
+ const bal = await vTokenContract.balanceOf(this.address.address);
38679
+ const assets = await vTokenContract.convert_to_assets(uint256_exports.bnToUint256(bal.toString()));
38680
+ const item = {
38681
+ pool_id: p.pool_id,
38682
+ pool_name: _pool?.name,
38683
+ max_weight: p.max_weight,
38684
+ current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
38685
+ v_token: p.v_token,
38686
+ amount: Web3Number.fromWei(assets.toString(), this.decimals()),
38687
+ usdValue: isErrorPositionsAPI || !vesuPosition ? Web3Number.fromWei("0", this.decimals()) : Web3Number.fromWei(vesuPosition.collateral.usdPrice.value, vesuPosition.collateral.usdPrice.decimals),
38688
+ APY: isErrorPoolsAPI || !assetInfo ? {
38689
+ baseApy: 0,
38690
+ defiSpringApy: 0,
38691
+ netApy: 0
38692
+ } : {
38693
+ baseApy: Number(Web3Number.fromWei(assetInfo.stats.supplyApy.value, assetInfo.stats.supplyApy.decimals).toFixed(6)),
38694
+ defiSpringApy: Number(Web3Number.fromWei(assetInfo.stats.defiSpringSupplyApr.value, assetInfo.stats.defiSpringSupplyApr.decimals).toFixed(6)),
38695
+ netApy: 0
38696
+ },
38697
+ currentUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.stats.currentUtilization.value, assetInfo.stats.currentUtilization.decimals).toFixed(6)),
38698
+ maxUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.config.maxUtilization.value, assetInfo.config.maxUtilization.decimals).toFixed(6))
38699
+ };
38700
+ item.APY.netApy = item.APY.baseApy + item.APY.defiSpringApy;
38701
+ return item;
38702
+ }
38664
38703
  /**
38665
38704
  * Retrieves the list of allowed pools and their detailed information from multiple sources:
38666
38705
  * 1. Contract's allowed pools
@@ -38699,45 +38738,7 @@ var strkfarm_risk_engine = (() => {
38699
38738
  isErrorPoolsAPI = true;
38700
38739
  }
38701
38740
  const totalAssets = (await this.getTVL()).amount;
38702
- const info = allowedPools.map(async (p) => {
38703
- const vesuPosition = vesuPositions.find((d) => d.pool.id.toString() === num_exports.getDecimalString(p.pool_id.address.toString()));
38704
- const _pool = pools.find((d) => {
38705
- logger.verbose(`pool check: ${d.id == num_exports.getDecimalString(p.pool_id.address.toString())}, id: ${d.id}, pool_id: ${num_exports.getDecimalString(p.pool_id.address.toString())}`);
38706
- return d.id == num_exports.getDecimalString(p.pool_id.address.toString());
38707
- });
38708
- logger.verbose(`pool: ${JSON.stringify(_pool)}`);
38709
- logger.verbose(typeof _pool);
38710
- logger.verbose(`name: ${_pool?.name}`);
38711
- if (!_pool) {
38712
- throw new Error(`Pool ${p.pool_id.address.toString()} not found`);
38713
- }
38714
- const assetInfo = _pool?.assets.find((d) => this.asset().address.eqString(d.address));
38715
- let vTokenContract = new Contract(vesu_rebalance_abi_default, p.v_token.address, this.config.provider);
38716
- const bal = await vTokenContract.balanceOf(this.address.address);
38717
- const assets = await vTokenContract.convert_to_assets(uint256_exports.bnToUint256(bal.toString()));
38718
- const item = {
38719
- pool_id: p.pool_id,
38720
- pool_name: _pool?.name,
38721
- max_weight: p.max_weight,
38722
- current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
38723
- v_token: p.v_token,
38724
- amount: Web3Number.fromWei(assets.toString(), this.decimals()),
38725
- usdValue: isErrorPositionsAPI || !vesuPosition ? Web3Number.fromWei("0", this.decimals()) : Web3Number.fromWei(vesuPosition.collateral.usdPrice.value, vesuPosition.collateral.usdPrice.decimals),
38726
- APY: isErrorPoolsAPI || !assetInfo ? {
38727
- baseApy: 0,
38728
- defiSpringApy: 0,
38729
- netApy: 0
38730
- } : {
38731
- baseApy: Number(Web3Number.fromWei(assetInfo.stats.supplyApy.value, assetInfo.stats.supplyApy.decimals).toFixed(6)),
38732
- defiSpringApy: Number(Web3Number.fromWei(assetInfo.stats.defiSpringSupplyApr.value, assetInfo.stats.defiSpringSupplyApr.decimals).toFixed(6)),
38733
- netApy: 0
38734
- },
38735
- currentUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.stats.currentUtilization.value, assetInfo.stats.currentUtilization.decimals).toFixed(6)),
38736
- maxUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.config.maxUtilization.value, assetInfo.config.maxUtilization.decimals).toFixed(6))
38737
- };
38738
- item.APY.netApy = item.APY.baseApy + item.APY.defiSpringApy;
38739
- return item;
38740
- });
38741
+ const info = allowedPools.map((p) => this.getPoolInfo(p, pools, vesuPositions, totalAssets, isErrorPositionsAPI, isErrorPoolsAPI));
38741
38742
  const data = await Promise.all(info);
38742
38743
  return {
38743
38744
  data,
@@ -3673,6 +3673,45 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
3673
3673
  }).filter((p) => p !== null);
3674
3674
  return pools;
3675
3675
  }
3676
+ async getPoolInfo(p, pools, vesuPositions, totalAssets, isErrorPositionsAPI, isErrorPoolsAPI) {
3677
+ const vesuPosition = vesuPositions.find((d) => d.pool.id.toString() === num2.getDecimalString(p.pool_id.address.toString()));
3678
+ const _pool = pools.find((d) => {
3679
+ logger.verbose(`pool check: ${d.id == num2.getDecimalString(p.pool_id.address.toString())}, id: ${d.id}, pool_id: ${num2.getDecimalString(p.pool_id.address.toString())}`);
3680
+ return d.id == num2.getDecimalString(p.pool_id.address.toString());
3681
+ });
3682
+ logger.verbose(`pool: ${JSON.stringify(_pool)}`);
3683
+ logger.verbose(typeof _pool);
3684
+ logger.verbose(`name: ${_pool?.name}`);
3685
+ if (!_pool) {
3686
+ throw new Error(`Pool ${p.pool_id.address.toString()} not found`);
3687
+ }
3688
+ const assetInfo = _pool?.assets.find((d) => this.asset().address.eqString(d.address));
3689
+ let vTokenContract = new Contract4(vesu_rebalance_abi_default, p.v_token.address, this.config.provider);
3690
+ const bal = await vTokenContract.balanceOf(this.address.address);
3691
+ const assets = await vTokenContract.convert_to_assets(uint2563.bnToUint256(bal.toString()));
3692
+ const item = {
3693
+ pool_id: p.pool_id,
3694
+ pool_name: _pool?.name,
3695
+ max_weight: p.max_weight,
3696
+ current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
3697
+ v_token: p.v_token,
3698
+ amount: Web3Number.fromWei(assets.toString(), this.decimals()),
3699
+ usdValue: isErrorPositionsAPI || !vesuPosition ? Web3Number.fromWei("0", this.decimals()) : Web3Number.fromWei(vesuPosition.collateral.usdPrice.value, vesuPosition.collateral.usdPrice.decimals),
3700
+ APY: isErrorPoolsAPI || !assetInfo ? {
3701
+ baseApy: 0,
3702
+ defiSpringApy: 0,
3703
+ netApy: 0
3704
+ } : {
3705
+ baseApy: Number(Web3Number.fromWei(assetInfo.stats.supplyApy.value, assetInfo.stats.supplyApy.decimals).toFixed(6)),
3706
+ defiSpringApy: Number(Web3Number.fromWei(assetInfo.stats.defiSpringSupplyApr.value, assetInfo.stats.defiSpringSupplyApr.decimals).toFixed(6)),
3707
+ netApy: 0
3708
+ },
3709
+ currentUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.stats.currentUtilization.value, assetInfo.stats.currentUtilization.decimals).toFixed(6)),
3710
+ maxUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.config.maxUtilization.value, assetInfo.config.maxUtilization.decimals).toFixed(6))
3711
+ };
3712
+ item.APY.netApy = item.APY.baseApy + item.APY.defiSpringApy;
3713
+ return item;
3714
+ }
3676
3715
  /**
3677
3716
  * Retrieves the list of allowed pools and their detailed information from multiple sources:
3678
3717
  * 1. Contract's allowed pools
@@ -3711,45 +3750,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
3711
3750
  isErrorPoolsAPI = true;
3712
3751
  }
3713
3752
  const totalAssets = (await this.getTVL()).amount;
3714
- const info = allowedPools.map(async (p) => {
3715
- const vesuPosition = vesuPositions.find((d) => d.pool.id.toString() === num2.getDecimalString(p.pool_id.address.toString()));
3716
- const _pool = pools.find((d) => {
3717
- logger.verbose(`pool check: ${d.id == num2.getDecimalString(p.pool_id.address.toString())}, id: ${d.id}, pool_id: ${num2.getDecimalString(p.pool_id.address.toString())}`);
3718
- return d.id == num2.getDecimalString(p.pool_id.address.toString());
3719
- });
3720
- logger.verbose(`pool: ${JSON.stringify(_pool)}`);
3721
- logger.verbose(typeof _pool);
3722
- logger.verbose(`name: ${_pool?.name}`);
3723
- if (!_pool) {
3724
- throw new Error(`Pool ${p.pool_id.address.toString()} not found`);
3725
- }
3726
- const assetInfo = _pool?.assets.find((d) => this.asset().address.eqString(d.address));
3727
- let vTokenContract = new Contract4(vesu_rebalance_abi_default, p.v_token.address, this.config.provider);
3728
- const bal = await vTokenContract.balanceOf(this.address.address);
3729
- const assets = await vTokenContract.convert_to_assets(uint2563.bnToUint256(bal.toString()));
3730
- const item = {
3731
- pool_id: p.pool_id,
3732
- pool_name: _pool?.name,
3733
- max_weight: p.max_weight,
3734
- current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
3735
- v_token: p.v_token,
3736
- amount: Web3Number.fromWei(assets.toString(), this.decimals()),
3737
- usdValue: isErrorPositionsAPI || !vesuPosition ? Web3Number.fromWei("0", this.decimals()) : Web3Number.fromWei(vesuPosition.collateral.usdPrice.value, vesuPosition.collateral.usdPrice.decimals),
3738
- APY: isErrorPoolsAPI || !assetInfo ? {
3739
- baseApy: 0,
3740
- defiSpringApy: 0,
3741
- netApy: 0
3742
- } : {
3743
- baseApy: Number(Web3Number.fromWei(assetInfo.stats.supplyApy.value, assetInfo.stats.supplyApy.decimals).toFixed(6)),
3744
- defiSpringApy: Number(Web3Number.fromWei(assetInfo.stats.defiSpringSupplyApr.value, assetInfo.stats.defiSpringSupplyApr.decimals).toFixed(6)),
3745
- netApy: 0
3746
- },
3747
- currentUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.stats.currentUtilization.value, assetInfo.stats.currentUtilization.decimals).toFixed(6)),
3748
- maxUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.config.maxUtilization.value, assetInfo.config.maxUtilization.decimals).toFixed(6))
3749
- };
3750
- item.APY.netApy = item.APY.baseApy + item.APY.defiSpringApy;
3751
- return item;
3752
- });
3753
+ const info = allowedPools.map((p) => this.getPoolInfo(p, pools, vesuPositions, totalAssets, isErrorPositionsAPI, isErrorPoolsAPI));
3753
3754
  const data = await Promise.all(info);
3754
3755
  return {
3755
3756
  data,
package/dist/index.d.ts CHANGED
@@ -395,6 +395,11 @@ declare class BaseStrategy<TVLInfo, ActionInfo> {
395
395
  withdrawCall(amountInfo: ActionInfo, receiver: ContractAddr, owner: ContractAddr): Call[];
396
396
  }
397
397
 
398
+ interface PoolProps {
399
+ pool_id: ContractAddr;
400
+ max_weight: number;
401
+ v_token: ContractAddr;
402
+ }
398
403
  interface Change {
399
404
  pool_id: ContractAddr;
400
405
  changeAmt: Web3Number;
@@ -488,6 +493,22 @@ declare class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAm
488
493
  usdValue: number;
489
494
  }>;
490
495
  static getAllPossibleVerifiedPools(asset: ContractAddr): Promise<any>;
496
+ getPoolInfo(p: PoolProps, pools: any[], vesuPositions: any[], totalAssets: Web3Number, isErrorPositionsAPI: boolean, isErrorPoolsAPI: boolean): Promise<{
497
+ pool_id: ContractAddr;
498
+ pool_name: any;
499
+ max_weight: number;
500
+ current_weight: number;
501
+ v_token: ContractAddr;
502
+ amount: Web3Number;
503
+ usdValue: Web3Number;
504
+ APY: {
505
+ baseApy: number;
506
+ defiSpringApy: number;
507
+ netApy: number;
508
+ };
509
+ currentUtilization: number;
510
+ maxUtilization: number;
511
+ }>;
491
512
  /**
492
513
  * Retrieves the list of allowed pools and their detailed information from multiple sources:
493
514
  * 1. Contract's allowed pools
package/dist/index.js CHANGED
@@ -3761,6 +3761,45 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
3761
3761
  }).filter((p) => p !== null);
3762
3762
  return pools;
3763
3763
  }
3764
+ async getPoolInfo(p, pools, vesuPositions, totalAssets, isErrorPositionsAPI, isErrorPoolsAPI) {
3765
+ const vesuPosition = vesuPositions.find((d) => d.pool.id.toString() === import_starknet7.num.getDecimalString(p.pool_id.address.toString()));
3766
+ const _pool = pools.find((d) => {
3767
+ logger.verbose(`pool check: ${d.id == import_starknet7.num.getDecimalString(p.pool_id.address.toString())}, id: ${d.id}, pool_id: ${import_starknet7.num.getDecimalString(p.pool_id.address.toString())}`);
3768
+ return d.id == import_starknet7.num.getDecimalString(p.pool_id.address.toString());
3769
+ });
3770
+ logger.verbose(`pool: ${JSON.stringify(_pool)}`);
3771
+ logger.verbose(typeof _pool);
3772
+ logger.verbose(`name: ${_pool?.name}`);
3773
+ if (!_pool) {
3774
+ throw new Error(`Pool ${p.pool_id.address.toString()} not found`);
3775
+ }
3776
+ const assetInfo = _pool?.assets.find((d) => this.asset().address.eqString(d.address));
3777
+ let vTokenContract = new import_starknet7.Contract(vesu_rebalance_abi_default, p.v_token.address, this.config.provider);
3778
+ const bal = await vTokenContract.balanceOf(this.address.address);
3779
+ const assets = await vTokenContract.convert_to_assets(import_starknet7.uint256.bnToUint256(bal.toString()));
3780
+ const item = {
3781
+ pool_id: p.pool_id,
3782
+ pool_name: _pool?.name,
3783
+ max_weight: p.max_weight,
3784
+ current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
3785
+ v_token: p.v_token,
3786
+ amount: Web3Number.fromWei(assets.toString(), this.decimals()),
3787
+ usdValue: isErrorPositionsAPI || !vesuPosition ? Web3Number.fromWei("0", this.decimals()) : Web3Number.fromWei(vesuPosition.collateral.usdPrice.value, vesuPosition.collateral.usdPrice.decimals),
3788
+ APY: isErrorPoolsAPI || !assetInfo ? {
3789
+ baseApy: 0,
3790
+ defiSpringApy: 0,
3791
+ netApy: 0
3792
+ } : {
3793
+ baseApy: Number(Web3Number.fromWei(assetInfo.stats.supplyApy.value, assetInfo.stats.supplyApy.decimals).toFixed(6)),
3794
+ defiSpringApy: Number(Web3Number.fromWei(assetInfo.stats.defiSpringSupplyApr.value, assetInfo.stats.defiSpringSupplyApr.decimals).toFixed(6)),
3795
+ netApy: 0
3796
+ },
3797
+ currentUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.stats.currentUtilization.value, assetInfo.stats.currentUtilization.decimals).toFixed(6)),
3798
+ maxUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.config.maxUtilization.value, assetInfo.config.maxUtilization.decimals).toFixed(6))
3799
+ };
3800
+ item.APY.netApy = item.APY.baseApy + item.APY.defiSpringApy;
3801
+ return item;
3802
+ }
3764
3803
  /**
3765
3804
  * Retrieves the list of allowed pools and their detailed information from multiple sources:
3766
3805
  * 1. Contract's allowed pools
@@ -3799,45 +3838,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
3799
3838
  isErrorPoolsAPI = true;
3800
3839
  }
3801
3840
  const totalAssets = (await this.getTVL()).amount;
3802
- const info = allowedPools.map(async (p) => {
3803
- const vesuPosition = vesuPositions.find((d) => d.pool.id.toString() === import_starknet7.num.getDecimalString(p.pool_id.address.toString()));
3804
- const _pool = pools.find((d) => {
3805
- logger.verbose(`pool check: ${d.id == import_starknet7.num.getDecimalString(p.pool_id.address.toString())}, id: ${d.id}, pool_id: ${import_starknet7.num.getDecimalString(p.pool_id.address.toString())}`);
3806
- return d.id == import_starknet7.num.getDecimalString(p.pool_id.address.toString());
3807
- });
3808
- logger.verbose(`pool: ${JSON.stringify(_pool)}`);
3809
- logger.verbose(typeof _pool);
3810
- logger.verbose(`name: ${_pool?.name}`);
3811
- if (!_pool) {
3812
- throw new Error(`Pool ${p.pool_id.address.toString()} not found`);
3813
- }
3814
- const assetInfo = _pool?.assets.find((d) => this.asset().address.eqString(d.address));
3815
- let vTokenContract = new import_starknet7.Contract(vesu_rebalance_abi_default, p.v_token.address, this.config.provider);
3816
- const bal = await vTokenContract.balanceOf(this.address.address);
3817
- const assets = await vTokenContract.convert_to_assets(import_starknet7.uint256.bnToUint256(bal.toString()));
3818
- const item = {
3819
- pool_id: p.pool_id,
3820
- pool_name: _pool?.name,
3821
- max_weight: p.max_weight,
3822
- current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
3823
- v_token: p.v_token,
3824
- amount: Web3Number.fromWei(assets.toString(), this.decimals()),
3825
- usdValue: isErrorPositionsAPI || !vesuPosition ? Web3Number.fromWei("0", this.decimals()) : Web3Number.fromWei(vesuPosition.collateral.usdPrice.value, vesuPosition.collateral.usdPrice.decimals),
3826
- APY: isErrorPoolsAPI || !assetInfo ? {
3827
- baseApy: 0,
3828
- defiSpringApy: 0,
3829
- netApy: 0
3830
- } : {
3831
- baseApy: Number(Web3Number.fromWei(assetInfo.stats.supplyApy.value, assetInfo.stats.supplyApy.decimals).toFixed(6)),
3832
- defiSpringApy: Number(Web3Number.fromWei(assetInfo.stats.defiSpringSupplyApr.value, assetInfo.stats.defiSpringSupplyApr.decimals).toFixed(6)),
3833
- netApy: 0
3834
- },
3835
- currentUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.stats.currentUtilization.value, assetInfo.stats.currentUtilization.decimals).toFixed(6)),
3836
- maxUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.config.maxUtilization.value, assetInfo.config.maxUtilization.decimals).toFixed(6))
3837
- };
3838
- item.APY.netApy = item.APY.baseApy + item.APY.defiSpringApy;
3839
- return item;
3840
- });
3841
+ const info = allowedPools.map((p) => this.getPoolInfo(p, pools, vesuPositions, totalAssets, isErrorPositionsAPI, isErrorPoolsAPI));
3841
3842
  const data = await Promise.all(info);
3842
3843
  return {
3843
3844
  data,
package/dist/index.mjs CHANGED
@@ -3693,6 +3693,45 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
3693
3693
  }).filter((p) => p !== null);
3694
3694
  return pools;
3695
3695
  }
3696
+ async getPoolInfo(p, pools, vesuPositions, totalAssets, isErrorPositionsAPI, isErrorPoolsAPI) {
3697
+ const vesuPosition = vesuPositions.find((d) => d.pool.id.toString() === num2.getDecimalString(p.pool_id.address.toString()));
3698
+ const _pool = pools.find((d) => {
3699
+ logger.verbose(`pool check: ${d.id == num2.getDecimalString(p.pool_id.address.toString())}, id: ${d.id}, pool_id: ${num2.getDecimalString(p.pool_id.address.toString())}`);
3700
+ return d.id == num2.getDecimalString(p.pool_id.address.toString());
3701
+ });
3702
+ logger.verbose(`pool: ${JSON.stringify(_pool)}`);
3703
+ logger.verbose(typeof _pool);
3704
+ logger.verbose(`name: ${_pool?.name}`);
3705
+ if (!_pool) {
3706
+ throw new Error(`Pool ${p.pool_id.address.toString()} not found`);
3707
+ }
3708
+ const assetInfo = _pool?.assets.find((d) => this.asset().address.eqString(d.address));
3709
+ let vTokenContract = new Contract4(vesu_rebalance_abi_default, p.v_token.address, this.config.provider);
3710
+ const bal = await vTokenContract.balanceOf(this.address.address);
3711
+ const assets = await vTokenContract.convert_to_assets(uint2563.bnToUint256(bal.toString()));
3712
+ const item = {
3713
+ pool_id: p.pool_id,
3714
+ pool_name: _pool?.name,
3715
+ max_weight: p.max_weight,
3716
+ current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
3717
+ v_token: p.v_token,
3718
+ amount: Web3Number.fromWei(assets.toString(), this.decimals()),
3719
+ usdValue: isErrorPositionsAPI || !vesuPosition ? Web3Number.fromWei("0", this.decimals()) : Web3Number.fromWei(vesuPosition.collateral.usdPrice.value, vesuPosition.collateral.usdPrice.decimals),
3720
+ APY: isErrorPoolsAPI || !assetInfo ? {
3721
+ baseApy: 0,
3722
+ defiSpringApy: 0,
3723
+ netApy: 0
3724
+ } : {
3725
+ baseApy: Number(Web3Number.fromWei(assetInfo.stats.supplyApy.value, assetInfo.stats.supplyApy.decimals).toFixed(6)),
3726
+ defiSpringApy: Number(Web3Number.fromWei(assetInfo.stats.defiSpringSupplyApr.value, assetInfo.stats.defiSpringSupplyApr.decimals).toFixed(6)),
3727
+ netApy: 0
3728
+ },
3729
+ currentUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.stats.currentUtilization.value, assetInfo.stats.currentUtilization.decimals).toFixed(6)),
3730
+ maxUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.config.maxUtilization.value, assetInfo.config.maxUtilization.decimals).toFixed(6))
3731
+ };
3732
+ item.APY.netApy = item.APY.baseApy + item.APY.defiSpringApy;
3733
+ return item;
3734
+ }
3696
3735
  /**
3697
3736
  * Retrieves the list of allowed pools and their detailed information from multiple sources:
3698
3737
  * 1. Contract's allowed pools
@@ -3731,45 +3770,7 @@ var VesuRebalance = class _VesuRebalance extends BaseStrategy {
3731
3770
  isErrorPoolsAPI = true;
3732
3771
  }
3733
3772
  const totalAssets = (await this.getTVL()).amount;
3734
- const info = allowedPools.map(async (p) => {
3735
- const vesuPosition = vesuPositions.find((d) => d.pool.id.toString() === num2.getDecimalString(p.pool_id.address.toString()));
3736
- const _pool = pools.find((d) => {
3737
- logger.verbose(`pool check: ${d.id == num2.getDecimalString(p.pool_id.address.toString())}, id: ${d.id}, pool_id: ${num2.getDecimalString(p.pool_id.address.toString())}`);
3738
- return d.id == num2.getDecimalString(p.pool_id.address.toString());
3739
- });
3740
- logger.verbose(`pool: ${JSON.stringify(_pool)}`);
3741
- logger.verbose(typeof _pool);
3742
- logger.verbose(`name: ${_pool?.name}`);
3743
- if (!_pool) {
3744
- throw new Error(`Pool ${p.pool_id.address.toString()} not found`);
3745
- }
3746
- const assetInfo = _pool?.assets.find((d) => this.asset().address.eqString(d.address));
3747
- let vTokenContract = new Contract4(vesu_rebalance_abi_default, p.v_token.address, this.config.provider);
3748
- const bal = await vTokenContract.balanceOf(this.address.address);
3749
- const assets = await vTokenContract.convert_to_assets(uint2563.bnToUint256(bal.toString()));
3750
- const item = {
3751
- pool_id: p.pool_id,
3752
- pool_name: _pool?.name,
3753
- max_weight: p.max_weight,
3754
- current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
3755
- v_token: p.v_token,
3756
- amount: Web3Number.fromWei(assets.toString(), this.decimals()),
3757
- usdValue: isErrorPositionsAPI || !vesuPosition ? Web3Number.fromWei("0", this.decimals()) : Web3Number.fromWei(vesuPosition.collateral.usdPrice.value, vesuPosition.collateral.usdPrice.decimals),
3758
- APY: isErrorPoolsAPI || !assetInfo ? {
3759
- baseApy: 0,
3760
- defiSpringApy: 0,
3761
- netApy: 0
3762
- } : {
3763
- baseApy: Number(Web3Number.fromWei(assetInfo.stats.supplyApy.value, assetInfo.stats.supplyApy.decimals).toFixed(6)),
3764
- defiSpringApy: Number(Web3Number.fromWei(assetInfo.stats.defiSpringSupplyApr.value, assetInfo.stats.defiSpringSupplyApr.decimals).toFixed(6)),
3765
- netApy: 0
3766
- },
3767
- currentUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.stats.currentUtilization.value, assetInfo.stats.currentUtilization.decimals).toFixed(6)),
3768
- maxUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.config.maxUtilization.value, assetInfo.config.maxUtilization.decimals).toFixed(6))
3769
- };
3770
- item.APY.netApy = item.APY.baseApy + item.APY.defiSpringApy;
3771
- return item;
3772
- });
3773
+ const info = allowedPools.map((p) => this.getPoolInfo(p, pools, vesuPositions, totalAssets, isErrorPositionsAPI, isErrorPoolsAPI));
3773
3774
  const data = await Promise.all(info);
3774
3775
  return {
3775
3776
  data,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@strkfarm/sdk",
3
- "version": "1.0.25",
3
+ "version": "1.0.26",
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",
@@ -172,6 +172,53 @@ export class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAmo
172
172
  return pools;
173
173
  }
174
174
 
175
+ async getPoolInfo(
176
+ p: PoolProps,
177
+ pools: any[],
178
+ vesuPositions: any[],
179
+ totalAssets: Web3Number,
180
+ isErrorPositionsAPI: boolean,
181
+ isErrorPoolsAPI: boolean,
182
+ ) {
183
+ const vesuPosition = vesuPositions.find((d: any) => d.pool.id.toString() === num.getDecimalString(p.pool_id.address.toString()));
184
+ const _pool = pools.find((d: any) => {
185
+ logger.verbose(`pool check: ${d.id == num.getDecimalString(p.pool_id.address.toString())}, id: ${d.id}, pool_id: ${num.getDecimalString(p.pool_id.address.toString())}`);
186
+ return d.id == num.getDecimalString(p.pool_id.address.toString());
187
+ });
188
+ logger.verbose(`pool: ${JSON.stringify(_pool)}`);
189
+ logger.verbose(typeof _pool);
190
+ logger.verbose(`name: ${_pool?.name}`);
191
+ if (!_pool) {
192
+ throw new Error(`Pool ${p.pool_id.address.toString()} not found`);
193
+ }
194
+ const assetInfo = _pool?.assets.find((d: any) => this.asset().address.eqString(d.address));
195
+ let vTokenContract = new Contract(VesuRebalanceAbi, p.v_token.address, this.config.provider);
196
+ const bal = await vTokenContract.balanceOf(this.address.address);
197
+ const assets = await vTokenContract.convert_to_assets(uint256.bnToUint256(bal.toString()));
198
+ const item = {
199
+ pool_id: p.pool_id,
200
+ pool_name: _pool?.name,
201
+ max_weight: p.max_weight,
202
+ current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
203
+ v_token: p.v_token,
204
+ amount: Web3Number.fromWei(assets.toString(), this.decimals()),
205
+ usdValue: isErrorPositionsAPI || !vesuPosition ? Web3Number.fromWei("0", this.decimals()) : Web3Number.fromWei(vesuPosition.collateral.usdPrice.value, vesuPosition.collateral.usdPrice.decimals),
206
+ APY: isErrorPoolsAPI || !assetInfo ? {
207
+ baseApy: 0,
208
+ defiSpringApy: 0,
209
+ netApy: 0,
210
+ } : {
211
+ baseApy: Number(Web3Number.fromWei(assetInfo.stats.supplyApy.value, assetInfo.stats.supplyApy.decimals).toFixed(6)),
212
+ defiSpringApy: Number(Web3Number.fromWei(assetInfo.stats.defiSpringSupplyApr.value, assetInfo.stats.defiSpringSupplyApr.decimals).toFixed(6)),
213
+ netApy: 0,
214
+ },
215
+ currentUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.stats.currentUtilization.value, assetInfo.stats.currentUtilization.decimals).toFixed(6)),
216
+ maxUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.config.maxUtilization.value, assetInfo.config.maxUtilization.decimals).toFixed(6)),
217
+ }
218
+ item.APY.netApy = item.APY.baseApy + item.APY.defiSpringApy;
219
+ return item;
220
+ }
221
+
175
222
  /**
176
223
  * Retrieves the list of allowed pools and their detailed information from multiple sources:
177
224
  * 1. Contract's allowed pools
@@ -262,45 +309,7 @@ export class VesuRebalance extends BaseStrategy<SingleTokenInfo, SingleActionAmo
262
309
 
263
310
  const totalAssets = (await this.getTVL()).amount;
264
311
 
265
- const info = allowedPools.map(async (p) => {
266
- const vesuPosition = vesuPositions.find((d: any) => d.pool.id.toString() === num.getDecimalString(p.pool_id.address.toString()));
267
- const _pool = pools.find((d: any) => {
268
- logger.verbose(`pool check: ${d.id == num.getDecimalString(p.pool_id.address.toString())}, id: ${d.id}, pool_id: ${num.getDecimalString(p.pool_id.address.toString())}`);
269
- return d.id == num.getDecimalString(p.pool_id.address.toString());
270
- });
271
- logger.verbose(`pool: ${JSON.stringify(_pool)}`);
272
- logger.verbose(typeof _pool);
273
- logger.verbose(`name: ${_pool?.name}`);
274
- if (!_pool) {
275
- throw new Error(`Pool ${p.pool_id.address.toString()} not found`);
276
- }
277
- const assetInfo = _pool?.assets.find((d: any) => this.asset().address.eqString(d.address));
278
- let vTokenContract = new Contract(VesuRebalanceAbi, p.v_token.address, this.config.provider);
279
- const bal = await vTokenContract.balanceOf(this.address.address);
280
- const assets = await vTokenContract.convert_to_assets(uint256.bnToUint256(bal.toString()));
281
- const item = {
282
- pool_id: p.pool_id,
283
- pool_name: _pool?.name,
284
- max_weight: p.max_weight,
285
- current_weight: isErrorPositionsAPI || !vesuPosition ? 0 : Number(Web3Number.fromWei(vesuPosition.collateral.value, this.decimals()).dividedBy(totalAssets.toString()).toFixed(6)),
286
- v_token: p.v_token,
287
- amount: Web3Number.fromWei(assets.toString(), this.decimals()),
288
- usdValue: isErrorPositionsAPI || !vesuPosition ? Web3Number.fromWei("0", this.decimals()) : Web3Number.fromWei(vesuPosition.collateral.usdPrice.value, vesuPosition.collateral.usdPrice.decimals),
289
- APY: isErrorPoolsAPI || !assetInfo ? {
290
- baseApy: 0,
291
- defiSpringApy: 0,
292
- netApy: 0,
293
- } : {
294
- baseApy: Number(Web3Number.fromWei(assetInfo.stats.supplyApy.value, assetInfo.stats.supplyApy.decimals).toFixed(6)),
295
- defiSpringApy: Number(Web3Number.fromWei(assetInfo.stats.defiSpringSupplyApr.value, assetInfo.stats.defiSpringSupplyApr.decimals).toFixed(6)),
296
- netApy: 0,
297
- },
298
- currentUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.stats.currentUtilization.value, assetInfo.stats.currentUtilization.decimals).toFixed(6)),
299
- maxUtilization: isErrorPoolsAPI || !assetInfo ? 0 : Number(Web3Number.fromWei(assetInfo.config.maxUtilization.value, assetInfo.config.maxUtilization.decimals).toFixed(6)),
300
- }
301
- item.APY.netApy = item.APY.baseApy + item.APY.defiSpringApy;
302
- return item;
303
- });
312
+ const info = allowedPools.map(p => this.getPoolInfo(p, pools, vesuPositions, totalAssets, isErrorPositionsAPI, isErrorPoolsAPI));
304
313
  const data = await Promise.all(info);
305
314
  return {
306
315
  data,