Dolomite Margin - Getters
Dolomite Margin has an extensive list of functions you can use to query the smart contract's state.
These functions are callable on instances of DolomiteMargin on each network Dolomite is deployed. See smart contract addresses to discover the address of DolomiteMargin on each network.
Getters for Accounts
getAccountPar
getAccountPar
Description:
Get the principal value for a particular account and market.
Parameters:
account
(Account.Info calldata
): The account to query, represented by anAccount.Info
struct.marketId
(uint256): The market to query.
Returns:
Types.Par memory
: A struct containing the principal value for the specified account and market.
Function Signature:
getAccountWei
getAccountWei
Description:
Get the token balance for a particular account and market.
Parameters:
account
(Account.Info calldata
): The account to query, represented by anAccount.Info
struct.marketId
(uint256): The market to query.
Returns:
Types.Wei memory
: A struct containing the token balance for the specified account and market.
Function Signature:
getAccountStatus
getAccountStatus
Description:
Get the status of an account (Normal, Liquidating, or Vaporizing).
Parameters:
account
(Account.Info calldata
): The account to query, represented by anAccount.Info
struct.
Returns:
Account.Status
: An enumeration value representing the account's status.
Function Signature:
getAccountMarketsWithBalances
getAccountMarketsWithBalances
Description:
Get a list of markets that have a non-zero balance for an account.
Parameters:
account
(Account.Info calldata
): The account to query, represented by anAccount.Info
struct.
Returns:
uint256[] memory
: An array of marketIds representing the markets with non-zero balances for the account.
Function Signature:
getAccountNumberOfMarketsWithBalances
getAccountNumberOfMarketsWithBalances
Description:
Get the number of markets that have a non-zero balance for an account.
Parameters:
account
(Account.Info calldata
): The account to query, represented by anAccount.Info
struct.
Returns:
uint256
: The number of markets with non-zero balances for the account.
Function Signature:
getAccountMarketWithBalanceAtIndex
getAccountMarketWithBalanceAtIndex
Description:
Get the marketId for an account's market with a non-zero balance at the given index.
Parameters:
account
(Account.Info calldata
): The account to query, represented by anAccount.Info
struct.index
(uint256): The index to query. Must be less than the value returned fromgetAccountNumberOfMarketsWithBalances
Returns:
uint256
: The marketId for the account's market with a non-zero balance at the specified index.
Function Signature:
getAccountNumberOfMarketsWithDebt
getAccountNumberOfMarketsWithDebt
Description:
Get the number of markets with which an account has a negative balance.
Parameters:
account
(Account.Info calldata
): The account to query, represented by anAccount.Info
struct.
Returns:
uint256
: The number of markets with which the account has a negative balance.
Function Signature:
getAccountValues
getAccountValues
Description:
Get the total supplied and total borrowed value of an account.
Parameters:
account
(Account.Info calldata
): The account to query, represented by anAccount.Info
struct.
Returns:
A tuple containing the following values:
Monetary.Value memory supplied
: A struct containing the supplied value of the account. Has 36 decimals of precision. Meaning, a value of123450000000000000000000000000000000000
is equal to$123.45
.Monetary.Value memory borrowed
: A struct containing the borrowed value of the account. Has 36 decimals of precision. Meaning, a value of123450000000000000000000000000000000000
is equal to$123.45
.
Function Signature:
getAdjustedAccountValues
getAdjustedAccountValues
Description:
Get the total supplied and total borrowed values of an account adjusted by the marginPremium
of each market. Supplied values are divided by (1 + marginPremium)
for each market, and borrowed values are multiplied by (1 + marginPremium)
for each market. Comparing these adjusted values gives the margin-ratio of the account, which will be compared to the global margin-ratio when determining if the account can be liquidated.
Parameters:
account
(Account.Info calldata
): The account to query, represented by anAccount.Info
struct.
Returns:
A tuple containing the following values:
Monetary.Value memory supplied
: A struct containing the supplied value of the account (adjusted formarginPremium
). Has 36 decimals of precision. Meaning, a value of123450000000000000000000000000000000000
is equal to$123.45
.Monetary.Value memory borrowed
: A struct containing the borrowed value of the account (adjusted formarginPremium
). Has 36 decimals of precision. Meaning, a value of123450000000000000000000000000000000000
is equal to$123.45
.
getAccountBalances
getAccountBalances
Description:
Get an account's summary for each market.
Parameters:
account
(Account.Info calldata
): The account to query, represented by anAccount.Info
struct.
Returns:
A tuple containing the following values:
uint[] memory
: An array of market IDs for each market.address[] memory
: An array of ERC20 token addresses for each market.Types.Par[] memory
: An array ofTypes.Par
structs representing the account's principal value for each market.Types.Wei[] memory
: An array ofTypes.Wei
structs representing the account's real (supplied or borrowed) number of tokens for each market.
Function Signature:
Getters for Markets
getMarketIdByTokenAddress
getMarketIdByTokenAddress
Get the ERC20 token address for a market.
Parameters
token
(address): The token to query.
Returns
uint256
: The token'smarketId
if the token is valid.
Function Signature
getMarketTokenAddress
getMarketTokenAddress
Get the ERC20 token address for a market.
Parameters
marketId
(uint256): The market to query.
Returns
address
: The token address associated with the givenmarketId
. Reverts if the providedmarketId
is invalid
Function Signature
getMarketIsClosing
getMarketIsClosing
Return true
if a particular market is in closing mode. Additional borrows cannot be taken from a market that is closing.
Parameters
marketId
(uint256): The market to query.
Returns
bool
:true
if the market is closing, otherwisefalse
.
Function Signature
getMarketPrice
getMarketPrice
Get the price of the token for a market.
Parameters
marketId
(uint256): The market to query.
Returns
Monetary.Price memory
: A struct containing the price of the token in USD. The number of decimals used to represent this number is36 - token.decimals
. Meaning, the USD price for USDC has30
decimals. This ensures that numbers are standardized to 36 decimals when representing monetary value.
Function Signature
getNumMarkets
getNumMarkets
Description:
Get the total number of markets.
Returns:
uint256
: The number of markets.
Function Signature:
getMarketTotalPar
getMarketTotalPar
Description:
Get the total principal amounts (borrowed and supplied) for a market.
Parameters:
marketId
(uint256): The market to query.
Returns:
Types.TotalPar memory
: A struct containing the total principal amounts (borrowed and supplied) for the specified market.
Function Signature:
getMarketCachedIndex
getMarketCachedIndex
Description:
Get the most recently cached interest index for a market. The Interest.Index
struct is used to convert between Par (scaled) and Wei (real) values.
Parameters:
marketId
(uint256): The market to query.
Returns:
Interest.Index memory
: A struct containing the most recent interest index for the specified market.
Function Signature:
getMarketCurrentIndex
getMarketCurrentIndex
Description:
Get the interest index for a market if it were to be updated right now at the current block.timestamp
.
Parameters:
marketId
(uint256): The market to query.
Returns:
Interest.Index memory
: A struct containing the estimated current interest index for the specified market.
Function Signature:
getMarketPriceOracle
getMarketPriceOracle
Description:
Get the price oracle address for a market.
Parameters:
marketId
(uint256): The market to query.
Returns:
IPriceOracle
: The address of the price oracle associated with the specified market.
Function Signature:
getMarketInterestSetter
getMarketInterestSetter
Description:
Get the interest-setter address for a market.
Parameters:
marketId
(uint256): The market to query.
Returns:
IInterestSetter
: The address of the interest-setter associated with the specified market.
Function Signature:
getMarketMarginPremium
getMarketMarginPremium
Description:
Get the margin premium for a market. A margin premium makes it so that any positions that include the market require a higher collateralization to avoid being liquidated.
Parameters:
marketId
(uint256): The market to query.
Returns:
Decimal.D256 memory
: A struct containing the margin premium for the specified market. Decimals are scaled to have 18 decimals of precision. Meaning a value of 1e16 (10000000000000000
) is equal to 0.01.
Function Signature:
getMarketSpreadPremium
getMarketSpreadPremium
Description:
Get the liquidation spread premium for a market. A spread premium makes it so that any liquidations that include the market have a higher spread than the global default.
Parameters:
marketId
(uint256): The market to query.
Returns:
Decimal.D256 memory
: A struct containing the spread premium for the specified market.
Function Signature:
getMarketMaxWei
getMarketMaxWei
Description:
Get the maximum supply Wei for a given market. A value of 0
denotes there being no maximum.
Parameters:
marketId
(uint256): The market to query.
Returns:
Types.Wei memory
: A struct containing the maximum supply Wei allowed for the specified market.
Function Signature:
getMarketInterestRate
getMarketInterestRate
Description:
Get the current borrower interest rate for a market.
Parameters:
marketId
(uint256): The market to query.
Returns:
Interest.Rate memory
: A struct containing the current interest rate for borrowers in the specified market. Interest rates are denoted as percentage-per-second. So a value of3,170,979,198
denotes an interest rate of ~10%, which is calculated using the following formula:
Function Signature:
getMarket
getMarket
Description:
Get basic information about a particular market.
Parameters:
marketId
(uint256): The market to query.
Returns:
Storage.Market memory
: A struct containing the current state of the specified market.
Function Signature:
getMarketWithInfo
getMarketWithInfo
Description:
Get comprehensive information about a particular market.
Parameters:
marketId
(uint256): The market to query.
Returns:
A tuple containing the values:
Storage.Market memory
: A struct containing the current state of the market.Interest.Index memory
: A struct containing the current estimated interest index.Monetary.Price memory
: A struct containing the current token price.Interest.Rate memory
: A struct containing the current market interest rate.
Function Signature:
Getters for Permissions
getIsLocalOperator
getIsLocalOperator
Description:
Return true
if a particular address is approved as an operator for an owner's accounts. Approved operators can act on the accounts of the owner as if it were the operator's own.
Parameters:
owner
(address
): The owner of the accounts.operator
(address
): The possible operator.
Returns:
bool
:true
if the operator is approved for the owner's accounts,false
otherwise.
Function Signature:
getIsGlobalOperator
getIsGlobalOperator
Description:
Return true
if a particular address is approved as a global operator. Such an address can act on any account as if it were the operator's own.
Parameters:
operator
(address
): The address to query.
Returns:
bool
:true
if the operator is a global operator,false
otherwise.
Function Signature:
getIsAutoTraderSpecial
getIsAutoTraderSpecial
Description:
Checks if the autoTrader
can only be invoked by a global operator.
Parameters:
autoTrader
(address
): The trader that should be checked for special call privileges.
Returns:
bool
:true
if theautoTrader
can only be invoked by a global operator,false
otherwise.
Function Signature:
owner
owner
Description:
Returns the address of the current owner of DolomiteMargin.
Returns:
address
: The address of the current owner.
Function Signature:
Getters for Risk Params
getMarginRatio
getMarginRatio
Description:
Get the global minimum margin-ratio that every position must maintain to prevent being liquidated.
Returns:
Decimal.D256 memory
: A struct representing the global margin-ratio. Has 18 decimals of precision, meaning a value of150000000000000000
equals 15%. The protocol uses this number as1 + margin-ratio
, so in the prior example, the returned result would mean115%
minimum collateralization (or86.9565%
LTV)
Function Signature:
getLiquidationSpread
getLiquidationSpread
Description:
Get the global liquidation spread. This is the spread between oracle prices that is used to incentivize the liquidation of risky positions.
Returns:
Decimal.D256 memory
: A struct representing the global liquidation spread. Has 18 decimals of precision. Meaning, a value of50000000000000000
is equal to 5%.
Function Signature:
getLiquidationSpreadForPair
getLiquidationSpreadForPair
Description:
Get the adjusted liquidation spread for a specific market pair. This is equal to the global liquidation spread multiplied by (1 + spreadPremium)
for each of the two markets.
Parameters:
heldMarketId
(uint256
): The market for which the account has collateral.owedMarketId
(uint256
): The market for which the account has borrowed tokens.
Returns:
Decimal.D256 memory
: A struct representing the adjusted liquidation spread for the given market pair. Has 18 decimals of precision. Meaning, a value of75000000000000000
is equal to 7.5%.
Function Signature:
getEarningsRate
getEarningsRate
Description:
Get the global earnings-rate variable that determines what percentage of the interest paid by borrowers gets passed on to suppliers. The remaining percentage is paid to the protocol owner.
Returns:
Decimal.D256 memory
: A struct representing the global earnings rate. Has 18 decimals of precision. Meaning, a value of850000000000000000
is 85% and 85% of the borrow rate is paid to suppliers.
Function Signature:
getMinBorrowedValue
getMinBorrowedValue
Description:
Get the global minimum-borrow value, which is the minimum value of any account's borrow position can have on DolomiteMargin.
Returns:
Monetary.Value memory
: A struct representing the global minimum borrow value. A value of0
means there is no minimum. Has 36 decimals of precision, meaning a value of100000000000000000000000000000000000000
denotes $100.
Function Signature:
getRiskParams
getRiskParams
Description:
Get all global risk parameters in a single struct.
Returns:
Storage.RiskParams memory
: A struct representing all global risk parameters.
Function Signature:
getRiskLimits
getRiskLimits
Description:
Get all global risk parameter limits in a single struct. These are the maximum limits at which the risk parameters can be set by the admin of DolomiteMargin. These values are immutable and cannot change after DolomiteMargin is initialized.
Returns:
Storage.RiskLimits memory
: A struct representing all global risk parameter limits.
Function Signature:
Last updated