Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Mlabs: Airdrop + database input file generation #68

Open
4 of 7 tasks
samuelWilliams99 opened this issue Jul 11, 2022 · 2 comments
Open
4 of 7 tasks

Mlabs: Airdrop + database input file generation #68

samuelWilliams99 opened this issue Jul 11, 2022 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@samuelWilliams99
Copy link
Contributor

samuelWilliams99 commented Jul 11, 2022

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

@samuelWilliams99 samuelWilliams99 added the enhancement New feature or request label Jul 11, 2022
@Luis-omega
Copy link

Should I be worried about the sequence of PrivateInvestors ?

For example, if we have :

[PrivateInvestor 2 23 , PrivateInvestor 3 14 , PrivateInvestor 2 99]

With the described approach the PrivateInvestor with address 2 would pay its part for every currency of it in the list, is this intended or should I reject such a list? If this is intended, should I merge all the occurrences or just leave them as is (this would impact the Airdrop table output)?

@samuelWilliams99
Copy link
Contributor Author

Let's merge, probably as a first pass to have them unique by address. You could even convert it to a Map Address Amount to be correct at a type level.

@samuelWilliams99 samuelWilliams99 linked a pull request Jul 18, 2022 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants