Standard Market

Standard markets create and manage liquidity pools based on the market's configurations set during the time of creation.

Configurations that can be set at the time of market creation include the authorization of pool creators, liquidity providers or traders. The transaction fee of a standard market can also be set from 0% to 1% in 0.1% increments.

The transaction fee applies to all liquidity pools within the market, specifically incurred on swap transactions.

A market fee can also be set during market creation where the owner of the market will collect 1/6 of all transaction fees and the other 5/6 will be collected by liquidity providers.

All configurations of a standard market can only be set at the time of creation and are not able to be changed after with the exception of the address of the market owner.

📘

Derives From Market Contract

This smart contract is derived from the Market smart contract where inherited properties, methods, logs, models and references are detailed.

Constructor

OpdexStandardMarket(ISmartContractState state,
                    uint transactionFee,
                    Address owner,
                    bool authPoolCreators,
                    bool authProviders,
                    bool authTraders,
                    bool enableMarketFee) : base(state, transactionFee)

Parameters

Type

Property

Description

ISmartContractState

state

Dependency injected smart contract state.
Omitted from parameters during deployment.

uint

transactionFee

The market transaction fee, 0-10 equal to 0-1%.

Address

owner

The address of the market's staking token.

bool

authPoolCreators

Flag to authorize liquidity pool creators.

bool

authProviders

Flag to authorize liquidity pool providers.

bool

authTraders

Flag to authorize traders.

bool

enableMarketFee

Flag to determine if 1/6 of transaction fees should be collected by the market.


Properties

Type

Property

Description

bool

AuthPoolCreators

Flag to authorize liquidity pool creators or not. This is immutable once the market is created.

bool

AuthProviders

Flag to authorize liquidity providers or not. This is immutable once the market is created.

bool

AuthTraders

Flag to authorize traders or not. This is immutable once the market is created.

Address

Owner

The address of the market owner.

bool

MarketFeeEnabled

Flag indicating if the market owner collects 1/6 of all transaction fees.


Methods


Is Authorized

Checks the if the provided address is authorized for the given permission.

bool IsAuthorized(Address address, byte permission);

Parameters

Type

Property

Description

Address

address

The address to check permissions for.

byte

permission

The permission to check authorization of. (1 - Create Pool, 2 - Trade, 3 - Provide, 4 - Set Permissions)

Returns

Type

Property

Description

bool

isAuthorized

Flag describing if the address is authorized or not.


Is Authorized - Multi

Checks the if the provided addresses are authorized for the given permission.

bool IsAuthorized(Address primary, Address secondary, byte permission);

Parameters

Type

Property

Description

Address

primary

The primary address to check permissions for.

Address

secondary

The secondary address to check permissions for.

bool

authorize

The permission to check authorizations for.

Returns

Type

Property

Description

bool

isAuthorized

Flag describing if both of the addresses are authorized or not.


Authorize

Allows permitted addresses to set an authorization for a provided address and permission.

🚧

Authorized Address Only

Only the market owner or addresses authorized to set permissions can call this method.

void Authorize(Address address, byte permission, bool authorize);

Parameters

Type

Property

Description

Address

address

The address to set the permission for.

byte

permission

The permission being set. See Permissions for list of available options.

bool

authorize

Flag describing if the address should be authorized or not.


Set Pending Ownership

Public method allowing the current contract owner to whitelist a new pending owner. The newly pending owner Claim Pending Ownership to accept ownership.

🚧

Market Owner Only

Only the address set as the market owner can call this method.

void SetPendingOwnership(Address pendingOwner);

Parameters

Type

Property

Description

Address

pendingOwner

The address to set as the new pending owner.


Claim Pending Ownership

Public method to allow the pending new owner to accept ownership replacing the current contract owner.

🚧

Pending Owner Only

Only the address set as the pending owner can call this method.

void ClaimPendingOwnership();

Collect Market Fees

Looks up a pool by the provided SRC token address and collects the specified amount of market fees (LP tokens). Collected fees from the pool are transferred to the current owner of the market.

See IOpdexLiquidityPool.GetBalance for retrieving the current amount of fees available for collection held by the market contract.

🚧

Market Owner Only

Only the address set as the market owner can call this method.

void CollectMarketFees(Address token, UInt256 amount);

Parameters

Type

Property

Description

Address

token

The SRC token address to lookup the liquidity pool by.

UInt256

amount

The amount of fees (LP tokens) to collect from the pool and transfer to the market owner.


Logs

Change Market Permission Log

Emitted when an addresses permissions change within a market.

Properties

Index

Type

Property

Description

:ballot-box-with-check:

Address

Address

The address affected by the permission change.

:black-square-button:

byte

Permission

The permission being modified.

:black-square-button:

bool

IsAuthorized

Flag determining if the address is authorized for the permission.


Set Pending Ownership Log

Emitted when a new address is set as the pending market owner.

Properties

Index

Type

Property

Description

:ballot-box-with-check:

Address

From

The current market owner's wallet address.

:ballot-box-with-check:

Address

To

The pending market owner's wallet address.


Claim Pending Ownership Log

Emitted when a pending address accepts ownership of the market.

Properties

Index

Type

Property

Description

:ballot-box-with-check:

Address

From

The current market owner's wallet address.

:ballot-box-with-check:

Address

To

The new market owner's wallet address.


References

OpdexMarket Smart Contract - Github

OpdexStandardMarket Smart Contract - Github

IOpdexStandardMarket Interface - Github


Did this page help you?