Socket
Socket
Sign inDemoInstall

@orca-so/sdk

Package Overview
Dependencies
Maintainers
2
Versions
51
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@orca-so/sdk - npm Package Compare versions

Comparing version 1.1.2 to 1.1.3

7

dist/constants/pools.d.ts

@@ -30,2 +30,9 @@ import { OrcaPoolParams } from "../model/orca/pool/pool-types";

export declare const portUsdcPool: OrcaPoolParams;
export declare const sbrUsdcPool: OrcaPoolParams;
export declare const socnUsdcPool: OrcaPoolParams;
export declare const psolUsdcPool: OrcaPoolParams;
export declare const msolSolPool: OrcaPoolParams;
export declare const orcaPaiPool: OrcaPoolParams;
export declare const orcaMsolPool: OrcaPoolParams;
export declare const socnSolPool: OrcaPoolParams;
/**

@@ -32,0 +39,0 @@ * Mapping for OrcaPool parameters

137

dist/constants/pools.js

@@ -22,3 +22,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.orcaPoolConfigs = exports.portUsdcPool = exports.slrsUsdcPool = exports.msolUsdcPool = exports.snyUsdcPool = exports.liqUsdcPool = exports.samoSolPool = exports.kinSolPool = exports.orcaUsdcPool = exports.orcaSolPool = exports.usdcUsdtPool = exports.mapsSolPool = exports.fidaSolPool = exports.merSolPool = exports.btcSolPool = exports.oxySolPool = exports.copeSolPool = exports.fttSolPool = exports.srmSolPool = exports.stepSolPool = exports.ropeSolPool = exports.raySolPool = exports.ethUsdcPool = exports.ethSolPool = exports.solUsdtPool = exports.solUsdcPool = void 0;
exports.orcaPoolConfigs = exports.socnSolPool = exports.orcaMsolPool = exports.orcaPaiPool = exports.msolSolPool = exports.psolUsdcPool = exports.socnUsdcPool = exports.sbrUsdcPool = exports.portUsdcPool = exports.slrsUsdcPool = exports.msolUsdcPool = exports.snyUsdcPool = exports.liqUsdcPool = exports.samoSolPool = exports.kinSolPool = exports.orcaUsdcPool = exports.orcaSolPool = exports.usdcUsdtPool = exports.mapsSolPool = exports.fidaSolPool = exports.merSolPool = exports.btcSolPool = exports.oxySolPool = exports.copeSolPool = exports.fttSolPool = exports.srmSolPool = exports.stepSolPool = exports.ropeSolPool = exports.raySolPool = exports.ethUsdcPool = exports.ethSolPool = exports.solUsdtPool = exports.solUsdcPool = void 0;
const web3_js_1 = require("@solana/web3.js");

@@ -482,2 +482,130 @@ const pool_types_1 = require("../model/orca/pool/pool-types");

});
exports.sbrUsdcPool = Object.freeze({
address: new web3_js_1.PublicKey("HiYggjP2fN53Jw46e5UuskqNP3HH98jceRxEgVoeRwNw"),
nonce: 255,
authority: new web3_js_1.PublicKey("ATkEV1nEkdp7zgaGpzFCsJ5WAyejcJbxqzGhQpfcDW4S"),
poolTokenMint: new web3_js_1.PublicKey("CS7fA5n4c2D82dUoHrYzS3gAqgqaoVSfgsr18kitp2xo"),
poolTokenDecimals: 6,
feeAccount: new web3_js_1.PublicKey("7S3KKuvcHfcKWBGLDwmoTgtB97JE8LHruP8jbmQkGfH"),
tokenIds: [Tokens.sbrToken.mint.toString(), Tokens.usdcToken.mint.toString()],
tokens: {
[Tokens.sbrToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.sbrToken), { addr: new web3_js_1.PublicKey("DrJTQqNZqNCf2HDLpYg9zRCMRwnhZEVQuGjeaWtX6CA7") }),
[Tokens.usdcToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.usdcToken), { addr: new web3_js_1.PublicKey("DEVLUv1uiUSukQoBdy9fDQyehi4N2Boojy8J2LQ8bK2E") }),
},
curveType: pool_types_1.CurveType.ConstantProduct,
feeStructure: {
traderFee: percentage_1.Percentage.fromFraction(25, 10000),
ownerFee: percentage_1.Percentage.fromFraction(5, 10000),
},
});
exports.socnUsdcPool = Object.freeze({
address: new web3_js_1.PublicKey("6Gh36sNXrGWYiWr999d9iZtqgnipJbWuBohyHBN1cJpS"),
nonce: 255,
authority: new web3_js_1.PublicKey("GXWEpRURaQZ9E62Q23EreTUfBy4hfemXgWFUWcg7YFgv"),
poolTokenMint: new web3_js_1.PublicKey("Dkr8B675PGnNwEr9vTKXznjjHke5454EQdz3iaSbparB"),
poolTokenDecimals: 6,
feeAccount: new web3_js_1.PublicKey("HsC1Jo38jK3EpoNAkxfoUJhQVPa28anewZpLfeouUNk7"),
tokenIds: [Tokens.socnToken.mint.toString(), Tokens.usdcToken.mint.toString()],
tokens: {
[Tokens.socnToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.socnToken), { addr: new web3_js_1.PublicKey("7xs9QsrxQDVoWQ8LQ8VsVjfPKBrPGjvg8ZhaLnU1i2VR") }),
[Tokens.usdcToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.usdcToken), { addr: new web3_js_1.PublicKey("FZFJK64Fk1t619zmVPqCx8Uy29zJ3WuvjWitCQuxXRo3") }),
},
curveType: pool_types_1.CurveType.ConstantProduct,
feeStructure: {
traderFee: percentage_1.Percentage.fromFraction(25, 10000),
ownerFee: percentage_1.Percentage.fromFraction(5, 10000),
},
});
exports.psolUsdcPool = Object.freeze({
address: new web3_js_1.PublicKey("GW1Xt9HHtvcnky8X7aBA3BoTgiirJKP5XwC5REFcZSsc"),
nonce: 254,
authority: new web3_js_1.PublicKey("GXueH9K1MzRncoTYbpLiXXC3WrKkmHUFxV5JEu8oADbw"),
poolTokenMint: new web3_js_1.PublicKey("C2YzN6MymD5HM2kPaH7bzcbqciyjfmpqyVaR3KA5V6z1"),
poolTokenDecimals: 6,
feeAccount: new web3_js_1.PublicKey("BhHd49JYH3Hk6TV5kCjmUgf7fQSQKDjaWTokMmBhTx9o"),
tokenIds: [Tokens.psolToken.mint.toString(), Tokens.usdcToken.mint.toString()],
tokens: {
[Tokens.psolToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.psolToken), { addr: new web3_js_1.PublicKey("F7XioZaGe99nosYJQCahx25TKgdUGufYf6sudm1JSgu") }),
[Tokens.usdcToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.usdcToken), { addr: new web3_js_1.PublicKey("BT14DfFyNS7qcBGc8TY4HAzDev4vvqsoFBJgjtQpdM2Z") }),
},
curveType: pool_types_1.CurveType.ConstantProduct,
feeStructure: {
traderFee: percentage_1.Percentage.fromFraction(25, 10000),
ownerFee: percentage_1.Percentage.fromFraction(5, 10000),
},
});
exports.msolSolPool = Object.freeze({
address: new web3_js_1.PublicKey("9EQMEzJdE2LDAY1hw1RytpufdwAXzatYfQ3M2UuT9b88"),
nonce: 250,
authority: new web3_js_1.PublicKey("6cwehd4xhKkJ2s7iGh4CaDb7KhMgqczSBnyNJieUYbHn"),
poolTokenMint: new web3_js_1.PublicKey("29cdoMgu6MS2VXpcMo1sqRdWEzdUR9tjvoh8fcK8Z87R"),
poolTokenDecimals: 6,
feeAccount: new web3_js_1.PublicKey("6j2tt2UVYMQwqG3hRtyydW3odzBFwy3pN33tyB3xCKQ6"),
tokenIds: [Tokens.msolToken.mint.toString(), Tokens.solToken.mint.toString()],
tokens: {
[Tokens.msolToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.msolToken), { addr: new web3_js_1.PublicKey("6xmki5RtGNHrfhTiHFfp9k3RQ9t8qgL1cYP2YCG2h179") }),
[Tokens.solToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.solToken), { addr: new web3_js_1.PublicKey("Ew2coQtVGLeca31vqB2ssHntjzZgUy1ad9VuuAX8yw7p") }),
},
curveType: pool_types_1.CurveType.Stable,
amp: 100,
feeStructure: {
traderFee: percentage_1.Percentage.fromFraction(6, 10000),
ownerFee: percentage_1.Percentage.fromFraction(1, 10000),
},
});
exports.orcaPaiPool = Object.freeze({
address: new web3_js_1.PublicKey("7LfLiCnoLPefaCVuh6z92TK2tPZUa9bPjW7gHT4jqrec"),
nonce: 254,
authority: new web3_js_1.PublicKey("AwUWHxHyQHomqCGJJvagiSDhb2xMqJUiE25qDytdMw49"),
poolTokenMint: new web3_js_1.PublicKey("C7TH2jEJJaxVwwuvkbcDGfHUiZvEkkeYjyAcdTMi5ujb"),
poolTokenDecimals: 6,
feeAccount: new web3_js_1.PublicKey("DrC2aGWrUmsnK6yAphSXEs8GW5nKUCkityaG8Bikn5Ne"),
tokenIds: [Tokens.orcaToken.mint.toString(), Tokens.paiToken.mint.toString()],
tokens: {
[Tokens.orcaToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.orcaToken), { addr: new web3_js_1.PublicKey("HSUFpGyNXEogXQLgEMQ7aMTxE4HZneRaBovbi9btXepM") }),
[Tokens.paiToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.paiToken), { addr: new web3_js_1.PublicKey("4c9rkBiqAY6fXpVvCbDwpDD44AGQ3MXSaCLcpmLUFtrX") }),
},
curveType: pool_types_1.CurveType.ConstantProduct,
feeStructure: {
traderFee: percentage_1.Percentage.fromFraction(25, 10000),
ownerFee: percentage_1.Percentage.fromFraction(5, 10000),
},
});
exports.orcaMsolPool = Object.freeze({
address: new web3_js_1.PublicKey("49tTgthTYLMPEqozZNyEQifqkGYxHqqDie9YxVczS3iB"),
nonce: 255,
authority: new web3_js_1.PublicKey("9FQ9gDtS6uNr5SMPafuzkDit2rMftHfQuz5mg2X3TqHT"),
poolTokenMint: new web3_js_1.PublicKey("CVapmQn7HaU1yMDW3q6oUV4hx6XoYv54T4zfGXkuJqkA"),
poolTokenDecimals: 6,
feeAccount: new web3_js_1.PublicKey("Hq9xxKdMavJd4teMZusF4PiGNGV3hxdcMZwAdngkHCg7"),
tokenIds: [Tokens.orcaToken.mint.toString(), Tokens.msolToken.mint.toString()],
tokens: {
[Tokens.orcaToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.orcaToken), { addr: new web3_js_1.PublicKey("7hoYJc4aqttctANrNe75gscdmQD9HcXZED6AjdDdZMQ9") }),
[Tokens.msolToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.msolToken), { addr: new web3_js_1.PublicKey("7MuvRUFT1wWiL7uJKdZqNwk9Fmz2HJ36bEArhDTnyFij") }),
},
curveType: pool_types_1.CurveType.ConstantProduct,
feeStructure: {
traderFee: percentage_1.Percentage.fromFraction(25, 10000),
ownerFee: percentage_1.Percentage.fromFraction(5, 10000),
},
});
exports.socnSolPool = Object.freeze({
address: new web3_js_1.PublicKey("2q6UMko5kTnv866W9MTeAFau94pLpsdeNjDdSYSgZUXr"),
nonce: 255,
authority: new web3_js_1.PublicKey("Gyd77CwV23qq937x9UDa4TDkxEeQF9tp8ifotYxqW3Kd"),
poolTokenMint: new web3_js_1.PublicKey("APNpzQvR91v1THbsAyG3HHrUEwvexWYeNCFLQuVnxgMc"),
poolTokenDecimals: 6,
feeAccount: new web3_js_1.PublicKey("42Xzazs9EvjtidvEDrj3JXbDtf6fpTq5XHh96mPctvBV"),
tokenIds: [Tokens.socnToken.mint.toString(), Tokens.solToken.mint.toString()],
tokens: {
[Tokens.socnToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.socnToken), { addr: new web3_js_1.PublicKey("C8DRXUqxXtUgvgBR7BPAmy6tnRJYgVjG27VU44wWDMNV") }),
[Tokens.solToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.solToken), { addr: new web3_js_1.PublicKey("DzdxH5qJ68PiM1p5o6PbPLPpDj8m1ZshcaMFATcxDZix") }),
},
curveType: pool_types_1.CurveType.Stable,
amp: 100,
feeStructure: {
traderFee: percentage_1.Percentage.fromFraction(6, 10000),
ownerFee: percentage_1.Percentage.fromFraction(1, 10000),
},
});
/**

@@ -513,2 +641,9 @@ * Mapping for OrcaPool parameters

F8gPSpwVHj8FdAJAYULDuZBxFEJut87hUbARYYx3471w: exports.portUsdcPool,
CS7fA5n4c2D82dUoHrYzS3gAqgqaoVSfgsr18kitp2xo: exports.sbrUsdcPool,
Dkr8B675PGnNwEr9vTKXznjjHke5454EQdz3iaSbparB: exports.socnUsdcPool,
C2YzN6MymD5HM2kPaH7bzcbqciyjfmpqyVaR3KA5V6z1: exports.psolUsdcPool,
"29cdoMgu6MS2VXpcMo1sqRdWEzdUR9tjvoh8fcK8Z87R": exports.msolSolPool,
C7TH2jEJJaxVwwuvkbcDGfHUiZvEkkeYjyAcdTMi5ujb: exports.orcaPaiPool,
CVapmQn7HaU1yMDW3q6oUV4hx6XoYv54T4zfGXkuJqkA: exports.orcaMsolPool,
APNpzQvR91v1THbsAyG3HHrUEwvexWYeNCFLQuVnxgMc: exports.socnSolPool,
};

@@ -16,2 +16,3 @@ import { OrcaToken } from "..";

export declare const oxyToken: OrcaToken;
export declare const paiToken: OrcaToken;
export declare const portToken: OrcaToken;

@@ -21,4 +22,6 @@ export declare const rayToken: OrcaToken;

export declare const samoToken: OrcaToken;
export declare const sbrToken: OrcaToken;
export declare const slrsToken: OrcaToken;
export declare const snyToken: OrcaToken;
export declare const socnToken: OrcaToken;
export declare const solToken: OrcaToken;

@@ -30,1 +33,2 @@ export declare const srmToken: OrcaToken;

export declare const msolToken: OrcaToken;
export declare const psolToken: OrcaToken;
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.msolToken = exports.usdtToken = exports.usdcToken = exports.stepToken = exports.srmToken = exports.solToken = exports.snyToken = exports.slrsToken = exports.samoToken = exports.ropeToken = exports.rayToken = exports.portToken = exports.oxyToken = exports.orcaToken = exports.merToken = exports.mapsToken = exports.liqToken = exports.kinToken = exports.fttToken = exports.fidaToken = exports.ethToken = exports.copeToken = exports.btcToken = void 0;
exports.psolToken = exports.msolToken = exports.usdtToken = exports.usdcToken = exports.stepToken = exports.srmToken = exports.solToken = exports.socnToken = exports.snyToken = exports.slrsToken = exports.sbrToken = exports.samoToken = exports.ropeToken = exports.rayToken = exports.portToken = exports.paiToken = exports.oxyToken = exports.orcaToken = exports.merToken = exports.mapsToken = exports.liqToken = exports.kinToken = exports.fttToken = exports.fidaToken = exports.ethToken = exports.copeToken = exports.btcToken = void 0;
const web3_js_1 = require("@solana/web3.js");

@@ -74,2 +74,8 @@ /**

});
exports.paiToken = Object.freeze({
tag: "PAI",
name: "Parrot Stable",
mint: new web3_js_1.PublicKey("Ea5SjE2Y6yvCeW5dYTn7PYMuW5ikXkvbGdcmSnXeaLjS"),
scale: 6,
});
exports.portToken = Object.freeze({

@@ -99,2 +105,8 @@ tag: "PORT",

});
exports.sbrToken = Object.freeze({
tag: "SBR",
name: "Saber",
mint: new web3_js_1.PublicKey("Saber2gLauYim4Mvftnrasomsv6NvAuncvMEZwcLpD1"),
scale: 6,
});
exports.slrsToken = Object.freeze({

@@ -112,2 +124,8 @@ tag: "SLRS",

});
exports.socnToken = Object.freeze({
tag: "SOCN",
name: "Socean",
mint: new web3_js_1.PublicKey("5oVNBeEEQvYi1cX3ir8Dx5n1P7pdxydbGF2X4TxVusJm"),
scale: 9,
});
exports.solToken = Object.freeze({

@@ -149,1 +167,7 @@ tag: "SOL",

});
exports.psolToken = Object.freeze({
tag: "pSOL",
name: "pSOL",
mint: new web3_js_1.PublicKey("9EaLkQrbjmbbuZG9Wdpo8qfNUEjHATJFSycEmw6f1rGX"),
scale: 9,
});

8

dist/model/orca/pool/orca-pool.d.ts
import { Connection, PublicKey, Keypair } from "@solana/web3.js";
import Decimal from "decimal.js";
import { OrcaU64, OrcaPool, OrcaToken, Quote, TransactionPayload } from "../../../public";
import { OrcaU64, OrcaPool, OrcaToken, OrcaPoolToken, Quote, TransactionPayload } from "../../../public";
import { OrcaPoolParams } from "./pool-types";

@@ -9,4 +9,4 @@ export declare class OrcaPoolImpl implements OrcaPool {

constructor(connection: Connection, config: OrcaPoolParams);
getTokenA(): OrcaToken;
getTokenB(): OrcaToken;
getTokenA(): OrcaPoolToken;
getTokenB(): OrcaPoolToken;
getLPBalance(owner: PublicKey): Promise<OrcaU64>;

@@ -16,2 +16,4 @@ getLPSupply(): Promise<OrcaU64>;

swap(owner: Keypair | PublicKey, inputToken: OrcaToken, amountIn: Decimal | OrcaU64, minimumAmountOut: Decimal | OrcaU64): Promise<TransactionPayload>;
deposit(owner: Keypair | PublicKey, maxTokenAIn: Decimal | OrcaU64, maxTokenBIn: Decimal | OrcaU64, minPoolTokenAmountOut: Decimal | OrcaU64): Promise<TransactionPayload>;
withdraw(owner: Keypair | PublicKey, poolTokenAmountIn: Decimal | OrcaU64, minTokenAOut: Decimal | OrcaU64, minTokenBOut: Decimal | OrcaU64): Promise<TransactionPayload>;
}

@@ -104,3 +104,63 @@ "use strict";

}
deposit(owner, maxTokenAIn, maxTokenBIn, minPoolTokenAmountOut) {
return __awaiter(this, void 0, void 0, function* () {
const _owner = new key_utils_1.Owner(owner);
const ownerAddress = _owner.publicKey;
const tokenA = this.getTokenA();
const tokenB = this.getTokenB();
const maxTokenAIn_U64 = public_1.U64Utils.toTokenU64(maxTokenAIn, tokenA, "maxTokenAIn");
const maxTokenBIn_U64 = public_1.U64Utils.toTokenU64(maxTokenBIn, tokenB, "maxTokenBIn");
const minPoolTokenAmountOut_U64 = public_1.U64Utils.toPoolU64(minPoolTokenAmountOut, this.poolParams, "poolTokenAmount");
// If tokenA is SOL, this will create a new wSOL account
// Otherwise, get tokenA's associated token account
const _a = yield (0, public_1.resolveOrCreateAssociatedTokenAddress)(this.connection, _owner, tokenA.mint, maxTokenAIn_U64), { address: userTokenAPublicKey } = _a, resolveTokenAInstrucitons = __rest(_a, ["address"]);
// If tokenB is SOL, this will create a new wSOL account
// Otherwise, get tokenB's associated token account
const _b = yield (0, public_1.resolveOrCreateAssociatedTokenAddress)(this.connection, _owner, tokenB.mint, maxTokenBIn_U64), { address: userTokenBPublicKey } = _b, resolveTokenBInstrucitons = __rest(_b, ["address"]);
// If the user lacks the pool token account, create it
const _c = yield (0, public_1.resolveOrCreateAssociatedTokenAddress)(this.connection, _owner, this.poolParams.poolTokenMint), { address: userPoolTokenPublicKey } = _c, resolvePoolTokenInstructions = __rest(_c, ["address"]);
// Approve transfer of the tokens being deposited
const _d = (0, pool_instructions_1.createApprovalInstruction)(ownerAddress, maxTokenAIn_U64, userTokenAPublicKey), { userTransferAuthority } = _d, transferTokenAInstruction = __rest(_d, ["userTransferAuthority"]);
const transferTokenBInstruction = __rest((0, pool_instructions_1.createApprovalInstruction)(ownerAddress, maxTokenBIn_U64, userTokenBPublicKey, userTransferAuthority), []);
// Create the deposit instruction
const depositInstruction = yield (0, pool_instructions_1.createDepositInstruction)(this.poolParams, userTransferAuthority.publicKey, userTokenAPublicKey, userTokenBPublicKey, userPoolTokenPublicKey, minPoolTokenAmountOut_U64, maxTokenAIn_U64, maxTokenBIn_U64, tokenA.addr, tokenB.addr, _owner);
return yield new public_1.TransactionBuilder(this.connection, ownerAddress, _owner)
.addInstruction(resolveTokenAInstrucitons)
.addInstruction(resolveTokenBInstrucitons)
.addInstruction(resolvePoolTokenInstructions)
.addInstruction(transferTokenAInstruction)
.addInstruction(transferTokenBInstruction)
.addInstruction(depositInstruction)
.build();
});
}
withdraw(owner, poolTokenAmountIn, minTokenAOut, minTokenBOut) {
return __awaiter(this, void 0, void 0, function* () {
const _owner = new key_utils_1.Owner(owner);
const ownerAddress = _owner.publicKey;
const tokenA = this.getTokenA();
const tokenB = this.getTokenB();
const minTokenAOut_U64 = public_1.U64Utils.toTokenU64(minTokenAOut, tokenA, "minTokenAOut");
const minTokenBOut_U64 = public_1.U64Utils.toTokenU64(minTokenBOut, tokenB, "minTokenBOut");
const poolTokenAmountIn_U64 = public_1.U64Utils.toPoolU64(poolTokenAmountIn, this.poolParams, "poolTokenAmount");
// Create a token account for tokenA, if necessary
const _a = yield (0, public_1.resolveOrCreateAssociatedTokenAddress)(this.connection, _owner, tokenA.mint, minTokenAOut_U64), { address: userTokenAPublicKey } = _a, resolveTokenAInstrucitons = __rest(_a, ["address"]);
// Create a token account for tokenB, if necessary
const _b = yield (0, public_1.resolveOrCreateAssociatedTokenAddress)(this.connection, _owner, tokenB.mint, minTokenBOut_U64), { address: userTokenBPublicKey } = _b, resolveTokenBInstrucitons = __rest(_b, ["address"]);
// Get user's poolToken token account
const _c = yield (0, public_1.resolveOrCreateAssociatedTokenAddress)(this.connection, _owner, this.poolParams.poolTokenMint), { address: userPoolTokenPublicKey } = _c, resolvePoolTokenInstructions = __rest(_c, ["address"]);
// Approve transfer of pool token
const _d = (0, pool_instructions_1.createApprovalInstruction)(ownerAddress, poolTokenAmountIn_U64, userPoolTokenPublicKey), { userTransferAuthority } = _d, transferPoolTokenInstruction = __rest(_d, ["userTransferAuthority"]);
// Create the withdraw instruction
const withdrawInstruction = yield (0, pool_instructions_1.createWithdrawInstruction)(this.poolParams, userTransferAuthority.publicKey, userTokenAPublicKey, userTokenBPublicKey, userPoolTokenPublicKey, poolTokenAmountIn_U64, minTokenAOut_U64, minTokenBOut_U64, tokenA.addr, tokenB.addr, _owner);
return yield new public_1.TransactionBuilder(this.connection, ownerAddress, _owner)
.addInstruction(resolveTokenAInstrucitons)
.addInstruction(resolveTokenBInstrucitons)
.addInstruction(resolvePoolTokenInstructions)
.addInstruction(transferPoolTokenInstruction)
.addInstruction(withdrawInstruction)
.build();
});
}
}
exports.OrcaPoolImpl = OrcaPoolImpl;
import { PublicKey } from "@solana/web3.js";
import { OrcaToken } from "../../..";
import { OrcaPoolToken } from "../../..";
import { Percentage } from "../../../public";

@@ -31,9 +31,2 @@ /**

};
/**
* An Orca Token within an OrcaPool
* @param addr The public key for this token for this Orca Pool
*/
export declare type OrcaPoolToken = OrcaToken & {
addr: PublicKey;
};
export declare enum CurveType {

@@ -40,0 +33,0 @@ ConstantProduct = 0,

@@ -32,3 +32,10 @@ /**

SLRS_USDC = "AtB4nUmdyQfuWWJ9xAHw9xyVnJFfSjSuVWkiYan8y86w",
PORT_USDC = "F8gPSpwVHj8FdAJAYULDuZBxFEJut87hUbARYYx3471w"
PORT_USDC = "F8gPSpwVHj8FdAJAYULDuZBxFEJut87hUbARYYx3471w",
SBR_USDC = "CS7fA5n4c2D82dUoHrYzS3gAqgqaoVSfgsr18kitp2xo",
SOCN_USDC = "Dkr8B675PGnNwEr9vTKXznjjHke5454EQdz3iaSbparB",
pSOL_USDC = "C2YzN6MymD5HM2kPaH7bzcbqciyjfmpqyVaR3KA5V6z1",
mSOL_SOL = "29cdoMgu6MS2VXpcMo1sqRdWEzdUR9tjvoh8fcK8Z87R",
ORCA_PAI = "C7TH2jEJJaxVwwuvkbcDGfHUiZvEkkeYjyAcdTMi5ujb",
ORCA_mSOL = "CVapmQn7HaU1yMDW3q6oUV4hx6XoYv54T4zfGXkuJqkA",
SOCN_SOL = "APNpzQvR91v1THbsAyG3HHrUEwvexWYeNCFLQuVnxgMc"
}

@@ -37,2 +37,9 @@ "use strict";

OrcaPoolConfig["PORT_USDC"] = "F8gPSpwVHj8FdAJAYULDuZBxFEJut87hUbARYYx3471w";
OrcaPoolConfig["SBR_USDC"] = "CS7fA5n4c2D82dUoHrYzS3gAqgqaoVSfgsr18kitp2xo";
OrcaPoolConfig["SOCN_USDC"] = "Dkr8B675PGnNwEr9vTKXznjjHke5454EQdz3iaSbparB";
OrcaPoolConfig["pSOL_USDC"] = "C2YzN6MymD5HM2kPaH7bzcbqciyjfmpqyVaR3KA5V6z1";
OrcaPoolConfig["mSOL_SOL"] = "29cdoMgu6MS2VXpcMo1sqRdWEzdUR9tjvoh8fcK8Z87R";
OrcaPoolConfig["ORCA_PAI"] = "C7TH2jEJJaxVwwuvkbcDGfHUiZvEkkeYjyAcdTMi5ujb";
OrcaPoolConfig["ORCA_mSOL"] = "CVapmQn7HaU1yMDW3q6oUV4hx6XoYv54T4zfGXkuJqkA";
OrcaPoolConfig["SOCN_SOL"] = "APNpzQvR91v1THbsAyG3HHrUEwvexWYeNCFLQuVnxgMc";
})(OrcaPoolConfig = exports.OrcaPoolConfig || (exports.OrcaPoolConfig = {}));

@@ -13,3 +13,3 @@ import { Keypair, PublicKey } from "@solana/web3.js";

*/
getTokenA: () => OrcaToken;
getTokenA: () => OrcaPoolToken;
/**

@@ -19,3 +19,3 @@ * Query the token of tokenB in this pool.

*/
getTokenB: () => OrcaToken;
getTokenB: () => OrcaPoolToken;
/**

@@ -58,2 +58,32 @@ * Query the balance for an user address

swap: (owner: Keypair | PublicKey, inputToken: OrcaToken, amountIn: Decimal | OrcaU64, minimumAmountOut: Decimal | OrcaU64) => Promise<TransactionPayload>;
/**
* Perform a deposit: send tokenA and tokenB, and receive a poolToken in return.
* Fee for the transaction will be paid by the owner's wallet.
*
* NOTE:
* 1. Associated Token Address initialization instructions will be appended if the ATA of the specified token does not exist in the user's wallet
* 2. OrcaU64 must have the same scale as the corresponding token scale value
*
* @param owner The keypair for the user's wallet or just the user's public key
* @param maxTokenAIn The maximum amount of tokenA to send
* @param maxTokenBIn The maximum amount of tokenB to send
* @param minPoolTokenAmountOut The amount of poolToken to receive
* @return The transaction signature of the deposit instruction
*/
deposit: (owner: Keypair | PublicKey, maxTokenAIn: Decimal | OrcaU64, maxTokenBIn: Decimal | OrcaU64, minPoolTokenAmountOut: Decimal | OrcaU64) => Promise<TransactionPayload>;
/**
* Perform a withdraw: send poolToken, and receive tokenA and tokenB in return.
* Fee for the transaction will be paid by the owner's wallet.
*
* NOTE:
* 1. Associated Token Address initialization instructions will be appended if the ATA of the specified token does not exist in the user's wallet
* 2. OrcaU64 must have the same scale as the corresponding token scale value
*
* @param owner The keypair for the user's wallet or just the user's public key
* @param poolTokenAmountIn The amount of poolToken to send
* @param minTokenAOut The minimum amount of tokenA to receive
* @param minTokenBOut The minimum amount of tokenB to receive
* @return The transaction signature of the withdraw instruction
*/
withdraw: (owner: Keypair | PublicKey, poolTokenAmountIn: Decimal | OrcaU64, minTokenAOut: Decimal | OrcaU64, minTokenBOut: Decimal | OrcaU64) => Promise<TransactionPayload>;
};

@@ -73,2 +103,9 @@ /**

};
/**
* An Orca Token within an OrcaPool
* @param addr The public key for this token for this Orca Pool
*/
export declare type OrcaPoolToken = OrcaToken & {
addr: PublicKey;
};
export declare type Quote = {

@@ -75,0 +112,0 @@ /**

import { u64 } from "@solana/spl-token";
import Decimal from "decimal.js";
import { OrcaToken, OrcaU64 } from "../..";
import { OrcaPoolParams } from "../../../model/orca/pool/pool-types";
export declare const ZERO: u64;

@@ -8,3 +9,4 @@ export declare const ONE: u64;

static toTokenU64(input: Decimal | OrcaU64, token: OrcaToken, varName: string): u64;
static toPoolU64(input: Decimal | OrcaU64, pool: OrcaPoolParams, varName: string): u64;
static ceilingDivision(dividend: u64, divisor: u64): [u64, u64];
}

@@ -19,2 +19,11 @@ "use strict";

}
static toPoolU64(input, pool, varName) {
if (input instanceof __1.OrcaU64) {
if (input.scale !== pool.poolTokenDecimals) {
throw new Error(`${varName}'s scale of ${input.scale} does not match pool's decimal of ${pool.poolTokenDecimals}`);
}
return input.toU64();
}
return decimal_utils_1.DecimalUtil.toU64(input, pool.poolTokenDecimals);
}
// Note: divisor input variable modified in place

@@ -21,0 +30,0 @@ // https://github.com/solana-labs/solana-program-library/blob/master/libraries/math/src/checked_ceil_div.rs#L5-L22

import { OrcaPoolParams } from "../../model/orca/pool/pool-types";
export declare function getTokens(poolParams: OrcaPoolParams, inputTokenId: string): {
inputPoolToken: import("../../model/orca/pool/pool-types").OrcaPoolToken;
outputPoolToken: import("../../model/orca/pool/pool-types").OrcaPoolToken;
inputPoolToken: import("..").OrcaPoolToken;
outputPoolToken: import("..").OrcaPoolToken;
};
import { u64 } from "@solana/spl-token";
import { Connection } from "@solana/web3.js";
import { OrcaPoolParams, OrcaPoolToken } from "../../../model/orca/pool/pool-types";
import { OrcaPoolToken } from "../..";
import { OrcaPoolParams } from "../../../model/orca/pool/pool-types";
export declare type PoolTokenCount = {

@@ -5,0 +6,0 @@ inputTokenCount: u64;

import { u64 } from "@solana/spl-token";
import { Keypair, PublicKey } from "@solana/web3.js";
import { OrcaPoolParams, OrcaPoolToken } from "../../../../model/orca/pool/pool-types";
import { OrcaPoolParams } from "../../../../model/orca/pool/pool-types";
import { OrcaPoolToken } from "../../../pools";
import { Instruction } from "../../models";
import { Owner } from "../key-utils";
export declare const createApprovalInstruction: (ownerAddress: PublicKey, approveAmount: u64, tokenUserAddress: PublicKey) => {
export declare const createApprovalInstruction: (ownerAddress: PublicKey, approveAmount: u64, tokenUserAddress: PublicKey, userTransferAuthority?: Keypair | undefined) => {
userTransferAuthority: Keypair;
} & Instruction;
export declare const createSwapInstruction: (poolParams: OrcaPoolParams, owner: Owner, inputToken: OrcaPoolToken, inputTokenUserAddress: PublicKey, outputToken: OrcaPoolToken, outputTokenUserAddress: PublicKey, amountIn: u64, minimumAmountOut: u64, userTransferAuthority: PublicKey) => Promise<Instruction>;
export declare const createDepositInstruction: (poolParams: OrcaPoolParams, userTransferAuthorityPublicKey: PublicKey, userTokenAPublicKey: PublicKey, userTokenBPublicKey: PublicKey, userPoolTokenPublicKey: PublicKey, poolTokenAmount: u64, maximumTokenA: u64, maximumTokenB: u64, tokenAPublicKey: PublicKey, tokenBPublicKey: PublicKey, owner: Owner) => Promise<Instruction>;
export declare const createWithdrawInstruction: (poolParams: OrcaPoolParams, userTransferAuthorityPublicKey: PublicKey, userTokenAPublicKey: PublicKey, userTokenBPublicKey: PublicKey, userPoolTokenPublicKey: PublicKey, poolTokenAmount: u64, minimumTokenA: u64, minimumTokenB: u64, tokenAPublicKey: PublicKey, tokenBPublicKey: PublicKey, owner: Owner) => Promise<Instruction>;

@@ -12,3 +12,3 @@ "use strict";

Object.defineProperty(exports, "__esModule", { value: true });
exports.createSwapInstruction = exports.createApprovalInstruction = void 0;
exports.createWithdrawInstruction = exports.createDepositInstruction = exports.createSwapInstruction = exports.createApprovalInstruction = void 0;
const spl_token_1 = require("@solana/spl-token");

@@ -18,4 +18,4 @@ const spl_token_swap_1 = require("@solana/spl-token-swap");

const constants_1 = require("../../constants");
const createApprovalInstruction = (ownerAddress, approveAmount, tokenUserAddress) => {
const userTransferAuthority = new web3_js_1.Keypair();
const createApprovalInstruction = (ownerAddress, approveAmount, tokenUserAddress, userTransferAuthority) => {
userTransferAuthority = userTransferAuthority || new web3_js_1.Keypair();
const approvalInstruction = spl_token_1.Token.createApproveInstruction(spl_token_1.TOKEN_PROGRAM_ID, tokenUserAddress, userTransferAuthority.publicKey, ownerAddress, [], approveAmount);

@@ -43,1 +43,19 @@ const revokeInstruction = spl_token_1.Token.createRevokeInstruction(spl_token_1.TOKEN_PROGRAM_ID, tokenUserAddress, ownerAddress, []);

exports.createSwapInstruction = createSwapInstruction;
const createDepositInstruction = (poolParams, userTransferAuthorityPublicKey, userTokenAPublicKey, userTokenBPublicKey, userPoolTokenPublicKey, poolTokenAmount, maximumTokenA, maximumTokenB, tokenAPublicKey, tokenBPublicKey, owner) => __awaiter(void 0, void 0, void 0, function* () {
const depositInstruction = spl_token_swap_1.TokenSwap.depositAllTokenTypesInstruction(poolParams.address, poolParams.authority, userTransferAuthorityPublicKey, userTokenAPublicKey, userTokenBPublicKey, tokenAPublicKey, tokenBPublicKey, poolParams.poolTokenMint, userPoolTokenPublicKey, constants_1.ORCA_TOKEN_SWAP_ID, spl_token_1.TOKEN_PROGRAM_ID, poolTokenAmount, maximumTokenA, maximumTokenB);
return {
instructions: [depositInstruction],
cleanupInstructions: [],
signers: owner.signer ? [owner.signer] : [],
};
});
exports.createDepositInstruction = createDepositInstruction;
const createWithdrawInstruction = (poolParams, userTransferAuthorityPublicKey, userTokenAPublicKey, userTokenBPublicKey, userPoolTokenPublicKey, poolTokenAmount, minimumTokenA, minimumTokenB, tokenAPublicKey, tokenBPublicKey, owner) => __awaiter(void 0, void 0, void 0, function* () {
const withdrawInstruction = spl_token_swap_1.TokenSwap.withdrawAllTokenTypesInstruction(poolParams.address, poolParams.authority, userTransferAuthorityPublicKey, poolParams.poolTokenMint, poolParams.feeAccount, userPoolTokenPublicKey, tokenAPublicKey, tokenBPublicKey, userTokenAPublicKey, userTokenBPublicKey, constants_1.ORCA_TOKEN_SWAP_ID, spl_token_1.TOKEN_PROGRAM_ID, poolTokenAmount, minimumTokenA, minimumTokenB);
return {
instructions: [withdrawInstruction],
cleanupInstructions: [],
signers: owner.signer ? [owner.signer] : [],
};
});
exports.createWithdrawInstruction = createWithdrawInstruction;
{
"name": "@orca-so/sdk",
"version": "1.1.2",
"version": "1.1.3",
"description": "Typescript SDK for the Orca protocol.",

@@ -5,0 +5,0 @@ "main": "dist/index.js",

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc