Skip to content

Mlabs: Airdrop + database input file generation #68

Open
@samuelWilliams99

Description

@samuelWilliams99

Following the Sendings module created to verify Sendings onchain, this task is to generate the input files for the airdrop and database from the PrivateSale type defined below:

type Amount = Natural

-- Invariants
-- Σ percentages = 100%
-- Description : Represent Vesting Tranches (Time Sequential and contiguous)
newtype Tranches = Tranches (NonEmpty Tranche)

data Tranche 
  = Tranche
    { percentage :: Integer -- out of 10,000
    , duration :: Integer -- number of slots
    }

data PrivateSale
  = PrivateSale
    { start :: POSIXTime
    , tranches :: Tranches
    , assetClass :: AssetClass
    , investors :: NonEmpty PrivateInvestor
    }

data PrivateInvestor
  = PrivateInvestor
    { address :: Address
    , allocation :: Amount
    }

This task is the following:

  • Create a CLI command that takes a filepath
  • Decode the file at the path into a PrivateSale (using derived JSON instances), throwing a reasonable error on failure to parse (see Sendings)
  • Verify the commented requirement on Tranches (Sum of Tranche %'s must be 100% (10,000))
  • Generate the list of (NativeScript, Integer) pairs for how much of PrivateSale.assetClass to send to each script.
    • The Scripts are generated like so - For each investor, split the allocation according to the tranches, with unlock time starting at posixTimeToSlot PrivateSale.start + PrivateSale.tranches[0].duration, then adding the duration of each subsequent Tranche to the unlock time.
    • Use the NativeScript type defined in the database spec:
      data NativeScript = NativeScript 
        { pkh :: String 
        , unlockTime :: Integer 
        }
    • Example: Say we have tranches: [(50%, 100 slots), (25%, 100 slots), (25%, 200 slots)], with a start time equilalent to slot 1000. For a user with 10000 tokens, we would send 5000 to a script that unlocks at slot 1100, 2500 to one that unlocks at 1200, and 2500 to one that unlocks at 1400.
  • Using the above, generate the following files:

Create your branch and PR from mlabs/private-sale-staging

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions