Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@bifrost-finance/slpx

Package Overview
Dependencies
Maintainers
5
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@bifrost-finance/slpx

SLPx offers ways to stake and unstake vToken assets.

  • 0.0.3
  • latest
  • npm
  • Socket score

Version published
Maintainers
5
Created
Source

SLPx

SLPx offers ways to stake and unstake vToken assets.

Key Features

  • Users can interact with slpx-contracts on GitHub at https://github.com/bifrost-finance/slpx-contracts.
  • It is built on viem and offers a user-friendly experience for Wagmi.

Supported Networks and Assets

  • Moonbeam Network: vGLMR, vFIL, vDOT
  • Moonriver Network: vMOVR, vBNC, vKSM
  • Astar Network: vASTR, vDOT
  • Ethereum Network: vETH

Install

npm install @bifrost-finance/slpx

Usage

First, import the necessary modules and instantiate the SLPx class:

import { usePublicClient, useWalletClient } from 'wagmi';
import SLPx from '@bifrost-finance/slpx';

// in React component
const publicClient = usePublicClient();
const { data: walletClient } = useWalletClient();
const slpx = new SLPx(publicClient, walletClient, channel);

Stake an Asset


import {  useContractReads, erc20ABI, useAccount } from 'wagmi';

const { address } = useAccount()
const vToken = 'vBNC'; // vGLMR, vFIL, vDOT, vMOVR, vBNC, vKSM, vASTR, vETH
const amount = 1.0;
const token = vToken?.replace(/^v/, '').toUpperCase();

// Query allowance
const { data, refetch } = useContractReads(
    {
        contracts: [
            {
                address: slpx.getContractAddressByToken(token),
                abi: erc20ABI,
                functionName: 'allowance',
                args: [address, slpx.getContractAddressByToken('SLPx')]
            }
        ]
    }
)

// Approving a Stake
slpx.approveStake(vToken, amount)
    .then(txHash => console.log(`Transaction hash: ${txHash}`))
    .catch(error => console.error(`Error approving stake: ${error}`));

// Get the minimum amount to stake
const minStake = slpx.getMinStake(vToken) 

// Staking an Asset
slpx.stakeAsset(vToken, amount)
    .then(txHash => console.log(`Transaction hash: ${txHash}`))
    .catch(error => console.error(`Error staking asset: ${error}`));

UnStake an Asset


import {  useContractReads, erc20ABI, useAccount } from 'wagmi';

const { address } = useAccount();
const vToken = 'vBNC'; // vGLMR, vFIL, vDOT, vMOVR, vBNC, vKSM, vASTR, vETH
const amount = 1.0;

// Query allowance
const { data, refetch } = useContractReads(
    {
        contracts: [
            {
                address: slpx.getContractAddressByToken(vToken),
                abi: erc20ABI,
                functionName: 'allowance',
                args: [address, slpx.getContractAddressByToken('SLPx')]
            }
        ]
    }
)

// Approving a Unstake
slpx.approveUnstake(vToken, amount)
    .then(txHash => console.log(`Transaction hash: ${txHash}`))
    .catch(error => console.error(`Error approving stake: ${error}`));

// Get the minimum amount to unstake
const minStake = slpx.getMinUnstake(vToken) 

// Unstaking an Asset
slpx.unstakeAsset(vToken, amount)
    .then(txHash => console.log(`Transaction hash: ${txHash}`))
    .catch(error => console.error(`Error staking asset: ${error}`));

vETH

After the completion of vETH Unstaking, the dedicated interface for claiming

// Get claim info (currently only supports vETH)
slpx.getClaimInfo('vETH')
    .then(info => console.log(`Claim info: ${JSON.stringify(info)}`))
    .catch(error => console.error(`Error getting claim info: ${error}`));
    
// To claim info (currently only supports vETH)
slpx.toClaim('vETH')
    .then(info => console.log(`Claim info: ${JSON.stringify(info)}`))
    .catch(error => console.error(`Error getting claim info: ${error}`));

FAQs

Package last updated on 17 Nov 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc