event TokensTraded()

This function fires an event after a token is successfully swapped

event TokensTraded()

Every trade on Bancor will emit this event with information on the trade itself.

event TokensTraded(
        bytes32 contextId,
        Token indexed pool,
        Token indexed sourceToken,
        Token indexed targetToken,
        uint256 sourceAmount,
        uint256 targetAmount,
        uint256 bntAmount,
        uint256 targetFeeAmount,
        uint256 bntFeeAmount,
        address trader
    );
Parameter NameTypeDescription

contextId

bytes32

Unique identifier for the specific transaction (can be used for grouping multiple events)

pool

Token

the address of the pool utilizing the trade

sourceToken

Token

The source token address

targetToken

Token

The target token address

sourceAmount

unit256

The amount of source tokens

targetAmount

unit256

The amount of target tokens

bntAmount

unit256

Amount of BNT tokens that were reallocated from sourceToken to targetToken trade liquidity

targetFeeAmount

unit256

The trading fee amount for target tokens

bntFeeAmount

unit256

The trading fee amount for BNT tokens

trader

address

The senders wallet address

Trades on the Bancor Network are represented by a single-hop in all cases. TokensTraded event tracks the key information. The sourceAmount is provided by the trader in exchange for the targetAmount (which already has the targetTokenFee subtracted from it).

Behind the scenes, the bntAmount is the BNT volume that facilitates the trade and has the bntFee subtracted from it.

Last updated