Skip to content

Latest commit

 

History

History
89 lines (81 loc) · 3.3 KB

NOTES.md

File metadata and controls

89 lines (81 loc) · 3.3 KB

Asteria Lab NOTES

Backend off chain database / api

  • Real Time calculation for VGC
  • Claims 1x a week
  • Rarity
  • Transactions

Business Workflow

  • Someone checks claimable balance PER TOKEN
    • Calculate VGC for 1 week intervals
    • Needs rarity for weighting yield
    • Needs "COMPLETE" ClaimTrainsactionLineItem summation
    • Needs timestamp for launch of new VGC curve
    • Formula something along the lines of
      • VGC yield per second since launch of workflow MINUS ClaimTransactionLineItem summation
  • Someone can claim multiple tokens in one transaction
    • Since off chain, must perform ownership check per token
    • 24 hour check for only one claim a day
    • Build transaction and sign it on the backend. Send claim object and sig to front end
    • Promise chain:
      • Create pending ClaimTransaction with ClaimTransactionLineItem
      • Sign ClaimTransaction data
      • Send ClaimTransaction data and signed data to front end
      • send to blockchain
        HAPPY PATH:
        • listen to blockchain event for transferring of tokens
        • mark txn as complete
General Todo items
  • VGC yield will be calculated in real time for WEEK long increments.

Data Models

  • StakeEvents table
    • id uuid
    • tokenContractAddress string
    • wallet string
    • tokenId int
    • status Enum STAKE_STATUS
    • stakedAt now()
  • Token table
    • id uuid
    • contractAddress string
    • currentOwner string
    • tokenId int
    • rarity float
  • ClaimTransaction table
    • id bigint
    • wallet string
    • status Enum STATUS
    • operation Enum OPERATION
    • amount decimal(36,18)
    • createdAt now()
    • updatedAt Timestamp
  • ClaimTransactionLineItem table
    • id bigint
    • transactionId bigint
    • tokenId int
    • amount decimal(36, 18)
  • Enum STATUS
    • PENDING
    • COMPLETE
    • FAILED
    • TIMEOUT
  • Enum OPERATION
    • NONE
    • CREDIT
    • DEBIT
  • Enum STAKE_STATUS
    • STAKED
    • UNSTAKED

API

  • POST /claim_transaction
    • Creates ClaimTransaction and child ClaimTransactionLineItem records
  • GET /tokens/:address
    • At the address level.
    • Also retrieves and returns token metadata (might as well do this all in one call)

Events

  • Listen for Stake/Unstake
  • Transfer token success

Process for adding to the data model

To add a new data model to the backend:

  1. Go to the Database package, create a DTO, model, and mappers (probably won't need validators in this case since it's only going to be outbound)
  2. Create an entity with sequelize, follow the paradigm in ListingEntity.ts, add it to InitializeEntities.ts and ensure to add a call to sync at the end of that exported function as well. You shouldn't have to worry about relationships, I imagine. Maybe you will, those are established in that file as well
    You can then add a controller and utilities to @roo/controllers interacting with that model following the paradigm in the other controllers. Then build and connect that to @roo/webserver like the others are. I added guidance on how building these subpackages works with lerna in the readme