• Staking
  • For Integrators
  • 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 aMATICb

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

Testnet Matic

Example

Testnet live transaction example

stakeAndClaimBonds(amount)

Stakes MATIC and claims aMATICb for the staked MATIC.

Parameters

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

Smart contract

Testnet PolygonPool Proxy

Example

Testnet live transaction example

Stake MATIC and claim aMATICc

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

Testnet MATIC

Example

Testnet live transaction example

stakeAndClaimCerts(amount)

Stakes MATIC and claims aMATICc for the staked MATIC.

Parameters

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

Smart contract

Testnet PolygonPool Proxy

Example

Testnet live transaction example

Unstake aMATICb and claim MATIC

unstakeFee

RESTful API endpoint that returns the current fee value for the unstaking operation.

Host

https://api.dev.stkr.io/

Endpoint

GET /v1alpha/polygon/unstakeFee

Parameters
  • address (address, required) — address of the staker.
Request
curl https://api.dev.stkr.io/v1alpha/polygon/unstakeFee?address=0x0000000000000000000000000000000000000000
Response
200
{"unstakeFee":"50000000000000000000","useBeforeBlock":6946279,"signature":"0x7ed0ac683aca82358813f0e40dd2f636b1e12e48d9c3f79194272b8da26cb770273d5c39d99981e8387f6d8c1ae69e9a3bb0dd4fd76cfb92d8ab3b1d3a0094e51c"}

approve(spender, value)

Lets the PolygonPool smart contract transfer user's ANKR tokens (needed to pay fees when unstaking aMATICb).

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

unstakeBonds(uint256 amount, uint256 fee, uint256 useBeforeBlock, bytes signature)

Lets the PolygonPool to exchange aMATICb for MATIC.

Parameters
  • amount (uint256, required) — amount aMATICc to be unstake.
  • fee (uint256, required) — fee paid in ANKR for the unstaking operation. Get the value from the unstakeFee endpoint response.
  • useBeforeBlock (uint256, required) — last valid blockchain block to unstake before. Get the value from the unstakeFee endpoint response.
  • signature (bytes, required) — notary signature for the fees. Get the value from the unstakeFee endpoint response.
Smart contract
Example

Unstake aMATICc and claim MATIC

unstakeFee

RESTful API endpoint that return the current fee value for the unstaking operation.

Parameters
  • address (address, required) — address of the staker.
Request
GET https://api.dev.stkr.io/v1alpha/polygon/unstakeFee?address=0x0000000000000000000000000000000000000000
Response
200
{"unstakeFee":"50000000000000000000","useBeforeBlock":6946279,"signature":"0x7ed0ac683aca82358813f0e40dd2f636b1e12e48d9c3f79194272b8da26cb770273d5c39d99981e8387f6d8c1ae69e9a3bb0dd4fd76cfb92d8ab3b1d3a0094e51c"}

approve(spender, value)

Lets the PolygonPool smart contract transfer user's ANKR tokens (needed to pay fees when unstaking aMATICb).

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

approve(spender, amount)

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

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

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

Lets the PolygonPool to exchange aMATICc for MATIC.

Parameters
  • shares (uint256, required) — amount aMATICc to be unstake.
  • fee (uint256, required) — fee paid in ANKR for the unstaking operation. Get the value from the unstakeFee endpoint response.
  • useBeforeBlock (uint256, required) — last valid blockchain block to unstake before. Get the value from the unstakeFee endpoint response.
  • signature (bytes, required) — notary signature for the fees. Get the value from the unstakeFee endpoint response.
Smart contract
Example

Get APR

averagePercentageRate(uint256 day)

Gets the APR for aMATICb or aMATICc.

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, aMATICc — 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.