Aperture-Finance / uniswap-v3-automation-sdk

14 stars 7 forks source link

add xPoints to PointUserStatusResponseSchema #253

Closed tommyzhao451 closed 1 month ago

vhenwan commented 1 month ago

@tommyzhao451 What's the logic on backend?

https://github.com/Aperture-Finance/automation-backend/blob/e65499a9bfdd7966a9c61ffd3cb2665f2ebf7db0/src/handlers/pointUserStatus.ts#L87C1-L105C5

  return {
    userStatus: {
      userAddress: info.user_address,
      inviteCode: info.invite_code,
      points: info.points ?? 0,
      xBound: !!info.x_id,
      discordBound: !!info.discord_id,
      telegramBound: !!info.telegram_id,
      referer: info.referer,
      referredCount: (list?.length ?? 0) - (info.num_referrals_softnuked ?? 0),
      referralPoints: info.referral_points ?? 0,
      twitterFreeRaffleConsumed: info.twitter_free_raffle_consumed ?? false,
      rafflePointsConsumed: info.raffle_points_consumed ?? 0,
      canDrawDailyRaffle: canDrawDailyRaffle,
      hasCompletedOnChainActivityForPoints:
        hasTodayCompletedOnChainActivityForPoints,
      streak: getStreak(info.dates_active ?? BigInt(0), nowMoment),
    },
  };

just add xPoints: info.xPoints ?? 0, ?

tommyzhao451 commented 1 month ago

@tommyzhao451 What's the logic on backend?

https://github.com/Aperture-Finance/automation-backend/blob/e65499a9bfdd7966a9c61ffd3cb2665f2ebf7db0/src/handlers/pointUserStatus.ts#L87C1-L105C5

  return {
    userStatus: {
      ...
    },
  };

just add xPoints: info.xPoints ?? 0, ?

Logic in backend will be in 2 separate PRs. https://github.com/Aperture-Finance/automation-backend/pull/683/files xPoints: isXPointsUploaded(nowMoment) ? info.x_points : undefined, where isXPointsUploaded depends on a environment flag that we'll manually flip after we've run the script to upload xPoints.

The 2nd PR isn't drafted yet, but it'll read user_points.csv (posted in product channel https://app.slack.com/client/T032M7F555M/C041ZB5C9T7), retweets (https://docs.google.com/spreadsheets/d/1p6FXtZSNxjtIXpgV8JAYVX95hbyK27dIH_RLSbfRZK0/edit#gid=2103406110), and followers (not obtained yet); and also read allUserInfo, map userInfos by x_id order by x_bound_at ascending limit 1, and for each of the csv lines, add up the xPoints and write it to dynamo.

tommyzhao451 commented 1 month ago

Frontend needs to check whether xPoints exists and not undefined. if so, then it's done tabulating and frontend can display it. Even if it returns 0, it means that backend is done tabulating and we can display it on frontend.