5.3.0 • Published 3 years ago

@hydraprotocol/sdk v5.3.0

Weekly downloads
-
License
MIT
Repository
-
Last release
3 years ago

Hydraprotocol Javascript SDK

Overview

A Javascript SDK for inteacting with Hydra Protocol.

Important links:

Disclaimer

This is experimental software all APIs are subject to change.

Installation

Install via your favourite npm client*:

yarn add --dev @hydraprotocol/sdk

* Coming soon!

Basic Usage

import { HydraSDK, Network } from "@hydraprotocol/sdk";
import { Wallet } from "@project-serum/anchor";
import { Connection } from "@solana/web3.js";
import { loadKeypair } from "./helpers";

// Setup configuration
const keypair = loadKeypair("./path/to/keypair");
const wallet = new Wallet(keypair);
const connection = new Connection("https://api.devnet.solana.com");

// Create the client
const hydra = HydraSDK.create(Network.DEVNET, connection, wallet);

// Call a contract method
const txHash = await hydra.liquidityPools.addLiquidity(
  tokenXMint,
  tokenYMint,
  poolId,
  tokenXAmount,
  tokenYAmount,
  slippage
);

console.log(`Your transaction hash: ${txHash}`);