Steer Protocol SDK - v1.5.0

Steer Finance SDK

A TypeScript SDK for interacting with Steer Finance services.

npm install @steer-finance/sdk viem
# or
yarn add @steer-finance/sdk viem
# or
pnpm add @steer-finance/sdk viem
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');

The StakingClient provides functionality for interacting with Steer Finance staking pools. It supports both single and dual reward staking pools.

  • 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
// 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
);
  • getStakingPools(chainId?: number, protocol?: string): Fetch available staking pools
  • stake(params: StakeParams): Stake tokens in a pool
  • withdraw(params: WithdrawParams): Withdraw tokens from a pool
  • getReward(params: GetRewardParams): Claim rewards
  • earned(stakingPool: Address, account: Address): Get earned rewards
  • totalSupply(stakingPool: Address): Get total staked tokens
  • balanceOf(stakingPool: Address, account: Address): Get staked balance
  • calculateAPR(pool: StakingPool, rewardTokenPriceUSD: number, totalStakedUSD: number): Calculate current pool APR
  • Node.js >= 18.0.0
  • viem >= 2.22.0
  1. Install dependencies:
npm install
  1. Build the package:
npm run build
  1. Run tests:
npm test
  1. Format code:
npm run format
  1. Lint code:
npm run lint

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
}
}

MIT