fix spot price again

This commit is contained in:
mihaisc 2022-04-05 19:55:35 +03:00
parent c531773136
commit 23e87b558e
2 changed files with 11 additions and 12 deletions

View File

@ -146,11 +146,9 @@ export function handleSwap(event: LOG_SWAP): void {
poolTx.baseToken = tokenOut.id poolTx.baseToken = tokenOut.id
poolTx.baseTokenValue = ammountOut.neg() poolTx.baseTokenValue = ammountOut.neg()
spotPrice = weiToDecimal( spotPrice = decimal.ONE.div(
event.params.newSpotPrice.toBigDecimal(), weiToDecimal(event.params.newSpotPrice.toBigDecimal(), tokenOut.decimals)
tokenOut.decimals
) )
pool.baseTokenLiquidity = tokenOutNewBalance pool.baseTokenLiquidity = tokenOutNewBalance
poolSnapshot.swapVolume = poolSnapshot.swapVolume.plus(ammountOut) poolSnapshot.swapVolume = poolSnapshot.swapVolume.plus(ammountOut)
@ -172,8 +170,9 @@ export function handleSwap(event: LOG_SWAP): void {
poolTx.baseToken = tokenIn.id poolTx.baseToken = tokenIn.id
poolTx.baseTokenValue = ammountIn poolTx.baseTokenValue = ammountIn
spotPrice = decimal.ONE.div( spotPrice = weiToDecimal(
weiToDecimal(event.params.newSpotPrice.toBigDecimal(), tokenOut.decimals) event.params.newSpotPrice.toBigDecimal(),
tokenOut.decimals
) )
pool.baseTokenLiquidity = tokenInNewBalance pool.baseTokenLiquidity = tokenInNewBalance
poolSnapshot.swapVolume = poolSnapshot.swapVolume.plus(ammountIn) poolSnapshot.swapVolume = poolSnapshot.swapVolume.plus(ammountIn)

View File

@ -8,9 +8,9 @@ dataSources:
name: ERC721Factory name: ERC721Factory
network: rinkeby network: rinkeby
source: source:
address: '0x548fd8639eC4Add192f12FC5c3EF6Dd80e1634ce' address: '0x6eb0184B64f22fB5e1316221E1eC84988F9E6b12'
abi: ERC721Factory abi: ERC721Factory
startBlock: 10364536 startBlock: 10422197
mapping: mapping:
kind: ethereum/events kind: ethereum/events
apiVersion: 0.0.6 apiVersion: 0.0.6
@ -24,7 +24,7 @@ dataSources:
- name: ERC20 - name: ERC20
file: ./abis/ERC20.json file: ./abis/ERC20.json
eventHandlers: eventHandlers:
- event: NFTCreated(indexed address,indexed address,string,address,string,string) - event: NFTCreated(address,indexed address,string,indexed address,string,string,bool,indexed address)
handler: handleNftCreated handler: handleNftCreated
- event: TokenCreated(indexed address,indexed address,string,string,uint256,address) - event: TokenCreated(indexed address,indexed address,string,string,uint256,address)
handler: handleNewToken handler: handleNewToken
@ -33,9 +33,9 @@ dataSources:
name: FactoryRouter name: FactoryRouter
network: rinkeby network: rinkeby
source: source:
address: '0xfe1a9F07718b40071F4c8d0f4bA22121dD5C0559' address: '0xF1Ef3C2332E44bdA219D9155E9a97201a1b5eC1C'
abi: FactoryRouter abi: FactoryRouter
startBlock: 10364536 startBlock: 10422197
mapping: mapping:
kind: ethereum/events kind: ethereum/events
apiVersion: 0.0.6 apiVersion: 0.0.6
@ -134,7 +134,7 @@ templates:
- name: ERC20 - name: ERC20
file: ./abis/ERC20.json file: ./abis/ERC20.json
eventHandlers: eventHandlers:
- event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256,uint256) - event: LOG_SWAP(indexed address,indexed address,indexed address,uint256,uint256,uint256,uint256,uint256,uint256)
handler: handleSwap handler: handleSwap
- event: LOG_JOIN(indexed address,indexed address,uint256,uint256) - event: LOG_JOIN(indexed address,indexed address,uint256,uint256)
handler: handleJoin handler: handleJoin