axiom-crypto / axiom-ideas

0 stars 0 forks source link

Circuit breaker based on rolling AUM #1

Open zxw344 opened 1 year ago

zxw344 commented 1 year ago

What is it?

A smart contract circuit breaker that enables a DeFi protocol to stop accepting deposits whenever its rolling AUM drops below a certain threshold. This function helps protect user funds during rapid protocol-level attacks or volatile market movements.

How does it work?

Whenever a withdraw transaction is initiated, the circuit breaker smart contract is also called. The circuit breaker smart contract then calls the Axiom contract to check on the protocol’s historical AUM (i.e. ETH balance in the smart contract address) and determine the rolling AUM. If the rolling AUM is lower than the threshold, then the circuit breaker will trigger a deposit lock. The TVL data can be accessed with Axiom V1. The calculation performed on top of the data can be achieved with Axiom V2.

Why use Axiom?

It is possible to make a circuit breaker without Axiom. However, the circuit breaker can only access real time or up to ~1 hour historical TVL data. This could result in the circuit breaker being triggered prematurely, if the threshold is set too high, or never triggered, if the threshold is set too low. Axiom allows the circuit breaker to access TVL data from an arbitrary time range and keep the most up to date info on a rolling basis without taking up onchain storage. It gives more flexibility in terms of setting the right parameters for the circuit breaker.