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
Chain | Address |
---|---|
Arbitrum Sepolia | 0x27afF823B1565EBB1D9Ca6a3ce0B39BC683ef19e |
Zircuit | 0xDa22a677F8331126295125B345a6A369C174Fe55 |
Functions
constructor
constructor(contract IFeeReferral _feeReferral) public
setFeeReferral
Update the saved FeeReferral contract
function setFeeReferral(contract IFeeReferral _feeReferral) external
Callable by owner only
Parameters
Name | Type | Description |
---|---|---|
_feeReferral | contract IFeeReferral | Address 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
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 FeeCalculator.SenderFeeDiscounts _discounts) external
Parameters
Name | Type | Description |
---|---|---|
_sender | address | The contract or EOA that will be calling DomFiVault and DomFiPerp. |
_discounts | struct FeeCalculator.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 . |
transferOwnership
function transferOwnership(address newOwner) public
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 . Default 0.1%.
withdrawFee
Fee for vault withdraws and redeems, before discounts. Range . 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
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;
}