UniswapV3PriceProvider

Overview

License: MIT

contract UniswapV3PriceProvider is PriceProvider, Initializable, AccessControlUpgradeable

Structs info

UniswapV3Metadata

struct UniswapV3Metadata {
	bool isActive;
	address[] aggregatorPath;
}

UniswapV3MetadataPair

struct UniswapV3MetadataPair {
	address token;
	address pairToken;
	uint8 tokenDecimals;
	uint8 pairTokenDecimals;
	uint32 pricePointTWAPperiod;
}

Events info

SetTokenAndPair

Emitted when the token and pair addresses are set for the UniswapV3PriceProvider contract.

Parameters:

Name
Type
Description

token

address

The address of the token that is set.

pair

address

The address of the pair that is set.

ChangeActive

Emitted when the active status of a token changes.

Parameters:

Name
Type
Description

token

address

The address of the token whose active status has changed.

active

bool

The new active status of the token.

SetTokenDecimals

Emitted when the token decimals is set.

Parameters:

Name
Type
Description

newTokenDecimals

uint8

The new token decimals.

SetTokenAndAggregator

Emitted when a token and its corresponding UniswapV3 aggregator path are set.

Parameters:

Name
Type
Description

token

address

The address of the token.

aggregatorPath

address[]

The array of UniswapV3 aggregator pairs used to get the price of the token.

Constants info

MODERATOR_ROLE (0x797669c9)

DESCRIPTION (0xf1ae8856)

MAX_PRICE_PATH_LENGTH (0x01a9a5d3)

State variables info

tokenDecimals (0x3b97e856)

uniswapV3Metadata (0xe84cbb89)

uniswapV3MetadataPair (0x918d7a98)

Modifiers info

onlyModerator

Modifier to restrict access to functions to only the contract moderator.

Functions info

initialize (0x8129fc1c)

Initializes the contract by setting up the access control roles and the number of decimals for the USD token. decimals is set to 18.

setTokenDecimals (0xf2cf47be)

Sets the number of decimals used by the token. Only the moderator can call this function.

Parameters:

Name
Type
Description

newTokenDecimals

uint8

The new number of decimals used by the token.

setTokenAndPair (0x8d46526f)

Set token and aggregator path.

Requirements:

  • The token must be listed in the UniswapV3PriceProvider contract.

  • Only the contract moderator can call this function.

Parameters:

Name
Type
Description

token

address

The address of the token.

aggregatorPath

address[]

The address of the aggregator path.

pricePointPeriod

uint32[]

The period for the price point.

changeActive (0x258a4532)

Changes the active status of a token in the UniswapV3PriceProvider con tract.

Requirements:

  • The token must be listed in the UniswapV3PriceProvider contract.

  • Only the contract moderator can call this function.

Parameters:

Name
Type
Description

token

address

The address of the token to change the active status for.

active

bool

The new active status of the token.

isListed (0xf794062e)

Check if a token is listed on UniswapV3.

Parameters:

Name
Type
Description

token

address

The address of the token to check.

Return values:

Name
Type
Description

[0]

bool

isListed the is listed status of token.

isActive (0x9f8a13d7)

Returns whether the specified token is active or not.

Parameters:

Name
Type
Description

token

address

The address of the token to check.

Return values:

Name
Type
Description

[0]

bool

A boolean indicating whether the token is active or not.

getPrice (0x41976e09)

This function requires that the token is active in the price provider. Returns the price of a given token in pairAsset, and the number of decimals for the price.

Parameters:

Name
Type
Description

token

address

The address of the token to get the price for.

Return values:

Name
Type
Description

priceMantissa

uint256

The price of the token in pairAsset.

priceDecimals

uint8

The number of decimals for the price.

getUnderlyingTokenPrice (0x8020c854)

getPriceDecimals (0x1b30aafc)

Returns the number of decimals used for the USD price.

Return values:

Name
Type
Description

[0]

uint8

The number of decimals used for the USD price.

getUniswapV3Metadata (0xb790348b)

Returns the metadata set up for token.

Parameters:

Name
Type
Description

token

address

The address of the token.

Return values:

Name
Type
Description

[0]

struct UniswapV3PriceProvider.UniswapV3Metadata

metadata The metadata includes the active status, pair address, pairAsset address, tokenDecimals, and pairAssetDecimals.

Last updated