Staking SDK

Integrate native Bitcoin staking into your own frontend application, allowing your community easy access to all the benefits of LBTC.

Our TypeScript Staking SDK can be integrated into any frontend application: wallets, portfolio management apps, staking dashboards, custody portals.

If you're interested in integrating our Staking SDK please fill out this Google Form so we can issue you with a referral code.

Important: You must take all measures to reduce the risk of unauthorized users as per the same countries in our Terms of Service!

User Staking (Deposit BTC, Receive LBTC)

1) Retrieve a BTC deposit address

Firstly, check for an existing Bitcoin deposit address. Each Bitcoin Deposit Address is associated with a destination chain and address (for minting LBTC), and a referral ID.

import { getDepositBtcAddress } from '@lombard.finance/sdk';
...
const depositBtcAddress = await getDepositBtcAddress({
  address: '0x...', // destination chain address
  chainId: 1, // destination chainID
  referralId: 'YOUR_REFERRAL_ID',
}); // bc1q...

If you have an address already, proceed to step 2. Otherwise, generate a new deposit address.

The user will first need to sign the destination address to prove ownership of their wallet address, as this will be the only place LBTC can be minted to for any deposits to the generated bitcoin deposit address.

import { signLbtcDestionationAddr } from '@lombard.finance/sdk';
...
// do connect to the wallet using web3.js or ethers.js or any other library
// and get the provider, account and chainId
const signedMessage = await signLbtcDestionationAddr({
  provider: window.ethereum,
  account: '0x...', // address of account on provider
  chainId: 1,
}); // '0x...'

Using this signature, generate a new deposit Bitcoin address (note this can take several minutes for the security consortium to validate). Populate the referralId with the referral code we've provided you:

import { generateDepositBtcAddress } from '@lombard.finance/sdk';
...
const depositBtcAddress = await generateDepositBtcAddress({
  address: '0x...',
  chainId: 1,
  signature: signedMessage,
  referralId: 'lombard',
}); // bc1q...

That's it! You now have an existing, or new, BTC deposit address, specify to the user. This address is a SegWit address for maximum compatibility, so your users can deposit from any wallet or centralized exchange.

2) Get Exchange Rate BTC: LBTC

It's important to show the user how much LBTC they will receive for any amount of BTC they wish to deposit. In the future we will allow automatic minting, where a small blockchain fee will be introduced to cover our costs.

import { getLBTCExchageRate } from '@lombard.finance/sdk';
...
const exchangeRate = await getLBTCExchageRate({
  chainId: 1,
  amount: 3,
});

3) Prompt the user to deposit Bitcoin

The user can now send BTC directly to the deposit address.

Note: The minimum amount is 0.0002 BTC (~$10 USD).

4) Check the user's Bitcoin deposits

import { getDepositsByAddress } from '@lombard.finance/sdk';
...
const deposits = await getDepositsByAddress({
  address: '0x...',
}); // [{...}]

5) User claims LBTC

After 6 Bitcoin confirmations, our security consortium will notarise the deposit and provide a signature. The user can then mint their LBTC with the signature provided.

import { claimLBTC } from '@lombard.finance/sdk';
...
// do connect to the wallet using web3.js or ethers.js or any other library
// and get the provider, account and chainId
const { receiptPromise, transactionHash } = await claimLBTC({
  data: 'PAYLOAD',
  proofSignature: 'SIGNATURE',
  provider: window.ethereum,
  account: '0x...',
  chainId: 1,
});
console.log(transactionHash); // '0x...'
const receipt = await receiptPromise; // {...}

User Unstaking:

1) Show the Network Security Fee to the user

There is an unstaking (withdrawal) fee in place to cover the Bitcoin network fee and to prevent malicious individuals from attacking the protocol. Hence, the user must only unstake amounts above this fee. This can be retrieved from the LBTC contract getBurnCommission function. Note: This will be added directly to the SDK in the future.

2) Unstake the BTC

To unstake BTC from Lombard, a user simply unstakes against the ERC20 contract and waits for the 7-day withdrawal period, after which the BTC will be sent to the specified (not original) address.

import { unstakeLBTC } from '@lombard.finance/sdk';
...
// do connect to the wallet using web3.js or ethers.js or any other library
// and get the provider, account and chainId
const { receiptPromise, transactionHash } = await unstakeLBTC({
  btcAddress: 'bs...',
  amount: 1,
  provider: window.ethereum,
  account: '0x...',
  chainId: 1,
});
console.log(transactionHash); // '0x...'
const receipt = await receiptPromise; // {...}

Last updated