DeltaDeFi
  • About
    • 👋Introduction
    • 📖Learn
      • Architecture
        • Account
        • App Vault
        • Hydra
        • Intent and Process
        • Order Book
      • Trade
        • Order Types
      • Whitepaper
  • Start Trading
    • ⚡Getting Started
      • Create Account
      • Deposit
      • Place Order
      • Cancel Order
      • Withdrawal
      • API Key / Dashboard
    • ⚙️Developers
      • Introduction
        • Base Url
        • Auth
        • Assets
      • Getting started
        • Deposit funds
        • Place a new order
        • Cancel an order
        • Withdraw funds
      • API Documentation
        • Account
          • Create new api key
          • Build deposit transaction
          • Submit deposit transaction
          • Deposit records
          • Withdrawal records
          • Order records
          • Build withdrawal transaction
          • Submit withdrawal transaction
          • Balances
        • App
          • Get mock USDX (testnet only)
          • Submit USDX transaction (testnet only)
        • Market
          • Market Price
          • Market Depth
          • Aggregated trades
        • Order
          • Build order transaction
          • Submit order Transaction
          • Build cancel Order Transaction
          • Submit cancel order transaction
      • Websocket Endpoints
        • Account streams
        • Market price streams
        • Market depth streams
      • SDK
        • Typescript
        • Python
  • FAQ
    • General
    • Product
    • Cardano
    • Disclaimer
Powered by GitBook
On this page
  • About
  • Installation
  • Getting Started
  • Posting Order
  • Cancel Order
  • Note
  1. Start Trading
  2. Developers
  3. SDK

Typescript

About

DeltaDeFi's Typescript SDK provides utility functions to interact with the API service and sign transactions with provided keys.

Installation

The SDK is hosted on npmjs.com, so you can directly import it using your favorite package manager.

npm i @deltadefi-protocol/typescript-sdk
yarn add @deltadefi-protocol/typescript-sdk

Getting Started

Placing and canceling orders are as simple as below.

import { AppWalletKeyType } from '@meshsdk/core';
import { ApiClient } from '@deltadefi-protocol/typescript-sdk';

// Obtain your API key through DeltaDeFi dashboard
const apiKey = process.env.API_KEY || '';

// Loading the wallet with seed phrase (same as your account obtaining API key)
// Documentation - https://meshjs.dev/apis/appwallet
const signingKey: AppWalletKeyType = {
    type: 'mnemonic',
    words: (process.env.MNEMONIC || '').split(',') || [],
};

// Initializing programmatic API client
const api = new ApiClient({ apiKey, signingKey, network: 'preprod' });

Posting Order

// Posting order instantly without fee
const buildRes = await api.postOrder({
    pair: 'ADAUSDX',
    side: 'sell',
    type: 'limit',
    quantity: 1000_000_000,
    price: 0.62,
});

Cancel Order

// Canceling order instantly without fee
const cancelRes = await api.orders.cancelOrder(buildRes.order.order_id);
console.log('cancel order response', cancelRes);

Note

Current seed phrase wallet loading supports only the first account's first address (i.e. m/1852'/1815'/0'/0/0 when you check inside your browser wallet), for example in Eternl's single address mode:

If you are looking to connect a more dynamic account, please get in touch with the team for support.

PreviousSDKNextPython

Last updated 2 months ago

⚙️