Closed AurevoirXavier closed 10 months ago
Yeah, eventually equals to 500000000 * stakingRing / ringPool + 500000000 * stakingKton / ktonPool
. So there is no problem with the formula, but it is complicated and can be optimized.
def staking_to_power(staked_ring, staked_kton, ring_pool, kton_pool)
raise 'require ring_pool > 0' if ring_pool <= 0
power_of_ring = 500_000_000 * (staked_ring / ring_pool)
power_of_kton = kton_pool > 0 ? 500_000_000 * (staked_kton / kton_pool) : 0
power_of_ring + power_of_kton
end
https://github.com/darwinia-network/darwinia2.0-staking-ui/blame/8f9d88b4c874c36cedf140f0a288250507d3b293/src/utils/misc.ts#L12-L15
It makes things complicated.
$$ \left( \text{{stakingRing}} + \left( \text{{stakingKton}} \times \frac{{\text{{ringPool}}}}{{\text{{ktonPool}}}} \right) \right) \div \left( 2 \times \text{{ringPool}} \right) \times 10^9 $$
$$ \frac{{\text{{stakingRing}} + \left( \text{{stakingKton}} \times \frac{{\text{{ringPool}}}}{{\text{{ktonPool}}}} \right)}}{{2 \times \text{{ringPool}}}} \times 10^9 $$
$$ \left( \frac{{\text{{stakingRing}}}}{{2 \times \text{{ringPool}}}} + \frac{{\text{{stakingKton}} \times \frac{{\text{{ringPool}}}}{{\text{{ktonPool}}}}}}{{2 \times \text{{ringPool}}}} \right) \times 10^9 $$
$$ 10^9 \times \frac{{\text{{stakingRing}}}}{{2 \times \text{{ringPool}}}} + 10^9 \times \frac{{\text{{stakingKton}} \times \frac{{\text{{ringPool}}}}{{\text{{ktonPool}}}}}}{{2 \times \text{{ringPool}}}} $$
It should be https://github.com/darwinia-network/darwinia/blob/2f0941d6f2a896bac2900d7c3f2d17a46ca6948b/pallet/staking/src/lib.rs#L778-L802.