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

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

Parameters:

Name
Type
Description

newModerator

address

The address to which moderator role is granted.

RevokeModeratorRole

Emitted when the moderator role is revoked from an account.

Parameters:

Name
Type
Description

moderator

address

The address from which moderator role is revoked.

SetTokenAndPair

Emitted when the token and pair addresses are set for the UniswapV2PriceProvider 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.

Constants info

MODERATOR_ROLE (0x797669c9)

DESCRIPTION (0xf1ae8856)

State variables info

tokenDecimals (0x3b97e856)

muteMetadata (0x2243c302)

Modifiers info

onlyAdmin

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

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.

grantModerator (0x6981c7ae)

Grants the moderator role to a new address.

Parameters:

Name
Type
Description

newModerator

address

The address of the new moderator.

revokeModerator (0x36445636)

Revokes the moderator role from an address.

Parameters:

Name
Type
Description

moderator

address

The address of the moderator to be revoked.

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 (0xa6ff9e94)

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:

Name
Type
Description

token

address

The address of the token to be set.

pair

address

The address of the pair to be set.

changeActive (0x258a4532)

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:

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 Mute.

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 listed or not.

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

price

uint256

The price of the token in pairAsset.

priceDecimals

uint8

The number of decimals for the price.

getReserves (0x32749461)

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

Parameters:

Name
Type
Description

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:

Name
Type
Description

reserveA

uint256

The reserve of the first token.

reserveB

uint256

The reserve of the second token.

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.

Last updated