Skip to main content

BTC->ETH->WBTC Aggregator Implementation

GitHub Repo

The TSAggregatorCornSiloEth implementation is available on the following repo.

Overview

  • Inherits: TSAggregator
  • Swaps received ETH for WBTC and deposits into CornSilo on the user's behalf, using the UniswapV3 router.
  • No parallel functionality for swapping into the Thorchain network.

State Variables

  • address public immutable weth
  • address public immutable wbtc
  • ISwapRouter public immutable swapRouter
  • ICornSilo public immutable cornSilo
  • uint24 public constant feeTier = 3000

Functions

constructor

Initializes the contract with required addresses.

constructor(address _ttp, address _weth, address _wbtc, address _swapRouter, address _cornSilo) TSAggregator(_ttp);

Parameters

NameTypeDescription
_ttpaddressAddress of the Token Transfer Proxy.
_wethaddressAddress of the Wrapped Ethereum token.
_wbtcaddressAddress of the Wrapped Bitcoin token.
_swapRouteraddressAddress of the Uniswap V3 Swap Router.
_cornSiloaddressAddress of the CornSilo contract.

swapOut

Swaps received ETH for WBTC and deposits it into CornSilo.

function swapOut(address token, address to, uint256 amountOutMin) public payable nonReentrant;

Parameters

NameTypeDescription
tokenaddressThe token address to swap from (must be WBTC).
toaddressThe recipient address of the swap (via Thorchain MEMO).
amountOutMinuint256The minimum amount of WBTC to receive.