sora-xor / sora-card

Designing a Better World Through Decentralized Technologies
4 stars 1 forks source link

[Tech]: XOR calculation for free KYC. #60

Closed Tieumsan closed 1 year ago

Tieumsan commented 1 year ago

Problem Statement

The business requirement for users to have 2 free KYC attempts is that they should be cumulated across the different balances. It seems that this requirement is not correctly implemented in the mobile wallets. We need to fix that.

Definition of Done

Incorporate the following steps when computing the necessary amount:

  1. Total balance of XOR returned from system.account (refer to https://soramitsu.atlassian.net/browse/SN-1468).
  2. Value from referrals.referrerBalances for the amount bonded in the referral program.
  3. Amount locked in XYK pools, which has already been computed within the applications following the procedures outlined in https://docs.google.com/document/d/1dExhgGX0PfqFQFoUC7pS3TJIQ2g1J0WyteCHog5b48c/edit#bookmark=id.i0bzjak08e7g.
  4. Include the amount locked in the Demeter one-sided staking pools. Demeter encompasses two types of staking: two-sided staking and one-sided staking. For the former, users are required to pool funds in Pool XYK before staking on Demeter, while the latter doesn't necessitate any preliminary locks. Consequently, calculations for two-sided staking should be omitted since it relies on the amount from (3) and computing it would lead to incorrect duplication. However, one-sided staking must be computed. To calculate the latter, execute a query on demeterFarmingPlatform.userInfos, filter the returned values so that only XOR objects are considered, and ensure that isFarm is set to false (indicating single-sided staking).

Sub-tasks

2bogd commented 1 year ago

@bgodlin Total balance of XOR is different in main Sora app on ios and web: on ios total = free + reserved on web total = free + reserved + bonded need to clarify this moment and make it same on all platforms

bgodlin commented 1 year ago

@bgodlin Total balance of XOR is different in main Sora app on ios and web: on ios total = free + reserved on web total = free + reserved + bonded need to clarify this moment and make it same on all platforms

Total refers to the sum of all balances obtained from the data object within the system.account chain state call response

Tieumsan commented 1 year ago

@bgodlin total = freeBalance + nativeStaking + liquidityPool

cc. @ra9mls

bgodlin commented 1 year ago

@BenoXYZ Kindly take note that only the previously aforementioned balances are considered (neither referral program bonded balances nor single-sided Demeter staking are encompassed). If you believe these should be taken into the consideration, I encourage you to let us know. This will allow us to either revise the requirements or create a new task based on your feedback.

arvifox commented 1 year ago

system.account storage: total = free + reserved + bonded

BenoXYZ commented 1 year ago

@bgodlin please include referral program bonded and single-sided Demeter staking

bgodlin commented 1 year ago

@bgodlin please include referral program bonded and single-sided Demeter staking

Derived from the cited comment, modifications were made to the requirements @arvifox @2bogd @RustemYuzlibaev @Tieumsan