Smart contract specifications

The codebase of our Liquid Staking Protocol can be found on GitHub, inside our milkyway-labs/milkyway-contracts repository. Particularly, you will find two smart contracts:

  1. The staking contract: it contains the logic that allows to stake TIA tokens in exchange for our milkTIA Liquid Staking Token, as well as unstaking such token to receive back TIA.

  2. The treasury contract: this is where all the fees collected by MilkyWay are stored and managed.

Both contracts are deployed on the Osmosis mainnet at the following addresses:

Smart contractAddressExplorer link

Staking contract

osmo1f5vfcph2dvfeqcqkhetwv75fda69z7e5c2dldm3kvgj23crkv6wqcn47a0

Treasury contract

osmo1r88fszmnpn8ez5wc42pssd2597mhtrdzex7tzzulj98fmqee2fksg7z5yh

Liquid staking some TIA

In order to liquid stake some TIA and receive milkTIA, you will need to broadcast a transaction containing a /cosmwasm.wasm.v1.MsgExecuteContract message having the following structure:

{
  "@type": "/cosmwasm.wasm.v1.MsgExecuteContract",
  "sender": "<Address of the user wanting to liquid stake their TIA>",
  "contract": "osmo1f5vfcph2dvfeqcqkhetwv75fda69z7e5c2dldm3kvgj23crkv6wqcn47a0",
  "funds": [
    {
      "denom": "ibc/D79E7D83AB399BFFF93433E54FAA480C191248FC556924A2A8351AE2638B3877",
      "amount": "<Amount of uTIA to be liquid staked (1 TIA = 1.000.000 uTIA)>"
    }
  ],
  "msg": {
    "liquid_stake": {}
  }
}

When creating this message, please note the following:

  1. Make sure the contract address is the one of our liquid staking contract: (osmo1f5vfcph2dvfeqcqkhetwv75fda69z7e5c2dldm3kvgj23crkv6wqcn47a0)

  2. Make sure the user has bridged the amount of TIA they want to liquid stake to the Osmosis mainnet using IBC. This because we only support IBC TIA to be liquid staked (denom: ibc/D79E7D83AB399BFFF93433E54FAA480C191248FC556924A2A8351AE2638B3877)

  3. Make sure the amount of tokens to be liquid staked is multiplied by 1.000.000 when creating the message. This means that if the users wants to liquid stake 10.5 TIA, you should set 10500000 as the amount.

Liquid unstaking milkTIA

In order to liquid unstake some milkTIA and receive back TIA, you will need to broadcast a transaction containing a /cosmwasm.wasm.v1.MsgExecuteContract message having the following structure:

{
  "@type": "/cosmwasm.wasm.v1.MsgExecuteContract",
  "sender": "<Address of the user that wants to liquid unstake their milkTIA>",
  "contract": "osmo1f5vfcph2dvfeqcqkhetwv75fda69z7e5c2dldm3kvgj23crkv6wqcn47a0",
  "funds": [
    {
      "denom": "factory/osmo1f5vfcph2dvfeqcqkhetwv75fda69z7e5c2dldm3kvgj23crkv6wqcn47a0/umilkTIA",
      "amount": "<Amount of umilkTIA to be unstaked (1 milkTIA = 1.000.000 umilkTIA)"
    }
  ],
  "msg": {
    "liquid_unstake": {}
  }
}

When creating this message, please note the following:

  1. Make sure the contract address is the one of our liquid staking contract: (osmo1f5vfcph2dvfeqcqkhetwv75fda69z7e5c2dldm3kvgj23crkv6wqcn47a0)

  2. Make sure the amount of tokens to be liquid unstaked is multiplied by 1.000.000 when creating the message. This means that if the users wants to liquid unstake 10.5 milkTIA, you should set 10500000 as the amount.

ℹī¸ Note

Please note that, differently from what happens when liquid staking their TIA tokens, users will not immediately receive back their TIA tokens when liquid unstaking milkTIA. This because, as per our architecture, we first need to process the batch requesting the staked TIA to be unlocked. This usually takes around 14 days, after which the TIA tokens will be ready to be claimed by the user. Claiming your tokens will require you to provide the batch_id that is returned to you when executing the liquid_unstake operation.

Claiming unstaked tokens

After you request your milkTIA to be unstaked, it will need around 14 days for them to be available again. Once that time has passed, you can use the following message in order to claim your tokens:

{
  "@type": "/cosmwasm.wasm.v1.MsgExecuteContract",
  "sender": "<Address of the user that wants to claim their tokens>",
  "contract": "osmo1f5vfcph2dvfeqcqkhetwv75fda69z7e5c2dldm3kvgj23crkv6wqcn47a0",
  "funds": [],
  "msg": {
    "withdraw": {
      "batch_id": <ID of the batch inside which your request was added>
    }
  }
}

When creating this message, please note the following:

  1. Make sure the contract address is the one of our liquid staking contract: (osmo1f5vfcph2dvfeqcqkhetwv75fda69z7e5c2dldm3kvgj23crkv6wqcn47a0)

  2. The batch_id provided matches the value returned by the liquid_unstake operation execution.

Last updated