generated from input-output-hk/plutus-starter
-
Notifications
You must be signed in to change notification settings - Fork 27
Open
Labels
enhancementNew feature or requestNew feature or request
Description
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 ofPrivateSale.assetClassto 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
NativeScripttype 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.
- The Scripts are generated like so - For each investor, split the allocation according to the tranches, with unlock time starting at
- Using the above, generate the following files:
- Airdrop input file, using the datatype and json instances defined here: https://github.com/smart-chain-fr/tokenomia/blob/main/src/Tokenomia/TokenDistribution/Distribution.hs#L47
- Database input file, as a json file containing
Map Address [LockedFund], defined in the database spec. - The above file paths may be fixed, or inputs to the script (but with defaults), depending on time.
Create your branch and PR from mlabs/private-sale-staging
Reactions are currently unavailable
Metadata
Metadata
Assignees
Labels
enhancementNew feature or requestNew feature or request