Uniswap

Track Uniswap prices with HAL

Uniswap is a protocol designed to facilitate automatic digital asset exchange between ETH and ERC20 tokens. Here are a few examples of using HAL to interact with any Uniswap contract. We will use the BAT token as an example, but the logic is the same for any token ERC20 token available on Uniswap.

Track when the price of BAT increases above a threshold

  1. Contracts Trigger > Create New

  2. Insert the address of the Uniswap exchange for the token you're interested in, in this case 0x2e642b8d59b45a1d8c5aef716a84ff44ea665914

  3. From the dropdown menu, select getEthToTokenInputPrice. This function returns the amount of tokens (in this case, BAT) that can be bought with input ETH

  4. In theeth_sold field, insert 1

  5. In the Returns field, insert the desired threshold

Track when a provider adds or removes liquidity

  1. Events Trigger > Create New

  2. Insert the address of the Uniswap exchange for the token you're interested in, in this case (BAT)0x2e642b8d59b45a1d8c5aef716a84ff44ea665914

  3. From the dropdown menu, select AddLiquidity (or RemoveLiquidity

  4. Fill in the providerand, optionally, thresholds on eth_amount or token_amount

Track token purchases for a specific buyer

  1. Events Trigger > Create New

  2. Insert the address of the Uniswap exchange for the token you're interested in, in this case 0x2e642b8d59b45a1d8c5aef716a84ff44ea665914

  3. From the dropdown menu, select TokenPurchase

  4. In the buyer field, insert the address of the buyer you want to track

  5. Optionally, add constraints on the eth_sold and tokens_bought fields.

Monitor your UNI balance

  1. Contracts Trigger > Create New

  2. Insert the address of the Uniswap exchange for the token you're interested in, in this case (BAT)0x2e642b8d59b45a1d8c5aef716a84ff44ea665914

  3. From the dropdown menu, select balanceOf

  4. In the _owner field, insert the address you want to track the balance for

  5. In the Returns field, select e.g. "more than X"

‚Äč