UniswapV2PriceProviderMock

Overview

License: MIT

contract UniswapV2PriceProviderMock is PriceProvider, Initializable, AccessControlUpgradeable

This implementation can be affected by price manipulation due to not using TWAP. For development purposes only

Structs info

PriceInfo

struct PriceInfo {
	uint256 price;
	uint8 tokenDecimals;
}

UniswapV2Metadata

struct UniswapV2Metadata {
	bool isActive;
	address pair;
	address pairAsset;
	uint8 tokenDecimals;
	uint8 pairAssetDecimals;
}

Events info

GrantModeratorRole

event GrantModeratorRole(address indexed newModerator)

RevokeModeratorRole

event RevokeModeratorRole(address indexed moderator)

SetTokenAndPrice

event SetTokenAndPrice(address indexed token, uint256 price)

ChangeActive

event ChangeActive(address indexed token, bool active)

Constants info

MODERATOR_ROLE (0x797669c9)

bytes32 constant MODERATOR_ROLE = keccak256("MODERATOR_ROLE")

DESCRIPTION (0xf1ae8856)

string constant DESCRIPTION = "Price provider that uses uniswapV2"

State variables info

usdDecimals (0x66a4b6c0)

uint8 usdDecimals

uniswapV2Metadata (0x809205db)

mapping(address => struct UniswapV2PriceProviderMock.UniswapV2Metadata) uniswapV2Metadata

tokenPrice (0x84ba3f69)

mapping(address => struct UniswapV2PriceProviderMock.PriceInfo) tokenPrice

Modifiers info

onlyAdmin

modifier onlyAdmin()

onlyModerator

modifier onlyModerator()

Functions info

initialize (0x8129fc1c)

function initialize() public initializer

grantModerator (0x6981c7ae)

function grantModerator(address newModerator) public onlyAdmin

revokeModerator (0x36445636)

function revokeModerator(address moderator) public onlyAdmin

setTokenAndPrice (0x179750ec)

function setTokenAndPrice(address token, uint256 price) public onlyModerator

changeActive (0x258a4532)

function changeActive(address token, bool active) public override onlyModerator

Changes the active status of a token.

Parameters:

isListed (0xf794062e)

function isListed(address token) public view override returns (bool)

Returns a boolean indicating whether the given token address is listed in the price provider.

Parameters:

Return values:

isActive (0x9f8a13d7)

function isActive(address token) public view override returns (bool)

Returns whether a token is active or not.

Parameters:

Return values:

getPrice (0x41976e09)

function getPrice(
    address token
) public view override returns (uint256 price, uint8 priceDecimals)

Returns the price of the specified token.

Parameters:

Return values:

getEvaluation (0x81fd01ea)

function getEvaluation(
    address token,
    uint256 tokenAmount
) public view override returns (uint256 evaluation)

Returns the evaluation of a given token amount based on the current price.

Parameters:

Return values:

getReserves (0x32749461)

function getReserves(
    address uniswapPair,
    address tokenA,
    address tokenB
) public view returns (uint256 reserveA, uint256 reserveB)

getPriceDecimals (0x1b30aafc)

function getPriceDecimals() public view override returns (uint8)

Returns the number of decimal places for the price returned by the price provider.

Return values:

Last updated