Skip to content

Feat: update credits logic #3

Description

@sirpy

Motivation

Match backend logic to the new operator vault

Details

Always make sure:

  • to record the history of all credits per user with their txhash.
  • to use depositForWithId when reacting to G$ deposit events (stream events or regular transfer)
  • for monthly stream bonus or user requested stream bonus use "stream"+timestamp as id for depositForWithId
  • deposit value is amount of G$ deposited/streamed so far multiplied by G$ price in reserve = USDC value to deposit.

Verify and add the following logic:

  1. On the celogd vault smart contract enforce minimum first deposit of 1$ worth of G$s (query reserve smart contract for G$ price).
  2. on celogd vault enforce minimum of 1$ worth of G$ a month stream flow speed
  3. add in antseedvault a method depositForWithId that prevents duplicate depositForWithId based on the id.
  4. on backend have an endpoint where user can notify backend of a deposit/stream on celo. the endpoint should use the depositForWithId for deposits. id should be the txhash+logindex.
  5. backend should check all deposit/stream events on celo every 1 minute via worker defined cron or specific wallet events when above endpoint is triggered with a specific wallet address
  6. for deposits give user his credits+10% bonus immediately, in case the deposit method fails (usually because of under the minimum first deposit or above total buyer vault balance), then record in user record the credits we owe him.
    make sure deposit value matches the event G$ value in $s. use the reserve price.
  7. for streams bonus (20%) is paid after a month or if stream has stopped/updated. implement the following bonus logic payment
    • a cron that runs once a day and iterates over records of user streams that have last been paid over a month ago.
    • when a stream has stopped/updated then credit the user his relative bonus amount to the time the stream was active out of a timespan of a month.
    • record for user if stream is active or not and when last bonus for stream was paid.
  8. implement an endpoint where user can request outstanding credit balance for both credit that failed to deposit or any outstanding streaming bonus. make sure to record the history of all credits per user with their txhash.
  9. implement an endpoint where user can request to withdraw his credits. make sure user can't withdraw the bonus part, only the value he deposited.
  10. implement an endpoint where user can request to close/unlock a channel

Metadata

Metadata

Assignees

Labels

No labels
No labels

Type

No type

Fields

No fields configured for issues without a type.

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions