Skip to main content

ERC20DebtLiquidityToken

Git Source

Inherits: ERC20DebtBase

Functions

constructor

constructor(
ERC20BaseConfig memory config
) ERC20DebtBase(config);

ownerMint

function ownerMint(
address sender,
address to,
uint256 assets,
uint256 shares
) public override(ERC20Base, IAmmalgamERC20) onlyOwner;

ownerBurn

function ownerBurn(address sender, address onBehalfOf, uint256 assets, uint256 shares) public override onlyOwner;

ownerTransfer

This function is reserved for moving collateral to liquidators, but here we reuse it to transfer debt from the pair to a borrower. Since the borrower might already be in trouble if this is called during a liquidation, we do not call validateOnUpdate to avoid failing on the loan to value check. This also means that saturation is not updated for this penalty owed. we think this is an acceptable discrepancy since it is only the penalty for over saturation that is not being included in the saturation update, which should be a negligible amount with respect to the total debt. Once a position is updated either by the users actions, or by a soft liquidation, this penalty will be adjusted to the correct value. in the Saturation State.

function ownerTransfer(address from, address to, uint256 amount) public override(ERC20Base, IAmmalgamERC20) onlyOwner;

Parameters

NameTypeDescription
fromaddressaddress from which shares are transferred
toaddressaddress to which shares are transferred
amountuint256amount of shares to transfer

borrowLiquidityCall

We use the callback to transfer debt to the caller and transfer borrowed assets to the receiver. This contract never has assets or shares unless they were sent to it by the pair within the context of this function getting called. Calling this function directly will not do anything because there are no assets or shares to transfer.

function borrowLiquidityCall(
address sender,
uint256 assetsX,
uint256 assetsY,
uint256 sharesL,
bytes calldata data
) public;

Parameters

NameTypeDescription
senderaddress
assetsXuint256amount of tokenX sent to this contract
assetsYuint256amount of tokenY sent to this contract
sharesLuint256amount of liquidity debt added to this contract
databytesencoded data containing the caller and receiver addresses