# Config

The config contract sets key exchange parameters.

## Contract

{% code overflow="wrap" %}

```solidity
/// @notice For maker types that requires mitigation of oracle front-running, order must comes from a gateway that will execute the order in a 2-step process with a delay that's longer than `orderDelaySeconds`
function getOrderDelaySeconds() external view returns (uint256) {
    return _getConfigStorage().orderDelaySeconds;
}

/// @notice Query max order validity duration
function getMaxOrderValidDuration() external view returns (uint256) {
    return _getConfigStorage().maxOrderValidDuration;
}

/// @notice Query max relayer fee. Denominated in collateral token.
function getMaxRelayFee() external view returns (uint256) {
    return _getConfigStorage().maxRelayFee;
}

/// @notice Query the margin ratio needed to open a position.
function getInitialMarginRatio(uint256 marketId) external view returns (uint256) {
    uint256 mRatio = _getConfigStorage().initialMarginRatioMap[marketId];
    if (mRatio == 0) {
        return 1 ether; // 100%
    }
    return mRatio;
}

/// @notice Query the margin ratio required to prevent liquidation.
function getMaintenanceMarginRatio(uint256 marketId) external view returns (uint256) {
    uint256 mRatio = _getConfigStorage().maintenanceMarginRatioMap[marketId];
    if (mRatio == 0) {
        return 1 ether; // 100%
    }
    return mRatio;
}

/// @notice Query what percentage of the liquidation penalty the liquidator can receive.
function getLiquidationFeeRatio(uint256 marketId) external view returns (uint256) {
    uint256 feeRatio = _getConfigStorage().liquidationFeeRatioMap[marketId];
    return feeRatio;
}

/// @notice Query what proportion of the liquidated position may charged as penalty.
function getLiquidationPenaltyRatio(uint256 marketId) external view returns (uint256) {
    uint256 penaltyRatio = _getConfigStorage().liquidationPenaltyRatioMap[marketId];
    return penaltyRatio;
}

/// @notice Query the borrowing fee rate when utilization ratio is 100% (for all borrowing fee receivers).
function getMaxBorrowingFeeRate(uint256 marketId) external view returns (uint256, uint256) {
    return IBorrowingFee(getAddressManager().getBorrowingFee()).getMaxBorrowingFeeRate(marketId);
}

/// @notice Query Pyth's price feed id for the given market.
function getPriceFeedId(uint256 marketId) external view returns (bytes32) {
    return _getConfigStorage().marketMap[marketId];
}

/// @notice Query whether a maker can use the vault callback function and receive borrowing fees.
function isWhitelistedMaker(uint256 marketId, address trader) external view returns (bool) {
    return _getConfigStorage().whitelistedMakerMap[marketId][trader];
}

/// @notice Query the global maximum amount of deposits allowed.
function getDepositCap() external view returns (uint256) {
    return _getConfigStorage().depositCap;
}

/// #notice Query the price band ratio.
function getPriceBandRatio(uint256 marketId) external view returns (uint256) {
    return _getConfigStorage().priceBandRatioMap[marketId];
}
```

{% endcode %}

## `fundingConfig`

Query market funding config for funding factor and `basePool` address.

{% code overflow="wrap" %}

```solidity
struct FundingConfig {
    uint256 fundingFactor;
    uint256 fundingExponentFactor;
    address basePool;
}

function getFundingConfig(
    uint256 marketId
)
returns (
    FundingConfig memory
)
```

{% endcode %}


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.nekodex.org/nekodex-playground/docs-for-devs/contracts/config.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
