rToken Technical Paper


As a solution of rToken proposed by StaFi, rToken protocol is an extensible cross-chain communication protocol between StaFi chain and other foreign chains such like Polkadot, Cosmos, Solana, etc. rToken protocol mainly consists two parts, one is smart contract on StaFi chain and the other is cross-chain bridge, StaFi chain is based on substrate and the smart contract’s programming language is Rust while cross-chain bridge is written in Go.


A few concepts need to be introduced before further introduction to the rToken protocol.


A pool is a multisig account of foreign chain to gather rtoken user’s origin token and invoke staking related calls such like Bond, Unbond and Claim on the foreign chain to earn more tokens. As a multisig account, a pool has no private key but an address and several sub-accounts and a threshold. There might be several pools for a rtoken.


When should the Pool invoke Bond/Unbond call? When should update the rate of rToken? Era was introduced as a concept of period to solve these problems. Pools invoke all the necessary calls on the foreign chain once and only once for each Era. Though the necessary calls might be a little different between different rToken, it usually contains Bond, Unbond, Claim, Restake and Transfer.
For chains which have Era itself such like Polkadot and Kusama, it’s easy to get the current Era, for those which do not have Era itself such like Cosmos and Ethereum, an Era equals to a certain number of blocks.

LiquidityBond and LiquidityUnbond

1.LiquidityBond is the entry point for users to obtain rToken on StaFi chain. User can submit their transfer voucher to mint rToken.
2.LiquidityUnbond is the entry point for users to redeem their origin token on StaFi chain.

Rate or rToken

Rate of rToken is used to calculate how many rToken to mint for user’s LiquidityBond and how many token should unbond and transfer back to user for user’s LiquidityUnbond. It is initialized to 1 and calculated as follows:


rToken-Relay is our Cross-Chain bridge project and mainly consists of three sections as follows:

Operation mechanism of rToken-Relay

In its current state rToken-Relay operates under a trusted federation model, the number of relayers should be the same with number of pool’s sub-accounts. In the figure above, the number of pool’s sub-accounts is 3 and threshold is set to 3 which means that only after all three relayers’s verification of user’s transfer voucher passed that StaFi chain would mint rToken for user.

Cross-chain model of rToken-Relay

Chain Events are detected by a trusted set of off-chain relayers who await finality, submit events to the other chain and vote on submissions to reach acceptance triggering a appropriate handler to perform transactions and report result.

Operation mode of relay in an Era period

rToken-Relay continuously listens for Era changes and reports to StaFi chain when it finds a new Era, after receiving a report of NewEra, there will be a total of five events emitted on StaFi chain one by one to get rToken-Relay to initiate corresponding transaction on the foreign chain and report corresponding transaction result back to StaFi for further processing.