Skip to main content

BinMargin.sol

BinMargin

struct BinMargin {
uint16 tradingFeeRate;
uint256 amount;
}

The BinMargin struct represents the margin information for an LP bin.

NameTypeDescription
tradingFeeRateuint16The trading fee rate associated with the LP bin
amountuint256The maker margin amount specified for the LP bin

BinMarginLib

The BinMarginLib library provides functions to operate on BinMargin structs.

TRADING_FEE_RATE_PRECISION

uint256 TRADING_FEE_RATE_PRECISION

tradingFee

function tradingFee(struct BinMargin self, uint16 _protocolFeeRate) internal pure returns (uint256)

Calculates the trading fee based on the margin amount and the trading fee rate.

  • Parameters:

    NameTypeDescription
    selfstruct BinMarginThe BinMargin struct
    _protocolFeeRateuint16The protocol fee rate for the market
  • Return Values:

    NameTypeDescription
    [0]uint256The trading fee amount

protocolFee

function protocolFee(struct BinMargin self, uint16 _protocolFeeRate) internal pure returns (uint256)

Calculates the protocol fee based on the margin amount and the trading fee rate.

  • Parameters:

    NameTypeDescription
    selfstruct BinMarginThe BinMargin struct
    _protocolFeeRateuint16The protocol fee rate for the market
  • Return Values:

    NameTypeDescription
    [0]uint256The protocol fee amount