balancednetwork / balanced-backend

Backend to balanced stats page and other services
Apache License 2.0
0 stars 1 forks source link

Fix pools endpoint #39

Closed hetfly closed 5 months ago

hetfly commented 6 months ago

https://balanced.icon.community/api/v1/pools

Either volume or fees are calculated incorrectly, all the pools generate ~0.15% fees, should be ~0.3.

sICX/bnUSD for example: image

{
  "quote_address": "cx88fd7df7ddff82f7cc735c871dc519838cb235bb",
  "quote_symbol": "bnUSD",
  "price_change_24h": 0.007934088371452375,
  "base_lp_fees_24h": 153.28570701671936,
  "quote_lp_fees_30d": 1294.2353339272786,
  "holders": null,
  "base_address": "cx2609b924e33ef00b648a409245c7ea394c467824",
  "base_decimals": 18,
  "price_change_7d": -0.010560467114247962,
  "quote_lp_fees_24h": 61.653793726985235,
  "base_baln_fees_30d": 4716.510166942451,
  "total_supply": 1.906692990475127e+24,
  "chain_id": 1,
  "quote_decimals": 18,
  "price_change_30d": -0.014742036135615144,
  "quote_baln_fees_30d": 1294.2353339272786,
  "base_price": 0.2771874016428549,
  "last_updated_timestamp": 1715795637,
  "pool_id": 2,
  "type": "balanced",
  "price_24h_low": 0.2737738416727836,
  "base_baln_fees_24h": 153.28570701671936,
  "quote_price": 1.0124685395405715,
  "name": "sICX/bnUSD",
  "price": 0.2737738416727836,
  "price_24h_high": 0.2737738416727836,
  "quote_baln_fees_24h": 61.653793726985235,
  "base_supply": 4462363.752329206,
  "base_name": "Staked ICX",
  "price_24h": 0.26583975330133125,
  "base_volume_24h": 256673.25532892125,
  "base_volume_30d": 6162562.327941995,
  "quote_supply": 1221678.4674165447,
  "quote_name": "Balanced Dollar",
  "price_7d": 0.2843343087870316,
  "quote_volume_24h": 67940.98907852655,
  "quote_volume_30d": 1755691.756152983,
  "base_liquidity": 1236911.0136933927,
  "base_symbol": "sICX",
  "price_30d": 0.28851587780839877,
  "base_lp_fees_30d": 4716.510166942451,
  "quote_liquidity": 1236911.0136933927
}
robcxyz commented 6 months ago

Sounds like you have done the calculation - Can you leave that in the issue? Like x times y should equal....

FezBox commented 5 months ago

@hetfly will run through this with @AntonAndell to identify if any fixes are required.