Installation
You can install the SDK usingnpm from the GitHub repository:
Copy
npm i github:bison-markets/sdk-ts
Basic Usage
example.ts
Copy
import { createBisonClient } from 'bison-sdk-ts';
import { createWalletClient, createPublicClient, http, custom } from 'viem';
import { base } from 'viem/chains';
// Create a client instance
const client = createBisonClient({
baseUrl: 'https://api.bison.markets'
});
// Create a wallet client for signing transactions
const walletClient = createWalletClient({
chain: base,
transport: custom(window.ethereum!),
});
// Create a public client for reading blockchain state
const publicClient = createPublicClient({
chain: base,
transport: http(),
});
// Deposit 100 USDC into the vault
const txHash = await client.executeDepositFlow({
walletClient,
publicClient,
userAddress: '0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
chain: 'base', // Addresses are auto-resolved and cached
amountUusdc: 100_000_000, // 100 USDC
});
console.log('Deposited! Transaction:', txHash);
// Start listening for account events
const disconnect = client.listen(
'0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266',
(event) => {
if (event.type === 'usdc_deposited') {
console.log('USDC deposit confirmed:', event.uusdcAmount / 1_000_000, 'USDC');
} else if (event.type === 'order_filled') {
console.log('Order filled:', event.orderId);
}
}
);
// Clean up when done
// disconnect();
Configuration
The SDK requires only the base URL of the Bison API:Copy
const client = createBisonClient({
baseUrl: 'https://api.bison.markets'
});