Stake with Lido

Cross-chain staking is as simple as calling the Swing SDK's stake method. Provide your user's wallet address and the amount of tokens to stake. The Swing SDK will handle the bridging and swapping the tokens from your chosen chain and over to the Lido contract on the Ethereum mainnet.

If you haven't setup the SDK or connected a wallet, follow these steps first.

await sdk.stake({
  fromChain: 'optimism',
  fromToken: 'USDC',
  amount: '100',
  fromUserAddress: '0x123',
  toUserAddress: '0x123',
})

Receive status updates

Use these events to update your UI with helpful information for your users.

sdk.on('TRANSFER', (transfer) => {
  switch (transfer.status) {
    case 'PENDING':
      console.log(`Creating a transaction for the ${transfer.step} step`);
      break;
    case 'CHAIN_SWITCH_REQUIRED':
      // Handle switching chains or alert the user to do it manually
      break;
    case 'ACTION_REQUIRED':
      console.log('Please complete the required action within your connected wallet');
      break;
    case 'CONFIRMING':
      console.log(`Waiting for the transaction from the ${transfer.step} step to complete`);
      break;
    case 'SUCCESS':
      console.log(`Transfer has completed the ${transfer.step} step`);
      break;
    case 'FAILED':
      console.log(`Transfer failed at the ${transfer.step} step:`, transfer.error);
      break;
  }