For Developers
Smart Contract API
Polygon Liquid Staking API

MATIC Liquid Staking API

To integrate with MATIC Liquid Staking, use the smart contract functions and examples below.

Stake MATIC and claim ankrMATIC

approve(spender, value)

Lets the PolygonPool smart contract transfer user's MATIC tokens.

Parameters
  • spender (address, required) — address of the PolygonPool contract.
  • value (uint256, required) — amount of MATIC to be staked.
Smart contract
Example

Testnet live transaction example (opens in a new tab)

stakeAndClaimCerts(amount)

Stakes MATIC and claims ankrMATIC for the staked MATIC.

Parameters

amount (uint256, required) — amount of MATIC to be staked.

Smart contract
Example

Testnet live transaction example (opens in a new tab)

Unstake ankrMATIC and claim MATIC

ethUnstakeFee()

Get the current unstake fee in ETH.

Smart contract

approve(spender, amount)

Approves the aMATICb smart contract to transfer user's aMATICc tokens to itself from the ankrMATIC smart contact and burn them.

Parameters
  • spender (address, required) — address of the aMATICb contract.
  • amount (uint256, required) — amount of ankrMATIC to be burned.
Smart contract
Example

unstakeCerts(uint256 shares, uint256 fee, uint256 useBeforeBlock, bytes signature)

Lets the PolygonPool to exchange ankrMATIC for MATIC.

Parameters
  • payableValue (ETH, required) – amount received querying ethUnstakeFee().
  • shares (uint256, required) — amount ankrMATIC to be unstake.
  • fee (uint256, required) — legacy param, should be set to 0.
  • useBeforeBlock (uint256, required) — legacy param, should be set to 0.
  • signature (bytes, required) — legacy param, should be 0x0.
Smart contract
Example

Get APR

averagePercentageRate(uint256 day)

Gets the APR for aMATICb or ankrMATIC.

The formula is best expressed by an example.

With 3 provided as the depth, the APR = ((((day 3 - day 2) / day 3) * 100) + ((day 2 - day 1) / day 2) * 100) + ((day 1 - current day) / day 1) * 100) / 3) * 365.

Parameters
  • day (uint256, required) — number of days to get the APR for. Max value — 7 days.
  • address (address, required) — address of the token contract to determine which token to get the APR for. Possible values: aMATICb — 0x99534Ef705Df1FFf4e4bD7bbaAF9b0dFf038EbFe, ankrMATIC — 0x26dcfbfa8bc267b250432c01c982eaf81cc5480c.
Smart contract
Example

averagePercentageRate being a read function, we suggest you visit the links and make a query entering a desired number of days to see an example.

Get staking metrics

To integrate Ankr Staking metrics into your dashboards or use metrics like APY in your products, read Liquid Staking Metrics.