Comment on page
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.
- 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 the
eth_sold
field, insert 1 - 5.In the
Returns
field, insert the desired threshold
- 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
(orRemoveLiquidity
- 4.Fill in the
provider
and, optionally, thresholds oneth_amount
ortoken_amount
- 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
andtokens_bought
fields.
- 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"
Last modified 3yr ago