Skip to main content

FundingManager

FundingManager

Funding manager for Domination Finance perpetual exchange

Computes a “funding rate” for products based on open interest, stores an integral, and updates it whenever a position is touched. Also integrates a flat base interest rate. Given a position with a historical snapshot of cumulative funding and interest, the current stored integrals allow DomFiPerp to compute how much the owner owes (or receives).

These rates are intended to incentivize even long/short orders (minimizing LP exposure) and collect fees for LPs.

Addresses

ChainAddress
Arbitrum Sepolia0x1ecd842199dA19B8673c40dDcC0799491f1D51fA

Functions

constructor

constructor() public

updateFunding

Update cumulative sums with the integral of the current funding and interest rates since last update.

function updateFunding(bytes32 _productId) external
Dev note

Called whenever a product's funding and interest rates change. Only callable by DomFiPerp

Parameters

NameTypeDescription
_productIdbytes32product to update

getFundingRate

get funding rate for the given product

function getFundingRate(bytes32 _productId) public view returns (FPSigned fundingRate)

Parameters

NameTypeDescription
_productIdbytes32product to get funding rate for

Return Values

NameTypeDescription
fundingRateFPSigned% per year charged for long and paid to short orders

getInterestRate

get interest rate for the given product

function getInterestRate(bytes32 _productId) public view returns (FPUnsigned interestRate)

Parameters

NameTypeDescription
_productIdbytes32product to get interest rate for

Return Values

NameTypeDescription
interestRateFPUnsignedflat % per year charged to both long and short orders

getCumulativeFunding

Get cumulative funding, as a percent, for a product since it was added. Compare this to a previous cumulative funding value to see the net funding accrued between the two measurements.

function getCumulativeFunding(bytes32 _productId) external view returns (FPSigned)

Parameters

NameTypeDescription
_productIdbytes32product in question

Return Values

NameTypeDescription
[0]FPSigned

getCumulativeInterest

Get cumulative interest, as a percent, for a product since it was added. Compare this to a previous cumulative interest value to see the interest accrued between the two measurements. Note that unlike funding, interest rate is always positive; cumulative interest will never decrease.

function getCumulativeInterest(bytes32 _productId) external view returns (FPUnsigned)

Parameters

NameTypeDescription
_productIdbytes32product in question

Return Values

NameTypeDescription
[0]FPUnsigned

setDomFiPerp

function setDomFiPerp(contract IDomFiPerp _domFiPerp) external

setMinFundingMultiplier

function setMinFundingMultiplier(FPUnsigned _minFundingMultiplier) external

setFundingMultiplier

function setFundingMultiplier(bytes32 _productId, FPUnsigned _fundingMultiplier) external

setInterestRate

function setInterestRate(bytes32 _productId, FPUnsigned _interestRate) external

setMaxInterestRate

function setMaxInterestRate(FPUnsigned _maxInterestRate) external

setMaxFundingRate

function setMaxFundingRate(FPUnsigned _maxFundingRate) external

setOwner

function setOwner(address _owner) external

Events

FundingUpdated

event FundingUpdated(
bytes32 productId,
FPSigned fundingRate,
FPSigned fundingChange,
FPSigned cumulativeFunding,
FPUnsigned interestRate,
FPUnsigned interestChange,
FPUnsigned cumulativeBaseInterests
)

DomFiPerpSet

event DomFiPerpSet(contract IDomFiPerp domFiPerp)

MinFundingMultiplierSet

event MinFundingMultiplierSet(FPUnsigned minFundingMultiplier)

FundingMultiplierSet

event FundingMultiplierSet(bytes32 productId, FPUnsigned fundingMultiplier)

BaseInterestRateSet

event BaseInterestRateSet(bytes32 productId, FPUnsigned baseInterestRate)

MaxFundingRateSet

event MaxFundingRateSet(FPUnsigned maxFundingRate)

MaxInterestRateSet

event MaxInterestRateSet(FPUnsigned maxInterestRate)

UpdateOwner

event UpdateOwner(address owner)

Modifiers

onlyOwner

modifier onlyOwner()

Errors

PerpOnly

error PerpOnly()

OwnerOnly

error OwnerOnly()

Variables

domFiPerp

owner

maxFundingRate

maxInterestRate

minFundingMultiplier

fundingMultipliers

lastUpdateTimes

baseInterestRates