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
Chain | Address |
---|---|
Arbitrum Sepolia | 0x426983E85b6530ada83c7099Ed52230Ee15C8D75 |
Base Sepolia | 0xB0b9f4627BDBcad1B9B2d240DA676750870e83A1 |
Base Mainnet | 0x25C77Ef7Acb8177c26C00918B7080aF59E8e7560 |
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
Name | Type | Description |
---|---|---|
productFee | FPUnsigned | default fee for the product |
account | address | account to open position for |
sender | address | sender of the transaction |
Return Values
Name | Type | Description |
---|---|---|
fee | FPUnsigned | fee total fee rate |
getDepositFee
Get deposit fee for a particular sender.
function getDepositFee(address sender) external view returns (FPUnsigned fee)
Since LP tokens are transferable, there's no point in allowing per- account discounts like we do for trade fees.
Parameters
Name | Type | Description |
---|---|---|
sender | address | sender of the transaction |
Return Values
Name | Type | Description |
---|---|---|
fee | FPUnsigned | total fee rate. Range |
getWithdrawFee
Get withdraw fee for a particular sender.
function getWithdrawFee(address sender) external view returns (FPUnsigned fee)
Since LP tokens are transferable, there's no point in allowing per- account discounts like we do for trade fees.
Parameters
Name | Type | Description |
---|---|---|
sender | address | sender of the transaction |
Return Values
Name | Type | Description |
---|---|---|
fee | FPUnsigned | total fee rate. Range |
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
Name | Type | Description |
---|---|---|
_account | address | Position owner who will receive a discount on their trade fees, whether calling DomFiPerp directly or through a manager. |
_discount | FPUnsigned | Their new discount. Must be <= 1 |
setDiscountsForSender
Set the fee discounts for a particular sender.
function setDiscountsForSender(address _sender, struct SenderFeeDiscounts _discounts) external
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The contract or EOA that will be calling DomFiVault and DomFiPerp. |
_discounts | struct SenderFeeDiscounts | Their new discounts. Must be <= 1. |
setDepositFee
Change depositFee
function setDepositFee(FPUnsigned _depositFee) external
Parameters
Name | Type | Description |
---|---|---|
_depositFee | FPUnsigned | New value of depositFee . Must be . |
setWithdrawFee
Change withdrawFee
function setWithdrawFee(FPUnsigned _withdrawFee) external
Parameters
Name | Type | Description |
---|---|---|
_withdrawFee | FPUnsigned | New value of withdrawFee . Must be . |
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
Name | Type | Description |
---|---|---|
tradeFeeDiscount | FPUnsigned | Fee discount for trades (increases and decreases). |
depositFeeDiscount | FPUnsigned | Fee discount for vault deposits. |
withdrawFeeDiscount | FPUnsigned | Fee discount for vault withdraws. |
struct SenderFeeDiscounts {
FPUnsigned tradeFeeDiscount;
FPUnsigned depositFeeDiscount;
FPUnsigned withdrawFeeDiscount;
}