Introduction
This SDK helps you integrate with Lido in two ways:
- Using React banner (simplest).
- Supporting a UI widget in your project (We provide js functions for staking, unstaking, statistics and transaction info).
Installation
- npm
- Yarn
npm install @lidofinance/polygon-sdk
yarn add @lidofinance/polygon-sdk
Using banner
import { PolidoStakeBanner } from '@lidofinance/polygon-sdk';
<PolidoStakeBanner direction="horizontal" />
6.3 APR + DeFi Yields
Stake MATIC with Lido and receive stMATIC while staking.
Put stMATIC in to DeFI integrations and earn up to 271.63% APY
Using SDK
import { PolidoSDK } from '@lidofinance/polygon-sdk';
import {CHAINS} from "@lido-sdk/constants";
import {useSDK} from "@lido-sdk/react";
try {
const { providerWeb3 } = useSDK();
const polidoSDK = new PolidoSDK(CHAINS.Mainnet, providerWeb3);
// First Approve Tokens for Staking by calling the unlockTokens method
const { amount } = await polidoSDK.unlockTokens({
amount: '20', // The amount of MATIC to approve
// Optional callback for getting information about transaction stage
onTxStageChange: txStageChangeCallback,
});
// Then, call the Stake method
const { transactionHash, stAmount } = await polidoSDK.stake({
amount: '20', // The amount of MATIC to stake
referral: '0x...', // Optional address field for assigning a referrer in case there is one
// Optional callback for getting information about transaction stage
onTxStageChange: txStageChangeCallback,
});
} catch (e) {
// Handle Errors
}