BotFi Swap Engine

The smart contract codes for BotFi's Swap Engine are accessible on GitHub: https://github.com/botfi-app/botfi-swaparrow-up-right

Events

Swap

// The event emitted after a successful swap
    event Swap(
        bytes32 routerId, 
        uint256 amount,
        address tokenA,
        uint    feeBps,
        address account  
    );

routerId: bytes32

The route ID bytes32 format. amount: uint256

The total transaction amount with protocol fee inclusive

tokenA: Address

The token that was exchanged for another.

feeBps: uint

The protocol fee percentage in basis point

account: Address

The address of the account that initiated the transaction

Functions

addRoute

id: bytes32

The router ID should be an empty bytes32 string for a new route and a valid route ID when editing an existing route. For new routes, an incremental ID is automatically generated.

group: bytes32

The route group categorises liquidity sources into various groups based on their functions. For example, all DEXs using Uniswap v2 source code are grouped as uni_v2.

router: address

The router address of the liquidity source, such as the Uniswap v2 router address.

factory: address

The factory address of the liquidity source, such as the Uniswap v2 factory address.

weth: address

The address of the wrapped Ether or wrapped native token used on the chain.

quoter: address

The quoter is a smart contract where quotes are queried from off-chain sources, such as the swap user interface, before executing a swap. For uni_v2-based contracts, this field is always set to 0x0000000000000000000000000000.

enabled: bool

A boolean value indicating whether the route should be active (true) or not (false).

enableRoute

A helper function to quickly enable or disable a route

id: bytes32

The route ID in bytes32 format.

opt: bool

A boolean value indicating whether the route should be active (true) or not (false).

getAllRoutes

This function retrieves all routes and returns an array of RouteParams, encompassing both active and inactive routes

pauseSwap

This function allows the activation or deactivation of BotFi's swap engine.

opt: bool

The 'opt' parameter accepts a boolean value indicating whether the swap engine should be enabled (true) or disabled (false).

swap

This function executes a swap based on the payload provided

routeId: bytes32

The route ID in bytes32 format.

amount: uint256

The total transaction amount with protocol fee inclusive

tokenA: Address

The token to be exchanged for another.

payload: bytes

The payload represents the calldata of the liquidity source, computed off-chain to save gas and enhance flexibility.

Last updated