1.19.3 • Published 6 months ago

@steerprotocol/sdk v1.19.3

Weekly downloads
-
License
MIT
Repository
-
Last release
6 months ago

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 viem

Usage

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

Requirements

  • Node.js >= 18.0.0
  • viem >= 2.22.0

Development

  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

Troubleshooting

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

1.15.0

6 months ago

1.14.1

6 months ago

1.11.4

8 months ago

1.14.0

7 months ago

1.11.3

8 months ago

1.13.0

7 months ago

1.12.1

7 months ago

1.11.2

8 months ago

1.12.0

7 months ago

1.11.1

8 months ago

1.19.0

6 months ago

1.18.1

6 months ago

1.11.8

7 months ago

1.18.0

6 months ago

1.15.3

6 months ago

1.11.7

7 months ago

1.17.0

6 months ago

1.15.2

6 months ago

1.11.6

7 months ago

1.16.0

6 months ago

1.15.1

6 months ago

1.11.5

7 months ago

1.19.3

6 months ago

1.18.4

6 months ago

1.9.0

8 months ago

1.19.2

6 months ago

1.18.3

6 months ago

1.7.1

8 months ago

1.19.1

6 months ago

1.18.2

6 months ago

1.11.0

8 months ago

1.10.0

8 months ago

1.7.0

9 months ago

1.6.0

9 months ago

1.5.0

10 months ago

1.4.0

10 months ago

1.3.0

10 months ago

1.2.0

10 months ago

1.1.0

10 months ago

1.0.0

10 months ago

0.1.4

11 months ago

0.1.3

11 months ago

0.1.2

11 months ago

0.1.1

11 months ago

0.1.0

11 months ago