Skip to main content

ALTBCPool

Git Source Inherits: PoolBase, ALTBCCalculator Author: @oscarsernarosero @mpetersoCode55 @cirsteve This contract serves the purpose of facilitating swaps between a pair of tokens, where one is an xToken and the other one is a yToken.

Functions

constructor

constructor
constructor(
    address _xToken,
    address _yToken,
    FeeInfo memory fees,
    ALTBCInput memory _tbcInput,
    bool _liquidityRemovalAllowed,
    address sender
)
    PoolBase(_xToken, _yToken, fees, _liquidityRemovalAllowed, sender)
    ALTBCCalculator(
        _xToken,
        _yToken,
        fees._lpFee,
        fees._protocolFee,
        fees._protocolFeeCollector,
        _tbcInput,
        _liquidityRemovalAllowed,
        sender
    );
Parameters
NameTypeDescription
_xTokenaddressaddress of the X token (x axis)
_yTokenaddressaddress of the Y token (y axis)
feesFeeInfofee infomation
_tbcInputALTBCInputinput parameters for the TBC
_liquidityRemovalAllowedboolif true, liquidity can be removed at any time. Removal of liquidity forbidden otherwise.
senderaddressaddress of the to-be owner

enableSwaps

Only the owner of the pool can call this function. This is the function to activate/deactivate trading.
function enableSwaps(bool _enable) external override onlyOwner;
Parameters
NameTypeDescription
_enableboolpass True to enable or False to disable

yTokenLiquidity

This function gets the liquidity in the pool for yToken in WAD
function yTokenLiquidity() external view override returns (uint256);
Returns
NameTypeDescription
<none>uint256the liquidity in the pool for yToken in WAD

withdrawRevenue

Only the owner can call this function. This function allows the owner of the pool to pull accrued revenue from the Pool.
function withdrawRevenue() external onlyOwner;

closePool

This function can be called only if the flag liquidityRemovalAllowed was set to true at construction time and the msg sender is the owner. This function closes the pool by removing all liquidity from it.
function closePool() external override onlyOwner ifLiquidityRemovalAllowed;

_validateLiquidityAdd

yBalance will include LPFees, Q and yLiquidity the first parameter is not used, but it is required by the base class. We can use the stored value of x. This function validates the liquidity addition to ensure it does not exceed the max supply of xToken.
function _validateLiquidityAdd(uint256, uint256 afterBalance) internal view override(ALTBCCalculator, CalculatorBase);
Parameters
NameTypeDescription
<none>uint256
afterBalanceuint256the balance of xToken after the addition