Skip to content

deltadefi-protocol/typescript-sdk

Folders and files

NameName
Last commit message
Last commit date

Latest commit

7619aa8 · Mar 23, 2025
Dec 15, 2024
Dec 15, 2024
Mar 23, 2025
Mar 23, 2025
Dec 10, 2024
Jan 27, 2024
Jul 2, 2024
Jan 27, 2024
Jan 27, 2024
Jan 24, 2025
Apr 23, 2024
Mar 23, 2025
Mar 23, 2025
Mar 18, 2025
Dec 15, 2024

Repository files navigation

UTxO Orderbook TypeScript SDK

The UTxO Orderbook TypeScript SDK provides a convenient way to interact with the DeltaDefi API. It includes classes and methods for managing accounts, orders, markets, and wallets.

Installation

To install the SDK, use npm:

npm i @deltadefi-protocol/typescript-sdk

Usage

Importing the SDK

import { ApiClient } from 'deltadefi-typescript-sdk';

Creating an Instance

const apiClient = new ApiClient({
    network: 'preprod',
    jwt: 'your-jwt-token',
    apiKey: 'your-api-key',
    signingKey: 'your-signing-key',
});

Sign In

const signInData: SignInRequest = {
    x_api_key: 'your-api-key',
    wallet_address: 'your-wallet-address',
};

apiClient.accounts
    .signIn(signInData)
    .then((response) => {
        console.log('Sign-in successful:', response);
    })
    .catch((error) => {
        console.error('Error during sign-in:', error);
    });

Orders

const postOrderData: PostOrderRequest = {
    symbol: 'ADAUSDX',
    side: 'buy',
    type: 'limit',
    quantity: 100,
    price: 1.5,
    max_slippage: true,
};

apiClient
    .postOrder(postOrderData)
    .then((response) => {
        console.log('Order posted successfully:', response);
    })
    .catch((error) => {
        console.error('Error posting order:', error);
    });

Markets

const marketDepthData: GetMarketDepthRequest = {
    pair: 'ADAUSDX',
};

apiClient.markets
    .getDepth(marketDepthData)
    .then((response) => {
        console.log('Market depth:', response);
    })
    .catch((error) => {
        console.error('Error getting market depth:', error);
    });

Wallet

const txHex = 'your-transaction-hex';

apiClient.wallet
    ?.signTx(txHex)
    .then((signedTx) => {
        console.log('Signed transaction:', signedTx);
    })
    .catch((error) => {
        console.error('Error signing transaction:', error);
    });

License

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0