1- import { ethereum } from '@graphprotocol/graph-ts' ;
1+ import { Address , ethereum } from '@graphprotocol/graph-ts' ;
22
33import {
4+ AssetTransferredToDestination ,
45 BaseAssetUpdated ,
6+ ConvertedExactTokens ,
57 ConversionConfigUpdated ,
68 ConversionPaused ,
79 ConversionResumed ,
@@ -18,9 +20,10 @@ import {
1820 wbtcPrimeConverterAddress ,
1921 wethPrimeConverterAddress ,
2022 xvsVaultConverterAddress ,
23+ wBnbBurnConverterAddress ,
2124} from '../constants/addresses' ;
2225import { getTokenConverter } from '../operations/get' ;
23- import { getOrCreateTokenConverter } from '../operations/getOrCreate' ;
26+ import { getOrCreateDestinationAmount , getOrCreateTokenConverter } from '../operations/getOrCreate' ;
2427import { updateOrCreateTokenConverterConfig } from '../operations/updateOrCreate' ;
2528import { getConverterNetworkId } from '../utilities/ids' ;
2629
@@ -59,6 +62,11 @@ export function handleInitializationWethPrimeConverter(block: ethereum.Block): v
5962 getOrCreateTokenConverter ( wethPrimeConverterAddress ) ;
6063}
6164
65+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
66+ export function handleInitializationWBnbBurnConverter ( block : ethereum . Block ) : void {
67+ getOrCreateTokenConverter ( wBnbBurnConverterAddress ) ;
68+ }
69+
6270export function handleConversionConfigUpdated ( event : ConversionConfigUpdated ) : void {
6371 getOrCreateTokenConverter ( event . address ) ;
6472 updateOrCreateTokenConverterConfig ( event . address , event . params ) ;
@@ -99,3 +107,48 @@ export function handlePriceOracleUpdated(event: PriceOracleUpdated): void {
99107 tokenConverter . priceOracleAddress = event . params . priceOracle ;
100108 tokenConverter . save ( ) ;
101109}
110+
111+ export function handleConvertedExactTokens ( event : ConvertedExactTokens ) : void {
112+ const tokenConverter = getTokenConverter ( event . address ) ! ;
113+
114+ // handle private conversions (conversions between converters)
115+ const senderConverter = getTokenConverter ( event . params . sender ) ;
116+ if ( ! ! senderConverter && senderConverter . address !== riskFundConverterAddress ) {
117+ const senderDestinationAmount = getOrCreateDestinationAmount (
118+ Address . fromBytes ( senderConverter . address ) ,
119+ Address . fromBytes ( senderConverter . destinationAddress ) ,
120+ event . params . tokenAddressOut ,
121+ ) ;
122+ senderDestinationAmount . amount = senderDestinationAmount . amount . plus ( event . params . amountOut ) ;
123+ senderDestinationAmount . save ( ) ;
124+ }
125+
126+ const destinationAmountEntity = getOrCreateDestinationAmount (
127+ event . address ,
128+ Address . fromBytes ( tokenConverter . destinationAddress ) ,
129+ event . params . tokenAddressIn ,
130+ ) ;
131+ destinationAmountEntity . amount = destinationAmountEntity . amount . plus ( event . params . amountIn ) ;
132+ destinationAmountEntity . save ( ) ;
133+ }
134+
135+ export function handleConversionEvent ( event : ConvertedExactTokens ) : void {
136+ const tokenConverter = getTokenConverter ( event . address ) ! ;
137+ const destinationAmountEntity = getOrCreateDestinationAmount (
138+ event . address ,
139+ Address . fromBytes ( tokenConverter . destinationAddress ) ,
140+ event . params . tokenAddressIn ,
141+ ) ;
142+ destinationAmountEntity . amount = destinationAmountEntity . amount . plus ( event . params . amountIn ) ;
143+ destinationAmountEntity . save ( ) ;
144+ }
145+
146+ export function handleAssetTransferredToDestination ( event : AssetTransferredToDestination ) : void {
147+ const destinationAmountEntity = getOrCreateDestinationAmount (
148+ event . address ,
149+ event . params . receiver ,
150+ event . params . asset ,
151+ ) ;
152+ destinationAmountEntity . amount = destinationAmountEntity . amount . plus ( event . params . amount ) ;
153+ destinationAmountEntity . save ( ) ;
154+ }
0 commit comments