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. OrderBookV1 instances) or accounts (e.g. trade contest winners).

Addresses

ChainAddress
Arbitrum Sepolia0x426983E85b6530ada83c7099Ed52230Ee15C8D75
Base Sepolia0xB0b9f4627BDBcad1B9B2d240DA676750870e83A1
Base Mainnet0x25C77Ef7Acb8177c26C00918B7080aF59E8e7560

Functions

initialize

function initialize(struct StorageInstance _app) external

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 SenderFeeDiscounts _discounts) external

Parameters

NameTypeDescription
_senderaddressThe contract or EOA that will be calling DomFiVault and DomFiPerp.
_discountsstruct 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.

tradeDiscountEnabled

function tradeDiscountEnabled() external view returns (bool)

depositDiscountEnabled

function depositDiscountEnabled() external view returns (bool)

withdrawDiscountEnabled

function withdrawDiscountEnabled() external view returns (bool)

senderFeeDiscounts

function senderFeeDiscounts(address _sender) external view returns (struct SenderFeeDiscounts)

tradeFeeDiscounts

function tradeFeeDiscounts(address _account) external view returns (FPUnsigned)

depositFee

function depositFee() external view returns (FPUnsigned)

withdrawFee

function withdrawFee() external view returns (FPUnsigned)

Events

EnableDiscounts

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

SetFeeDiscountsForSender

event SetFeeDiscountsForSender(address sender, struct SenderFeeDiscounts discounts)

SetTradeFeeDiscount

event SetTradeFeeDiscount(address account, FPUnsigned discounts)

SetDepositFee

event SetDepositFee(FPUnsigned depositFee)

SetWithdrawFee

event SetWithdrawFee(FPUnsigned withdrawFee)

SetFeeReferral

event SetFeeReferral(contract IFeeReferral feeReferral)

Errors

InvalidDepositFee

error InvalidDepositFee()

InvalidWithdrawFee

error InvalidWithdrawFee()

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;
}