Skip to main content

FeeCalculator

FeeCalculator

Fee calculator for Domination Finance perpetual exchange

Computes fees for trades, deposits, and withdrawals. Pulls info from FeeReferral to grant discounts to individual senders (e.g. OrderBookV2 instances) or accounts (e.g. trade contest winners).

Addresses

ChainAddress
Arbitrum Sepolia0x27afF823B1565EBB1D9Ca6a3ce0B39BC683ef19e

Functions

constructor

constructor(contract IFeeReferral _feeReferral) public

setFeeReferral

Update the saved FeeReferral contract

function setFeeReferral(contract IFeeReferral _feeReferral) external
Dev note

Callable by owner only

Parameters

NameTypeDescription
_feeReferralcontract IFeeReferralAddress of the new FeeReferral

getTradeFee

Get trade fee for a particular account, sender, and product.

function getTradeFee(
FPUnsigned productFee,
address account,
address sender
) external view returns (
FPUnsigned fee
)

Parameters

NameTypeDescription
productFeeFPUnsigneddefault fee for the product
accountaddressaccount to open position for
senderaddresssender of the transaction

Return Values

NameTypeDescription
feeFPUnsignedfee total fee rate

getDepositFee

Get deposit fee for a particular sender.

function getDepositFee(address sender) external view returns (FPUnsigned fee)
Dev note

Since LP tokens are transferable, there's no point in allowing per- account discounts like we do for trade fees.

Parameters

NameTypeDescription
senderaddresssender of the transaction

Return Values

NameTypeDescription
feeFPUnsignedtotal fee rate. Range [0,1)[0, 1)

getWithdrawFee

Get withdraw fee for a particular sender.

function getWithdrawFee(address sender) external view returns (FPUnsigned fee)
Dev note

Since LP tokens are transferable, there's no point in allowing per- account discounts like we do for trade fees.

Parameters

NameTypeDescription
senderaddresssender of the transaction

Return Values

NameTypeDescription
feeFPUnsignedtotal fee rate. Range [0,1)[0, 1)

enableDiscounts

Toggle tradeDiscountEnabled, depositDiscountEnabled, and withdrawDiscountEnabled.

function enableDiscounts(
bool _tradeDiscountEnabled,
bool _depositDiscountEnabled,
bool _withdrawDiscountEnabled
) external

setTradeFeeDiscount

Set the trade fee discount for a particular account.

function setTradeFeeDiscount(address _account, FPUnsigned _discount) external

Parameters

NameTypeDescription
_accountaddressPosition owner who will receive a discount on their trade fees, whether calling DomFiPerp directly or through a manager.
_discountFPUnsignedTheir new discount. Must be <= 1

setDiscountsForSender

Set the fee discounts for a particular sender.

function setDiscountsForSender(address _sender, struct FeeCalculator.SenderFeeDiscounts _discounts) external

Parameters

NameTypeDescription
_senderaddressThe contract or EOA that will be calling DomFiVault and DomFiPerp.
_discountsstruct FeeCalculator.SenderFeeDiscountsTheir new discounts. Must be <= 1.

setDepositFee

Change depositFee

function setDepositFee(FPUnsigned _depositFee) external

Parameters

NameTypeDescription
_depositFeeFPUnsignedNew value of depositFee. Must be 1\le 1.

setWithdrawFee

Change withdrawFee

function setWithdrawFee(FPUnsigned _withdrawFee) external

Parameters

NameTypeDescription
_withdrawFeeFPUnsignedNew value of withdrawFee. Must be 1\le 1.

transferOwnership

function transferOwnership(address newOwner) public
Dev note

Starts the ownership transfer of the contract to a new account. Replaces the pending transfer if there is one. Can only be called by the current owner.

Events

EnableDiscounts

event EnableDiscounts(bool tradeDiscountEnabled, bool depositDiscountEnabled, bool withdrawDiscountEnabled)

SetTradeFeeDiscount

event SetTradeFeeDiscount(address account, FPUnsigned discounts)

SetFeeDiscountsForSender

event SetFeeDiscountsForSender(address sender, struct FeeCalculator.SenderFeeDiscounts discounts)

SetDepositFee

event SetDepositFee(FPUnsigned depositFee)

SetWithdrawFee

event SetWithdrawFee(FPUnsigned withdrawFee)

SetFeeReferral

event SetFeeReferral(contract IFeeReferral feeReferral)

Errors

InvalidDepositFee

error InvalidDepositFee()

InvalidWithdrawFee

error InvalidWithdrawFee()

Variables

feeReferral

tradeDiscountEnabled

If true, consult tradeFeeDiscounts and senderFeeDiscounts when computing trade fees. Disabled by default.

depositDiscountEnabled

If true, consult senderFeeDiscounts when computing vault deposit fees. Disabled by default.

withdrawDiscountEnabled

If true, consult senderFeeDiscounts when computing vault withdraw fees. Disabled by default.

senderFeeDiscounts

Grants a reduction in various fees to transaction senders: users, OrderBookV2, custom contracts, etc. See SenderFeeDiscounts.

tradeFeeDiscounts

Grants a trade fee reduction to position owners, if enabled by tradeDiscountEnabled.

depositFee

Fee for vault deposits and mints, before discounts. Range [0,1)[0,1). Default 0.1%.

withdrawFee

Fee for vault withdraws and redeems, before discounts. Range [0,1)[0,1). Default 0.1%.

Types

SenderFeeDiscounts

A set of fee discounts for a particular caller of the exchange contracts. Additive with any discounts granted to a position owner, or to referral discounts.

Fields

NameTypeDescription
tradeFeeDiscountFPUnsignedFee discount for trades (increases and decreases). [0,1][0,1]
depositFeeDiscountFPUnsignedFee discount for vault deposits. [0,1][0,1]
withdrawFeeDiscountFPUnsignedFee discount for vault withdraws. [0,1][0,1]
struct SenderFeeDiscounts {
FPUnsigned tradeFeeDiscount;
FPUnsigned depositFeeDiscount;
FPUnsigned withdrawFeeDiscount;
}