Demystifying the Technical Architecture of MilkyWay

Josie Leung
MilkyWay Zone
6 min readNov 16, 2023

--

This article will provide a detailed examination of the technical structure of MilkyWay, explaining the complex components and processes that constitute this project.

Read on to find out what the team is working on now and what will happen behind the scenes of our dApp.

What is MilkyWay?

Short recap in case you are unfamiliar with MilkyWay. Skip otherwise.

MilkyWay offers a liquid staking solution for the Celestia ecosystem, and it will initially be deployed and operated on Osmosis due to technical constraints that cannot be immediately addressed. When users stake their TIA coins with MilkyWay, they receive an on-chain representation of their TIA staking position, known as stTIA. This empowers Celestia token holders to access liquidity for their staked assets, enabling trading or their use as collateral in various DeFi products.

Understanding Key Terms

Before diving into the technical architecture of MilkyWay, let’s get comfortable with a few terms that will pop up:

  • TIA — the native coin on Celestia.
  • stTIA — receipt token that users receive when staking TIA with MilkyWay. It is a reward-bearing token that increases linearly against TIA over time.
  • Operators — 7 trusted entities entrusted with the operation of the MilkyWay protocol, guardians of the Multisigs.
  • Validators — established Celestia validators who receive delegations from MilkyWay and selection process will be governed by the MilkyWay DAO in the near future.
  • Staker Multisig — account on Celestia managed by the operators that holds stakers’ funds, grants permission to Grantee to perform staking actions.
  • Grantee — account on Celestia with limited authorisation used by Coordinator to perform staking actions.
  • Coordinator — an off-chain program that coordinates between Celestia and Osmosis with the Grantee account to perform transfer and staking actions.

Now that we’re familiar with these terms, let’s delve into the core components of MilkyWay.

Staking Process

A crucial aspect of any Liquid Staking project is the staking process. For MilkyWay, the system is designed to be both efficient and secure.

Here’s a step-by-step breakdown of the procedure:

  1. Initiation: When a user stakes TIA on MilkyWay — the TIA is transferred from Celestia to Osmosis via IBC, then deposited into a CosmWasm Staking Contract.
  2. Calculation and Minting: The contract calculates the amount of stTIA to provide based on TIA’s exchange rate. Please refer to the following section for the exchange rate calculation. It then mints stTIA and provides the user with stTIA as a tokenized representation of the staked TIA coin. The stTIA is sent to the user’s Osmosis account.

Sounds simple and familiar right? Now the user can use the stTIA for other DeFi activities.
But actually MilkyWay’s job continues when the user is merrily checking out various stTIA usage options on our upcoming Discovery page.

  1. IBC Transfer Message: The contract then sends the user’s TIA from Osmosis to the Staker Multisig on Celestia.
  2. Monitoring: The Coordinator tracks funds moving from Osmosis to Celestia for MilkyWay transactions.
  3. Stake: The Coordinator stakes uniformly across all MilkyWay’s validators on Celestia using the Grantee’s account.

Exchange Rate of stTIA:TIA

In the MilkyWay protocol, it is important to maintain an accurate stTIA: TIA exchange rate. Exchange rate is based on the following formula:

TotalNativeToken = Staked TIA + accrued staking rewards.
TotalLiquidStakedToken = stTIA minted

It will initially start at a 1:1 ratio and will be dynamically updated based on the accrued staking rewards. To understand how this works, let’s consider an example:

Alice is MilkyWay’s first user and she stakes 100 TIA, she then receives 100 stTIA in return.

Let’s assume that time has passed and 10 rewards were accrued.

Now, the new exchange rate would be:

If Alice decides to withdraw her TIA, she receives 110 TIA for 100 stTIA based on the new exchange rate.

Please note that this is an illustrative example of how the exchange rate works and did not account for the validator’s commission and the MilkyWay DAO fee.

Compound Staking Rewards

It is also important that we automate the compounding of staking rewards for users. After all, who wants to manually claim staking rewards every block?

To address these needs, we have designed a system that will update the exchange rate and compound staking rewards simultaneously.

Here’s a step-by-step breakdown of what happens in the background:

  1. Claim and Transfer: The Coordinator periodically claims staking rewards on behalf of the users and transfers them back to the Osmosis Staking Contract
  2. Exchange Rate Update : The Staking Contract rebalances the rate based on the above formula.
  3. Auto Compound: Rewards are then staked back to the validators by repeating steps 3–5 in the Staking process mentioned above.

Withdrawal Process

Users can choose to withdraw their TIA on MilkyWay which involves the 21 unbonding time mandated by Celestia, or swap their stTIA for TIA on Osmosis or other listed DEXes for instant withdraw.

Here are the steps to withdraw on MilkyWay — which starts with a user initiating a one-click request to withdraw their TIA.

And under the hood:

  1. Request Initiation and Burn:The withdrawal request goes to the Osmosis Staking Contract which groups the request into a batch. The contract also stores the user’s withdrawal information for the claim process, which is detailed further in the Claim section below.
  2. Undelegate: At the end of every batch period, which is set as 3 days at launch, the Coordinator delivers the requests to Celestia to undelegate uniformly across all MilkyWay’s validators .The user’s stTIA is burnt once the batch is submitted at the end of the batch period.
  3. Wait: Wait for the 21 unbonding period.
  4. IBC Transfer: The Coordinator then sends the TIA from Celestia back to Osmosis.

Now the TIA is ready for claiming.

Claim Process

  1. Claim: Users can claim their TIA after the batch and unbonding period have ended.
  2. Release: The contract uses previously stored information to map each user’s address to the corresponding amount, then releases TIA to the user.

Limits and Restrictions

To ensure a secure and smooth operation for any blockchain project, it’s necessary to impose certain limitations. MilkyWay will launch with the following constraints:

  1. Minimum Liquid Staking Amount — This measure is to prevent DDOS attacks.
  2. Withdrawal Batching — The batch period is set at three days at launch due to a limit on the number of concurrent withdrawal entries. The default maximum entry is seven.
  3. Manual Claiming — This is to comply with the staking rewards regulations of certain countries.
  4. OFAC Sanctioned Countries Restriction — Users from OFAC sanctioned countries will not be able to access our dApp, this is to comply with OFAC’s regulations.
  5. 7 Operators — Celestia’s signature limit is currently set at 7.
  6. Grantee Account’s Limited Authorization — Grantee Account can only stake to specified validator list and transfer between specified accounts.

This article discusses the smooth operation of the MilkyWay protocol. Additional details on Operators, Validators and handling edge cases will follow.

We welcome any feedback, comments, or contributions!

--

--