# Automating TenderVaults Rebasing with Gelato ## Why Automate ? Tenderize's Liquid Staking Tokens are rebasing tokens. As our vaults earn staking rewards, they need to be periodically rebased to reflect the rewards in the supply of the LSTs. Any action from users (stake, unstake, withdraw and transfer) will trigger these rebases automatically, meaning these vaults can be fully autonomous. As a validator offering white label liquid staking using Tenderize, you can create an even better user experience for your clients by automating these "rebases". This would allow for consistent propagation of staking rewards to token balances without offloading that (gas) cost to your clients. ## Getting Started In this guide we'll use [Gelato Network](https://gelato.network)'s "functions" to automate rebases. Gelato offers a nice [user interface](https://app.gelato.network/functions) in which you can manage and adjust how and when these functions are triggered on-chain (e.g. time-interval, based on an event, etc.) To get started head to [app.gelato.network](https://app.gelato.network/functions), connect your wallet and click the "Create Task" button to create your first task ! ![image](https://hackmd.io/_uploads/ryvx6btca.png) ## Creating a Trigger Now we'll need to create a "trigger", this decides when gelato network will fire our rebase call. ### Time-based / Cron Job The easiest trigger would be to just try rebasing on a fixed time interval, e.g. once every day. You can set this up with regular scheduling, or [cron jobs](https://crontab.guru/). ### Event Based (Coming Soon!) A more advanced, but better way to trigger rebases is to use events. Ideally we rebase right after your validator has distributed staking rewards to its delegators. We could watch the following events for this: - Livepeer: `BondingManager::Reward` - The Graph: `Staking::AllocationClosed` - Polygon: `RootChain::NewHeaderBlock` **As of writing Gelato does not have support to filter events by topics, this approach will be explained further when this feature becomes available** ## Calling your Trigger ### Option A: Simple Transaction Sending a simple "rebase" transaction to your preferred Tenderizer vault is the easiest way. Simply enter the contract address of the `Tenderizer` vault you'd like to be rebasing. #### Finding Your Tenderizer Address Go to the Tenderize Registry on [etherscan](https://etherscan.io/address/0xa7cA8732Be369CaEaE8C230537Fc8EF82a3387EE#readProxyContract#F5)/[arbiscan](https://arbiscan.io/address/0xa7cA8732Be369CaEaE8C230537Fc8EF82a3387EE#readProxyContract#F5) and call `getTenderizer` with following params: - Token Address for LPT, GRT or MATIC (depending on which you need) which you can find at the bottom of this article - Address of your validator/indexer/orchestrator ![image](https://hackmd.io/_uploads/SyIdPfF9a.png) For example, the Tenderizer address for `livepool.eth` for Livepeer is `0x4a3c14d7450c30f712e89659af21f90df56bc9ba`. Let's enter this in the Gelato app. The ABI will automatically fill in after a few seconds, after which we can select the `rebase()` option from the dropdown menu. Make sure you also select the right network ! *The ABI will be fetched automatically if the contract is linked to the implementation. If this is not the case go to etherscan/arbiscan. Press "Code" followed by the "Is This A Proxy?" button and complete the steps.* ![image](https://hackmd.io/_uploads/HJJPGftc6.png) ### Option B: Calling A Solidity Function (Coming Soon) Coming soon ! ## Creating The Task Press the "Create Task" button to create your task and complete the steps in your wallet. ![image](https://hackmd.io/_uploads/BJLIuMY5a.png) As a final step top up your [1Balance](https://app.gelato.network/1balance) in the Gelato app to pay for the initial relays (USDC on Polygon). ### Useful Information #### Token Addresses - LPT (Arbitrum): [0x289ba1701c2f088cf0faf8b3705246331cb8a839](https://arbiscan.io/token/0x289ba1701c2f088cf0faf8b3705246331cb8a839) - GRT (Arbitrum): [0x9623063377ad1b27544c965ccd7342f7ea7e88c7](https://arbiscan.io/token/0x9623063377ad1b27544c965ccd7342f7ea7e88c7) - MATIC (Ethereum): [https://etherscan.io/token/0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0](https://etherscan.io/token/https://etherscan.io/token/0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0)