Mars Protocol Code Review Breakdown — Session #2 Airdrop Contract in Action & Overview of the Vesting Contract

Changes to the Airdrop Contract

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
pub merkle_root: String,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum SudoMsg {
Clawback {},
}

Airdrop Contract in Action

git clone https://github.com/mars-protocol/hub
cd hub
git checkout <version>
make install
marsd init myname –-chain-id my-testnet-1
marsd start
marsd query wasm list-contracts 2
marsd query wasm contract-state smart <contract_address> smart '{<query>}'
  • terra_acct_pk : Public key of the Mars Classic token holder, in hex encoding
  • mars_acct: Mars address to which the claimed tokens shall to sent
  • amount: Amount of Mars tokens claim
  • proof: Proof that leaf {terra-acct}:{amount} exists in the Merkle tree, in hex encoding
  • signature: Signature produced by signing message airdrop for {terra-acct} of {amount} umars shall be released to {mars-acct} by the Terra account’s private key, in hex encoding
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
Claim {
terra_acct_pk: String,
mars_acct: String,
amount: Uint128,
proof: Vec<String>,
signature: String,
},
}
marsd tx gov submit-proposal sudo-contract <contract_address> '{"clawback":{}}' --deposit 1 1000000umars --gas auto --gas-adjustment 1.4 --gas-prices 0umars
marsd query gov proposal 1
marsd tx gov vote 1 yes --from myname --gas auto --gas-adjustment 1.4

Overview of the Vesting Contract

#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
pub struct InstantiateMsg {
pub owner: String,
pub unlock_schedule: Schedule,
}
  • start_time: Time when vesting/unlocking starts
  • cliff: Time before with no token is to be vested/unlocked
  • duration: Duration of the vesting/unlocking process. At time start_time + duration, the tokens are vested/unlocked in full
#[derive(Serialize, Deserialize, Copy, Clone, Debug, PartialEq, JsonSchema)]
pub struct Schedule {
pub start_time: u64,
pub cliff: u64,
pub duration: u64,
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum ExecuteMsg {
CreatePosition {
user: String,
vest_schedule: Schedule,
},
Withdraw {},
TransferOwnership(String),
}
#[derive(Serialize, Deserialize, Clone, Debug, PartialEq, JsonSchema)]
#[serde(rename_all = "snake_case")]
pub enum QueryMsg {
VotingPower {
user: String,
},
VotingPowers {
start_after: Option<String>,
limit: Option<u32>,
},
Position {
user: String,
},
Positions {
start_after: Option<String>,
limit: Option<u32>,
},
}

What’s Next

DISCLAIMER

--

--

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store