From 23e87b558e9b6d055fa0c19cc6b9c18f28513886 Mon Sep 17 00:00:00 2001 From: mihaisc Date: Tue, 5 Apr 2022 19:55:35 +0300 Subject: [PATCH] fix spot price again --- src/mappings/pool.ts | 11 +++++------ subgraph.yaml | 12 ++++++------ 2 files changed, 11 insertions(+), 12 deletions(-) diff --git a/src/mappings/pool.ts b/src/mappings/pool.ts index bf38d2b..68b9ea8 100644 --- a/src/mappings/pool.ts +++ b/src/mappings/pool.ts @@ -146,11 +146,9 @@ export function handleSwap(event: LOG_SWAP): void { poolTx.baseToken = tokenOut.id poolTx.baseTokenValue = ammountOut.neg() - spotPrice = weiToDecimal( - event.params.newSpotPrice.toBigDecimal(), - tokenOut.decimals + spotPrice = decimal.ONE.div( + weiToDecimal(event.params.newSpotPrice.toBigDecimal(), tokenOut.decimals) ) - pool.baseTokenLiquidity = tokenOutNewBalance poolSnapshot.swapVolume = poolSnapshot.swapVolume.plus(ammountOut) @@ -172,8 +170,9 @@ export function handleSwap(event: LOG_SWAP): void { poolTx.baseToken = tokenIn.id poolTx.baseTokenValue = ammountIn - spotPrice = decimal.ONE.div( - weiToDecimal(event.params.newSpotPrice.toBigDecimal(), tokenOut.decimals) + spotPrice = weiToDecimal( + event.params.newSpotPrice.toBigDecimal(), + tokenOut.decimals ) pool.baseTokenLiquidity = tokenInNewBalance poolSnapshot.swapVolume = poolSnapshot.swapVolume.plus(ammountIn) diff --git a/subgraph.yaml b/subgraph.yaml index 63fb049..a110c87 100644 --- a/subgraph.yaml +++ b/subgraph.yaml @@ -8,9 +8,9 @@ dataSources: name: ERC721Factory network: rinkeby source: - address: '0x548fd8639eC4Add192f12FC5c3EF6Dd80e1634ce' + address: '0x6eb0184B64f22fB5e1316221E1eC84988F9E6b12' abi: ERC721Factory - startBlock: 10364536 + startBlock: 10422197 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -24,7 +24,7 @@ dataSources: - name: ERC20 file: ./abis/ERC20.json 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 - event: TokenCreated(indexed address,indexed address,string,string,uint256,address) handler: handleNewToken @@ -33,9 +33,9 @@ dataSources: name: FactoryRouter network: rinkeby source: - address: '0xfe1a9F07718b40071F4c8d0f4bA22121dD5C0559' + address: '0xF1Ef3C2332E44bdA219D9155E9a97201a1b5eC1C' abi: FactoryRouter - startBlock: 10364536 + startBlock: 10422197 mapping: kind: ethereum/events apiVersion: 0.0.6 @@ -134,7 +134,7 @@ templates: - name: ERC20 file: ./abis/ERC20.json 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 - event: LOG_JOIN(indexed address,indexed address,uint256,uint256) handler: handleJoin