Skip to main content

ITokenController

Git Source

The interface of a ERC20 facade for multiple token types with functionality similar to ERC1155.

The TokenController provides support to the AmmalgamPair contract for token management.

Functions

underlyingTokens

Get the underlying tokens for the AmmalgamERC20Controller.

function underlyingTokens() external view returns (IERC20, IERC20);

Returns

NameTypeDescription
<none>IERC20The addresses of the underlying tokens.
<none>IERC20

getReserves

Fetches the current reserves of asset X and asset Y, as well as the block of the last operation.

function getReserves() external view returns (uint112 reserveXAssets, uint112 reserveYAssets, uint256 blockLast);

Returns

NameTypeDescription
reserveXAssetsuint112The current reserve of asset X.
reserveYAssetsuint112The current reserve of asset Y.
blockLastuint256The block number of the last operation.

getTickRange

returns the tick range used to represent the price range

function getTickRange() external view returns (int16 minTick, int16 maxTick);

Returns

NameTypeDescription
minTickint16the minimum tick representing the lowest estimated price
maxTickint16the maximum tick representing the highest estimated price

externalLiquidity

function externalLiquidity() external view returns (uint112);

updateExternalLiquidity

Updates the external liquidity value.

This function sets the external liquidity to a new value and emits an event with the new value. It can only be called by the fee setter.

function updateExternalLiquidity(
uint112 _externalLiquidity
) external;

Parameters

NameTypeDescription
_externalLiquidityuint112The new external liquidity value.

configLongTermInterval

Resets the long-term interval configuration.

Allows the contract owner to reset the long-term interval configuration to the specified value.

function configLongTermInterval(
uint24 _longTermIntervalConfigFactor
) external;

Parameters

NameTypeDescription
_longTermIntervalConfigFactoruint24The new factor of mid-term interval configuration to be set for the long-term interval configuration.

tokens

Return the IAmmalgamERC20 token corresponding to the token type

function tokens(
uint256 tokenType
) external view returns (IAmmalgamERC20);

Parameters

NameTypeDescription
tokenTypeuint256The type of token for which the scaler is being computed. Can be one of BORROW_X, DEPOSIT_X, BORROW_Y, DEPOSIT_Y, BORROW_L, or DEPOSIT_L.

Returns

NameTypeDescription
<none>IAmmalgamERC20The IAmmalgamERC20 token

totalAssets

Computes the current total Assets.

If the last lending state update is outdated (i.e., not matching the current block timestamp), the function recalculates the assets based on the duration since the last update, the lending state, and reserve balances. If the timestamp is current, the previous scaler (without recalculation) is returned.

function totalAssets() external view returns (uint128[6] memory);

Returns

NameTypeDescription
<none>uint128[6]totalAssets An array of six uint128 values representing the total assets for each of the 6 amalgam token types. These values may be adjusted based on the time elapsed since the last update. If the timestamp is up-to-date, the previously calculated total assets are returned without recalculation.

Events

Sync

Emitted when reserves are synchronized

event Sync(uint256 reserveXAssets, uint256 reserveYAssets);

Parameters

NameTypeDescription
reserveXAssetsuint256The updated reserve for token X
reserveYAssetsuint256The updated reserve for token Y

UpdateExternalLiquidity

Emitted when external liquidity is updated

event UpdateExternalLiquidity(uint112 externalLiquidity);

Parameters

NameTypeDescription
externalLiquidityuint112The updated value for external liquidity