Skip to content

Commit b8056f6

Browse files
committed
feat: use priceoracle of the pool
1 parent 97108f1 commit b8056f6

File tree

2 files changed

+5
-2
lines changed

2 files changed

+5
-2
lines changed

debts/engine.go

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -240,6 +240,7 @@ func (eng *DebtEngine) createTvlSnapshots(blockNum int64, marketToTvl MarketToTv
240240
return utils.GetFloat64Decimal(
241241
eng.GetPriceForTvl(
242242
latestOracle,
243+
state.(*schemas.PoolState).PriceOracle,
243244
underlyingToken,
244245
amount.Convert(), version), 8)
245246
}
@@ -528,10 +529,12 @@ func (eng *DebtEngine) CalculateSessionDebt(blockNum int64, session *schemas.Cre
528529
}
529530

530531
// helper methods
531-
func (eng *DebtEngine) GetPriceForTvl(priceOracle schemas.PriceOracleT, tokenAddr string, amount *big.Int, version core.VersionType) *big.Int {
532+
func (eng *DebtEngine) GetPriceForTvl(_po schemas.PriceOracleT, poolPriceOracleT schemas.PriceOracleT, tokenAddr string, amount *big.Int, version core.VersionType) *big.Int {
533+
priceOracle := poolPriceOracleT
532534
tokenPrice := eng.priceHandler.GetTokenLastPF(priceOracle, tokenAddr, version)
533535
tokenDecimals := eng.repo.GetToken(tokenAddr).Decimals
534536
if version.MoreThan(core.NewVersion(1)) { // than decimals 8
537+
// log.Info("GetPriceForTvl", tokenPrice, amount, tokenDecimals, tokenAddr, priceOracle)
535538
return utils.GetInt64(new(big.Int).Mul(tokenPrice.PriceBI.Convert(), amount), tokenDecimals)
536539
}
537540
// for v1

jsonnet/mocks/syncAdapterV2.jsonnet

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
address: '#Pool_1',
124124
dieselToken: '#DieselToken_1',
125125
underlyingToken: '#Token_1',
126-
priceOracle: '#PriceOracle_0',
126+
priceOracle: '#PriceOracle_1',
127127
},
128128
],
129129
cmState: [

0 commit comments

Comments
 (0)