VaultManager
contract in which this kind of feature can be used: the angle()
function and the liquidate()
function.who
and a data
parameter. This is what allows stakeholders of the protocol to specify a contract (who
) to perform swaps if needed. The data
parameter can be used by the who
contract to know which route it should use to do the swap.VaultManager
contract expects that the who
contract conforms to the ISwapper
interface. This means that they must implement the swap
function below:ISwapper
contract lets this contract know that it got inTokenObtained
of inToken
and that it should swap these inToken
to outToken
. The execution of the transaction fails in the VaultManager
if the ISwapper
contract fails make sure that at the end of the call the outTokenRecipient
is not at least outTokenOwed
.VaultManager
with ETH as a collat. If you want to get to get exposure to 1.5 ETH from 0.5 ETH, you need to call the angle()
function of the contract and perform the following actions (in the right order):addCollateral
: 1.5 ETHborrow
: 1 ETH worth of stablecoinsangle()
function is coded in a way that in this case stablecoins are sent before collateral is given. As such, if you specify in your call to the angle()
a who
contract along with data
needed for this contract to know how to process the swap, then the operation will succeed even if the msg.sender
just has 0.5 ETH in your balance.to
address specified in the transaction should either be the who
contract, or it should have approved the who
contract for the collateral (for the who
contract to fetch stablecoins from this address).VaultManager
sends 1 ETH worth of stablecoins to the who
contract (which should in many cases and depending on the implementation be the to
contract)msg.sender
address (your address). The who
contract could for instance perform 1Inch or UniswapV3 swaps.VaultManager
fetches the 1.5 ETH from the msg.sender
address and concludes the transactionliquidate
function, to perform such swaps, you should specify a who
contract which supports the ISwapper
interface, depending on the implementation of the who
contract, the to
address should be the who
address. The data
parameter given should help the who
contract perform the swap.VaultManager
contract sends 1.1 ETH to the to
contractwho
contract swaps a portion (or all) these 1.1 ETH for 1 ETH worth of stablecoinsVaultManager
burns the 1 ETH worth of stablecoins from the from
address given in the function. For this to work, the from
address should have by the way given approval to the msg.sender
for the stablecoin.