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
Contracts Trigger > Create New
Insert the address of the Uniswap exchange for the token you're interested in, in this case
0x2e642b8d59b45a1d8c5aef716a84ff44ea665914
From the dropdown menu, select
getEthToTokenInputPrice
. This function returns the amount of tokens (in this case, BAT) that can be bought with input ETHIn the
eth_sold
field, insert 1In the
Returns
field, insert the desired threshold
Track when a provider adds or removes liquidity
Events Trigger > Create New
Insert the address of the Uniswap exchange for the token you're interested in, in this case (BAT)
0x2e642b8d59b45a1d8c5aef716a84ff44ea665914
From the dropdown menu, select
AddLiquidity
(orRemoveLiquidity
Fill in the
provider
and, optionally, thresholds oneth_amount
ortoken_amount
Track token purchases for a specific buyer
Events Trigger > Create New
Insert the address of the Uniswap exchange for the token you're interested in, in this case
0x2e642b8d59b45a1d8c5aef716a84ff44ea665914
From the dropdown menu, select
TokenPurchase
In the
buyer
field, insert the address of the buyer you want to trackOptionally, add constraints on the
eth_sold
andtokens_bought
fields.
Monitor your UNI balance
Contracts Trigger > Create New
Insert the address of the Uniswap exchange for the token you're interested in, in this case (BAT)
0x2e642b8d59b45a1d8c5aef716a84ff44ea665914
From the dropdown menu, select
balanceOf
In the
_owner
field, insert the address you want to track the balance forIn the
Returns
field, select e.g. "more than X"
Last updated