M1CollateralValueCalculator

M1CollateralValueCalculator

Aggregation contracts used to calculate the value of M1 collateral.

View Methods

getAssetInBaseCurrency

function getAssetInBaseCurrency(address asset,uint256 amounts, address oracle) override public view returns (uint256)

Calculate the value of a specified amount of assets

Call Params

Name
Type
Description

assets

address

contract address of assets

amounts

uint256

the evaluated amount of assets

oracle

address

Underlying asset take-or-pay contracts in collateral assets

Return Value

Type
Description

uint256

Returns the value of the specified amount of assets passed in.

getSingleLpInBaseCurrency

function getSingleLpInBaseCurrency(address lpContractAddress, uint256 lpAmounts, address oracle) external view returns (uint256);

Calculate the value of the specified amount of LP token

Call Params

Name
Type
Description

lpContractAddress

address

token address of the LP token

lpAmounts

uint256

the amount need to be evaluate

oracle

address

Underlying asset take-or-pay contracts in collateral assets

Return Value

Type
Description

uint256

The evaluated results

getUniswapV2InBaseCurrency

function getUniswapV2InBaseCurrency(address v2Pair, uint256 lpAmounts, address oracle) external view returns (uint256)

计算Uniswap v2 LP token数量的价值

Call Params

Name
Type
Description

v2Pair

address

the pool address ofUniswap V2 LP

lpAmounts

uint256

the amount need to be evaluate

oracle

address

Underlying asset take-or-pay contracts in collateral assets

Return Value

Type
Description

uint256

The evaluated results to the corresponding asset and amount.

getUniswapV2LpAmounts

function getUniswapV2LpAmounts(address v2Pair, uint256 lpAmounts) external view returns (address token0, address token1, uint256 amount0, uint256 amount1)

Get the address and number of underlying asset contracts corresponding to the number of Uniswap v2 LP tokens.

Call Params

Name
Type
Description

v2Pair

address

the pool address ofUniswap V2 LP

lpAmounts

uint256

the LP amount need to be evaluate

Return Value

Name
Type
Description

token0

address

Uniswap v2 LP corresponds to the token0 contract address.

token1

address

Uniswap v2 LP corresponds to the token1 contract address.

amount0

uint256

The amount of assets corresponding to token0 for Uniswap v2 LP.

amount1

uint256

The amount of assets corresponding to token1 for Uniswap v2 LP.

getUniswapV3NFTInBaseCurrency

function getUniswapV3NFTInBaseCurrency( address nonfungiblePositionManagerAddress, uint256 tokenId, address oracle) external view returns (uint256);

Get the value of Uniswap v3 NFT

Call Params

Name
Type
Description

nonfungiblePositionManagerAddress

address

Each pair of Uniswap is grouped under a single administrative address. They have different token IDs but the same address.

tokenId

uint256

token id

oracle

address

Underlying asset take-or-pay contracts in collateral assets

Return Value

Type
Description

uint256

Returns the value of the token ID passed into Uniswap v3.

getUniswapV3NFTAmounts

function getUniswapV3NFTAmounts(uint256 tokenId, address nonfungiblePositionManagerAddress) external view returns (address token0, address token1, uint24 fee, uint256 amount0, uint256 amount1);

Get the address of the underlying asset contract corresponding to Uniswap v3 NFT and its amount.

The number of assets in Uniswap V3 NFT changes all the time, and the Pool is able to monitor it in real-time.

Call Params

Name
Type
Description

tokenId

uint256

token id

nonfungiblePositionManagerAddress

address

Uniswap v3's nft position manager address

Return Value

Name
Type
Description

token0

address

Uniswap v3 NFT corresponds to token0 contract address.

token1

address

Uniswap v3 NFT corresponds to token1 contract address.

fee

uint256

The uncollected fee of the NFT

amount0

uint256

Uniswap v3 NFT amount of assets corresponding to token0.

amount1

uint256

Uniswap v3 NFT amount of assets corresponding to token1.

getUniswapV3NFTPoolAddress

function getUniswapV3NFTPoolAddress(uint256 tokenId, address nonfungiblePositionManagerAddress) external view returns(address)

Get the address of the pool contract corresponding to the tokenId of Uniswap v3

Call Params

Name
Type
Description

tokenId

uint256

token id

nonfungiblePositionManagerAddress

address

Uniswap v3's nft position manager address

Return Value

Name
Description

address

Uniswap v3 NFT corresponds to the contract address of the pool.

getUniswapV3NFTInBaseCurrencyV2

function getUniswapV3NFTInBaseCurrencyV2( address nonfungiblePositionManagerAddress, uint256 tokenId, address oracle) external view returns (uint256 currencyValue,address token0, address token1, uint256 fee , uint256 amount0, uint256 amount1);

Get the value of Uniswap v3 and basic information about the underlying assets

Call Params

Name
Type
Description

nonfungiblePositionManagerAddress

address

Uniswap v3's nft position manager address

tokenId

uint256

token id

oracle

address

Underlying asset take-or-pay contracts in collateral assets

Return Value

Name
Type
Description

currencyValue

uint256

Returns the value of the tokenid of Uniswap v3.

token0

address

Uniswap v3 NFT corresponds to token0 contract address.

token1

address

Uniswap v3 NFT corresponds to token1 contract address.

fee

uint256

Uniswap v3 uncollected fee

amount0

uint256

the amount of assets corresponding to token0 in the NFT.

amount1

uint256

the amount of assets corresponding to token1 in the NFT.

Last updated