Tracking consumeMarketFeeAmount and marketFeeAmount
This commit is contained in:
parent
26b451dbad
commit
09991be437
|
@ -258,6 +258,8 @@ type FixedRateExchangeSwap @entity {
|
|||
createdTimestamp: Int!
|
||||
tx: String!
|
||||
oceanFeeAmount: BigDecimal!
|
||||
marketFeeAmount: BigDecimal!
|
||||
consumeMarketFeeAmount: BigDecimal!
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -191,11 +191,19 @@ export function handleSwap(event: Swapped): void {
|
|||
BigInt.fromI32(18).toI32()
|
||||
)
|
||||
|
||||
// Track OPC swap fee
|
||||
// Track fees
|
||||
swap.oceanFeeAmount = weiToDecimal(
|
||||
event.params.oceanFeeAmount.toBigDecimal(),
|
||||
BigInt.fromI32(baseToken.decimals).toI32()
|
||||
)
|
||||
swap.marketFeeAmount = weiToDecimal(
|
||||
event.params.marketFeeAmount.toBigDecimal(),
|
||||
BigInt.fromI32(baseToken.decimals).toI32()
|
||||
)
|
||||
swap.consumeMarketFeeAmount = weiToDecimal(
|
||||
event.params.consumeMarketFeeAmount.toBigDecimal(),
|
||||
BigInt.fromI32(baseToken.decimals).toI32()
|
||||
)
|
||||
|
||||
swap.save()
|
||||
|
||||
|
|
|
@ -585,6 +585,8 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
createdTimestamp
|
||||
tx
|
||||
oceanFeeAmount
|
||||
marketFeeAmount
|
||||
consumeMarketFeeAmount
|
||||
__typename
|
||||
}
|
||||
}}`
|
||||
|
@ -631,6 +633,12 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
const oceanFeeAmount = web3.utils.fromWei(
|
||||
new BN(tx.returnValues.oceanFeeAmount)
|
||||
)
|
||||
const marketFeeAmount = web3.utils.fromWei(
|
||||
new BN(tx.returnValues.marketFeeAmount)
|
||||
)
|
||||
const consumeMarketFeeAmount = web3.utils.fromWei(
|
||||
new BN(tx.returnValues.consumeMarketFeeAmount)
|
||||
)
|
||||
|
||||
await sleep(sleepMs)
|
||||
user1Balance = await datatoken.balance(datatokenAddress, user1)
|
||||
|
@ -655,6 +663,11 @@ describe('Fixed Rate Exchange tests', async () => {
|
|||
assert(swaps.createdTimestamp >= time, 'incorrect: createdTimestamp')
|
||||
assert(swaps.createdTimestamp < time + 25, 'incorrect: createdTimestamp 2')
|
||||
assert(swaps.oceanFeeAmount === oceanFeeAmount, 'incorrect: oceanFeeAmount')
|
||||
assert(swaps.marketFeeAmount === marketFeeAmount, 'wrong marketFeeAmount')
|
||||
assert(
|
||||
swaps.consumeMarketFeeAmount === consumeMarketFeeAmount,
|
||||
'wrong consumeMarketFeeAmount'
|
||||
)
|
||||
assert(swaps.tx === tx.transactionHash, 'incorrect value for: tx')
|
||||
assert(swaps.__typename === 'FixedRateExchangeSwap', 'incorrect __typename')
|
||||
})
|
||||
|
|
Loading…
Reference in New Issue