@hypurrquant/defi-cli 1.0.5 → 1.0.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.
@@ -5847,7 +5847,7 @@ var init_dist2 = __esm({
5847
5847
  total_borrow: 0n
5848
5848
  };
5849
5849
  }
5850
- const [supplyRate, borrowRate, totalSupply, totalBorrows] = await Promise.all([
5850
+ const [supplyRate, borrowRate, totalSupplyVtoken, totalBorrows, exchangeRate] = await Promise.all([
5851
5851
  client.readContract({ address: vtoken, abi: CTOKEN_ABI, functionName: "supplyRatePerBlock" }).catch((e) => {
5852
5852
  throw DefiError.rpcError(`[${this.protocolName}] supplyRatePerBlock failed: ${e}`);
5853
5853
  }),
@@ -5855,22 +5855,24 @@ var init_dist2 = __esm({
5855
5855
  throw DefiError.rpcError(`[${this.protocolName}] borrowRatePerBlock failed: ${e}`);
5856
5856
  }),
5857
5857
  client.readContract({ address: vtoken, abi: CTOKEN_ABI, functionName: "totalSupply" }).catch(() => 0n),
5858
- client.readContract({ address: vtoken, abi: CTOKEN_ABI, functionName: "totalBorrows" }).catch(() => 0n)
5858
+ client.readContract({ address: vtoken, abi: CTOKEN_ABI, functionName: "totalBorrows" }).catch(() => 0n),
5859
+ client.readContract({ address: vtoken, abi: CTOKEN_ABI, functionName: "exchangeRateStored" }).catch(() => 0n)
5859
5860
  ]);
5860
5861
  const supplyPerBlock = Number(supplyRate) / 1e18;
5861
5862
  const borrowPerBlock = Number(borrowRate) / 1e18;
5862
5863
  const supplyApy = supplyPerBlock * BSC_BLOCKS_PER_YEAR * 100;
5863
5864
  const borrowApy = borrowPerBlock * BSC_BLOCKS_PER_YEAR * 100;
5864
- const supplyF = Number(totalSupply);
5865
+ const totalSupplyUnderlying = exchangeRate > 0n ? totalSupplyVtoken * exchangeRate / 10n ** 18n : totalSupplyVtoken;
5866
+ const supplyF = Number(totalSupplyUnderlying);
5865
5867
  const borrowF = Number(totalBorrows);
5866
- const utilization = supplyF > 0 ? borrowF / supplyF * 100 : 0;
5868
+ const utilization = supplyF > 0 ? Math.round(borrowF / supplyF * 1e4) / 100 : 0;
5867
5869
  return {
5868
5870
  protocol: this.protocolName,
5869
5871
  asset,
5870
5872
  supply_apy: supplyApy,
5871
5873
  borrow_variable_apy: borrowApy,
5872
5874
  utilization,
5873
- total_supply: totalSupply,
5875
+ total_supply: totalSupplyUnderlying,
5874
5876
  total_borrow: totalBorrows
5875
5877
  };
5876
5878
  }