1.1.52 • Published 6 months ago

@0xshogun/sdk v1.1.52

Weekly downloads
-
License
ISC
Repository
github
Last release
6 months ago

Shogun SDK Integration

Overview

The Shogun SDK is a TypeScript library that enables cross-chain swaps and transfers between EVM chains and Solana. It provides quote fetching, transaction execution, and fee management capabilities.

Installation

npm install @0xshogun/sdk

or

yarn add @0xshogun/sdk

Features

  • Cross-chain token swaps between EVM chains and Solana
  • Quote fetching for optimal swap rates
  • Transaction execution management
  • Fee estimation and management
  • Balance tracking across chains

Supported Chains

  • Ethereum
  • Base
  • Arbitrum
  • Binance Smart Chain
  • Berachain
  • Sonic
  • Solana

Requirements

  • Node.js 16 or higher
  • TypeScript 4.5 or higher

Quick Start

import { ShogunQuoteApiClient } from '@0xshogun/sdk';

// Initialize the client

const client = new ShogunQuoteApiClient(
  'YOUR_API_KEY', // Dextra API key
  'https://api.shogun.com' // Dextra API endpoint
);

// Fetch a quote

const quoteParams: QuoteParams = {
  srcChain: 1, // Token IN chain ID
  destChain: 8453, // Token Out chain ID
  srcToken: '0x...', // Source token address
  destToken: '...', // Destination token address
  amount: '1000000000000000000', // Amount in smallest unit (e.g. wei)
  senderAddress: '0x...', // Sender's wallet address
  affiliateWallet: '0x...', // Affiliate EVM or Solana wallet address
  affiliateFee: '1', // Affiliate fee in percent as 1%
  slippage: 0.5, // Slippage percentage
  destinationAddress: '...', // Destination wallet address
  dstChainOrderAuthorityAddress: '...' // Destination chain order authority address
  dynamicSlippage: true // Or false, only for Solana transactions
};

const quote = await client.fetchQuote(quoteParams);

Balance Checking

The SDK provides balance checking capabilities for both EVM and Solana chains through the ShogunBalancesApiClient.

import { ShogunBalancesApiClient } from '@0xshogun/sdk';

// Initialize the balances client
const balancesClient = new ShogunBalancesApiClient('YOUR_API_KEY'); // YOUR_API_KEY is CODEX API key

// Check EVM wallet balances
const evmBalances = await balancesClient.getEvmWalletBalance('0x...');

// Get token info including prices
const tokenInfo = await balancesClient.getTokenInfo(
  evmBalances,
  '0x...', // wallet address
);

// Check Solana token balances
const solanaBalances = await balancesClient.getSolanaTokenBalances('...');

// Get USD price for a specific token
const tokenPrice = await balancesClient.getTokenUSDPrice(
  '0x...', // token address
  1 // chain ID
);

// Validate addresses
const isValid = balancesClient.isValidAddress('0x...');

Development

Install dependencies

npm install

Build the package

npm run build

Run tests

npm test

Format code

npm run format

Lint code

npm run lint

Contributing Contributions are welcome! Please read our Contributing Guide for details on our code of conduct and the process for submitting pull requests.

1.1.52

6 months ago

1.1.51-beta

6 months ago

1.1.50-beta

6 months ago

1.1.49

6 months ago

1.1.48

6 months ago

1.1.47

6 months ago

1.1.46

7 months ago

1.1.45

7 months ago

1.1.44

7 months ago

1.1.43

7 months ago

1.1.42

7 months ago

1.1.41

7 months ago

1.1.40

7 months ago

1.1.39

7 months ago

1.1.38

7 months ago

1.1.37

7 months ago

1.1.36

7 months ago

1.1.35

7 months ago

1.1.34

7 months ago

1.1.33

7 months ago

1.1.32

7 months ago

1.1.31

7 months ago

1.1.30

7 months ago

1.1.29

7 months ago

1.1.28

7 months ago

1.1.27

7 months ago

1.1.26

7 months ago

1.1.25

7 months ago

1.1.21

7 months ago

1.1.20

7 months ago

1.1.19

7 months ago

1.1.18

7 months ago

1.1.17

7 months ago

1.1.16

7 months ago

1.1.15

7 months ago

1.1.14

7 months ago

1.1.13

7 months ago

1.1.12

7 months ago

1.1.11

7 months ago

1.1.10

7 months ago

1.1.9

7 months ago

1.1.8

7 months ago

1.1.7

7 months ago

1.1.6

7 months ago

1.1.5

7 months ago

1.1.4

7 months ago

1.1.3

7 months ago

1.1.2

7 months ago

1.1.0

7 months ago

1.0.17

7 months ago

1.0.16

7 months ago

1.0.15

7 months ago

1.0.14

7 months ago

1.0.13

7 months ago

1.0.12

7 months ago

1.0.11

7 months ago

1.0.10

7 months ago

1.0.9

7 months ago

1.0.8

7 months ago

1.0.7

7 months ago

1.0.6

7 months ago

1.0.5

7 months ago

1.0.4

7 months ago

1.0.3

7 months ago

1.0.2

7 months ago

1.0.1

7 months ago

1.0.0

7 months ago