Novel on-chain Keeper protocol which reacts upon price actions immediately, within the same transaction.
A novel on-chain Keeper protocol which reacts upon price actions immediately, within the same transaction.
DeFi protocols have suffered issues from latent Oracles and slow reaction by the Liquidation Keepers. No more! This protocol allows DeFi protocols to immediately react to price actions, as soon as they occur on-chain.
The protocol mechanism is implemented as a pair of Guardian Tokens which can wrap any pair of ERC20 tokens and deploy them at one or more Automated Market Maker DEXes. These tokens intercept the "transfer" functions and reverse-calculate the price as soon as transactions occur, and immediately call registered callbacks. These callbacks are typically liquidation or rebalancing operations performed by the DeFi protocols utilizing the Guardian Oracle-Keeper Protocol.
The contracts are written in Solidity using the Foundry toolkit for building, testing and simulation.
The Guardian Tokens are ERC20 tokens issued in pairs which we call Friends. They wrap existing ERC20 tokens and provide additional functionality. In a way, they are indistinguishable to the liquidity pool from any other tokens, thus acting as Trojan Horses.
For example, we have a protocol in need of liquidations based on the ETH/USDC pricing. The function "liquidate(uint256 price)" has to be called when the price crosses the specified value.
Our protocol creates a pair of Guardian Tokens called gWETH and gUSDC, each wrapping WETH (wrapped 1-to-1 ETH) and USDC respectively. Note that these new tokens are Friends, effectively aware of each other. Each one of them is tracking its total supply (well, the supply owned bu authorized DEXes to be precise as this is discussed below in the Safety section). Upon each transfer, the ratio of the total supplies is calculated, which determines their relative price.
Outside protocols can subscribe to one-time function callbacks for a fee. If the callback function would be responsible for re-subscribing again, which makes the process simple and flexible.
When the price changes, the tokens go through the list of subscriptions and call the relevant callbacks with the price as parameter. More on the efficient data structures for this below.
Now this pair of Guardian Tokens can be deployed as liquidity on any DEX. As traders trade these tokens, they call the callbacks and perform liquidations on various protocols.