@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.
package/dist/index.js CHANGED
@@ -5735,7 +5735,7 @@ var init_dist2 = __esm({
5735
5735
  total_borrow: 0n
5736
5736
  };
5737
5737
  }
5738
- const [supplyRate, borrowRate, totalSupply, totalBorrows] = await Promise.all([
5738
+ const [supplyRate, borrowRate, totalSupplyVtoken, totalBorrows, exchangeRate] = await Promise.all([
5739
5739
  client.readContract({ address: vtoken, abi: CTOKEN_ABI, functionName: "supplyRatePerBlock" }).catch((e) => {
5740
5740
  throw DefiError.rpcError(`[${this.protocolName}] supplyRatePerBlock failed: ${e}`);
5741
5741
  }),
@@ -5743,22 +5743,24 @@ var init_dist2 = __esm({
5743
5743
  throw DefiError.rpcError(`[${this.protocolName}] borrowRatePerBlock failed: ${e}`);
5744
5744
  }),
5745
5745
  client.readContract({ address: vtoken, abi: CTOKEN_ABI, functionName: "totalSupply" }).catch(() => 0n),
5746
- client.readContract({ address: vtoken, abi: CTOKEN_ABI, functionName: "totalBorrows" }).catch(() => 0n)
5746
+ client.readContract({ address: vtoken, abi: CTOKEN_ABI, functionName: "totalBorrows" }).catch(() => 0n),
5747
+ client.readContract({ address: vtoken, abi: CTOKEN_ABI, functionName: "exchangeRateStored" }).catch(() => 0n)
5747
5748
  ]);
5748
5749
  const supplyPerBlock = Number(supplyRate) / 1e18;
5749
5750
  const borrowPerBlock = Number(borrowRate) / 1e18;
5750
5751
  const supplyApy = supplyPerBlock * BSC_BLOCKS_PER_YEAR * 100;
5751
5752
  const borrowApy = borrowPerBlock * BSC_BLOCKS_PER_YEAR * 100;
5752
- const supplyF = Number(totalSupply);
5753
+ const totalSupplyUnderlying = exchangeRate > 0n ? totalSupplyVtoken * exchangeRate / 10n ** 18n : totalSupplyVtoken;
5754
+ const supplyF = Number(totalSupplyUnderlying);
5753
5755
  const borrowF = Number(totalBorrows);
5754
- const utilization = supplyF > 0 ? borrowF / supplyF * 100 : 0;
5756
+ const utilization = supplyF > 0 ? Math.round(borrowF / supplyF * 1e4) / 100 : 0;
5755
5757
  return {
5756
5758
  protocol: this.protocolName,
5757
5759
  asset,
5758
5760
  supply_apy: supplyApy,
5759
5761
  borrow_variable_apy: borrowApy,
5760
5762
  utilization,
5761
- total_supply: totalSupply,
5763
+ total_supply: totalSupplyUnderlying,
5762
5764
  total_borrow: totalBorrows
5763
5765
  };
5764
5766
  }