haedal-farm-sdk
v0.6.0
Published
This SDK is published by [Haedal](https://www.haedal.xyz).
Downloads
21
Readme
Farming Docs
This SDK is published by Haedal.
Installation
To start using the Farming SDK, you need to first install it in your TypeScript project. You can add it to your project via npm, yarn or bun:
npm link: https://www.npmjs.com/package/haedal-farm-sdk
npm install haedal-farm-sdkor
bun install haedal-farm-sdk1. Initializing the SDK
Initialize the SDK with the necessary configuration parameters. Typically, this involves setting up the network and API keys if required:
- Mainnet:
const MainnetSDK = initFarmsSDK({ env: 'mainnet'})- Testnet:
const TestnetSDK = initFarmsSDK({ env: 'testnet'})2. Set Wallet Address
After linking the wallet, the wallet address must be set in the SDK:
sdk.senderAddress = '0x..'Function Description
1. Queries
1. Get farm List
const farmsList = await sdk.Farms.getFarmsList()2. Get Available Rewards
const reward = await sdk.Farms.getAvailableRewards({
poolId: '0x...',
stakeCoinType: '0x...',
stakeObjectId: '0x...',
})2. Get Staked Balance And Staked Object Id
const { stakeObjectId, stakedBalance } = await sdk.Farms.getFarmDeposit({
stakeCoinType: '0x...',
poolId: ''
})2. Stake
const tx = new Transaction()
const txResult = await sdk.Farms.buildStakePayload( {
poolId: '0x...',
stakeCoinType: '0x...',
stakeObjectId: '0x...', // Staked Object Id
decimals: 9,
amount: 0 // The actual amount pledged by the user
lpCoin: ''
}, tx) 3. Unstake
const tx = new Transaction()
const txResult = await sdk.Farms.buildUnstakePayload( {
poolId: '0x...',
stakeCoinType: '0x...',
stakeObjectId: '0x...', // Staked Object Id
amount: 0 // The converted amount entered by the user eg: input 1 -> 1000000000
claimReward: true // Whether to extract rewards when Unstake
rewardConfigs: [] // Reward Token List
}, tx) 4. Unstake And Return LP Coin
const tx = new Transaction()
const lpCoin = await sdk.Farms.buildRawWithdrawPayload( {
poolId: '0x...',
stakeCoinType: '0x...',
stakeObjectId: '0x...', // Staked Object Id
amount: 0 // The converted amount entered by the user eg: input 1 -> 1000000000
claimReward: true // Whether to extract rewards when Unstake
rewardConfigs: [] // Reward Token List
}, tx) 5. Harvest
const tx = new Transaction()
const txResult = await sdk.Farms.buildHarvestPayload( {
poolId: '0x...',
stakeCoinType: '0x...',
stakeObjectId: '0x...',
rewardCoinType: ''
rewardBank: ''
}, tx) 