Skip to content

Conversation

@rafinskipg
Copy link
Collaborator

This PR introduces the SwapperSDK, a TypeScript SDK for seamless token swaps and cross-chain bridges across Solana, Ethereum, Base, Polygon, and Arbitrum networks.

Key Features

  • Multi-chain swaps: Native and token swaps on Solana, Ethereum, Base, Polygon, and Arbitrum
  • Cross-chain bridges: Bridge tokens between supported networks with automatic routing
  • Type-safe API: Full TypeScript support with comprehensive type definitions
  • Token constants: Pre-defined token configurations for major tokens on all networks
  • Retry logic: Built-in retry mechanism with exponential backoff for reliability
  • Debugging support: Optional debug logging for API requests/responses

Usage Examples

Simple Solana swap:
import SwapperSDK, { TOKENS, NetworkId } from '@phantom/swapper-sdk';

const sdk = new SwapperSDK({ apiUrl: 'https://api.phantom.app' });

const quotes = await sdk.getQuotes({
  sellToken: TOKENS.SOLANA_MAINNET.SOL,
  buyToken: TOKENS.SOLANA_MAINNET.USDC,
  sellAmount: '100000000', // 0.1 SOL
  from: {
    address: 'Your-Solana-Address',
    networkId: NetworkId.SOLANA_MAINNET,
  },
});

Cross-chain bridge from Ethereum to Solana:

  const bridgeQuotes = await sdk.getQuotes({
    sellToken: TOKENS.ETHEREUM_MAINNET.USDC,
    buyToken: TOKENS.SOLANA_MAINNET.USDC,
    sellAmount: '10000000', // 10 USDC
    from: {
      address: '0xYour-ETH-Address',
      networkId: NetworkId.ETHEREUM_MAINNET,
    },
    to: {
      address: 'Your-Solana-Address',
      networkId: NetworkId.SOLANA_MAINNET,
    },
  });

Token Constants

The SDK exports pre-configured token definitions:

  • TOKENS.ETHEREUM_MAINNET - ETH, USDC, USDT, WETH
  • TOKENS.BASE_MAINNET - ETH, USDC, WETH
  • TOKENS.POLYGON_MAINNET - MATIC, USDC, USDT, WETH
  • TOKENS.ARBITRUM_ONE - ETH, USDC, USDT, WETH
  • TOKENS.SOLANA_MAINNET - SOL, USDC, USDT, WSOL

@rafinskipg rafinskipg requested a review from a team as a code owner August 9, 2025 19:17
@socket-security
Copy link

socket-security bot commented Aug 9, 2025

Review the following changes in direct dependencies. Learn more about Socket for GitHub.

Diff Package Supply Chain
Security
Vulnerability Quality Maintenance License
Addedeventsource@​2.0.21001009885100

View full report

}

// Log retry attempt
// console.log(`Attempt ${attempt} failed, retrying after ${delay}ms...`, error);
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

we should remove the console.logs

}

const walletAddress = addresses.find(
addr => addr.addressType === networkConfig.addressFormat as any
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

no any

@maximgeerinck maximgeerinck self-requested a review August 11, 2025 16:30
Copy link
Collaborator

@maximgeerinck maximgeerinck left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

awaiting legal feedback

@rafinskipg rafinskipg marked this pull request as draft September 5, 2025 14:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants