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
.
For further insights into how the reward pool operates, please refer to the Token Incentive section in our white paper.
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
.
For additional details on the reward pool mechanics, kindly refer to the Token Incentive section in our white paper.
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.
This dual-purpose function provides flexibility in determining rewards across different token conversions within the system. For additional details on the reward pool mechanics, kindly refer to the Point Calculation section in our white paper.
Parameters:
_reserve
uint
Reserve amount.
_amount
uint
LocalSP or GlobalSP amount.
_w
uint
Weight
Return Values:
reward
uint
Amount of governance token received.
grantSP
The grantSP
function is triggered by the _grantSP function in the Pair contract to reward users with Points upon dual investment deposit. The interim value, known as localPoint
, is computed in the Pair contract and passed as the amount
parameter to this function. Here, the user's localPoint undergoes multiplication by a bonus ratio if the user also stakes sGov tokens (sDYSON tokens) in the pool's Gauge contract. And finally, convert the localPoint to Point. The steps are as follows:
Retrieve the
bonus ratio
by invoking thebonus
function in the pool's Gauge contract, where the maximum ratio returned is 1.5e18. For detailed bonus calculations, refer to the bonus section in the Gauge contract.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.
For additional details on the reward pool mechanics, kindly refer to the Point Calculation section in our white paper.
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