Farming Liquidity
This document provides descriptions to interact with the AlphaHunter contract.
This document provides detailed descriptions of the key functions used to interact with the AlphaHunter contract. AlphaHunter contract supports farming activities such as staking, unstaking, or harvesting rewards for liquidity positions.
Additionally, utilities for fetching position data are documented.
stakePosition
async function stakePosition(positionId: number)
Description Stake a liquidity position to the AlphaHunter contract.
Parameters
positionId
(number): The ID of the position to stake.
Returns
Promise<string | ethers.TransactionResponse | Error>
: Resolves to the transaction hash or an error.
Throws
Error if the position ID is invalid.
Error if no connected wallet address is found.
Usage Example
import { stakePosition } from '@storyhunt/wrapper-sdk';
(async () => {
try {
const txHash = await stakePosition(1234);
console.log(`Stake successful: ${txHash}`);
} catch (error) {
console.error('Error staking position:', error);
}
})();
unstakePosition
async function unstakePosition(positionId: number)
Description Unstake a liquidity position from the AlphaHunter farming contract.
Parameters
positionId
(number): The ID of the position to unstake.
Returns
Promise<string | ethers.TransactionResponse | Error>
: Resolves to the transaction hash or an error.
Throws
Error if the position ID is invalid.
Error if no connected wallet address is found.
Usage Example
import { unstakePosition } from '@storyhunt/wrapper-sdk';
(async () => {
try {
const txHash = await unstakePosition(1234);
console.log(`Unstake successful: ${txHash}`);
} catch (error) {
console.error('Error unstaking position:', error);
}
})();
harvestPosition
async function harvestPosition(positionId: number)
Description Harvest farming rewards for a liquidity position from the AlphaHunter contract.
Parameters
positionId
(number): The ID of the position to harvest rewards from.
Returns
Promise<string | ethers.TransactionResponse | Error>
: Resolves to the transaction hash or an error.
Throws
Error if the position ID is invalid.
Error if no connected wallet address is found.
Error if reward tokens are unavailable.
Usage Example
import { harvestPosition } from '@storyhunt/wrapper-sdk';
(async () => {
try {
const txHash = await harvestPosition(1234);
console.log(`Harvest successful: ${txHash}`);
} catch (error) {
console.error('Error harvesting position:', error);
}
})();
fetchPositionData
async function fetchPositionData(positionId: number, address: string)
Description Fetch farming position details from the subgraph.
Parameters
positionId
(number): The ID of the position to fetch.address
(string): The owner's address.
Returns
Promise<any | null>
: The position data or null if not found.
Usage Example
import { fetchPositionData } from '@storyhunt/wrapper-sdk';
(async () => {
try {
const positionData = await fetchPositionData(1234, '0xYourWalletAddress');
console.log('Position Data:', positionData);
console.log('Position ID:', positionData.id);
} catch (error) {
console.error('Error fetching position data:', error);
}
})();