npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@ankr.com/stakefi-slot-auction

v0.0.42

Published

SDK for polkadot & slot auction staking

Downloads

10

Readme

StakeFi Polkadot & Slot Auction Staking

This SDK can be used for polkadot and slot auction staking on StakeFi platform.

To install dependency, run next command:

yarn add @ankr.com/stakefi-slot-auction

Since this library depends on Web3, it has ankr.com/stakefi-web3 package inside.

Create SDK

Firstly you need to create SDK instance and store it somewhere in your state. Each SDK instance is assigned to chosen polakdot network, that can be Kusama or Polkadot. If its required to manage both networks at the same time then create two SDK instances.

// create new web3 key provider
const keyProvider = new Web3KeyProvider({
  // required chain id for MetaMask
  expectedChainId: 5,
});
// create SDK instance
const sdk = new SlotAuctionSdk(keyProvider, {
  // url to polkadot RPC (network type is strictly depends on polkadot URL)
  polkadotUrl: 'wss://westend-rpc.polkadot.io',
  // base url to api gateway
  baseUrl: 'https://api.dev.stkr.io/',
  // don't do status check
  crowdloanStatusCheck: false,
});
// dispatch it to state somewhere
dispatch(SDK_INIT, {sdk});

HINT: By default slot auction SDK uses always connected Web3 key provider, so its not required to connect it manually, because it asks user to connect MetaMask only when its required for application.

Basic methods

Some methods can be used without connection to polkadot.js, here is list of such methods:

  • getAvailableCrowdloans - list available crowdloans
  • getCrowdloanById - get crowdloan by id
  • requestDepositAddress - request deposit address for selected crowdloan
  • getCrowdloanBalances - get claimable and total your crowdloan balances (if you know polkadot address, of course)
  • getClaimableStakingRewards - get claimable staking rewards in ethereum network
  • getClaimMethodsForStakingRewards - list possible clam methods (ERC20 or PARACHAIN)
  • claimStakingRewards - claim staking rewards as ERC20 tokens or as PARACHAIN token
  • checkCrowdloanStatus - check crowdloan status check (it can be disabled in config for testing purposes)

Connect to PolkadotJS

Once its required to do connect for lending or staking you need to do connect.

// you can check does it connected already
if (sdk.isConnected()) {
  return;
}
// connect to polkadot.js (promise is resolved once user accepted connection or expection is thrown)
await sdk.connect();

Once you're connected to polkadot.js, next methods are available for you:

  • depositFundsToCrowdloan - lend funds to specified crowdloan project
  • claimRewardPoolTokens - claim aDOTp once project is winner
  • createRawTokenSignature - ask user to create raw token signature (internal)
  • createVerifiableTokenSignature - ask user to create verifiable token sig (internal)

Lend KSM/DOT tokens

To lend KSM/DOT tokens to project just use next snippet (don't forget to specify crowloan to participate).

const stakingAmount = prompt('Enter staking amount: ');
// find crowdloan u're interested of
const [crowdloan] = sdk.getAvailableCrowdloans('LOAN_STATUS_ONGOING');
if (!crowdloan) throw new Error(`There is no availabe ongoing crowdloans`);
// choose one of available polkadot accounts 
const [polkadotAccount] = await sdk.getPolkadotAccounts();
// lend funds to crowdloan
await sdk.depositFundsToCrowdloan(polkadotAccount, crowdloan.loanId, new BigNumber(`${stakingAmount}`));

Claim aDOTp tokens

After crowdloan launch you're allowed to claim aDOTp tokens for some project.

const [crowdloan] = sdk.getAvailableCrowdloans('LOAN_STATUS_SUCCEED');
if (!crowdloan) throw new Error(`There is no availabe succeed crowdloans`);
// choose one of available polkadot accounts 
const [polkadotAccount] = await sdk.getPolkadotAccounts();
// lend funds to crowdloan
const metaMaskAccount = await sdk.getEthereumAccount();
await sdk.claimRewardPoolTokens(polkadotAccount, crowdloan.loanId, metaMaskAccount);

Claim aDOTp staking rewards

After some period (at least 1 block) of staking aDOTp you can claim your staking rewards.

const [crowdloan] = sdk.getAvailableCrowdloans('LOAN_STATUS_SUCCEED');
if (!crowdloan) throw new Error(`There is no availabe succeed crowdloans`);
// determine available claim methods (optional), it can be ERC20 or PARACHAIN
const claimMethods = await sdk.getClaimMethodsForStakingRewards();
if (!claimMethods.includes('ERC20')) throw new Error(`ERC20 claim method is not available`);
// find some polkadot account
const [polkadotAddress] = await sdk.getPolkadotAccounts();
await sdk.claimStakingRewards(polkadotAddress, crowdloan, 'ERC20');