@orca-so/sdk
Advanced tools
Comparing version 1.1.0 to 1.1.1
@@ -20,2 +20,3 @@ import { OrcaPoolParams } from "../model/orca/pool/pool-types"; | ||
export declare const mapsSolPool: OrcaPoolParams; | ||
export declare const usdcUsdtPool: OrcaPoolParams; | ||
export declare const orcaSolPool: OrcaPoolParams; | ||
@@ -26,2 +27,6 @@ export declare const orcaUsdcPool: OrcaPoolParams; | ||
export declare const liqUsdcPool: OrcaPoolParams; | ||
export declare const snyUsdcPool: OrcaPoolParams; | ||
export declare const msolUsdcPool: OrcaPoolParams; | ||
export declare const slrsUsdcPool: OrcaPoolParams; | ||
export declare const portUsdcPool: OrcaPoolParams; | ||
/** | ||
@@ -28,0 +33,0 @@ * Mapping for OrcaPool parameters |
@@ -22,3 +22,3 @@ "use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.orcaPoolConfigs = exports.liqUsdcPool = exports.samoSolPool = exports.kinSolPool = exports.orcaUsdcPool = exports.orcaSolPool = 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.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"); | ||
@@ -301,2 +301,21 @@ const pool_types_1 = require("../model/orca/pool/pool-types"); | ||
}); | ||
exports.usdcUsdtPool = Object.freeze({ | ||
address: new web3_js_1.PublicKey("F13xvvx45jVGd84ynK3c8T89UejQVxjCLtmHfPmAXAHP"), | ||
nonce: 255, | ||
authority: new web3_js_1.PublicKey("3cGHDS8uWhdxQj14vTmFtYHX3NMouPpE4o9MjQ43Bbf4"), | ||
poolTokenMint: new web3_js_1.PublicKey("H2uzgruPvonVpCRhwwdukcpXK8TG17swFNzYFr2rtPxy"), | ||
poolTokenDecimals: 6, | ||
feeAccount: new web3_js_1.PublicKey("B4RNxMJGRzKFQyTq2Uwkmpyjtew13n7KtdqZy6qgENTu"), | ||
tokenIds: [Tokens.usdcToken.mint.toString(), Tokens.usdtToken.mint.toString()], | ||
tokens: { | ||
[Tokens.usdcToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.usdcToken), { addr: new web3_js_1.PublicKey("6uUn2okWk5v4x9Gc4n2LLGHtWoa9tmizHq1363dW7t9W") }), | ||
[Tokens.usdtToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.usdtToken), { addr: new web3_js_1.PublicKey("AiwmnLy7xPT28dqZpkRm6i1ZGwELUCzCsuN92v4JkSeU") }), | ||
}, | ||
curveType: pool_types_1.CurveType.Stable, | ||
amp: 100, | ||
feeStructure: { | ||
traderFee: percentage_1.Percentage.fromFraction(6, 10000), | ||
ownerFee: percentage_1.Percentage.fromFraction(1, 10000), | ||
}, | ||
}); | ||
exports.orcaSolPool = Object.freeze({ | ||
@@ -392,2 +411,74 @@ address: new web3_js_1.PublicKey("2ZnVuidTHpi5WWKUwFXauYGhvdT9jRKYv5MDahtbwtYr"), | ||
}); | ||
exports.snyUsdcPool = Object.freeze({ | ||
address: new web3_js_1.PublicKey("BDn3Fj9UXVi2mRVMR2jzpCrAZZphnwfkvFhs192yhCTu"), | ||
nonce: 255, | ||
authority: new web3_js_1.PublicKey("FvjsfbbzZAcrVdfrGtZUjGWAjWHXrfMG8Bjwc17vVSK3"), | ||
poolTokenMint: new web3_js_1.PublicKey("AZpo4BJHHRetF96v6SGinFZBMXM4yWMo4RA8C4PriDLk"), | ||
poolTokenDecimals: 6, | ||
feeAccount: new web3_js_1.PublicKey("DiULDJAYXdbtX8CfFsU2jCgHvQWT7u3gwRwpvQxfEMvr"), | ||
tokenIds: [Tokens.snyToken.mint.toString(), Tokens.usdcToken.mint.toString()], | ||
tokens: { | ||
[Tokens.snyToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.snyToken), { addr: new web3_js_1.PublicKey("14RHMRzwx9Y4Z41qpr9sTwJZ58wXqV1R9WTkUA7ybmKG") }), | ||
[Tokens.usdcToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.usdcToken), { addr: new web3_js_1.PublicKey("Dw9D9T4bBC3oGdMqxE1xWfPSCJ27SYwWD8rFfUxU99QG") }), | ||
}, | ||
curveType: pool_types_1.CurveType.ConstantProduct, | ||
feeStructure: { | ||
traderFee: percentage_1.Percentage.fromFraction(25, 10000), | ||
ownerFee: percentage_1.Percentage.fromFraction(5, 10000), | ||
}, | ||
}); | ||
exports.msolUsdcPool = Object.freeze({ | ||
address: new web3_js_1.PublicKey("Hme4Jnqhdz2jAPUMnS7jGE5zv6Y1ynqrUEhmUAWkXmzn"), | ||
nonce: 255, | ||
authority: new web3_js_1.PublicKey("9Z7E42k46kxnBjAh8YGXDw3rRGwwxQUBYM7Ccrmwg6ZP"), | ||
poolTokenMint: new web3_js_1.PublicKey("8PSfyiTVwPb6Rr2iZ8F3kNpbg65BCfJM9v8LfB916r44"), | ||
poolTokenDecimals: 6, | ||
feeAccount: new web3_js_1.PublicKey("3W3Skj2vQsNEMhGRQprFXQy3Q8ZbM6ojdgiDCokVPWno"), | ||
tokenIds: [Tokens.msolToken.mint.toString(), Tokens.usdcToken.mint.toString()], | ||
tokens: { | ||
[Tokens.msolToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.msolToken), { addr: new web3_js_1.PublicKey("GBa7G5f1FqAXEgByuHXsqsEdpyMjRgT9SNxZwmmnEJAY") }), | ||
[Tokens.usdcToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.usdcToken), { addr: new web3_js_1.PublicKey("7hFgNawzzmpDM8TTVCKm8jykBrym8C3TQdb8TDAfAVkD") }), | ||
}, | ||
curveType: pool_types_1.CurveType.ConstantProduct, | ||
feeStructure: { | ||
traderFee: percentage_1.Percentage.fromFraction(25, 10000), | ||
ownerFee: percentage_1.Percentage.fromFraction(5, 10000), | ||
}, | ||
}); | ||
exports.slrsUsdcPool = Object.freeze({ | ||
address: new web3_js_1.PublicKey("87Xz6RK1uzP5NEhSjMewZtDAZyg4V1tYAa1KHnvge17b"), | ||
nonce: 254, | ||
authority: new web3_js_1.PublicKey("5D9v9y6Kbswe6k1wnVceuqRXHMsRQJ8xzx8hadSH6EAM"), | ||
poolTokenMint: new web3_js_1.PublicKey("AtB4nUmdyQfuWWJ9xAHw9xyVnJFfSjSuVWkiYan8y86w"), | ||
poolTokenDecimals: 6, | ||
feeAccount: new web3_js_1.PublicKey("CLxeBxNq42AtmD43F5BTqCHTnkVHX8sP9cVPdtRkTL7D"), | ||
tokenIds: [Tokens.slrsToken.mint.toString(), Tokens.usdcToken.mint.toString()], | ||
tokens: { | ||
[Tokens.slrsToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.slrsToken), { addr: new web3_js_1.PublicKey("CM7oGYHy1oxzHoum8Cxv4pwnndm6Jbs3NkBZkc6v9S9d") }), | ||
[Tokens.usdcToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.usdcToken), { addr: new web3_js_1.PublicKey("3QqPbMcUMZu3Rz762g7JgvpUxhRHPtE9HFk2MSDRmPqa") }), | ||
}, | ||
curveType: pool_types_1.CurveType.ConstantProduct, | ||
feeStructure: { | ||
traderFee: percentage_1.Percentage.fromFraction(25, 10000), | ||
ownerFee: percentage_1.Percentage.fromFraction(5, 10000), | ||
}, | ||
}); | ||
exports.portUsdcPool = Object.freeze({ | ||
address: new web3_js_1.PublicKey("4if9Gy7dvjU7XwunKxdnCcPsaT3yAHPXdz2XS1eo19LG"), | ||
nonce: 254, | ||
authority: new web3_js_1.PublicKey("BshtCZRCHj2RZYC7u5sW3ioRJo9ZiYA4T5p8muFwrKnb"), | ||
poolTokenMint: new web3_js_1.PublicKey("F8gPSpwVHj8FdAJAYULDuZBxFEJut87hUbARYYx3471w"), | ||
poolTokenDecimals: 6, | ||
feeAccount: new web3_js_1.PublicKey("5JZXUbCfaSo3y9PYq47Hj5Yc6hVFa4j7MkDzBJfMSRSN"), | ||
tokenIds: [Tokens.portToken.mint.toString(), Tokens.usdcToken.mint.toString()], | ||
tokens: { | ||
[Tokens.portToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.portToken), { addr: new web3_js_1.PublicKey("2wuSqR5z2Guft2yt57Hx7K6i1AYNoUi8fjxHUeAgaKXo") }), | ||
[Tokens.usdcToken.mint.toString()]: Object.assign(Object.assign({}, Tokens.usdcToken), { addr: new web3_js_1.PublicKey("AvP1Db3SyUxLGMSc4nSXjJkjm1kAjiLjog7cup19eWa3") }), | ||
}, | ||
curveType: pool_types_1.CurveType.ConstantProduct, | ||
feeStructure: { | ||
traderFee: percentage_1.Percentage.fromFraction(25, 10000), | ||
ownerFee: percentage_1.Percentage.fromFraction(5, 10000), | ||
}, | ||
}); | ||
/** | ||
@@ -413,2 +504,3 @@ * Mapping for OrcaPool parameters | ||
"99pfC8fWymXgbq3CvrExhx3UxQDC1fMWEWLbNT83F45e": exports.mapsSolPool, | ||
H2uzgruPvonVpCRhwwdukcpXK8TG17swFNzYFr2rtPxy: exports.usdcUsdtPool, | ||
"2uVjAuRXavpM6h1scGQaxqb6HVaNRn6T2X7HHXTabz25": exports.orcaSolPool, | ||
@@ -419,2 +511,6 @@ n8Mpu28RjeYD7oUX3LG1tPxzhRZh3YYLRSHcHRdS3Zx: exports.orcaUsdcPool, | ||
"3PD9SZFwXKkXr4akLf4ofo37ZUMycwML89R2P3qxcbZG": exports.liqUsdcPool, | ||
AZpo4BJHHRetF96v6SGinFZBMXM4yWMo4RA8C4PriDLk: exports.snyUsdcPool, | ||
"8PSfyiTVwPb6Rr2iZ8F3kNpbg65BCfJM9v8LfB916r44": exports.msolUsdcPool, | ||
AtB4nUmdyQfuWWJ9xAHw9xyVnJFfSjSuVWkiYan8y86w: exports.slrsUsdcPool, | ||
F8gPSpwVHj8FdAJAYULDuZBxFEJut87hUbARYYx3471w: exports.portUsdcPool, | ||
}; |
@@ -16,5 +16,8 @@ import { OrcaToken } from ".."; | ||
export declare const oxyToken: OrcaToken; | ||
export declare const portToken: OrcaToken; | ||
export declare const rayToken: OrcaToken; | ||
export declare const ropeToken: OrcaToken; | ||
export declare const samoToken: OrcaToken; | ||
export declare const slrsToken: OrcaToken; | ||
export declare const snyToken: OrcaToken; | ||
export declare const solToken: OrcaToken; | ||
@@ -25,1 +28,2 @@ export declare const srmToken: OrcaToken; | ||
export declare const usdtToken: OrcaToken; | ||
export declare const msolToken: OrcaToken; |
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.usdtToken = exports.usdcToken = exports.stepToken = exports.srmToken = exports.solToken = exports.samoToken = exports.ropeToken = exports.rayToken = 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.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; | ||
const web3_js_1 = require("@solana/web3.js"); | ||
@@ -74,2 +74,8 @@ /** | ||
}); | ||
exports.portToken = Object.freeze({ | ||
tag: "PORT", | ||
name: "Port Finance", | ||
mint: new web3_js_1.PublicKey("PoRTjZMPXb9T7dyU7tpLEZRQj7e6ssfAE62j2oQuc6y"), | ||
scale: 6, | ||
}); | ||
exports.rayToken = Object.freeze({ | ||
@@ -93,2 +99,14 @@ tag: "RAY", | ||
}); | ||
exports.slrsToken = Object.freeze({ | ||
tag: "SLRS", | ||
name: "Solrise Finance", | ||
mint: new web3_js_1.PublicKey("SLRSSpSLUTP7okbCUBYStWCo1vUgyt775faPqz8HUMr"), | ||
scale: 6, | ||
}); | ||
exports.snyToken = Object.freeze({ | ||
tag: "SNY", | ||
name: "SNY", | ||
mint: new web3_js_1.PublicKey("4dmKkXNHdgYsXqBHCuMikNQWwVomZURhYvkkX5c4pQ7y"), | ||
scale: 6, | ||
}); | ||
exports.solToken = Object.freeze({ | ||
@@ -124,1 +142,7 @@ tag: "SOL", | ||
}); | ||
exports.msolToken = Object.freeze({ | ||
tag: "mSOL", | ||
name: "Marinade.finance", | ||
mint: new web3_js_1.PublicKey("mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So"), | ||
scale: 9, | ||
}); |
@@ -14,3 +14,3 @@ import { Connection, PublicKey, Keypair } from "@solana/web3.js"; | ||
getQuote(inputToken: OrcaToken, inputAmount: Decimal | OrcaU64, slippage?: Decimal): Promise<Quote>; | ||
swap(owner: Keypair, inputToken: OrcaToken, amountIn: Decimal | OrcaU64, minimumAmountOut: Decimal | OrcaU64): Promise<TransactionPayload>; | ||
swap(owner: Keypair | PublicKey, inputToken: OrcaToken, amountIn: Decimal | OrcaU64, minimumAmountOut: Decimal | OrcaU64): Promise<TransactionPayload>; | ||
} |
@@ -28,2 +28,3 @@ "use strict"; | ||
const pool_instructions_1 = require("../../../public/utils/web3/instructions/pool-instructions"); | ||
const key_utils_1 = require("../../../public/utils/web3/key-utils"); | ||
const quote_builder_1 = require("../../quote/quote-builder"); | ||
@@ -45,3 +46,3 @@ class OrcaPoolImpl { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const address = yield public_1.deriveAssociatedTokenAddress(owner, this.poolParams.poolTokenMint); | ||
const address = yield (0, public_1.deriveAssociatedTokenAddress)(owner, this.poolParams.poolTokenMint); | ||
const accountInfo = yield this.connection.getAccountInfo(address); | ||
@@ -52,3 +53,3 @@ // User does not have a balance for this account | ||
} | ||
const result = public_1.deserializeAccount(accountInfo === null || accountInfo === void 0 ? void 0 : accountInfo.data); | ||
const result = (0, public_1.deserializeAccount)(accountInfo === null || accountInfo === void 0 ? void 0 : accountInfo.data); | ||
if (result == undefined) { | ||
@@ -71,7 +72,7 @@ throw new Error("Failed to parse user account for LP token."); | ||
const feeStructure = this.poolParams.feeStructure; | ||
const { inputPoolToken, outputPoolToken } = public_1.getTokens(this.poolParams, inputToken.mint.toString()); | ||
const { inputPoolToken, outputPoolToken } = (0, public_1.getTokens)(this.poolParams, inputToken.mint.toString()); | ||
const inputAmountU64 = public_1.U64Utils.toTokenU64(inputAmount, inputPoolToken, "inputAmount"); | ||
const poolTokenCount = yield public_1.getTokenCount(this.connection, this.poolParams, inputPoolToken, outputPoolToken); | ||
const poolTokenCount = yield (0, public_1.getTokenCount)(this.connection, this.poolParams, inputPoolToken, outputPoolToken); | ||
const { value: { feeCalculator }, } = yield this.connection.getRecentBlockhashAndContext("singleGossip"); | ||
const quoteParams = Object.assign(Object.assign({}, poolTokenCount), { inputToken: inputPoolToken, outputToken: outputPoolToken, feeStructure: feeStructure, slippageTolerance: slippageTolerance, lamportsPerSignature: feeCalculator.lamportsPerSignature }); | ||
const quoteParams = Object.assign(Object.assign({}, poolTokenCount), { inputToken: inputPoolToken, outputToken: outputPoolToken, feeStructure: feeStructure, slippageTolerance: slippageTolerance, lamportsPerSignature: feeCalculator.lamportsPerSignature, amp: this.poolParams.amp !== undefined ? new spl_token_1.u64(this.poolParams.amp) : undefined }); | ||
const quoteBuilder = quote_builder_1.QuoteBuilderFactory.getBuilder(this.poolParams.curveType); | ||
@@ -87,14 +88,15 @@ const quote = quoteBuilder === null || quoteBuilder === void 0 ? void 0 : quoteBuilder.buildQuote(quoteParams, inputAmountU64); | ||
return __awaiter(this, void 0, void 0, function* () { | ||
const ownerAddress = owner.publicKey; | ||
const { inputPoolToken, outputPoolToken } = public_1.getTokens(this.poolParams, inputToken.mint.toString()); | ||
const _owner = new key_utils_1.Owner(owner); | ||
const ownerAddress = _owner.publicKey; | ||
const { inputPoolToken, outputPoolToken } = (0, public_1.getTokens)(this.poolParams, inputToken.mint.toString()); | ||
const amountInU64 = public_1.U64Utils.toTokenU64(amountIn, inputPoolToken, "amountIn"); | ||
const minimumAmountOutU64 = public_1.U64Utils.toTokenU64(minimumAmountOut, outputPoolToken, "minimumAmountOut"); | ||
const _a = yield public_1.resolveOrCreateAssociatedTokenAddress(this.connection, owner, inputPoolToken.mint, amountInU64), { address: inputPoolTokenUserAddress } = _a, resolveInputAddrInstructions = __rest(_a, ["address"]); | ||
const _b = yield public_1.resolveOrCreateAssociatedTokenAddress(this.connection, owner, outputPoolToken.mint, amountInU64), { address: outputPoolTokenUserAddress } = _b, resolveOutputAddrInstructions = __rest(_b, ["address"]); | ||
const _a = yield (0, public_1.resolveOrCreateAssociatedTokenAddress)(this.connection, _owner, inputPoolToken.mint, amountInU64), { address: inputPoolTokenUserAddress } = _a, resolveInputAddrInstructions = __rest(_a, ["address"]); | ||
const _b = yield (0, public_1.resolveOrCreateAssociatedTokenAddress)(this.connection, _owner, outputPoolToken.mint, amountInU64), { address: outputPoolTokenUserAddress } = _b, resolveOutputAddrInstructions = __rest(_b, ["address"]); | ||
if (inputPoolTokenUserAddress === undefined || outputPoolTokenUserAddress === undefined) { | ||
throw new Error("Unable to derive input / output token associated address."); | ||
} | ||
const _c = pool_instructions_1.createApprovalInstruction(ownerAddress, amountInU64, inputPoolTokenUserAddress), { userTransferAuthority } = _c, approvalInstruction = __rest(_c, ["userTransferAuthority"]); | ||
const swapInstruction = yield pool_instructions_1.createSwapInstruction(this.poolParams, owner, inputPoolToken, inputPoolTokenUserAddress, outputPoolToken, outputPoolTokenUserAddress, amountInU64, minimumAmountOutU64, userTransferAuthority.publicKey); | ||
return yield new public_1.TransactionBuilder(this.connection, ownerAddress) | ||
const _c = (0, pool_instructions_1.createApprovalInstruction)(ownerAddress, amountInU64, inputPoolTokenUserAddress), { userTransferAuthority } = _c, approvalInstruction = __rest(_c, ["userTransferAuthority"]); | ||
const swapInstruction = yield (0, pool_instructions_1.createSwapInstruction)(this.poolParams, _owner, inputPoolToken, inputPoolTokenUserAddress, outputPoolToken, outputPoolTokenUserAddress, amountInU64, minimumAmountOutU64, userTransferAuthority.publicKey); | ||
return yield new public_1.TransactionBuilder(this.connection, ownerAddress, _owner) | ||
.addInstruction(resolveInputAddrInstructions) | ||
@@ -101,0 +103,0 @@ .addInstruction(resolveOutputAddrInstructions) |
@@ -14,4 +14,5 @@ import { PublicKey } from "@solana/web3.js"; | ||
* @param tokens The id, token object of the tokens in this pool | ||
* @param curveType Trading curve type. 0 - ConstantProduct, 1 - ConstantPrice, 3 - Offset | ||
* @param curveType Trading curve type. 0 - ConstantProduct, 1 - ConstantPrice, 2 - Stable, 3 - Offset | ||
* @param feeStructure The % of fees collected by this pool | ||
* @param amp The amplification coefficient for a stable curve pool (defines how flat the AMM curve is when prices are similar) | ||
*/ | ||
@@ -29,2 +30,3 @@ export declare type OrcaPoolParams = { | ||
feeStructure: FeeStructure; | ||
amp?: number; | ||
}; | ||
@@ -31,0 +33,0 @@ /** |
@@ -11,2 +11,3 @@ import { u64 } from "@solana/spl-token"; | ||
lamportsPerSignature: number; | ||
amp?: u64; | ||
}; | ||
@@ -13,0 +14,0 @@ export interface QuoteBuilder { |
@@ -6,2 +6,3 @@ "use strict"; | ||
const constant_product_quote_1 = require("./constant-product-quote"); | ||
const stable_quote_1 = require("./stable-quote"); | ||
class QuoteBuilderFactory { | ||
@@ -12,2 +13,4 @@ static getBuilder(curveType) { | ||
return new constant_product_quote_1.ConstantProductPoolQuoteBuilder(); | ||
case pool_types_1.CurveType.Stable: | ||
return new stable_quote_1.StablePoolQuoteBuilder(); | ||
default: | ||
@@ -14,0 +17,0 @@ return undefined; |
@@ -23,2 +23,3 @@ /** | ||
MAPS_SOL = "99pfC8fWymXgbq3CvrExhx3UxQDC1fMWEWLbNT83F45e", | ||
USDC_USDT = "H2uzgruPvonVpCRhwwdukcpXK8TG17swFNzYFr2rtPxy", | ||
ORCA_SOL = "2uVjAuRXavpM6h1scGQaxqb6HVaNRn6T2X7HHXTabz25", | ||
@@ -28,3 +29,7 @@ ORCA_USDC = "n8Mpu28RjeYD7oUX3LG1tPxzhRZh3YYLRSHcHRdS3Zx", | ||
SAMO_SOL = "D6N9j8F2DhtzDtrdpT74y3u2YmYAzcggiLc3nTjqux9M", | ||
LIQ_USDC = "3PD9SZFwXKkXr4akLf4ofo37ZUMycwML89R2P3qxcbZG" | ||
LIQ_USDC = "3PD9SZFwXKkXr4akLf4ofo37ZUMycwML89R2P3qxcbZG", | ||
SNY_USDC = "AZpo4BJHHRetF96v6SGinFZBMXM4yWMo4RA8C4PriDLk", | ||
mSOL_USDC = "8PSfyiTVwPb6Rr2iZ8F3kNpbg65BCfJM9v8LfB916r44", | ||
SLRS_USDC = "AtB4nUmdyQfuWWJ9xAHw9xyVnJFfSjSuVWkiYan8y86w", | ||
PORT_USDC = "F8gPSpwVHj8FdAJAYULDuZBxFEJut87hUbARYYx3471w" | ||
} |
@@ -27,2 +27,3 @@ "use strict"; | ||
OrcaPoolConfig["MAPS_SOL"] = "99pfC8fWymXgbq3CvrExhx3UxQDC1fMWEWLbNT83F45e"; | ||
OrcaPoolConfig["USDC_USDT"] = "H2uzgruPvonVpCRhwwdukcpXK8TG17swFNzYFr2rtPxy"; | ||
OrcaPoolConfig["ORCA_SOL"] = "2uVjAuRXavpM6h1scGQaxqb6HVaNRn6T2X7HHXTabz25"; | ||
@@ -33,2 +34,6 @@ OrcaPoolConfig["ORCA_USDC"] = "n8Mpu28RjeYD7oUX3LG1tPxzhRZh3YYLRSHcHRdS3Zx"; | ||
OrcaPoolConfig["LIQ_USDC"] = "3PD9SZFwXKkXr4akLf4ofo37ZUMycwML89R2P3qxcbZG"; | ||
OrcaPoolConfig["SNY_USDC"] = "AZpo4BJHHRetF96v6SGinFZBMXM4yWMo4RA8C4PriDLk"; | ||
OrcaPoolConfig["mSOL_USDC"] = "8PSfyiTVwPb6Rr2iZ8F3kNpbg65BCfJM9v8LfB916r44"; | ||
OrcaPoolConfig["SLRS_USDC"] = "AtB4nUmdyQfuWWJ9xAHw9xyVnJFfSjSuVWkiYan8y86w"; | ||
OrcaPoolConfig["PORT_USDC"] = "F8gPSpwVHj8FdAJAYULDuZBxFEJut87hUbARYYx3471w"; | ||
})(OrcaPoolConfig = exports.OrcaPoolConfig || (exports.OrcaPoolConfig = {})); |
@@ -49,3 +49,3 @@ import { Keypair, PublicKey } from "@solana/web3.js"; | ||
* | ||
* @param owner The keypair for the user's wallet | ||
* @param owner The keypair for the user's wallet or just the user's public key | ||
* @param inputToken An Orca supported token in the user's wallet to swap from | ||
@@ -56,3 +56,3 @@ * @param amountIn The amount of inputToken to swap from | ||
*/ | ||
swap: (owner: Keypair, inputToken: OrcaToken, amountIn: Decimal | OrcaU64, minimumAmountOut: Decimal | OrcaU64) => Promise<TransactionPayload>; | ||
swap: (owner: Keypair | PublicKey, inputToken: OrcaToken, amountIn: Decimal | OrcaU64, minimumAmountOut: Decimal | OrcaU64) => Promise<TransactionPayload>; | ||
}; | ||
@@ -59,0 +59,0 @@ /** |
@@ -1,2 +0,2 @@ | ||
import { Keypair, Signer, Transaction, TransactionInstruction, TransactionSignature } from "@solana/web3.js"; | ||
import { Signer, Transaction, TransactionInstruction, TransactionSignature } from "@solana/web3.js"; | ||
export declare const emptyInstruction: Instruction; | ||
@@ -6,3 +6,3 @@ export declare type Instruction = { | ||
cleanupInstructions: TransactionInstruction[]; | ||
signers: Keypair[]; | ||
signers: Signer[]; | ||
}; | ||
@@ -9,0 +9,0 @@ export declare type TransactionPayload = { |
import { u64 } from "@solana/spl-token"; | ||
import { Connection, Keypair, PublicKey } from "@solana/web3.js"; | ||
import { Connection, PublicKey } from "@solana/web3.js"; | ||
import { Instruction } from "../models/instruction"; | ||
import { Owner } from "./key-utils"; | ||
export declare type ResolvedTokenAddressInstruction = { | ||
address: PublicKey; | ||
} & Instruction; | ||
export declare function resolveOrCreateAssociatedTokenAddress(connection: Connection, owner: Keypair, tokenMint: PublicKey, amountIn?: u64): Promise<ResolvedTokenAddressInstruction>; | ||
export declare function resolveOrCreateAssociatedTokenAddress(connection: Connection, owner: Owner, tokenMint: PublicKey, amountIn?: u64): Promise<ResolvedTokenAddressInstruction>; | ||
export declare function deriveAssociatedTokenAddress(walletAddress: PublicKey, tokenMint: PublicKey): Promise<PublicKey>; |
@@ -27,5 +27,5 @@ "use strict"; | ||
yield connection.getAccountInfo(derivedAddress).then((info) => { | ||
const tokenAccountInfo = deserialize_account_1.deserializeAccount(info === null || info === void 0 ? void 0 : info.data); | ||
const tokenAccountInfo = (0, deserialize_account_1.deserializeAccount)(info === null || info === void 0 ? void 0 : info.data); | ||
if (!tokenAccountInfo) { | ||
resolveAtaInstruction = token_instructions_1.createAssociatedTokenAccountInstruction(derivedAddress, owner.publicKey, owner.publicKey, tokenMint, owner); | ||
resolveAtaInstruction = (0, token_instructions_1.createAssociatedTokenAccountInstruction)(derivedAddress, owner.publicKey, owner.publicKey, tokenMint, owner); | ||
} | ||
@@ -44,3 +44,3 @@ }); | ||
// Create a temp-account to transfer SOL in the form of WSOL | ||
return token_instructions_1.createWSOLAccountInstructions(owner.publicKey, tokens_1.solToken.mint, amountIn, accountRentExempt); | ||
return (0, token_instructions_1.createWSOLAccountInstructions)(owner.publicKey, tokens_1.solToken.mint, amountIn, accountRentExempt); | ||
} | ||
@@ -47,0 +47,0 @@ }); |
@@ -1,3 +0,2 @@ | ||
/// <reference types="node" /> | ||
import { AccountInfo } from "@solana/spl-token"; | ||
export declare const deserializeAccount: (data: Buffer | undefined) => AccountInfo | undefined; |
@@ -28,3 +28,3 @@ "use strict"; | ||
]); | ||
const tokens = accountInfos.map((info) => info != undefined ? deserialize_account_1.deserializeAccount(info.data) : undefined); | ||
const tokens = accountInfos.map((info) => info != undefined ? (0, deserialize_account_1.deserializeAccount)(info.data) : undefined); | ||
const inputTokenAccount = tokens[0], outputTokenAccount = tokens[1]; | ||
@@ -31,0 +31,0 @@ if (inputTokenAccount === undefined || outputTokenAccount === undefined) { |
@@ -5,5 +5,6 @@ import { u64 } from "@solana/spl-token"; | ||
import { Instruction } from "../../models"; | ||
import { Owner } from "../key-utils"; | ||
export declare const createApprovalInstruction: (ownerAddress: PublicKey, approveAmount: u64, tokenUserAddress: PublicKey) => { | ||
userTransferAuthority: Keypair; | ||
} & Instruction; | ||
export declare const createSwapInstruction: (poolParams: OrcaPoolParams, owner: Keypair, inputToken: OrcaPoolToken, inputTokenUserAddress: PublicKey, outputToken: OrcaPoolToken, outputTokenUserAddress: PublicKey, amountIn: u64, minimumAmountOut: u64, userTransferAuthority: PublicKey) => Promise<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>; |
@@ -37,5 +37,5 @@ "use strict"; | ||
cleanupInstructions: [], | ||
signers: [owner], | ||
signers: owner.signer ? [owner.signer] : [], | ||
}; | ||
}); | ||
exports.createSwapInstruction = createSwapInstruction; |
import { u64 } from "@solana/spl-token"; | ||
import { Keypair, PublicKey } from "@solana/web3.js"; | ||
import { PublicKey } from "@solana/web3.js"; | ||
import { Instruction } from "../.."; | ||
import { ResolvedTokenAddressInstruction } from "../ata-utils"; | ||
import { Owner } from "../key-utils"; | ||
export declare const createWSOLAccountInstructions: (owner: PublicKey, solMint: PublicKey, amountIn: u64, rentExemptLamports: number) => ResolvedTokenAddressInstruction; | ||
export declare function createAssociatedTokenAccountInstruction(associatedTokenAddress: PublicKey, fundSource: PublicKey, destination: PublicKey, tokenMint: PublicKey, fundAddressOwner: Keypair): Instruction; | ||
export declare function createAssociatedTokenAccountInstruction(associatedTokenAddress: PublicKey, fundSource: PublicKey, destination: PublicKey, tokenMint: PublicKey, fundAddressOwner: Owner): Instruction; |
@@ -73,5 +73,5 @@ "use strict"; | ||
cleanupInstructions: [], | ||
signers: [fundAddressOwner], | ||
signers: fundAddressOwner.signer ? [fundAddressOwner.signer] : [], | ||
}; | ||
} | ||
exports.createAssociatedTokenAccountInstruction = createAssociatedTokenAccountInstruction; |
import { Connection, PublicKey } from "@solana/web3.js"; | ||
import { Instruction, TransactionPayload } from "../.."; | ||
import { Instruction } from "../.."; | ||
import { TransactionPayload } from "../../models"; | ||
import { Owner } from "../key-utils"; | ||
export declare class TransactionBuilder { | ||
@@ -7,5 +9,6 @@ private connection; | ||
private instructions; | ||
constructor(connection: Connection, feePayer: PublicKey); | ||
private owner; | ||
constructor(connection: Connection, feePayer: PublicKey, owner: Owner); | ||
addInstruction(instruction: Instruction): TransactionBuilder; | ||
build(): Promise<TransactionPayload>; | ||
} |
@@ -15,6 +15,7 @@ "use strict"; | ||
class TransactionBuilder { | ||
constructor(connection, feePayer) { | ||
constructor(connection, feePayer, owner) { | ||
this.connection = connection; | ||
this.feePayer = feePayer; | ||
this.instructions = []; | ||
this.owner = owner; | ||
} | ||
@@ -43,10 +44,13 @@ addInstruction(instruction) { | ||
transaction.feePayer = this.feePayer; | ||
const payload = { | ||
return { | ||
transaction: transaction, | ||
signers: signers, | ||
execute: () => __awaiter(this, void 0, void 0, function* () { | ||
return web3_js_1.sendAndConfirmTransaction(this.connection, transaction, signers); | ||
}), | ||
execute: this.owner.isKeyPair | ||
? () => __awaiter(this, void 0, void 0, function* () { | ||
return (0, web3_js_1.sendAndConfirmTransaction)(this.connection, transaction, signers); | ||
}) | ||
: () => __awaiter(this, void 0, void 0, function* () { | ||
throw new Error("Please use a Keypair for the owner parameter to enable the execute function"); | ||
}), | ||
}; | ||
return payload; | ||
}); | ||
@@ -53,0 +57,0 @@ } |
{ | ||
"name": "@orca-so/sdk", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"description": "Typescript SDK for the Orca protocol.", | ||
@@ -9,5 +9,6 @@ "main": "dist/index.js", | ||
"dependencies": { | ||
"@orca-so/stablecurve": "^1.0.5", | ||
"@solana/spl-token": "^0.1.5", | ||
"@solana/spl-token-swap": "^0.1.2", | ||
"@solana/web3.js": "^1.17.0", | ||
"@solana/web3.js": "^1.24.1", | ||
"decimal.js": "^10.3.1" | ||
@@ -14,0 +15,0 @@ }, |
@@ -18,3 +18,2 @@ # Orca Typescript SDK | ||
- More trader information (APY, Volume) | ||
- Support @project-serum/sol-wallet-adapter to support browser use-case | ||
- Deposit/Withdraw from OrcaPools | ||
@@ -21,0 +20,0 @@ |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
147711
81
2291
5
95
+ Added@orca-so/stablecurve@^1.0.5
+ Added@orca-so/stablecurve@1.0.8(transitive)
Updated@solana/web3.js@^1.24.1