vPoolManager

Helper contract for building and accessing VirtuSwap Virtual Pools

Read-only functions

function getVirtualPool

function getVirtualPool(
     address jkPair,
     address ikPair
) public view override returns (VirtualPoolModel memory vPool)

Returns a Virtual Pool constructed from a given Active Pool and a given Reference Pool. If a Virtual Pool pool cannot be constructed from the given pair of pools, an error occurs.

See How Virtual Pools Work for details on how Virtual Pools are constructed.

Parameters:

Name
Type
Description

jkPair

address

Address of the Active Pool

ikPair

address

Address of the Reference Pool

function getVirtualPools

function getVirtualPools(
    address token0,
    address token1
) external view override returns (VirtualPoolModel[] memory vPools)

Returns all Virtual Pools that are available between two given tokens.

See How Virtual Pools Work for details on how Virtual Pools are constructed.

Parameters:

Name
Type
Description

token0

address

First token

token1

address

Second token

function pairFactory

function pairFactory() 
    external view 
returns (address);

Returns the vPairFactory instance.

State-changing functions

function updateVirtualPoolBalances

function updateVirtualPoolBalances(
        VirtualPoolModel memory vPool,
        uint256 balance0,
        uint256 balance1
    ) external overrides)

Updates balances of a Virtual Pool. This function is called by swapNativeToReserve and swapReserveToNative methods of the vPair contract after a trade is executed using the Virtual Pool. The goal is to make Virtual Pool behave exactly like a regular AMM pool would, i.e. that every trade immediately effects the liquidity of the pool.

Parameters:

Name
Type
Description

vPool

VirtualPoolModel

The Virtual Pool to be updated

balance0

uint256

Balance of asset0 in the Virtual Pool

balance1

uint256

Balance of asset1 in the Virtual Pool

Last updated