Token_0: Base token (e.g. sSHD for the pair sSHD/sSCRT) Token_1: Quote token (e.g. sSCRT for the pair sSHD/sSCRT) Token_0_Pool: Total amount in the token pool of the base token Token_1_Pool: Total amount in the token pool of the quote token Slippage: Fraction as a decimal number (e.g. 0.02 for 2% slippage)
Amount_In: Amount of Token_0 Amount_Out: Amount of Token_1 Target_Token: Token_1 Source_Token: Token_0 Target_Token_Pool: Total amount in the token pool of the Target_Token Source_Token_Pool: Total amount in the token pool of the Source_Token
Amount_In: Amount of Token_1 Amount_Out: Amount of Token_0 Target_Token: Token_0 Source_Token: Token_1 Target_Token_Pool: Total amount in the token pool of the Target_Token Source_Token_Pool: Total amount in the token pool of the Source_Token
Fee = Amount_In * Fee.Nom / Fee.Denom
Amount_Out = Target_Token_Pool * (Amount_In - Fee) / (Source_Token_Pool + Amount_In - Fee)
Price = Amount_Out / (Amount_In - Fee)
Deposit_0: The amount of deposited Token_0 Deposit_1: The amount of deposited Token_1 Slippage: Fraction as a decimal number (e.g. 0.02 for 2%) Slippage_amount: Accepting slippage LP Token: Liquidity token Withdraw_amount: Amount of LP Token to remove from liquidity Slippage: Fraction as a decimal number (e.g. 0.02 for 2%) Pool_withdraw_0: Amount of Token_0 to receive Pool_withdraw_1: Amount of Token_1 to receive Min: Function which returns the minimum of the two input
IF Slippage * Deposit_0 / Deposit_1 > Token_0_pool / Token_1_pool
THEN Slippage_amount = 1 - Slippage
OTHERWISE Thow an exception and don't allow to proceed.
IF LP balance is 0
THEN sqrt(Deposit_0 * Deposit_1)
OTHERWISE min(Deposit_0 * LP_token_balance / Token_0_pool, Deposit_1 * LP_token_balance / Token_1_pool)
Pool_withdraw_0 = Token_0_pool * Withdraw_amount / LP_token_balance
Pool_withdraw_1 = Token_1_pool * Withdraw_amount / LP_token_balance
Current_timestamp: the timestamp of the block in milliseconds where the claim reward or adding new staker is called.
Last_timestamp: the last stored timestamp of the block in milliseconds where claim reward method was called in staking contract.
Staker_percentage: % from whole total staking amount belong to staker
Staker: Person who is staking LP token
Stake_amount: Amount of LP token which belongs to staker
Total_staking_amount: total amount of lp token of all stakers
Seconds: 24 * 60 * 60 * 1000 = 86,400,000
Daily_reward_amount: Staking amount which is constant and set by admin
Cons: Constant value used for calculating Staker_percentage, which is 100
Staker_percentage = Stake_amount * Cons / Total_staking_amount
IF last_timestamp < current_timestamp
THEN 0
OTHERWISE Daily_reward_amount * Staker_percentage * (current_timestamp - last_timestamp) / (Seconds * Cons)