Architecture
The K9 Finance DAO Farming architecture has 2 main parts:
FarmingFactory contract
FarmingInstance contract
and utilizes the Shibaswap v2 liquidity.
FarmingInstance contract
FarmingInstance contract represents the farming pool. Each farming pool on the platform is a separate smart-contract deployed by the FarmingFactory contract.
Deposit
Users can deposit their knBONE/BONE LP (received from Shibaswap) via "Stake" UI and deposit()
function. LPs other than mentioned in the farming pool are not accepted.
Withdraw
Users can withdraw their total deposited funds via withdraw()
. By doing so, users receive their LP tokens and the accumulated rewards.
Zap
This function allows depositing one of the token0
and token1
of the liquidity pair.
When users deposit via zap()
, the following steps are executed:
The entry fee is taken,
The received deposit is split according to the liquidity ratio of
token0/token1
on Shibaswap,One half is swapped to another token in order to provide liquidity,
Once the swapped amount is received, the
token0
andtoken1
amounts are used to provide liquidity,Once the liquidity provided and the LP tokens are received, these LP tokens are deposited into farming pool.
So, the zap()
function executes providing liquidity, which allows users to eliminate providing liquidity manually by themselves. Zapping fee is applied to cover the providing liquidity cost.
Unzap
Unzap()
function executes the opposite steps:
Yser selects the token to receive,
esKNINE + bonusToken (optional) reward is claimed,
LP tokens are withdrawn from the farming pool,
Liquidity is removed from the Shibaswap v2 liquidity pool,
token0
ortoken1
amount is swapped accordingly totoken1
ortoken0
(defined by the user's choice oftokenOut),
Once the swapped tokens received, the exit fee is taken,
The full
tokenOut
amount is transferred to the user's wallet.
Exit fee is applied to cover the removing liquidity cost.
claimRewardsAll
By calling this function user can claim all the accumulated rewards of a single farming pool. This includes:
Main reward received from stake, zap or both (whichever is present),
Accumulated bonus reward (if present).
claimRewards
This function allows claiming rewards from 'stake' or 'zap' separately. fromStake
value defines which reward is claimed:
FALSE
- zapping reward,TRUE
- staking reward.
The associated bonus reward is also claimed.
FarmingFactory contract
Farming factory contract is responsible for creating new farming pools that support Shibaswap liquidity pairs. Users can't interact with this contract.
Management
The administrators have the following access to manage the farming factory:
create/stop new farming pool,
create/stop bonus reward pool,
set the farming pool reward payout,
set zapping and unzapping fees,
manage the factory parameters.
Last updated