MutePriceProvider

Overview

License: MIT

contract MutePriceProvider is PriceProvider, Initializable, AccessControlUpgradeable

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

Structs info

MuteMetadata

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

Events info

GrantModeratorRole

event GrantModeratorRole(address indexed newModerator)

Emitted when the moderator role is granted to a new account.

Parameters:

NameTypeDescription

newModerator

address

The address to which moderator role is granted.

RevokeModeratorRole

event RevokeModeratorRole(address indexed moderator)

Emitted when the moderator role is revoked from an account.

Parameters:

NameTypeDescription

moderator

address

The address from which moderator role is revoked.

SetTokenAndPair

event SetTokenAndPair(address indexed token, address indexed pair)

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

Parameters:

NameTypeDescription

token

address

The address of the token that is set.

pair

address

The address of the pair that is set.

ChangeActive

event ChangeActive(address indexed token, bool active)

Emitted when the active status of a token changes.

Parameters:

NameTypeDescription

token

address

The address of the token whose active status has changed.

active

bool

The new active status of the token.

SetTokenDecimals

event SetTokenDecimals(uint8 newTokenDecimals)

Emitted when the token decimals is set.

Parameters:

NameTypeDescription

newTokenDecimals

uint8

The new token decimals.

Constants info

MODERATOR_ROLE (0x797669c9)

bytes32 constant MODERATOR_ROLE = keccak256("MODERATOR_ROLE")

DESCRIPTION (0xf1ae8856)

string constant DESCRIPTION = "Price provider that uses mute.io"

State variables info

tokenDecimals (0x3b97e856)

uint8 tokenDecimals

muteMetadata (0x2243c302)

mapping(address => struct MutePriceProvider.MuteMetadata) muteMetadata

Modifiers info

onlyAdmin

modifier onlyAdmin()

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

onlyModerator

modifier onlyModerator()

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

Functions info

initialize (0x8129fc1c)

function initialize() public initializer

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

grantModerator (0x6981c7ae)

function grantModerator(address newModerator) public onlyAdmin

Grants the moderator role to a new address.

Parameters:

NameTypeDescription

newModerator

address

The address of the new moderator.

revokeModerator (0x36445636)

function revokeModerator(address moderator) public onlyAdmin

Revokes the moderator role from an address.

Parameters:

NameTypeDescription

moderator

address

The address of the moderator to be revoked.

setTokenDecimals (0xf2cf47be)

function setTokenDecimals(uint8 newTokenDecimals) public onlyModerator

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

Parameters:

NameTypeDescription

newTokenDecimals

uint8

The new number of decimals used by the token.

setTokenAndPair (0xa6ff9e94)

function setTokenAndPair(address token, address pair) public onlyModerator

Sets the token and pair addresses for the MutePriceProvider contract.

Requirements:

  • token and pair addresses must not be zero.

  • Only the contract moderator can call this function.

  • The token and pair addresses must be valid.

  • The metadata struct for the token address must be updated with the pair address, pairAsset address, tokenDecimals, and pairAssetDecimals.

Parameters:

NameTypeDescription

token

address

The address of the token to be set.

pair

address

The address of the pair to be set.

changeActive (0x258a4532)

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

Changes the active status of a token in the MutePriceProvider contract.

Requirements:

  • The token must be listed in the MutePriceProvider contract.

  • Only the contract moderator can call this function.

Parameters:

NameTypeDescription

token

address

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

active

bool

The new active status of the token.

isListed (0xf794062e)

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

Check if a token is listed on Mute.

Parameters:

NameTypeDescription

token

address

The address of the token to check.

Return values:

NameTypeDescription

[0]

bool

A boolean indicating whether the token is listed or not.

isActive (0x9f8a13d7)

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

Returns whether the specified token is active or not.

Parameters:

NameTypeDescription

token

address

The address of the token to check.

Return values:

NameTypeDescription

[0]

bool

A boolean indicating whether the token is active or not.

getPrice (0x41976e09)

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

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:

NameTypeDescription

token

address

The address of the token to get the price for.

Return values:

NameTypeDescription

price

uint256

The price of the token in pairAsset.

priceDecimals

uint8

The number of decimals for the price.

getReserves (0x32749461)

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

Returns the reserves of the specified Mute pair for the given tokens.

Parameters:

NameTypeDescription

mutePair

address

The address of the Mute pair.

tokenA

address

The address of the first token.

tokenB

address

The address of the second token.

Return values:

NameTypeDescription

reserveA

uint256

The reserve of the first token.

reserveB

uint256

The reserve of the second token.

getPriceDecimals (0x1b30aafc)

function getPriceDecimals() public view override returns (uint8)

Returns the number of decimals used for the USD price.

Return values:

NameTypeDescription

[0]

uint8

The number of decimals used for the USD price.

Last updated