Horizon Academy
English V3
English V3
  • Horizon Academy
  • Horizon Protocol
    • Introduction
      • Tokenomics
      • Business Model
      • Synthetic Assets - zAssets
    • Security Audit
    • Community
      • How to Initiate a HIP
      • HIPs
        • HIP-23 Revenue Sharing Model: Intent-based System Phase one
        • HIP-22: Create a zUSD - USDC pool on Pancakeswap V3
        • HIP-21: Stop Incentives to the zBNB - BNB pool on Wombat Exchange
        • HIP-20: Suspend zMATIC Market and Introduce zPOL Ahead of MATIC to POL Migration
        • HIP-19: Temporarily reduce C-Ratio to 350%
        • HIP-18: Add DOGE and SHIBA to Horizon Futures
        • HIP-17: Add DOT, AVAX, and MATIC to Horizon Futures
        • HIP-16: Add XRP, ADA, and LINK to Horizon Futures
        • HIP-15: Add SOL to Horizon Futures
        • HIP-14: Reduce Trading Fees during Horizon Futures Promotional Period
        • HIP-13: Suspend zNVDA market ahead of Stock Split and convert zNVDA to zUSD
        • HIP-12: Updated Utilization of zUSD & zBNB Liquidity
        • HIP-11: Redirect HZN from EARN Pool to PancakeSwap as ‘Bribe’ using Cakepie
        • HIP-10: Use zAssets from Community Fund staking to provide liquidity on Wombat via Yield Aggregator
        • HIP-9: Redirect HZN from EARN Pools to Wombat Exchange as ‘Bribes’
        • HIP-8: Move the zUSD-BUSD and zBNB-BNB Liquidity Pools to Wombat Exchange
        • HIP-7: Utilize the Community Fund for Additional Liquidity
        • HIP-6: Lower Target C-Ratio to 600% from 700%
        • HIP-5: List New zAssets
        • HIP-4: Use Keepers to Close Weekly Fee Periods
        • HIP-3: Suspend zTSLA ahead of Stock Split
        • HIP-2: Lower Target C-Ratio to 700%
        • HIP-1: Create incentivized zBNB/BNB pool
      • Community Grant Program
    • FAQs
  • Stake & Earn
    • Introduction
    • Staking on Horizon Protocol
      • Staking and Rewards
      • Mint, Burn, and Claim
      • Collaterialization and C-Ratio
      • Liquidation
      • Managing Risk
      • C-Ratio Strategies
      • Hedge your Portfolio
    • Interfaces
      • Account - Escrow
      • Account - Authorize
      • Account - History
    • Guides
      • How to Stake by Minting zUSD
      • Adding Liquidity for zUSD and zBNB pools
      • Add Liquidity for HZN-BNB
      • Remove LP Tokens for zUSD-BUSD Pool
      • Setting Up Chainlink Automation
  • Educational Articles
    • Glossary and Definitions
    • What are DeFi Derivatives and how are they used
    • A Brief History of Synthetic Assets and Financial Derivatives
    • DeFi Derivative Projects
Powered by GitBook
On this page
  • What is Chainlink Automation?
  • Step 0. Grant Contract Authorization
  • Step 1. Get LINK BEP-20 Tokens
  • Step 2. Convert LINK BEP-20 to BEP-677
  • Step 3. Register Upkeep
  • Step 4. Auto-Claiming
  • Optional Step 5. Canceling Your Upkeep
  1. Stake & Earn
  2. Guides

Setting Up Chainlink Automation

Use Chainlink Automation to Auto-Claim

PreviousRemove LP Tokens for zUSD-BUSD PoolNextGlossary and Definitions

Welcome to the Guide for using Chainlink Automation to auto-claim your weekly staking rewards on Horizon Stake.

The following guide will take you through the process of setting Chainlink Automation up (screenshots may reflect and older version of the UI).

Note that setting up Chainlink Automation for Horizon Stake will help with auto-claiming, but it does not auto-burn to fix your C-Ratio.

We will be looking into how to potentially include auto-burning into the Chainlink Automation contract so it can be completely hands-off in the future.

Chainlink Automation Quick Start

What is Chainlink Automation?

Chainlink Automation is a decentralized automation service. For Horizon Stake, the way Chainlink Automation works is it will check every block to see if a reward claim is available. If it is, it will automatically claim your rewards for you on your behalf. Each claim transaction will cost LINK tokens, though checking if a claim is available or not is free and will not cost anything.

Before you start, it is important to note that a Chainlink Automation upkeep costs money to maintain. A minimum balance of LINK tokens is required to be stored in an upkeep for it to operate and each weekly claim will deduct a small amount of LINK tokens.

Also, the entire process currently is only supported by MetaMask wallet.

To activate, you need to give the Chainlink Automation upkeep contract permission to take the actions you want and deposit enough money (in the form of ERC-677 LINK tokens) for it to take these actions for you.

For more information about Chainlink Automation, you can read about it here:

One of the most important questions will be how many LINK tokens are required to maintain an upkeep. There is specific documentation regarding this available here:

Step 0. Grant Contract Authorization

The pre-requisite step is to allow the Chainlink Automation upkeep contract to claim for you by giving it permission to claim on your behalf.

The target contract address you will be giving permission to is: 0xa623F29ae4cEd27dFBB39a94152F3184140f6c21

To grant authorization, please complete the following steps:

You should get a wallet confirmation screen as shown below.

Once confirmed, authorization will have been completed.

Step 1. Get LINK BEP-20 Tokens

The first thing you will need to do to create a Chainlink Automation Upkeep is to acquire LINK tokens.

  1. You can acquire LINK BEP-20 tokens at DEXs, such as PancakeSwap, or CEXs, such as Binance. It is recommended to buy at least 10 LINK tokens to maintain your Auto-Claim Upkeep. This balance could maintain your upkeep for about 4-5 months, but the true duration is based on market prices.

  2. If you are buying LINK tokens on a CEX, such as Binance, make sure you are withdrawing the LINK onto the BNB Chain (BEP-20 token) and not withdrawing onto the Ethereum chain (ERC-20 token). Since the Chainlink Automation upkeep is operating on the BNB Chain for Horizon Protocol, it must be a BEP-20 LINK token.

The screenshots below will focus on using PancakeSwap to buy LINK BEP-20 tokens:

Step 2. Convert LINK BEP-20 to BEP-677

Chainlink Automation uses a special wrapped ERC-677 format, which allows you to include additional data along with the contract. This functionality is required for Chainlink Automation upkeep to be able to perform its decentralized automation.

In this step, we will be converting LINK BEP-20 into a LINK BEP-677 token.

Fun fact: the LINK BEP-677 token is a wrapped ERC677 token, which is a synthetic asset that uses the original BEP-20 token as collateral.

To convert, we will be going to the following website:

After a successful swap, the PegSwap page will typically freeze. Just refresh it (this is a known bug) and it should show your tokens have swapped.

Lastly, if you want to add the token to your Metamask wallet, this is the Wrapped ERC677 LINK token address for the BNB Chain: 0x404460C6A5EdE2D891e8297795264fDe62ADBB75

More details on the contract address here:

Step 3. Register Upkeep

We are at the final step of this process.

We will now register your upkeep:

Target contract address: 0xa623F29ae4cEd27dFBB39a94152F3184140f6c21

Information to be written above:

  • Upkeep Name: Horizon Protocol Auto-Claim (limited length, you can choose whatever name)

  • Gas limit: 700,000 (gas limit will be higher than how much it would cost to just claim directly because it is a contract calling another contract. Typical gas required for small transactions are around 250000, within the same order of magnitude. It is unusual to see 2300 as a gas limit written in the text box.)

  • Starting Balance (LINK): 10+ (add how much LINK, the wrapped ERC677 ones, that you want to deposit into your upkeep. It is recommended to deposit at least 10 as the Minimum Balance to maintain the upkeep can fluctuate based on market prices)

  • Check data (Hexadecimal): Your Wallet Address (Is the public address of your wallet you want to claim rewards on)

  • Your email address (Email Needed for Upkeep notifications)

The above information can be changed later, but it will cost a transaction.

If everything is set up properly and you have rewards to claim with the proper C-Ratio, the Upkeep should immediately claim your rewards for you.

Remember to refresh your Upkeep page until the "Minimum Balance" shows up. "Balance" should also show up.

Here you will find additional information about automation costs:

Step 4. Auto-Claiming

This isn't really a step, but just showing how the Auto-Claiming will work.

For reference, the automated Upkeep transaction cost $1.22 ($0.95 + 30% premium). The 30% premium on BNB Chain is lower than on any of the other chains. You can compare here:

The above Upkeep transaction can also be found here:

Optional Step 5. Canceling Your Upkeep

The final step is for canceling Upkeeps. Canceling your Upkeep consists of two parts:

  1. Cancel Upkeep

  2. Withdraw Funds

The process for Cancel Upkeep and Withdraw Funds will lose you a bit of LINK (in this case, we went from 6 --> 5.9).

If you check your wallet, you should see your LINK there. Note that this is still the Wrapped LINK ERC677 token. You will need to go to Step 2. and perform a reverse swap to get back LINK BEP-20 tokens.

We can start this step by going back to . Make sure your wallet is connected.

https://automation.chain.link/bsc
Step 0. Grant Contract Authorization
Step 1. Get LINK BEP-20 Tokens
Step 2. Convert LINK BEP-20 to BEP-677
Step 3. Register Upkeep
Step 4. Auto-Claiming
Optional Step 5. Canceling Your Upkeep
LogoChainlink Automation Documentation | Chainlink Documentation
LogoManaging Upkeeps | Chainlink Documentation
Logo🥞 PancakeSwap - A next evolution DeFi exchange on BNB Smart Chain (BSC)
LogoPegSwap | Chainlink
LogoLINK Token Contracts | Chainlink Documentation
LogoAutomation | Chainlinkchainlink
LogoChainlink Automation Economics | Chainlink Documentation
[gas limit] * [current gas price] * [gasCeilingMultiplier]
LogoSupported Blockchain Networks | Chainlink Documentation
LogoUpkeep details | Chainlinkchainlink
Go to the “Authorize” tab on the “Account” page.
Add the wallet/contract address to authorize and select what permissions to give it. Below in "Manage Authorizations", you can see all permissions that have been given out previously with the ability to remove these permissions at any time.
Your wallet will ask you to confirm.
Connect your wallet to PancakeSwap. Click on "CAKE" on the right side Swap section of the page to open the modal.
Find the LINK token. You can access this modal by clicking on a token on the Swap screen. Search for LINK. Click Import.
After clicking Import, you will see this. Check "I understand" and then click "Import".
If you are using MetaMask, you will see the following pop up. Click Add Token.
You will now see LINK selected in the Swap section of the page. Enter the amount you want to trade for.
We will be trading for 6 LINK with BNB.
The MetaMask transaction (to show approximate fees involved).
Once the Transaction has been submitted, you will get this screen. If LINK is not already in your wallet as a token, you can click "Add LINK to Wallet". You can also always click the MetaMask fox logo in the Swap section to prompt adding the token to your wallet.
When you first get to https://pegswap.chain.link/, you will need to connect your wallet.
Connect your wallet to Pegswap. Always confirm that the address is correct.
Once your wallet is connected, you can go ahead and type in what you want to swap. Your wallet should show and you should see Binance Pegged LINK and Wrapped ERC677 LINK in the "Swap Chainlink" section.
When you click Swap, this will show up in your wallet (this is in MetaMask, other wallets might be slightly different). You will need to give it permission. In this guide, we will be converting all of our LINK BEP-20 (all 6 tokens).
Here are the transaction fees. Click confirm (off screen to the bottom) to finish the Swap.
This is the Chainlink Automation page.
Connect your wallet. Currently only supports MetaMask.
MetaMask pop up to Connect.
After connecting, you should be able to click on your wallet to confirm that you already have LINK tokens ready. Next, click "Register new Upkeep" to get started.
Select "Custom logic".
Input the Target contract address (address available below).
Fill in the above information and then click "Register Upkeep". Information details below.
Once you click "Register Upkeep", the submission will be in process and your MetaMask will prompt you for confirmation.
MetaMask confirmation with transaction cost.
Once confirmed, the Upkeep page will look like this. Please wait until the transaction is confirmed.
Once the transaction confirmed, you will see this.
Upon completion, your Upkeep page should look like this, with "Status" showing "Active".
If you had not claimed before you set up an Upkeep and a Claim was available, this is what your Claim page will look like before.
And this is what your Claim page will look like after (basically, you didn't click "Claim Now" because your Upkeep claimed for you). Note that the Upkeep can only Claim when you have the proper C-Ratio. The Upkeep currently cannot auto-burn for you.
If you go to https://automation.chain.link/, you will see "Perform Upkeep" in History.
If you go to , you should also be able to see your automated transaction.
Click on "Actions", and then "Cancel upkeep".
MetaMask prompt for confirmation.
Waiting for final confirmation.
Transaction confirmation that upkeep is cancelled.
Your "Status" should now say "Cancelled". Click on "Actions" to "Withdraw funds".
Confirm the "Withdrawal address" is your wallet. Click Confirm.
MetaMask confirmation screen.
Waiting for transaction confirmation.
Funds withdrawn.
https://bscscan.com/address/0x9657a0FD98e88464E1159d98b517A4945dbFBFC8