Roles - Borrower
For a user perspective of borrower actions, visit this page.
Summary
Borrowers will find Twyne useful for a variety of reasons. They may want to borrow more than other protocols allow, or they may want to borrow the same amount but with more protection against losses from liquidations. A collateral vault holds the borrowers position and functions similarly to a smart account. A borrower can have multiple collateral vaults, but a collateral vault only holds 1 type of collateral and has 1 borrower (owner) at any given time. If a collateral vault is liquidated, the liquidator becomes the new owner of the collateral vault.
Function Calls
A borrower must first create a collateral vault. Once the vault exists, a borrower sets 3 parameters to control their position: the amount of collateral in the collateral vault, the amount of assets borrowed from the underlying protocol, and the user-specified Twyne LTV.
Creating the vault
A borrower must call the createCollateralVault(address,address,uint)()
function of the CollateralVaultFactory in order to create a collateral vault. The call can happen through the EVC (inside of an EVC batch) or with a direct call to the factory. The collateral asset, borrowed asset, and Twyne LTV should all be specified at the time of vault creation.
Collateral amount
The borrower can add collateral with deposit(uint)()
, depositUnderlying(uint)
, or teleport(uint,uint)
. Only the collateral vault owner, the borrower, can call these functions. deposit(uint)()
allows the borrower to deposit the collateral vault asset (such as aWETH or eWETH) into the vault. depositUnderlying(uint)
allows the borrower to deposit WETH directly to the vault, bypassing the need to deposit into another protocol first. teleport(uint,uint)
is used to allow quick transfer of a position from another protocol that includes an existing borrow, without requiring the borrower to unwind their borrow. These actions use the ERC20 transferFrom()
function call, so an approval or Permit2 signature is necessary for them to function properly.
The borrower can remove collateral, as long as it is not being used for a borrow, with withdraw(uint,address)()
or redeemUnderlying(uint,address)()
. withdraw(uint,address)()
does the reverse of deposit(uint)()
, returning the collateral vault asset (such as aWETH or eWETH) from the vault. redeemUnderlying(uint,address)()
does the reverse of depositUnderlying(uint)
and returns the base asset (such as WETH).
Borrowed amount
The borrower can increase their borrowed assets with borrow(uint,address)()
or decrease the borrowed assets with repay(uint)()
. This action interacts
Twyne LTV
The Twyne LTV, explained in more detail in the user docs, can be set using setTwyneLiqLTV(uint)()
. The LTV value must stay within the bounds required by the checkLiqLTV(uint,address,address)()
function of VaultManager.