fixed swapper change issue (#510)

* fixed swapper change issue

* fix lint
This commit is contained in:
mihaisc 2022-08-03 08:20:25 -07:00 committed by GitHub
parent 8416d773cc
commit 06bbaa54c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 9 deletions

View File

@ -1,4 +1,4 @@
import { BigInt, Address, BigDecimal, log } from '@graphprotocol/graph-ts' import { BigInt, Address, BigDecimal } from '@graphprotocol/graph-ts'
import { import {
ExchangeActivated, ExchangeActivated,
ExchangeAllowedSwapperChanged, ExchangeAllowedSwapperChanged,
@ -62,7 +62,6 @@ export function handleRateChange(event: ExchangeRateChanged): void {
event.params.exchangeId.toHexString(), event.params.exchangeId.toHexString(),
event.address event.address
) )
const fixedRateExchange = getFixedRateExchange(fixedRateId) const fixedRateExchange = getFixedRateExchange(fixedRateId)
const newExchangeUpdate = new FixedRateExchangeUpdate( const newExchangeUpdate = new FixedRateExchangeUpdate(
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId) getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId)
@ -72,6 +71,7 @@ export function handleRateChange(event: ExchangeRateChanged): void {
newExchangeUpdate.tx = event.transaction.hash.toHex() newExchangeUpdate.tx = event.transaction.hash.toHex()
newExchangeUpdate.block = event.block.number.toI32() newExchangeUpdate.block = event.block.number.toI32()
newExchangeUpdate.exchangeId = fixedRateId newExchangeUpdate.exchangeId = fixedRateId
fixedRateExchange.price = weiToDecimal( fixedRateExchange.price = weiToDecimal(
event.params.newRate.toBigDecimal(), event.params.newRate.toBigDecimal(),
BigInt.fromI32(18).toI32() BigInt.fromI32(18).toI32()
@ -147,12 +147,11 @@ export function handleAllowedSwapperChanged(
const newExchangeUpdate = new FixedRateExchangeUpdate( const newExchangeUpdate = new FixedRateExchangeUpdate(
getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId) getUpdateOrSwapId(event.transaction.hash.toHex(), fixedRateId)
) )
newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32() newExchangeUpdate.createdTimestamp = event.block.timestamp.toI32()
newExchangeUpdate.tx = event.transaction.hash.toHex() newExchangeUpdate.tx = event.transaction.hash.toHex()
newExchangeUpdate.block = event.block.number.toI32() newExchangeUpdate.block = event.block.number.toI32()
newExchangeUpdate.oldAllowedSwapper = fixedRateExchange.allowedSwapper newExchangeUpdate.oldAllowedSwapper = fixedRateExchange.allowedSwapper
newExchangeUpdate.exchangeId = fixedRateId
fixedRateExchange.allowedSwapper = event.params.allowedSwapper.toHex() fixedRateExchange.allowedSwapper = event.params.allowedSwapper.toHex()
newExchangeUpdate.newAllowedSwapper = fixedRateExchange.allowedSwapper newExchangeUpdate.newAllowedSwapper = fixedRateExchange.allowedSwapper
newExchangeUpdate.save() newExchangeUpdate.save()
@ -195,7 +194,6 @@ export function handleSwap(event: Swapped): void {
swap.save() swap.save()
updateFixedRateExchangeSupply(event.params.exchangeId, event.address) updateFixedRateExchangeSupply(event.params.exchangeId, event.address)
log.error('start addFixedSwap', [])
if (event.params.tokenOutAddress.toHexString() == fixedRateExchange.baseToken) if (event.params.tokenOutAddress.toHexString() == fixedRateExchange.baseToken)
addFixedSwap( addFixedSwap(
@ -203,7 +201,6 @@ export function handleSwap(event: Swapped): void {
swap.dataTokenAmount swap.dataTokenAmount
) )
else addFixedSwap(fixedRateExchange.baseToken, swap.baseTokenAmount) else addFixedSwap(fixedRateExchange.baseToken, swap.baseTokenAmount)
log.error('addFixedSwap saved', [])
// update datatoken lastPriceToken and lastPriceValue // update datatoken lastPriceToken and lastPriceValue
const datatoken = getToken( const datatoken = getToken(
Address.fromString(fixedRateExchange.datatoken), Address.fromString(fixedRateExchange.datatoken),

View File

@ -43,9 +43,6 @@ export function getToken(address: Address, isDatatoken: boolean): Token {
} }
export function createNftToken(address: Address): Nft { export function createNftToken(address: Address): Nft {
log.warning('started creating nft token with address: {}', [
address.toHexString()
])
ERC721Template.create(address) ERC721Template.create(address)
const token = new Nft(address.toHexString()) const token = new Nft(address.toHexString())
token.name = '' token.name = ''