@o2exchange/sdk
v0.0.3
Published
SDK for the O2 Exchange
Downloads
129
Readme
@o2exchange/sdk
Official TypeScript SDK for interacting with the O2 Exchange API and smart contracts.
Installation
npm install @o2exchange/sdk [email protected]pnpm install @o2exchange/sdk [email protected]bun add @o2exchange/sdk [email protected]Usage
API Client
import { TraderAccount } from '@o2exchange/sdk';
import { Action, OrderType, OrderSide } from '@o2exchange/sdk';
const traderAccount = await TraderAccount.create({
api: 'https://api.testnet.o2.app',
provider: 'https://testnet.fuel.network/v1/graphql',
pair: ['FUEL', 'USDC'],
tradeAccountId: '0x....',
sessionKey: '0x....',
});
const { tx_id, orders } = await traderAccount.executeActions([{
type: Action.CreateOrder,
payload: {
type: OrderType.Spot,
side: OrderSide.Buy,
price: 100_000000000n,
quantity: 5_000000000n,
},
}]);
console.log('tx_id', tx_id);
console.log('orders', orders);