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.
// 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 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 APRnpm install
npm run build
npm test
npm run format
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