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
- Mainnet MATIC — 0x7d1afa7b718fb893db30a3abc0cfc608aacfebb0 (opens in a new tab)
- Testnet MATIC — 0x499d11e0b6eac7c0593d8fb292dcbbf815fb29ae (opens in a new tab)
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
- Mainnet PolygonPool Proxy — 0xCfD4B4Bc15C8bF0Fd820B0D4558c725727B3ce89 (opens in a new tab)
- Testnet PolygonPool Proxy — 0xAf2FdE2a233bc2E7B0B8Fa6066aD2df980B6fa67 (opens in a new tab)
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
- Mainnet PolygonPool Proxy — 0xCfD4B4Bc15C8bF0Fd820B0D4558c725727B3ce89 (opens in a new tab)
- Testnet PolygonPool Proxy — 0xAf2FdE2a233bc2E7B0B8Fa6066aD2df980B6fa67 (opens in a new tab)
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 theaMATICb
contract.amount
(uint256, required) — amount of ankrMATIC to be burned.
Smart contract
- Mainnet ankrMATIC — 0x26dcfbfa8bc267b250432c01c982eaf81cc5480c (opens in a new tab)
- Testnet ankrMATIC — 0x148bf822cae6a61b2f278801ef4369fddd2a80df (opens in a new tab)
Example
- Mainnet live transaction example (opens in a new tab)
- Testnet live transaction example (opens in a new tab)
unstakeCerts(uint256 shares, uint256 fee, uint256 useBeforeBlock, bytes signature)
Lets the PolygonPool
to exchange ankrMATIC for MATIC.
Parameters
payableValue
(ETH, required) – amount received queryingethUnstakeFee()
.shares
(uint256, required) — amount ankrMATIC to be unstake.fee
(uint256, required) — legacy param, should be set to0
.useBeforeBlock
(uint256, required) — legacy param, should be set to0
.signature
(bytes, required) — legacy param, should be0x0
.
Smart contract
- Mainnet PolygonPool Proxy — 0xCfD4B4Bc15C8bF0Fd820B0D4558c725727B3ce89 (opens in a new tab)
- Testnet PolygonPool Proxy — 0xAf2FdE2a233bc2E7B0B8Fa6066aD2df980B6fa67 (opens in a new tab)
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.