@steerprotocol/sdk v1.19.3
Steer Finance SDK
A TypeScript SDK for interacting with Steer Finance services.
Installation
npm install @steer-finance/sdk viem
# or
yarn add @steer-finance/sdk viem
# or
pnpm add @steer-finance/sdk viemUsage
import { createPublicClient, http } from 'viem';
import { mainnet } from 'viem/chains';
import { SteerClient } from '@steer-finance/sdk';
// Create viem client
const client = createPublicClient({
chain: mainnet,
transport: http()
});
// Initialize the Steer client
const steerClient = new SteerClient({
apiKey: 'your-api-key',
environment: 'production', // or 'development'
client: client, // Pass your viem client
});
// Use the client
const response = await steerClient.getData<YourDataType>('endpoint');Staking Client
The StakingClient provides functionality for interacting with Steer Finance staking pools. It supports both single and dual reward staking pools.
Features
- Fetch available staking pools
- Stake and withdraw tokens
- Claim rewards
- Check earned rewards and balances
- Calculate APR for staking pools
- Support for both single and dual reward pools
Example Usage
// Initialize the staking client
const stakingClient = steerClient.staking;
// Get all staking pools
const pools = await stakingClient.getStakingPools();
// Get pools for a specific chain
const polygonPools = await stakingClient.getStakingPools(137); // Polygon chain ID
// Stake tokens
await stakingClient.stake({
stakingPool: '0x...', // staking pool address
amount: 1000000000000000000n // amount in wei
});
// Check earned rewards
const earned = await stakingClient.earned('0x...', '0x...'); // pool address, account address
console.log('Earned rewards:', earned.data);
// Calculate APR
const apr = stakingClient.calculateAPR(
pool,
rewardTokenPriceUSD,
totalStakedUSD
);Available Methods
getStakingPools(chainId?: number, protocol?: string): Fetch available staking poolsstake(params: StakeParams): Stake tokens in a poolwithdraw(params: WithdrawParams): Withdraw tokens from a poolgetReward(params: GetRewardParams): Claim rewardsearned(stakingPool: Address, account: Address): Get earned rewardstotalSupply(stakingPool: Address): Get total staked tokensbalanceOf(stakingPool: Address, account: Address): Get staked balancecalculateAPR(pool: StakingPool, rewardTokenPriceUSD: number, totalStakedUSD: number): Calculate current pool APR
Requirements
- Node.js >= 18.0.0
- viem >= 2.22.0
Development
- Install dependencies:
npm install- Build the package:
npm run build- Run tests:
npm test- Format code:
npm run format- Lint code:
npm run lintTroubleshooting
CommonJS/ESM Import Issues
If you encounter the following error:
import { SteerClient } from "@steerprotocol/sdk";
^^^^^^^^^^^
SyntaxError: Named export 'SteerClient' not found. The requested module '@steerprotocol/sdk' is a CommonJS module...Add the following to your tsconfig.json:
{
"compilerOptions": {
"esModuleInterop": true,
"allowSyntheticDefaultImports": true
}
}License
MIT
6 months ago
6 months ago
8 months ago
7 months ago
8 months ago
7 months ago
7 months ago
8 months ago
7 months ago
8 months ago
6 months ago
6 months ago
7 months ago
6 months ago
6 months ago
7 months ago
6 months ago
6 months ago
7 months ago
6 months ago
6 months ago
7 months ago
6 months ago
6 months ago
8 months ago
6 months ago
6 months ago
8 months ago
6 months ago
6 months ago
8 months ago
8 months ago
9 months ago
9 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
10 months ago
11 months ago
11 months ago
11 months ago
11 months ago
11 months ago