Skip to content

texture-fi/vault-sdk

Repository files navigation

Typescript SDK

Create position

import { PublicKey, Connection } from '@solana/web3.js';
import { Vault } from '@texture/vault';

const connection = new Connection();
const walletPublicKey = new PublicKey(/* test key */);

const vault = new Vault(connection, walletPublicKey);

const vaultKey = new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ') // vault key,

const instructions = [
    await vault.createPosition(vaultKey);
];

// send transaction

Refresh position

import { PublicKey, Connection } from '@solana/web3.js';
import { Vault } from '@texture/vault';

const connection = new Connection();
const walletPublicKey = new PublicKey(/* test key */);

const vault = new Vault(connection, walletPublicKey);

const vaultKey = new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ') // vault key,
const positionKey = new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ') // position key,

const instructions = [
    await vault.refreshPosition(vaultKey, positionKey);
];

// send transaction

Deposit

import { PublicKey, Connection } from '@solana/web3.js';
import { Vault } from '@texture/vault';

const connection = new Connection();
const walletPublicKey = new PublicKey(/* test key */);

const vault = new Vault(connection, walletPublicKey);

const vaultKey = new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ') // vault key,
const positionKey = new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ') // position key,
const liquiditySourceKey = new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ') // liquiditySource key,

const reserveKeys = [new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ')] // reserve keys
const amount = 100000000 // deposit amount

const instructions = [
    // refresh prices
    // refresh reserves
    await vault.deposit({vaultKey, positionKey, liquiditySourceKey, reserveKeys, amount});
    // refresh position
];

// send transaction

Withdraw

import { PublicKey, Connection } from '@solana/web3.js';
import { Vault } from '@texture/vault';

const connection = new Connection();
const walletPublicKey = new PublicKey(/* test key */);

const vault = new Vault(connection, walletPublicKey);

const vaultKey = new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ') // vault key,
const positionKey = new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ') // position key,
const liquidityDestinationKey = new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ') // liquidityDestination key,

const reserveKeys = [new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ')] // reserve keys
const amount = 100000000 // withdraw amount

const instructions = [
    // refresh prices
    // refresh reserves
    await vault.withdraw({vaultKey, positionKey, liquidityDestinationKey, reserveKeys, amount});
    // refresh position
];

// send transaction

Claim reward

import { PublicKey, Connection } from '@solana/web3.js';
import { Vault } from '@texture/vault';

const connection = new Connection();
const walletPublicKey = new PublicKey(/* test key */);

const vault = new Vault(connection, walletPublicKey);

const vaultKey = new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ') // vault key,
const positionKey = new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ') // position key,
const destinationWallet = new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ') // destinationWallet key,

const rewardMint = new PublicKey('3VZpYYp2DnjTDRC1qfy8Y9KKgV7QVGfrkViLg1BuhKiZ') // reward mint address

const instructions = [
    // refresh position
    await vault.clainReward(vaultKey, positionKey, destinationWallet, rewardMint);
];

// send transaction

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published