@solana/spl-token-swap
Advanced tools
Comparing version 0.1.3 to 0.1.4
@@ -45,3 +45,2 @@ "use strict"; | ||
const Layout = __importStar(require("./layout")); | ||
const send_and_confirm_transaction_1 = require("./util/send-and-confirm-transaction"); | ||
const account_1 = require("./util/account"); | ||
@@ -284,3 +283,3 @@ exports.TOKEN_SWAP_PROGRAM_ID = new web3_js_1.PublicKey('SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8'); | ||
*/ | ||
static createTokenSwap(connection, payer, tokenSwapAccount, authority, tokenAccountA, tokenAccountB, poolToken, mintA, mintB, feeAccount, tokenAccountPool, swapProgramId, tokenProgramId, tradeFeeNumerator, tradeFeeDenominator, ownerTradeFeeNumerator, ownerTradeFeeDenominator, ownerWithdrawFeeNumerator, ownerWithdrawFeeDenominator, hostFeeNumerator, hostFeeDenominator, curveType, curveParameters) { | ||
static createTokenSwap(connection, payer, tokenSwapAccount, authority, tokenAccountA, tokenAccountB, poolToken, mintA, mintB, feeAccount, tokenAccountPool, swapProgramId, tokenProgramId, tradeFeeNumerator, tradeFeeDenominator, ownerTradeFeeNumerator, ownerTradeFeeDenominator, ownerWithdrawFeeNumerator, ownerWithdrawFeeDenominator, hostFeeNumerator, hostFeeDenominator, curveType, curveParameters, confirmOptions) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -301,3 +300,3 @@ let transaction; | ||
transaction.add(instruction); | ||
yield (0, send_and_confirm_transaction_1.sendAndConfirmTransaction)('createAccount and InitializeSwap', connection, transaction, payer, tokenSwapAccount); | ||
yield (0, web3_js_1.sendAndConfirmTransaction)(connection, transaction, [payer, tokenSwapAccount], confirmOptions); | ||
return tokenSwap; | ||
@@ -318,5 +317,5 @@ }); | ||
*/ | ||
swap(userSource, poolSource, poolDestination, userDestination, hostFeeAccount, userTransferAuthority, amountIn, minimumAmountOut) { | ||
swap(userSource, poolSource, poolDestination, userDestination, hostFeeAccount, userTransferAuthority, amountIn, minimumAmountOut, confirmOptions) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield (0, send_and_confirm_transaction_1.sendAndConfirmTransaction)('swap', this.connection, new web3_js_1.Transaction().add(TokenSwap.swapInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, userSource, poolSource, poolDestination, userDestination, this.poolToken, this.feeAccount, hostFeeAccount, this.swapProgramId, this.tokenProgramId, amountIn, minimumAmountOut)), this.payer, userTransferAuthority); | ||
return yield (0, web3_js_1.sendAndConfirmTransaction)(this.connection, new web3_js_1.Transaction().add(TokenSwap.swapInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, userSource, poolSource, poolDestination, userDestination, this.poolToken, this.feeAccount, hostFeeAccount, this.swapProgramId, this.tokenProgramId, amountIn, minimumAmountOut)), [this.payer, userTransferAuthority], confirmOptions); | ||
}); | ||
@@ -367,5 +366,5 @@ } | ||
*/ | ||
depositAllTokenTypes(userAccountA, userAccountB, poolAccount, userTransferAuthority, poolTokenAmount, maximumTokenA, maximumTokenB) { | ||
depositAllTokenTypes(userAccountA, userAccountB, poolAccount, userTransferAuthority, poolTokenAmount, maximumTokenA, maximumTokenB, confirmOptions) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield (0, send_and_confirm_transaction_1.sendAndConfirmTransaction)('depositAllTokenTypes', this.connection, new web3_js_1.Transaction().add(TokenSwap.depositAllTokenTypesInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, userAccountA, userAccountB, this.tokenAccountA, this.tokenAccountB, this.poolToken, poolAccount, this.swapProgramId, this.tokenProgramId, poolTokenAmount, maximumTokenA, maximumTokenB)), this.payer, userTransferAuthority); | ||
return yield (0, web3_js_1.sendAndConfirmTransaction)(this.connection, new web3_js_1.Transaction().add(TokenSwap.depositAllTokenTypesInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, userAccountA, userAccountB, this.tokenAccountA, this.tokenAccountB, this.poolToken, poolAccount, this.swapProgramId, this.tokenProgramId, poolTokenAmount, maximumTokenA, maximumTokenB)), [this.payer, userTransferAuthority], confirmOptions); | ||
}); | ||
@@ -416,5 +415,5 @@ } | ||
*/ | ||
withdrawAllTokenTypes(userAccountA, userAccountB, poolAccount, userTransferAuthority, poolTokenAmount, minimumTokenA, minimumTokenB) { | ||
withdrawAllTokenTypes(userAccountA, userAccountB, poolAccount, userTransferAuthority, poolTokenAmount, minimumTokenA, minimumTokenB, confirmOptions) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield (0, send_and_confirm_transaction_1.sendAndConfirmTransaction)('withdraw', this.connection, new web3_js_1.Transaction().add(TokenSwap.withdrawAllTokenTypesInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, this.poolToken, this.feeAccount, poolAccount, this.tokenAccountA, this.tokenAccountB, userAccountA, userAccountB, this.swapProgramId, this.tokenProgramId, poolTokenAmount, minimumTokenA, minimumTokenB)), this.payer, userTransferAuthority); | ||
return yield (0, web3_js_1.sendAndConfirmTransaction)(this.connection, new web3_js_1.Transaction().add(TokenSwap.withdrawAllTokenTypesInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, this.poolToken, this.feeAccount, poolAccount, this.tokenAccountA, this.tokenAccountB, userAccountA, userAccountB, this.swapProgramId, this.tokenProgramId, poolTokenAmount, minimumTokenA, minimumTokenB)), [this.payer, userTransferAuthority], confirmOptions); | ||
}); | ||
@@ -463,5 +462,5 @@ } | ||
*/ | ||
depositSingleTokenTypeExactAmountIn(userAccount, poolAccount, userTransferAuthority, sourceTokenAmount, minimumPoolTokenAmount) { | ||
depositSingleTokenTypeExactAmountIn(userAccount, poolAccount, userTransferAuthority, sourceTokenAmount, minimumPoolTokenAmount, confirmOptions) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield (0, send_and_confirm_transaction_1.sendAndConfirmTransaction)('depositSingleTokenTypeExactAmountIn', this.connection, new web3_js_1.Transaction().add(TokenSwap.depositSingleTokenTypeExactAmountInInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, userAccount, this.tokenAccountA, this.tokenAccountB, this.poolToken, poolAccount, this.swapProgramId, this.tokenProgramId, sourceTokenAmount, minimumPoolTokenAmount)), this.payer, userTransferAuthority); | ||
return yield (0, web3_js_1.sendAndConfirmTransaction)(this.connection, new web3_js_1.Transaction().add(TokenSwap.depositSingleTokenTypeExactAmountInInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, userAccount, this.tokenAccountA, this.tokenAccountB, this.poolToken, poolAccount, this.swapProgramId, this.tokenProgramId, sourceTokenAmount, minimumPoolTokenAmount)), [this.payer, userTransferAuthority], confirmOptions); | ||
}); | ||
@@ -507,5 +506,5 @@ } | ||
*/ | ||
withdrawSingleTokenTypeExactAmountOut(userAccount, poolAccount, userTransferAuthority, destinationTokenAmount, maximumPoolTokenAmount) { | ||
withdrawSingleTokenTypeExactAmountOut(userAccount, poolAccount, userTransferAuthority, destinationTokenAmount, maximumPoolTokenAmount, confirmOptions) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
return yield (0, send_and_confirm_transaction_1.sendAndConfirmTransaction)('withdrawSingleTokenTypeExactAmountOut', this.connection, new web3_js_1.Transaction().add(TokenSwap.withdrawSingleTokenTypeExactAmountOutInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, this.poolToken, this.feeAccount, poolAccount, this.tokenAccountA, this.tokenAccountB, userAccount, this.swapProgramId, this.tokenProgramId, destinationTokenAmount, maximumPoolTokenAmount)), this.payer, userTransferAuthority); | ||
return yield (0, web3_js_1.sendAndConfirmTransaction)(this.connection, new web3_js_1.Transaction().add(TokenSwap.withdrawSingleTokenTypeExactAmountOutInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, this.poolToken, this.feeAccount, poolAccount, this.tokenAccountA, this.tokenAccountB, userAccount, this.swapProgramId, this.tokenProgramId, destinationTokenAmount, maximumPoolTokenAmount)), [this.payer, userTransferAuthority], confirmOptions); | ||
}); | ||
@@ -512,0 +511,0 @@ } |
@@ -36,3 +36,2 @@ "use strict"; | ||
const Layout = __importStar(require("./layout")); | ||
const send_and_confirm_transaction_1 = require("./util/send-and-confirm-transaction"); | ||
const account_1 = require("./util/account"); | ||
@@ -292,3 +291,3 @@ exports.TOKEN_SWAP_PROGRAM_ID = new web3_js_1.PublicKey('SwaPpA9LAaLfeLi3a68M4DjnLqgtticKg6CnyNwgAC8'); | ||
*/ | ||
static async createTokenSwap(connection, payer, tokenSwapAccount, authority, tokenAccountA, tokenAccountB, poolToken, mintA, mintB, feeAccount, tokenAccountPool, swapProgramId, tokenProgramId, tradeFeeNumerator, tradeFeeDenominator, ownerTradeFeeNumerator, ownerTradeFeeDenominator, ownerWithdrawFeeNumerator, ownerWithdrawFeeDenominator, hostFeeNumerator, hostFeeDenominator, curveType, curveParameters) { | ||
static async createTokenSwap(connection, payer, tokenSwapAccount, authority, tokenAccountA, tokenAccountB, poolToken, mintA, mintB, feeAccount, tokenAccountPool, swapProgramId, tokenProgramId, tradeFeeNumerator, tradeFeeDenominator, ownerTradeFeeNumerator, ownerTradeFeeDenominator, ownerWithdrawFeeNumerator, ownerWithdrawFeeDenominator, hostFeeNumerator, hostFeeDenominator, curveType, curveParameters, confirmOptions) { | ||
let transaction; | ||
@@ -308,3 +307,3 @@ const tokenSwap = new TokenSwap(connection, tokenSwapAccount.publicKey, swapProgramId, tokenProgramId, poolToken, feeAccount, authority, tokenAccountA, tokenAccountB, mintA, mintB, new Numberu64(tradeFeeNumerator), new Numberu64(tradeFeeDenominator), new Numberu64(ownerTradeFeeNumerator), new Numberu64(ownerTradeFeeDenominator), new Numberu64(ownerWithdrawFeeNumerator), new Numberu64(ownerWithdrawFeeDenominator), new Numberu64(hostFeeNumerator), new Numberu64(hostFeeDenominator), curveType, payer); | ||
transaction.add(instruction); | ||
await (0, send_and_confirm_transaction_1.sendAndConfirmTransaction)('createAccount and InitializeSwap', connection, transaction, payer, tokenSwapAccount); | ||
await (0, web3_js_1.sendAndConfirmTransaction)(connection, transaction, [payer, tokenSwapAccount], confirmOptions); | ||
return tokenSwap; | ||
@@ -324,4 +323,4 @@ } | ||
*/ | ||
async swap(userSource, poolSource, poolDestination, userDestination, hostFeeAccount, userTransferAuthority, amountIn, minimumAmountOut) { | ||
return await (0, send_and_confirm_transaction_1.sendAndConfirmTransaction)('swap', this.connection, new web3_js_1.Transaction().add(TokenSwap.swapInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, userSource, poolSource, poolDestination, userDestination, this.poolToken, this.feeAccount, hostFeeAccount, this.swapProgramId, this.tokenProgramId, amountIn, minimumAmountOut)), this.payer, userTransferAuthority); | ||
async swap(userSource, poolSource, poolDestination, userDestination, hostFeeAccount, userTransferAuthority, amountIn, minimumAmountOut, confirmOptions) { | ||
return await (0, web3_js_1.sendAndConfirmTransaction)(this.connection, new web3_js_1.Transaction().add(TokenSwap.swapInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, userSource, poolSource, poolDestination, userDestination, this.poolToken, this.feeAccount, hostFeeAccount, this.swapProgramId, this.tokenProgramId, amountIn, minimumAmountOut)), [this.payer, userTransferAuthority], confirmOptions); | ||
} | ||
@@ -371,4 +370,4 @@ static swapInstruction(tokenSwap, authority, userTransferAuthority, userSource, poolSource, poolDestination, userDestination, poolMint, feeAccount, hostFeeAccount, swapProgramId, tokenProgramId, amountIn, minimumAmountOut) { | ||
*/ | ||
async depositAllTokenTypes(userAccountA, userAccountB, poolAccount, userTransferAuthority, poolTokenAmount, maximumTokenA, maximumTokenB) { | ||
return await (0, send_and_confirm_transaction_1.sendAndConfirmTransaction)('depositAllTokenTypes', this.connection, new web3_js_1.Transaction().add(TokenSwap.depositAllTokenTypesInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, userAccountA, userAccountB, this.tokenAccountA, this.tokenAccountB, this.poolToken, poolAccount, this.swapProgramId, this.tokenProgramId, poolTokenAmount, maximumTokenA, maximumTokenB)), this.payer, userTransferAuthority); | ||
async depositAllTokenTypes(userAccountA, userAccountB, poolAccount, userTransferAuthority, poolTokenAmount, maximumTokenA, maximumTokenB, confirmOptions) { | ||
return await (0, web3_js_1.sendAndConfirmTransaction)(this.connection, new web3_js_1.Transaction().add(TokenSwap.depositAllTokenTypesInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, userAccountA, userAccountB, this.tokenAccountA, this.tokenAccountB, this.poolToken, poolAccount, this.swapProgramId, this.tokenProgramId, poolTokenAmount, maximumTokenA, maximumTokenB)), [this.payer, userTransferAuthority], confirmOptions); | ||
} | ||
@@ -418,4 +417,4 @@ static depositAllTokenTypesInstruction(tokenSwap, authority, userTransferAuthority, sourceA, sourceB, intoA, intoB, poolToken, poolAccount, swapProgramId, tokenProgramId, poolTokenAmount, maximumTokenA, maximumTokenB) { | ||
*/ | ||
async withdrawAllTokenTypes(userAccountA, userAccountB, poolAccount, userTransferAuthority, poolTokenAmount, minimumTokenA, minimumTokenB) { | ||
return await (0, send_and_confirm_transaction_1.sendAndConfirmTransaction)('withdraw', this.connection, new web3_js_1.Transaction().add(TokenSwap.withdrawAllTokenTypesInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, this.poolToken, this.feeAccount, poolAccount, this.tokenAccountA, this.tokenAccountB, userAccountA, userAccountB, this.swapProgramId, this.tokenProgramId, poolTokenAmount, minimumTokenA, minimumTokenB)), this.payer, userTransferAuthority); | ||
async withdrawAllTokenTypes(userAccountA, userAccountB, poolAccount, userTransferAuthority, poolTokenAmount, minimumTokenA, minimumTokenB, confirmOptions) { | ||
return await (0, web3_js_1.sendAndConfirmTransaction)(this.connection, new web3_js_1.Transaction().add(TokenSwap.withdrawAllTokenTypesInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, this.poolToken, this.feeAccount, poolAccount, this.tokenAccountA, this.tokenAccountB, userAccountA, userAccountB, this.swapProgramId, this.tokenProgramId, poolTokenAmount, minimumTokenA, minimumTokenB)), [this.payer, userTransferAuthority], confirmOptions); | ||
} | ||
@@ -463,4 +462,4 @@ static withdrawAllTokenTypesInstruction(tokenSwap, authority, userTransferAuthority, poolMint, feeAccount, sourcePoolAccount, fromA, fromB, userAccountA, userAccountB, swapProgramId, tokenProgramId, poolTokenAmount, minimumTokenA, minimumTokenB) { | ||
*/ | ||
async depositSingleTokenTypeExactAmountIn(userAccount, poolAccount, userTransferAuthority, sourceTokenAmount, minimumPoolTokenAmount) { | ||
return await (0, send_and_confirm_transaction_1.sendAndConfirmTransaction)('depositSingleTokenTypeExactAmountIn', this.connection, new web3_js_1.Transaction().add(TokenSwap.depositSingleTokenTypeExactAmountInInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, userAccount, this.tokenAccountA, this.tokenAccountB, this.poolToken, poolAccount, this.swapProgramId, this.tokenProgramId, sourceTokenAmount, minimumPoolTokenAmount)), this.payer, userTransferAuthority); | ||
async depositSingleTokenTypeExactAmountIn(userAccount, poolAccount, userTransferAuthority, sourceTokenAmount, minimumPoolTokenAmount, confirmOptions) { | ||
return await (0, web3_js_1.sendAndConfirmTransaction)(this.connection, new web3_js_1.Transaction().add(TokenSwap.depositSingleTokenTypeExactAmountInInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, userAccount, this.tokenAccountA, this.tokenAccountB, this.poolToken, poolAccount, this.swapProgramId, this.tokenProgramId, sourceTokenAmount, minimumPoolTokenAmount)), [this.payer, userTransferAuthority], confirmOptions); | ||
} | ||
@@ -505,4 +504,4 @@ static depositSingleTokenTypeExactAmountInInstruction(tokenSwap, authority, userTransferAuthority, source, intoA, intoB, poolToken, poolAccount, swapProgramId, tokenProgramId, sourceTokenAmount, minimumPoolTokenAmount) { | ||
*/ | ||
async withdrawSingleTokenTypeExactAmountOut(userAccount, poolAccount, userTransferAuthority, destinationTokenAmount, maximumPoolTokenAmount) { | ||
return await (0, send_and_confirm_transaction_1.sendAndConfirmTransaction)('withdrawSingleTokenTypeExactAmountOut', this.connection, new web3_js_1.Transaction().add(TokenSwap.withdrawSingleTokenTypeExactAmountOutInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, this.poolToken, this.feeAccount, poolAccount, this.tokenAccountA, this.tokenAccountB, userAccount, this.swapProgramId, this.tokenProgramId, destinationTokenAmount, maximumPoolTokenAmount)), this.payer, userTransferAuthority); | ||
async withdrawSingleTokenTypeExactAmountOut(userAccount, poolAccount, userTransferAuthority, destinationTokenAmount, maximumPoolTokenAmount, confirmOptions) { | ||
return await (0, web3_js_1.sendAndConfirmTransaction)(this.connection, new web3_js_1.Transaction().add(TokenSwap.withdrawSingleTokenTypeExactAmountOutInstruction(this.tokenSwap, this.authority, userTransferAuthority.publicKey, this.poolToken, this.feeAccount, poolAccount, this.tokenAccountA, this.tokenAccountB, userAccount, this.swapProgramId, this.tokenProgramId, destinationTokenAmount, maximumPoolTokenAmount)), [this.payer, userTransferAuthority], confirmOptions); | ||
} | ||
@@ -509,0 +508,0 @@ static withdrawSingleTokenTypeExactAmountOutInstruction(tokenSwap, authority, userTransferAuthority, poolMint, feeAccount, sourcePoolAccount, fromA, fromB, userAccount, swapProgramId, tokenProgramId, destinationTokenAmount, maximumPoolTokenAmount) { |
/// <reference types="node" /> | ||
import BN from 'bn.js'; | ||
import { Buffer } from 'buffer'; | ||
import type { Connection, TransactionSignature } from '@solana/web3.js'; | ||
import type { ConfirmOptions, Connection, TransactionSignature } from '@solana/web3.js'; | ||
import { Account, PublicKey, TransactionInstruction } from '@solana/web3.js'; | ||
@@ -101,3 +101,3 @@ export declare const TOKEN_SWAP_PROGRAM_ID: PublicKey; | ||
*/ | ||
static createTokenSwap(connection: Connection, payer: Account, tokenSwapAccount: Account, authority: PublicKey, tokenAccountA: PublicKey, tokenAccountB: PublicKey, poolToken: PublicKey, mintA: PublicKey, mintB: PublicKey, feeAccount: PublicKey, tokenAccountPool: PublicKey, swapProgramId: PublicKey, tokenProgramId: PublicKey, tradeFeeNumerator: number, tradeFeeDenominator: number, ownerTradeFeeNumerator: number, ownerTradeFeeDenominator: number, ownerWithdrawFeeNumerator: number, ownerWithdrawFeeDenominator: number, hostFeeNumerator: number, hostFeeDenominator: number, curveType: number, curveParameters?: Numberu64): Promise<TokenSwap>; | ||
static createTokenSwap(connection: Connection, payer: Account, tokenSwapAccount: Account, authority: PublicKey, tokenAccountA: PublicKey, tokenAccountB: PublicKey, poolToken: PublicKey, mintA: PublicKey, mintB: PublicKey, feeAccount: PublicKey, tokenAccountPool: PublicKey, swapProgramId: PublicKey, tokenProgramId: PublicKey, tradeFeeNumerator: number, tradeFeeDenominator: number, ownerTradeFeeNumerator: number, ownerTradeFeeDenominator: number, ownerWithdrawFeeNumerator: number, ownerWithdrawFeeDenominator: number, hostFeeNumerator: number, hostFeeDenominator: number, curveType: number, curveParameters?: Numberu64, confirmOptions?: ConfirmOptions): Promise<TokenSwap>; | ||
/** | ||
@@ -115,3 +115,3 @@ * Swap token A for token B | ||
*/ | ||
swap(userSource: PublicKey, poolSource: PublicKey, poolDestination: PublicKey, userDestination: PublicKey, hostFeeAccount: PublicKey | null, userTransferAuthority: Account, amountIn: number | Numberu64, minimumAmountOut: number | Numberu64): Promise<TransactionSignature>; | ||
swap(userSource: PublicKey, poolSource: PublicKey, poolDestination: PublicKey, userDestination: PublicKey, hostFeeAccount: PublicKey | null, userTransferAuthority: Account, amountIn: number | Numberu64, minimumAmountOut: number | Numberu64, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>; | ||
static swapInstruction(tokenSwap: PublicKey, authority: PublicKey, userTransferAuthority: PublicKey, userSource: PublicKey, poolSource: PublicKey, poolDestination: PublicKey, userDestination: PublicKey, poolMint: PublicKey, feeAccount: PublicKey, hostFeeAccount: PublicKey | null, swapProgramId: PublicKey, tokenProgramId: PublicKey, amountIn: number | Numberu64, minimumAmountOut: number | Numberu64): TransactionInstruction; | ||
@@ -128,3 +128,3 @@ /** | ||
*/ | ||
depositAllTokenTypes(userAccountA: PublicKey, userAccountB: PublicKey, poolAccount: PublicKey, userTransferAuthority: Account, poolTokenAmount: number | Numberu64, maximumTokenA: number | Numberu64, maximumTokenB: number | Numberu64): Promise<TransactionSignature>; | ||
depositAllTokenTypes(userAccountA: PublicKey, userAccountB: PublicKey, poolAccount: PublicKey, userTransferAuthority: Account, poolTokenAmount: number | Numberu64, maximumTokenA: number | Numberu64, maximumTokenB: number | Numberu64, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>; | ||
static depositAllTokenTypesInstruction(tokenSwap: PublicKey, authority: PublicKey, userTransferAuthority: PublicKey, sourceA: PublicKey, sourceB: PublicKey, intoA: PublicKey, intoB: PublicKey, poolToken: PublicKey, poolAccount: PublicKey, swapProgramId: PublicKey, tokenProgramId: PublicKey, poolTokenAmount: number | Numberu64, maximumTokenA: number | Numberu64, maximumTokenB: number | Numberu64): TransactionInstruction; | ||
@@ -142,3 +142,3 @@ /** | ||
*/ | ||
withdrawAllTokenTypes(userAccountA: PublicKey, userAccountB: PublicKey, poolAccount: PublicKey, userTransferAuthority: Account, poolTokenAmount: number | Numberu64, minimumTokenA: number | Numberu64, minimumTokenB: number | Numberu64): Promise<TransactionSignature>; | ||
withdrawAllTokenTypes(userAccountA: PublicKey, userAccountB: PublicKey, poolAccount: PublicKey, userTransferAuthority: Account, poolTokenAmount: number | Numberu64, minimumTokenA: number | Numberu64, minimumTokenB: number | Numberu64, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>; | ||
static withdrawAllTokenTypesInstruction(tokenSwap: PublicKey, authority: PublicKey, userTransferAuthority: PublicKey, poolMint: PublicKey, feeAccount: PublicKey, sourcePoolAccount: PublicKey, fromA: PublicKey, fromB: PublicKey, userAccountA: PublicKey, userAccountB: PublicKey, swapProgramId: PublicKey, tokenProgramId: PublicKey, poolTokenAmount: number | Numberu64, minimumTokenA: number | Numberu64, minimumTokenB: number | Numberu64): TransactionInstruction; | ||
@@ -153,3 +153,3 @@ /** | ||
*/ | ||
depositSingleTokenTypeExactAmountIn(userAccount: PublicKey, poolAccount: PublicKey, userTransferAuthority: Account, sourceTokenAmount: number | Numberu64, minimumPoolTokenAmount: number | Numberu64): Promise<TransactionSignature>; | ||
depositSingleTokenTypeExactAmountIn(userAccount: PublicKey, poolAccount: PublicKey, userTransferAuthority: Account, sourceTokenAmount: number | Numberu64, minimumPoolTokenAmount: number | Numberu64, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>; | ||
static depositSingleTokenTypeExactAmountInInstruction(tokenSwap: PublicKey, authority: PublicKey, userTransferAuthority: PublicKey, source: PublicKey, intoA: PublicKey, intoB: PublicKey, poolToken: PublicKey, poolAccount: PublicKey, swapProgramId: PublicKey, tokenProgramId: PublicKey, sourceTokenAmount: number | Numberu64, minimumPoolTokenAmount: number | Numberu64): TransactionInstruction; | ||
@@ -165,4 +165,4 @@ /** | ||
*/ | ||
withdrawSingleTokenTypeExactAmountOut(userAccount: PublicKey, poolAccount: PublicKey, userTransferAuthority: Account, destinationTokenAmount: number | Numberu64, maximumPoolTokenAmount: number | Numberu64): Promise<TransactionSignature>; | ||
withdrawSingleTokenTypeExactAmountOut(userAccount: PublicKey, poolAccount: PublicKey, userTransferAuthority: Account, destinationTokenAmount: number | Numberu64, maximumPoolTokenAmount: number | Numberu64, confirmOptions?: ConfirmOptions): Promise<TransactionSignature>; | ||
static withdrawSingleTokenTypeExactAmountOutInstruction(tokenSwap: PublicKey, authority: PublicKey, userTransferAuthority: PublicKey, poolMint: PublicKey, feeAccount: PublicKey, sourcePoolAccount: PublicKey, fromA: PublicKey, fromB: PublicKey, userAccount: PublicKey, swapProgramId: PublicKey, tokenProgramId: PublicKey, destinationTokenAmount: number | Numberu64, maximumPoolTokenAmount: number | Numberu64): TransactionInstruction; | ||
} |
{ | ||
"name": "@solana/spl-token-swap", | ||
"version": "0.1.3", | ||
"version": "0.1.4", | ||
"description": "SPL Token Swap JavaScript API", | ||
@@ -45,4 +45,4 @@ "license": "MIT", | ||
"bn.js": "^5.1.3", | ||
"@solana/web3.js": "^1.10.0", | ||
"@solana/buffer-layout": "^3.0.0" | ||
"@solana/web3.js": "^1.42.0", | ||
"@solana/buffer-layout": "^4.0.0" | ||
}, | ||
@@ -59,6 +59,3 @@ "devDependencies": { | ||
"typescript-esm": "^2.0.0" | ||
}, | ||
"engines": { | ||
"node": ">= 10" | ||
} | ||
} |
@@ -5,3 +5,7 @@ import assert from 'assert'; | ||
import * as BufferLayout from '@solana/buffer-layout'; | ||
import type {Connection, TransactionSignature} from '@solana/web3.js'; | ||
import type { | ||
ConfirmOptions, | ||
Connection, | ||
TransactionSignature, | ||
} from '@solana/web3.js'; | ||
import { | ||
@@ -13,6 +17,6 @@ Account, | ||
TransactionInstruction, | ||
sendAndConfirmTransaction, | ||
} from '@solana/web3.js'; | ||
import * as Layout from './layout'; | ||
import {sendAndConfirmTransaction} from './util/send-and-confirm-transaction'; | ||
import {loadAccount} from './util/account'; | ||
@@ -370,2 +374,3 @@ | ||
curveParameters?: Numberu64, | ||
confirmOptions?: ConfirmOptions, | ||
): Promise<TokenSwap> { | ||
@@ -436,7 +441,6 @@ let transaction; | ||
await sendAndConfirmTransaction( | ||
'createAccount and InitializeSwap', | ||
connection, | ||
transaction, | ||
payer, | ||
tokenSwapAccount, | ||
[payer, tokenSwapAccount], | ||
confirmOptions, | ||
); | ||
@@ -468,5 +472,5 @@ | ||
minimumAmountOut: number | Numberu64, | ||
confirmOptions?: ConfirmOptions, | ||
): Promise<TransactionSignature> { | ||
return await sendAndConfirmTransaction( | ||
'swap', | ||
this.connection, | ||
@@ -491,4 +495,4 @@ new Transaction().add( | ||
), | ||
this.payer, | ||
userTransferAuthority, | ||
[this.payer, userTransferAuthority], | ||
confirmOptions, | ||
); | ||
@@ -569,5 +573,5 @@ } | ||
maximumTokenB: number | Numberu64, | ||
confirmOptions?: ConfirmOptions, | ||
): Promise<TransactionSignature> { | ||
return await sendAndConfirmTransaction( | ||
'depositAllTokenTypes', | ||
this.connection, | ||
@@ -592,4 +596,4 @@ new Transaction().add( | ||
), | ||
this.payer, | ||
userTransferAuthority, | ||
[this.payer, userTransferAuthority], | ||
confirmOptions, | ||
); | ||
@@ -670,5 +674,5 @@ } | ||
minimumTokenB: number | Numberu64, | ||
confirmOptions?: ConfirmOptions, | ||
): Promise<TransactionSignature> { | ||
return await sendAndConfirmTransaction( | ||
'withdraw', | ||
this.connection, | ||
@@ -694,4 +698,4 @@ new Transaction().add( | ||
), | ||
this.payer, | ||
userTransferAuthority, | ||
[this.payer, userTransferAuthority], | ||
confirmOptions, | ||
); | ||
@@ -769,5 +773,5 @@ } | ||
minimumPoolTokenAmount: number | Numberu64, | ||
confirmOptions?: ConfirmOptions, | ||
): Promise<TransactionSignature> { | ||
return await sendAndConfirmTransaction( | ||
'depositSingleTokenTypeExactAmountIn', | ||
this.connection, | ||
@@ -790,4 +794,4 @@ new Transaction().add( | ||
), | ||
this.payer, | ||
userTransferAuthority, | ||
[this.payer, userTransferAuthority], | ||
confirmOptions, | ||
); | ||
@@ -861,5 +865,5 @@ } | ||
maximumPoolTokenAmount: number | Numberu64, | ||
confirmOptions?: ConfirmOptions, | ||
): Promise<TransactionSignature> { | ||
return await sendAndConfirmTransaction( | ||
'withdrawSingleTokenTypeExactAmountOut', | ||
this.connection, | ||
@@ -883,4 +887,4 @@ new Transaction().add( | ||
), | ||
this.payer, | ||
userTransferAuthority, | ||
[this.payer, userTransferAuthority], | ||
confirmOptions, | ||
); | ||
@@ -887,0 +891,0 @@ } |
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
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
0
121619
32
2576
- Removed@solana/buffer-layout@3.0.0(transitive)
Updated@solana/buffer-layout@^4.0.0
Updated@solana/web3.js@^1.42.0