For Developers
Development Details
Polygon Liquid Staking

MATIC staking mechanics

MATIC Liquid Staking lets the user stake their funds through the corresponding smart contracts on Ethereum or a swap pool on Polygon, accumulate rewards, and receive their stake and rewards when unstaking.

Ankr principles for the staking are:

  • Make all staking transactions on the Ethereum or Polygon network.
  • On Ethereum, use classic Ankr Liquid Staking logic.
  • On Polygon, use a swap pool to perform a simple swap MATIC–ankrMATIC–MATIC with a fixed price.
  • Accumulate and bridge together all the staked MATIC within Ankr.
  • Use the existing MATIC validator node owned by Ankr, thus there are no limits on staking amount and staking period.
  • Use a dynamic exchange ratio for ankrMATIC to MATIC.
  • Recalculate ankrMATIC/MATIC exchange ratio daily and update it in the ankrMATIC smart contract.

The following explains staking requirements, fees, rewards, validators, smart contracts and function calls to interact with these smart contracts.

Requirements

The requirements when staking are:

  • Minimum value to stake — 1 MATIC.
  • Maximum value to stake:
    • On Ethereum — unlimited, at the user’s discretion.
    • On Polygon — limited by the swap pool's provider capacity. Current provider — Ankr itself.
  • Staking can be repeated anytime, without waiting for the current staking to complete.

The requirements when unstaking are:

  • Minimum value to unstake — 0 MATIC.
  • Maximum value to unstake:
  • On Ethereum — staked amount + % of the reward, up to the user’s balance.
  • On Polygon — limited by the swap pool's provider capacity. Current provider — Ankr itself. If max capacity is reached in an unstaking request, switch to classic unstake on Ethereum.
  • Withdrawal period after unstaking:
    • On Ethereum — >= 80 epochs. Typically, it’s around 1-2 days.
    • On Polygon — instantly.
  • ankrMATIC to MATIC exchange ratio is dynamic, as ankrMATIC grows in value to MATIC, daily.
  • User can unstake a part of or all the staked MATIC anytime.

Fees

When staking:

  • On Ethereum — a 5% technical service fee from the staking reward.
  • On Polygon — a 5% technical service fee from the staking reward.

When unstaking:

  • On Ethereum — no technical service.
  • On Polygon — a 0.5% technical service fee from the unstaked amount.

The user must also count in the gas price in ETH for outgoing transactions for staking/unstaking on Ethereum.

Rewards

User's ankrMATIC value grows steadily to MATIC over time.

Validators receive rewards on the regular basis at the end of each epoch.

The APY is calculated from the validators' rewards.

Validators

There is a single Ankr validator on Polygon (opens in a new tab).

Smart contracts

Smart contracts involved in MATIC Liquid Staking on Ethereum are:

Smart contract code can be viewed by following the links and selecting the Contract tab.

Staking workflow

On Ethereum

The workflow is both user and Ankr-driven. The user part is Steps 1–2, the Ankr part is Steps 3–7.

User calls Matic::approve(address spender, uint256 amountToSpend) to approve the chosen MATIC amount to be sent to the PolygonPool smart contract.

User sends a request to Ankr PolygonPool smart contract on Ethereum, calling stakeAndClaimCerts(uint256 amount) (ankrMATIC). The request is sent via Ankr Staking and MetaMask or another wallet connected to Ethereum.

Upon receiving the stake, the PolygonPool smart contract calculates the equivalent amount of ankrMATIC and mints it to the user’s address found in the stake transaction.

PolygonPool emits a StakePending(msg.sender, amount) event.

On the Ankr Staking Dashbaord, the user can import the received ankrMATIC tokens to MetaMask or another wallet connected to Ethereum.

Ankr backend collects the MATIC staked by users, transferring them from the smart contract to the address controlled by the platform, and makes a validator stake on the Ankr MATIC Validator node if the conditions below are met.

Ankr Staking Dashboard can call ankrMATIC::balanceOf(address account) to check the user’s current ankrMATIC balance.

The Ankr backend monitors blockchain events coming from the PolygonPool smart contract. Upon a new staking event, the backend:

  1. Checks if the newly available MATIC number (N) is >= to the minimum threshold. If yes, the available MATIC are sent from the PolygonPool smart contract to the address managed by Ankr. Else, the backend waits for the next stake event from PolygonPool. N is a config parameter.

  2. At the point when MATIC tokens become available at the Ankr address, a staking transaction is issued.

  3. The Ankr backend monitors staking status and rewards, and restakes the rewards when the sum of the staked MATIC reward is > threshold. The threshold is a config parameter.

On Polygon

User sends a transaction to MaticSwapPool to swaps their MATIC for ankrMATIC.

Ankr, being the main liquidity provider, rebalances the pool to have enough MATIC and ankrMATIC in it for the users.

Rebalancing MaticSwapPool

The pool must be kept in balance, so:

  • Whenever there's more MATIC in it than ankrMATIC, Ankr bridges MATIC to the Ethereum network, stakes it, gets ankrMATIC and bridges it back to Polygon to add to the pool.
  • Whenever there's more ankrMATIC in it than MATIC, Ankr bridges ankrMATIC to the Ethereum network, unstakes it, gets MATIC and bridges it back to Polygon to add to the pool.

Daily exchange ratio updates

The ratio updates can be obtained by calling the ankrMATIC::ratio() (opens in a new tab) read function.

Unstaking workflow

On Ethereum

The workflow is both user and Ankr-driven. The user part is Step 1, the Ankr part is Steps 2–11.

  1. User navigates to the dedicated page on Ankr Staking and unstakes their MATIC.
  2. Ankr Staking Dashboard checks the user’s ankrMATIC balance and displays a form to enter the number of MATIC to unstake.
  3. Ankr Staking Dashboard calls PolygonPool::unstakeCerts(uint256 amount, uint256 fee, uint256 useBeforeBlock, bytes memory signature).
  4. PolygonPool transfers the equal amount of ankrMATIC from the user to itself (technically, it locks the amount of ankrMATIC to unstake in the user’s account).
  5. PolygonPool issues an unstake event MaticClaimPending(msg.sender, amount).
  6. Ankr Staking Dashboard displays a notification to the user to indicate the unstaking request has been registered.
  7. Ankr backend detects the unstake event and sends an unstake request to the MATIC smart contract on the Ethereum blockchain.
  8. When unstake is completed and MATIC received at the platform address, the backend sends the MATIC to the Polygon Pool smart contract: PolygonPool::serveClaims().
  9. PolygonPool sends the MATIC to the user address, burns the ankrMATIC tokens, and issues an event saying the unstake request has been completed.

On Polygon

User sends a transaction to MaticSwapPool to swaps their ankrMATIC for MATIC. If the current pool capacity matches the unstake request, the user swaps their ankrMATIC via the Ankr's swap pool on Polygon for MATIC. No unbonding period applied for sending MATIC to the user's wallet, since it's an instant swap procedure.

Ankr, being the main liquidity provider, rebalances the pool to have enough MATIC and ankrMATIC in it for the users.