1.0.12 • Published 1 year ago

@sentre/otc-sdk v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

OTC SDK

https://img.shields.io/npm/v/@sentre/otc-sdk https://img.shields.io/npm/dw/@sentre/otc-sdk https://img.shields.io/bundlephobia/min/@sentre/otc-sdk https://img.shields.io/github/issues-raw/descartesnetwork/otc-sdk https://img.shields.io/github/license/descartesnetwork/otc-sdk

https://img.shields.io/twitter/follow/SentreProtocol?style=social

Solana OTC Service SDK. Users can exchange SPL tokens for SOL even with no SOL for transaction fees. Currently, the service is available on mainnet ONLY.

✨ Receive exactly desired amount of SOL. No slippage. No price impact.

✨ Never care about transaction fees.

✨ Zero down time.

Installation

npm i @sentre/otc-sdk

or,

yarn add @sentre/otc-sdk

Who are using?

  1. Any Arts - Buy NFTs on Magic Eden by your SPL tokens.
  2. Sen Assets - Feel annoying to withdraw SOL from Binance for transaction fees on Solana? This app will let you exchange SPL tokens to SOL with no transaction fees.

Usage

import { OTC } from '@sentre/otc-sdk'

const otc = new OTC()

/**
 * Get whitelisted spl tokens
 * You can quick review whitelist by: https://cors.sentre.io/otc/whitelist
 */
const whitelist = await otc.getWhitelist()
// {
//   usdc: {
//     address: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
//     symbol: 'USDC',
//     decimals: 6,
//     url: 'https://www.circle.com/en/usdc',
//   },
//   uxd: {
//     address: '7kbnvuGBxxj8AG9qp8Scn56muWGaRaFqxg1FsRp3PaFT',
//     symbol: 'UXD',
//     decimals: 6,
//     url: 'https://uxd.fi/',
//   }
// }

/**
 * Get SOL price based on USDC or UXD
 */
const solPriceBasedOnUSDC = await otc.getSolPrice({ tokenSymbol: 'usdc' })
// {
//   data: {
//     id: 'So11111111111111111111111111111111111111112',
//     mintSymbol: 'SOL',
//     vsToken: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
//     vsTokenSymbol: 'USDC',
//     price: 34.968693228,
//   },
//   timeTaken: 0.047694273001980036,
// }
const solPriceBasedOnUXD = await otc.getSolPrice({ tokenSymbol: 'uxd' })
// {
//   data: {
//     id: 'So11111111111111111111111111111111111111112',
//     mintSymbol: 'SOL',
//     vsToken: '7kbnvuGBxxj8AG9qp8Scn56muWGaRaFqxg1FsRp3PaFT',
//     vsTokenSymbol: 'UXD',
//     price: 34.972632341,
//   },
//   timeTaken: 0.010716108001361135,
// }

/**
 * Get exchange tx of usdc for 1 sol
 */
const wallet = <Your_Wallet_Instance_Here>
const tx = await otc.exchange({
  walletAddress: wallet.publicKey.toBase58(),
  tokenSymbol: 'usdc',
  solAmount: 1
})
const signedTx = await wallet.signTransaction(tx)
const txId = await sendTransaction(signedTx) // This function is just a pseudo-code and should replaced it by yours.

Whitelist

👉 Current whitelist: https://cors.sentre.io/otc/whitelist

👉 Wanna support more SPL tokens? Let's create a proposal here: https://github.com/DescartesNetwork/otc-sdk

1.0.12

1 year ago

1.0.11

2 years ago

1.0.10

2 years ago

1.0.9

2 years ago

1.0.8

2 years ago

1.0.7

2 years ago

1.0.6

2 years ago

1.0.5

2 years ago

1.0.4

2 years ago

1.0.3

2 years ago

1.0.2

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago