Skip to content

Commit

Permalink
fix price
Browse files Browse the repository at this point in the history
  • Loading branch information
rbajollari committed Jun 21, 2024
1 parent 2363757 commit bdb7630
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 3 deletions.
6 changes: 4 additions & 2 deletions client/spot_prices.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package client
import (
"fmt"

sdkmath "cosmossdk.io/math"

"github.com/ethereum/go-ethereum/common"
balancerpool "github.com/ojo-network/ethereum-api/abi/balancer/pool"
"github.com/ojo-network/ethereum-api/abi/camelot"
Expand Down Expand Up @@ -32,7 +34,7 @@ func (c *Client) PollSpotPrices(pools []pool.Pool) {
c.logger.Info().Interface("spotPrice", spotPrice).Msg("spot price received")
c.indexer.AddPrice(spotPrice)
case pool.PoolBalancer:
spotPrice = c.QueryAlgebraSpotPrice(p, blockNum)
spotPrice = c.QueryBalancerSpotPrice(p, blockNum)
c.logger.Info().Interface("spotPrice", spotPrice).Msg("spot price received")
c.indexer.AddPrice(spotPrice)
}
Expand Down Expand Up @@ -98,6 +100,6 @@ func (c *Client) QueryBalancerSpotPrice(p pool.Pool, blockNum uint64) indexer.Sp
BlockNum: indexer.BlockNum(blockNum),
Timestamp: utils.CurrentUnixTime(),
ExchangePair: p.ExchangePair(),
Price: p.SqrtPriceX96ToDec(poolRate),
Price: sdkmath.LegacyNewDecFromBigIntWithPrec(poolRate, 18),
}
}
2 changes: 1 addition & 1 deletion pool/pool.go
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ func (p *Pool) ConvertBalancerEventToSpotPrice(event *vault.PoolSwap, price *big
BlockNum: indexer.BlockNum(event.Raw.BlockNumber),
Timestamp: utils.CurrentUnixTime(),
ExchangePair: p.ExchangePair(),
Price: p.SqrtPriceX96ToDec(price),
Price: sdkmath.LegacyNewDecFromBigIntWithPrec(price, 18),
}
}

Expand Down

0 comments on commit bdb7630

Please sign in to comment.