Farm
This contract handles all business logic related to Point
calculation.
rescueERC20
Allows the owner to rescue tokens stuck in the contract
Parameters:
tokenAddress
address
Address of the token to be rescued.
to
address
Address that will receive the rescued tokens.
amount
uint
Amount of tokens to be rescued.
setPool
Sets the Gauge contract for a given pool. It associates a specified Pair (pool) with its corresponding Gauge contract. It updates the Gauge contract address, last reserve, last update time, reward rate, and weight for the pool. This function ensures that the Farm contract is aware of the parameters managed by the Gauge contract, allowing for accurate reward calculations and maintaining up-to-date information about the pool's state.
Parameters:
poolId
address
Address of the Pair contract (pool).
gauge
address
Address of the Gauge contract.
setPoolRewardRate
Updates a pool's rewardRate
and weight
triggered by the pool's Gauge
contract.
Parameters:
poolId
address
Address of the Pair contract (pool).
rewardRate
uint
New rewardRate.
weight
uint
New weight.
setGlobalRewardRate
Updates the governance token pool's rewardRate
and weight
.
Parameters:
rewardRate
uint
New rewardRate.
weight
uint
New weight.
getCurrentPoolReserve
Retrieves the present reserve amount for a specified pool. The reserve undergoes linear growth over time, following the formula:
reserve = timeElapse * rewardRate + lastReserve
.
Parameters:
poolId
address
Address of the Pair contract (pool).
Return Values:
reserve
uint
Current reserve amount of the pool.
getCurrentGlobalReserve
Similar to getCurrentPoolReserve
, this function fetches the current reserve amount specifically for the governance token pool. The global reserve undergoes linear growth over time, following the formula:
globalReserve = timeElapse * globalRewardRate + lastGlobalReserve
.
Return Values:
reserve
uint
Current reserve amount of the governance token pool.
_calcRewardAmount
This function calculates the reward amount by executing conversion calculations for both localPoint to point and point to $DYSN. The formula is articulated as:
reward = reserve * (1 - 2^(-amount/w))
.
For localPoint to point conversion, the formula becomes:
point = pointReserve * (1 - 2^(-localPoint/w))
.Likewise, for point to $DYSN conversion, the expression is:
$DYSN = dysonReserve * (1 - 2^(-point/w))
.The parameter
w
plays a crucial role in determining the sensitivity of the Point exchange rate.
Parameters:
_reserve
uint
Reserve amount.
_amount
uint
LocalSP or GlobalSP amount.
_w
uint
Weight
Return Values:
reward
uint
Amount of governance token received.
grantSP
Enhance the user's localPoint by the bonus ratio if the user holds voting power through sGov token deposits. The formula used is:
localPoint = localPoint * (bonus + 1e18) / 1e18;
. This boosts the localPoint based on the user's voting power, with the potential for a maximum2.5x
boost, given the maximum bonus of1.5e18
obtained from the Gauge contract.Convert the user's localPoint to Points by calling the
_calcRewardAmount
function.
Parameters:
to
address
User's address.
amount
uint
Amount of localSP.
swap
This function allows a third party to convert a user's Points to the governance token ($DYSN) following these key rules:
Accessibility: Any third party can trigger this function.
Cooldown Requirement: Users can only perform a swap after their cooldown period ends, determined by their generation in the referral system.
Referral System Registration: To initiate a swap, users must be registered in the referral system. Upon swapping, the user's referrer receives 1/3 of the user's Points.
The function carries out the following tasks:
Point to $DYSN Conversion: It uses the
_calcRewardAmount
function to convert the user's Points to $DYSN, minting the corresponding $DYSN tokens to the user while resetting their Points to zero.Referrer Bonus: An extra 1/3 of the swapped Points is minted and awarded to the user's referrer.
Global Pool Update: The global pool's reserve is updated to maintain an accurate representation of the overall system state.
Parameters:
user
address
User's address.
Return Values:
amountOut
uint
Amount of governance token received.
Last updated