Skip to main content

ICargoIntegration

Intro

The ICargoIntegration interface is for abstracting differences between different rebalancers into the same standard. All CargoIntegration contracts should inherit from this interface and make sure to follow it, this way all CLPTokens can use this same interface for calling any integration contract, therefore integrating with any rebalancer.

Functions

token0Address

Function for returning the token0 address of a given rebalancer _poolAddress

ICargoIntegration.sol
function token0Address(
address _poolAddress
) external view returns (address _token0Address);

Params:

  • _poolAddress address of rebalancer pool

Returns:

  • _token0Address address of token0

token1Address

Function for returning the token1 address of a given rebalancer _poolAddress

ICargoIntegration.sol
function token1Address(
address _poolAddress
) external view returns (address _token1Address);

Params:

  • _poolAddress address of rebalancer pool

Returns:

  • _token1Address address of token0

deposit

Function for adding liquidity to a rebalancer pool.

ICargoIntegration.sol
function deposit(
address _poolAddress,
uint256 _amount0Desired,
uint256 _amount1Desired
) external payable returns (
uint256 shares,
uint256 amount0Deposited,
uint256 amount1Deposited
);

Params:

  • _poolAddress address of rebalancer pool
  • _amount0Desired maximum amount of token0 that user wants to deposit
  • _amount1Desired maximum amount of token1 that user wants to deposit

Returns:

  • shares number of LP tokens minted
  • amount0Deposited amount of token0 actually deposited to mint shares
  • amount1Deposited amount of token1 actually deposited to mint shares

withdraw

Function for removing liquidity from a rebalancer pool.

ICargoIntegration.sol
function withdraw(
address _poolAddress,
uint256 _shares,
address _to
) external returns (
uint256 amount0,
uint256 amount1
);

Params:

  • _poolAddress address of rebalancer pool
  • _shares amount of LP shares to burn
  • _to address to where the underlying tokens should be sent

Returns:

  • amount0 amount of token0 underlying shares
  • amount1 amount of token1 underlying shares

getAmountsFromPosition

Function for getting underlying amounts for a given number of shares (LP tokens)

ICargoIntegration.sol
function getAmountsFromPosition(
address _poolAddress,
uint256 _clpTotalSupply
) external view returns (
uint256 amount0,
uint256 amount1
);

Params:

  • _poolAddress address of rebalancer pool
  • _clpTotalSupply amount of LP shares

Returns:

  • amount0 amount of token0 underlying _clpTotalSupply
  • amount1 amount of token1 underlying _clpTotalSupply

getUniswapPool

Function for getting the uniswap pool address of a rebalancer pool.

ICargoIntegration.sol
function getUniswapPool(
address _poolAddress
) external view returns (
address _uniPoolAddress
);

Params:

  • _poolAddress address of rebalancer pool

Returns:

  • _uniPoolAddress address of Uniswap V3 Pool.

getTickLower

Function for getting the lower tick of a rebalancer's position.

ICargoIntegration.sol
function getTickLower(
address _poolAddress
) external view returns (
int24 _tickLower
);

Params:

  • _poolAddress address of rebalancer pool

Returns:

  • _tickLower position's lower tick

getTickUpper

Function for getting the upper tick of a rebalancer's position.

ICargoIntegration.sol
function getTickUpper(
address _poolAddress
) external view returns (
int24 _tickUpper
);

Params:

  • _poolAddress address of rebalancer pool

Returns:

  • _tickUpper position's upper tick