Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

@jup-ag/common

Package Overview
Dependencies
Maintainers
0
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@jup-ag/common - npm Package Compare versions

Comparing version 6.0.0-beta.9 to 6.1.0

dist/index.d.mts

321

dist/index.d.ts

@@ -104,2 +104,6 @@ import { PublicKey, Signer, Keypair, TransactionSignature, VersionedTransactionResponse, BlockhashWithExpiryBlockHeight, Connection, Transaction, VersionedTransaction, ConfirmedTransactionMeta, Blockhash, TransactionInstruction, AddressLookupTableAccount, Cluster, FeeCalculator } from '@solana/web3.js';

useSharedAccounts?: boolean;
/**
* Use the optimized wrapped SOL token account for swapping
*/
allowOptimizedWrappedSolTokenAccount?: boolean;
}

@@ -135,25 +139,14 @@ type SetupInstructions = {

declare function extractTokenBalanceChangeFromTransaction(meta: ConfirmedTransactionMeta, keyMap: Map<string, number>, tokenAccountAddress: PublicKey): number | undefined;
declare function extractTokenBalanceChangeFromTransaction(meta: ConfirmedTransactionMeta, user: PublicKey, mint: PublicKey): number | undefined;
/** Assumption: user is the signer so it can never be rolled */
declare function extractSOLChangeFromTransaction(meta: ConfirmedTransactionMeta, keyMap: Map<string, number>, user: PublicKey): number;
declare function extractTokenBalanceChangesFromEvents(events: Event[], inputMint: PublicKey, outputMint: PublicKey): [number, number];
declare function fetchSourceAddressAndDestinationAddress({ inputMint, outputMint, connection, userPublicKey, }: {
inputMint: PublicKey;
outputMint: PublicKey;
connection: Connection;
userPublicKey: PublicKey;
}): Promise<{
sourceAddress: PublicKey;
destinationAddress: PublicKey;
}>;
declare function getTokenBalanceChangesFromTransactionResponse({ txid, inputMint, outputMint, user, sourceAddress, destinationAddress, transactionResponse, hasWrappedSOL, }: {
declare function getTokenBalanceChangesFromTransactionResponse({ txid, user, inputMint, outputMint, transactionResponse, hasWrappedSOL, }: {
txid: TransactionSignature;
user: PublicKey;
inputMint: PublicKey;
outputMint: PublicKey;
user: PublicKey;
sourceAddress: PublicKey;
destinationAddress: PublicKey;
transactionResponse: VersionedTransactionResponse | null;
hasWrappedSOL: boolean;
}): number[];
}): [number, number];
declare function getUnixTs(): number;

@@ -230,2 +223,4 @@ declare function getSignature(transaction: Transaction | VersionedTransaction): string;

declare function getEvents(transactionResponse: VersionedTransactionResponse): Event[];
type Jupiter = {

@@ -604,2 +599,92 @@ version: '0.1.0';

{
name: 'exactOutRoute';
accounts: [
{
name: 'tokenProgram';
isMut: false;
isSigner: false;
},
{
name: 'userTransferAuthority';
isMut: false;
isSigner: true;
},
{
name: 'userSourceTokenAccount';
isMut: false;
isSigner: false;
},
{
name: 'userDestinationTokenAccount';
isMut: false;
isSigner: false;
},
{
name: 'destinationTokenAccount';
isMut: false;
isSigner: false;
isOptional: true;
},
{
name: 'sourceMint';
isMut: false;
isSigner: false;
},
{
name: 'destinationMint';
isMut: false;
isSigner: false;
},
{
name: 'platformFeeAccount';
isMut: true;
isSigner: false;
isOptional: true;
},
{
name: 'token2022Program';
isMut: false;
isSigner: false;
isOptional: true;
},
{
name: 'eventAuthority';
isMut: false;
isSigner: false;
},
{
name: 'program';
isMut: false;
isSigner: false;
}
];
args: [
{
name: 'routePlan';
type: {
vec: {
defined: 'RoutePlanStep';
};
};
},
{
name: 'outAmount';
type: 'u64';
},
{
name: 'quotedInAmount';
type: 'u64';
},
{
name: 'slippageBps';
type: 'u16';
},
{
name: 'platformFeeBps';
type: 'u8';
}
];
returns: 'u64';
},
{
name: 'sharedAccountsExactOutRoute';

@@ -807,2 +892,29 @@ docs: ['Route by using program owned token accounts and open orders accounts.'];

{
name: 'claim';
accounts: [
{
name: 'wallet';
isMut: true;
isSigner: false;
},
{
name: 'programAuthority';
isMut: true;
isSigner: false;
},
{
name: 'systemProgram';
isMut: false;
isSigner: false;
}
];
args: [
{
name: 'id';
type: 'u8';
}
];
returns: 'u64';
},
{
name: 'claimToken';

@@ -994,3 +1106,3 @@ accounts: [

{
name: 'a_to_b';
name: 'aToB';
type: 'bool';

@@ -1052,3 +1164,3 @@ }

{
name: 'a_to_b';
name: 'aToB';
type: 'bool';

@@ -1062,3 +1174,3 @@ }

{
name: 'x_to_y';
name: 'xToY';
type: 'bool';

@@ -1090,3 +1202,3 @@ }

{
name: 'x_to_y';
name: 'xToY';
type: 'bool';

@@ -1139,7 +1251,7 @@ }

{
name: 'from_token_id';
name: 'fromTokenId';
type: 'u64';
},
{
name: 'to_token_id';
name: 'toTokenId';
type: 'u64';

@@ -1162,3 +1274,3 @@ }

{
name: 'bridge_stake_seed';
name: 'bridgeStakeSeed';
type: 'u32';

@@ -1182,5 +1294,163 @@ }

name: 'MeteoraDlmm';
},
{
name: 'OpenBookV2';
fields: [
{
name: 'side';
type: {
defined: 'Side';
};
}
];
},
{
name: 'RaydiumClmmV2';
},
{
name: 'StakeDexPrefundWithdrawStakeAndDepositStake';
fields: [
{
name: 'bridgeStakeSeed';
type: 'u32';
}
];
},
{
name: 'Clone';
fields: [
{
name: 'poolIndex';
type: 'u8';
},
{
name: 'quantityIsInput';
type: 'bool';
},
{
name: 'quantityIsCollateral';
type: 'bool';
}
];
},
{
name: 'SanctumS';
fields: [
{
name: 'srcLstValueCalcAccs';
type: 'u8';
},
{
name: 'dstLstValueCalcAccs';
type: 'u8';
},
{
name: 'srcLstIndex';
type: 'u32';
},
{
name: 'dstLstIndex';
type: 'u32';
}
];
},
{
name: 'SanctumSAddLiquidity';
fields: [
{
name: 'lstValueCalcAccs';
type: 'u8';
},
{
name: 'lstIndex';
type: 'u32';
}
];
},
{
name: 'SanctumSRemoveLiquidity';
fields: [
{
name: 'lstValueCalcAccs';
type: 'u8';
},
{
name: 'lstIndex';
type: 'u32';
}
];
},
{
name: 'RaydiumCP';
},
{
name: 'WhirlpoolSwapV2';
fields: [
{
name: 'aToB';
type: 'bool';
},
{
name: 'remainingAccountsInfo';
type: {
option: {
defined: 'RemainingAccountsInfo';
};
};
}
];
},
{
name: 'OneIntro';
}
];
};
},
{
name: 'RemainingAccountsSlice';
type: {
kind: 'struct';
fields: [
{
name: 'accountsType';
type: {
defined: 'AccountsType';
};
},
{
name: 'length';
type: 'u8';
}
];
};
},
{
name: 'RemainingAccountsInfo';
type: {
kind: 'struct';
fields: [
{
name: 'slices';
type: {
vec: {
defined: 'RemainingAccountsSlice';
};
};
}
];
};
},
{
name: 'AccountsType';
type: {
kind: 'enum';
variants: [
{
name: 'TransferHookA';
},
{
name: 'TransferHookB';
}
];
};
}

@@ -1330,2 +1600,7 @@ ];

msg: "Exact out amount doesn't match";
},
{
code: 6018;
name: 'SourceAndDestinationMintCannotBeTheSame';
msg: 'Source mint and destination mint cannot the same';
}

@@ -1452,2 +1727,2 @@ ];

export { ALDRIN_SWAP_PROGRAM_ID, ALDRIN_SWAP_V2_PROGRAM_ID, BALANSOL_PROGRAM_ID, BONK_SWAP_PROGRAM_AUTHORITY, BONK_SWAP_PROGRAM_ID, BONK_SWAP_STATE_ID, CREMA_PARTNER_ACCOUNT, CREMA_PROGRAM_ID, CROPPER_PROGRAM_ID, CYKURA_FACTORY_STATE_ADDRESS, CYKURA_PROGRAM_ID, DELTA_FI_PROGRAM_ID, DELTA_FI_USER_ID, DEVNET_SERUM_DEX_PROGRAM, DRADEX_DEX_USER, DRADEX_LOGGER_PROGRAM_ID, DRADEX_MASTER_ID, DRADEX_PROGRAM_ID, ErrorDetails, ExchangeParams, ExecuteParams, Fee, GOOSE_FX_CONTROLLER_ID, GOOSE_FX_PROGRAM_ID, IDL_V6, INDEXED_ROUTE_MAP_URL, INVARIANT_PROGRAM_AUTHORITY_ID, INVARIANT_PROGRAM_ID, INVARIANT_STATE_ID, IndexedRouteMap, Instruction, JUPITER_COMMON_ERRORS, JUPITER_FEE_OWNER, JUPITER_PROGRAM_ID_DEVNET, JUPITER_PROGRAM_ID_STAGING, JUPITER_PROGRAM_V4_ID, JUPITER_PROGRAM_V6_ID, JUPITER_V6_ERRORS, Jupiter, LAMPORTS_PER_SIGNATURE, LIFINITY_PROGRAM_ID, LIFINITY_V2_PROGRAM_ID, MAINNET_SERUM_DEX_PROGRAM, MARCO_POLO_PROGRAM_AUTHORITY, MARCO_POLO_PROGRAM_ID, MARCO_POLO_STATE_ID, MARINADE_PROGRAM_ID, MARKETS_URL, MERCURIAL_SWAP_PROGRAM_ID, METEORA_PROGRAM_ID, METEORA_VAULT_PROGRAM_ID, OPENBOOK_PROGRAM_ID, ORCA_V1_PROGRAM_ID, ORCA_V2_PROGRAM_ID, OnTransaction, Owner, PENGUIN_PROGRAM_ID, PHOENIX_PROGRAM_ID, PlatformFee, PlatformFeeAndAccounts, QuoteMintToReferrer, RAYDIUM_AMM_V4_PROGRAM_ID, RAYDIUM_CLMM_PROGRAM_ID, SABER_ADD_DECIMALS_PROGRAM_ID, SAROS_PROGRAM_ID, SENCHA_PROGRAM_ID, STEPN_PROGRAM_ID, STEP_TOKEN_SWAP_PROGRAM_ID, SYMMETRY_PROGRAM_ID, SetupInstructions, SwapMode, SwapResult, TOKEN_LIST_URL, TokenMintAddress, TransactionBuilder, TransactionFeeInfo, TransactionPayload, WHIRLPOOL_PROGRAM_ID, WRAPPED_SOL_MINT, calculateTransactionDepositAndFee, calculateTransactionDepositAndFeeV2, createAndCloseWSOLAccount, createAssociatedTokenAccountIdempotentInstruction, executeTransaction, extractSOLChangeFromTransaction, extractTokenBalanceChangeFromTransaction, extractTokenBalanceChangesFromEvents, fetchSourceAddressAndDestinationAddress, findAssociatedTokenAddress, findOrCreateAssociatedAccountByMint, getEmptyInstruction, getReferralTokenAccount, getRemoteRouteMap, getSignature, getTokenBalanceChangesFromTransactionResponse, getTransactionBlockhash, getUnixTs, indexedRouteMapToRouteMap, mapCommonErrorToJupiterError, routeMapToIndexedRouteMap, signTransaction, wait };
export { ALDRIN_SWAP_PROGRAM_ID, ALDRIN_SWAP_V2_PROGRAM_ID, BALANSOL_PROGRAM_ID, BONK_SWAP_PROGRAM_AUTHORITY, BONK_SWAP_PROGRAM_ID, BONK_SWAP_STATE_ID, CREMA_PARTNER_ACCOUNT, CREMA_PROGRAM_ID, CROPPER_PROGRAM_ID, CYKURA_FACTORY_STATE_ADDRESS, CYKURA_PROGRAM_ID, DELTA_FI_PROGRAM_ID, DELTA_FI_USER_ID, DEVNET_SERUM_DEX_PROGRAM, DRADEX_DEX_USER, DRADEX_LOGGER_PROGRAM_ID, DRADEX_MASTER_ID, DRADEX_PROGRAM_ID, type ErrorDetails, type ExchangeParams, type ExecuteParams, type Fee, GOOSE_FX_CONTROLLER_ID, GOOSE_FX_PROGRAM_ID, IDL_V6, INDEXED_ROUTE_MAP_URL, INVARIANT_PROGRAM_AUTHORITY_ID, INVARIANT_PROGRAM_ID, INVARIANT_STATE_ID, type IndexedRouteMap, type Instruction, JUPITER_COMMON_ERRORS, JUPITER_FEE_OWNER, JUPITER_PROGRAM_ID_DEVNET, JUPITER_PROGRAM_ID_STAGING, JUPITER_PROGRAM_V4_ID, JUPITER_PROGRAM_V6_ID, JUPITER_V6_ERRORS, type Jupiter, LAMPORTS_PER_SIGNATURE, LIFINITY_PROGRAM_ID, LIFINITY_V2_PROGRAM_ID, MAINNET_SERUM_DEX_PROGRAM, MARCO_POLO_PROGRAM_AUTHORITY, MARCO_POLO_PROGRAM_ID, MARCO_POLO_STATE_ID, MARINADE_PROGRAM_ID, MARKETS_URL, MERCURIAL_SWAP_PROGRAM_ID, METEORA_PROGRAM_ID, METEORA_VAULT_PROGRAM_ID, OPENBOOK_PROGRAM_ID, ORCA_V1_PROGRAM_ID, ORCA_V2_PROGRAM_ID, type OnTransaction, Owner, PENGUIN_PROGRAM_ID, PHOENIX_PROGRAM_ID, type PlatformFee, type PlatformFeeAndAccounts, type QuoteMintToReferrer, RAYDIUM_AMM_V4_PROGRAM_ID, RAYDIUM_CLMM_PROGRAM_ID, SABER_ADD_DECIMALS_PROGRAM_ID, SAROS_PROGRAM_ID, SENCHA_PROGRAM_ID, STEPN_PROGRAM_ID, STEP_TOKEN_SWAP_PROGRAM_ID, SYMMETRY_PROGRAM_ID, type SetupInstructions, SwapMode, type SwapResult, TOKEN_LIST_URL, type TokenMintAddress, TransactionBuilder, type TransactionFeeInfo, type TransactionPayload, WHIRLPOOL_PROGRAM_ID, WRAPPED_SOL_MINT, calculateTransactionDepositAndFee, calculateTransactionDepositAndFeeV2, createAndCloseWSOLAccount, createAssociatedTokenAccountIdempotentInstruction, executeTransaction, extractSOLChangeFromTransaction, extractTokenBalanceChangeFromTransaction, extractTokenBalanceChangesFromEvents, findAssociatedTokenAddress, findOrCreateAssociatedAccountByMint, getEmptyInstruction, getEvents, getReferralTokenAccount, getRemoteRouteMap, getSignature, getTokenBalanceChangesFromTransactionResponse, getTransactionBlockhash, getUnixTs, indexedRouteMapToRouteMap, mapCommonErrorToJupiterError, routeMapToIndexedRouteMap, signTransaction, wait };

@@ -388,2 +388,92 @@ "use strict";Object.defineProperty(exports, "__esModule", {value: true}); function _interopRequireDefault(obj) { return obj && obj.__esModule ? obj : { default: obj }; }// src/utils/executeTransaction.ts

{
name: "exactOutRoute",
accounts: [
{
name: "tokenProgram",
isMut: false,
isSigner: false
},
{
name: "userTransferAuthority",
isMut: false,
isSigner: true
},
{
name: "userSourceTokenAccount",
isMut: false,
isSigner: false
},
{
name: "userDestinationTokenAccount",
isMut: false,
isSigner: false
},
{
name: "destinationTokenAccount",
isMut: false,
isSigner: false,
isOptional: true
},
{
name: "sourceMint",
isMut: false,
isSigner: false
},
{
name: "destinationMint",
isMut: false,
isSigner: false
},
{
name: "platformFeeAccount",
isMut: true,
isSigner: false,
isOptional: true
},
{
name: "token2022Program",
isMut: false,
isSigner: false,
isOptional: true
},
{
name: "eventAuthority",
isMut: false,
isSigner: false
},
{
name: "program",
isMut: false,
isSigner: false
}
],
args: [
{
name: "routePlan",
type: {
vec: {
defined: "RoutePlanStep"
}
}
},
{
name: "outAmount",
type: "u64"
},
{
name: "quotedInAmount",
type: "u64"
},
{
name: "slippageBps",
type: "u16"
},
{
name: "platformFeeBps",
type: "u8"
}
],
returns: "u64"
},
{
name: "sharedAccountsExactOutRoute",

@@ -591,2 +681,29 @@ docs: ["Route by using program owned token accounts and open orders accounts."],

{
name: "claim",
accounts: [
{
name: "wallet",
isMut: true,
isSigner: false
},
{
name: "programAuthority",
isMut: true,
isSigner: false
},
{
name: "systemProgram",
isMut: false,
isSigner: false
}
],
args: [
{
name: "id",
type: "u8"
}
],
returns: "u64"
},
{
name: "claimToken",

@@ -778,3 +895,3 @@ accounts: [

{
name: "a_to_b",
name: "aToB",
type: "bool"

@@ -836,3 +953,3 @@ }

{
name: "a_to_b",
name: "aToB",
type: "bool"

@@ -846,3 +963,3 @@ }

{
name: "x_to_y",
name: "xToY",
type: "bool"

@@ -874,3 +991,3 @@ }

{
name: "x_to_y",
name: "xToY",
type: "bool"

@@ -923,7 +1040,7 @@ }

{
name: "from_token_id",
name: "fromTokenId",
type: "u64"
},
{
name: "to_token_id",
name: "toTokenId",
type: "u64"

@@ -946,3 +1063,3 @@ }

{
name: "bridge_stake_seed",
name: "bridgeStakeSeed",
type: "u32"

@@ -966,5 +1083,163 @@ }

name: "MeteoraDlmm"
},
{
name: "OpenBookV2",
fields: [
{
name: "side",
type: {
defined: "Side"
}
}
]
},
{
name: "RaydiumClmmV2"
},
{
name: "StakeDexPrefundWithdrawStakeAndDepositStake",
fields: [
{
name: "bridgeStakeSeed",
type: "u32"
}
]
},
{
name: "Clone",
fields: [
{
name: "poolIndex",
type: "u8"
},
{
name: "quantityIsInput",
type: "bool"
},
{
name: "quantityIsCollateral",
type: "bool"
}
]
},
{
name: "SanctumS",
fields: [
{
name: "srcLstValueCalcAccs",
type: "u8"
},
{
name: "dstLstValueCalcAccs",
type: "u8"
},
{
name: "srcLstIndex",
type: "u32"
},
{
name: "dstLstIndex",
type: "u32"
}
]
},
{
name: "SanctumSAddLiquidity",
fields: [
{
name: "lstValueCalcAccs",
type: "u8"
},
{
name: "lstIndex",
type: "u32"
}
]
},
{
name: "SanctumSRemoveLiquidity",
fields: [
{
name: "lstValueCalcAccs",
type: "u8"
},
{
name: "lstIndex",
type: "u32"
}
]
},
{
name: "RaydiumCP"
},
{
name: "WhirlpoolSwapV2",
fields: [
{
name: "aToB",
type: "bool"
},
{
name: "remainingAccountsInfo",
type: {
option: {
defined: "RemainingAccountsInfo"
}
}
}
]
},
{
name: "OneIntro"
}
]
}
},
{
name: "RemainingAccountsSlice",
type: {
kind: "struct",
fields: [
{
name: "accountsType",
type: {
defined: "AccountsType"
}
},
{
name: "length",
type: "u8"
}
]
}
},
{
name: "RemainingAccountsInfo",
type: {
kind: "struct",
fields: [
{
name: "slices",
type: {
vec: {
defined: "RemainingAccountsSlice"
}
}
}
]
}
},
{
name: "AccountsType",
type: {
kind: "enum",
variants: [
{
name: "TransferHookA"
},
{
name: "TransferHookB"
}
]
}
}

@@ -1114,2 +1389,7 @@ ],

msg: "Exact out amount doesn't match"
},
{
code: 6018,
name: "SourceAndDestinationMintCannotBeTheSame",
msg: "Source mint and destination mint cannot the same"
}

@@ -1174,2 +1454,3 @@ ]

devnet: "https://jupiter-devnet.zhen8558.workers.dev/markets?v=3",
// 'https://api.jup.ag/api/markets/cache/devnet',
"mainnet-beta": "https://cache.jup.ag/markets?v=3",

@@ -1200,2 +1481,3 @@ testnet: "https://api.jup.ag/api/markets/cache/devnet"

code: 7e3,
// a code that is not in the list of errors
name: "TransactionNotConfirmed",

@@ -1206,2 +1488,3 @@ msg: "Transaction was not confirmed"

code: 7001,
// a code that is not in the list of errors
name: "BalancesNotExtractedProperly",

@@ -1230,3 +1513,8 @@ msg: "Balances cannot be extracted properly"

var _anchor = require('@coral-xyz/anchor');
var program = new (0, _anchor.Program)(IDL_V6, JUPITER_PROGRAM_V6_ID, {});
// src/program.ts
var JUPITER_PROGRAM = new (0, _anchor.Program)(IDL_V6, JUPITER_PROGRAM_V6_ID, {});
// src/utils/getEvents.ts
function getEvents(transactionResponse) {

@@ -1241,5 +1529,4 @@ var _a;

const eventData = _anchor.utils.bytes.base64.encode(ixData.subarray(8));
const event = program.coder.events.decode(eventData);
if (!event)
return;
const event = JUPITER_PROGRAM.coder.events.decode(eventData);
if (!event) return;
events.push(event);

@@ -1254,16 +1541,2 @@ });

var _spltoken = require('@solana/spl-token');
// src/utils/ata.ts
function getAssociatedTokenAddressSync(mint, owner, tokenProgramId = _spltoken.TOKEN_PROGRAM_ID) {
const [ata] = _web3js.PublicKey.findProgramAddressSync(
[owner.toBuffer(), tokenProgramId.toBuffer(), mint.toBuffer()],
_spltoken.ASSOCIATED_TOKEN_PROGRAM_ID
);
return ata;
}
// src/utils/transactionHelpers.ts
function getKeyMap(message, accountKeysFromLookups) {

@@ -1275,19 +1548,16 @@ return message.getAccountKeys({ accountKeysFromLookups }).keySegments().flat().reduce((acc, key, index) => {

}
function diffTokenBalance(accountKeyIndex, meta) {
function diffTokenBalance(meta, owner, mint) {
var _a, _b, _c, _d;
const postBalance = (_b = (_a = meta.postTokenBalances) == null ? void 0 : _a.find(
(postTokenBalance) => postTokenBalance.accountIndex === accountKeyIndex
(postTokenBalance) => postTokenBalance.owner === owner && postTokenBalance.mint === mint
)) == null ? void 0 : _b.uiTokenAmount.amount;
const preBalance = (_d = (_c = meta.preTokenBalances) == null ? void 0 : _c.find((preTokenBalance) => preTokenBalance.accountIndex === accountKeyIndex)) == null ? void 0 : _d.uiTokenAmount.amount;
if (!postBalance)
return;
const preBalance = (_d = (_c = meta.preTokenBalances) == null ? void 0 : _c.find(
(preTokenBalance) => preTokenBalance.owner === owner && preTokenBalance.mint === mint
)) == null ? void 0 : _d.uiTokenAmount.amount;
if (!postBalance) return;
return Math.abs(parseInt(postBalance) - (preBalance !== void 0 ? parseInt(preBalance) : 0));
}
function extractTokenBalanceChangeFromTransaction(meta, keyMap, tokenAccountAddress) {
if (!meta)
return;
const accountKeyIndex = keyMap.get(tokenAccountAddress.toBase58());
if (accountKeyIndex === void 0)
return;
return diffTokenBalance(accountKeyIndex, meta);
function extractTokenBalanceChangeFromTransaction(meta, user, mint) {
if (!meta) return;
return diffTokenBalance(meta, user.toBase58(), mint.toBase58());
}

@@ -1314,24 +1584,7 @@ function extractSOLChangeFromTransaction(meta, keyMap, user) {

}
async function fetchSourceAddressAndDestinationAddress({
inputMint,
outputMint,
connection,
userPublicKey
}) {
const accountInfos = await connection.getMultipleAccountsInfo([inputMint, outputMint]);
const [sourceAddress, destinationAddress] = [inputMint, outputMint].map(
(mint, idx) => {
var _a;
return getAssociatedTokenAddressSync(mint, userPublicKey, ((_a = accountInfos[idx]) == null ? void 0 : _a.owner) || _spltoken.TOKEN_PROGRAM_ID);
}
);
return { sourceAddress, destinationAddress };
}
function getTokenBalanceChangesFromTransactionResponse({
txid,
user,
inputMint,
outputMint,
user,
sourceAddress,
destinationAddress,
transactionResponse,

@@ -1342,6 +1595,8 @@ hasWrappedSOL

let destinationTokenBalanceChange;
let events = [];
let swapEvents = [];
if (transactionResponse && transactionResponse.meta) {
let { meta, transaction } = transactionResponse;
const events = getEvents(transactionResponse);
const swapEvents = events.filter((event) => event.name === "SwapEvent");
events = getEvents(transactionResponse);
swapEvents = events.filter((event) => event.name === "SwapEvent");
[sourceTokenBalanceChange, destinationTokenBalanceChange] = extractTokenBalanceChangesFromEvents(

@@ -1354,4 +1609,4 @@ swapEvents,

const keyMap = getKeyMap(transaction.message, meta.loadedAddresses);
sourceTokenBalanceChange = inputMint.equals(WRAPPED_SOL_MINT) && !hasWrappedSOL ? extractSOLChangeFromTransaction(meta, keyMap, user) : extractTokenBalanceChangeFromTransaction(meta, keyMap, sourceAddress);
destinationTokenBalanceChange = outputMint.equals(WRAPPED_SOL_MINT) && !hasWrappedSOL ? extractSOLChangeFromTransaction(meta, keyMap, user) : extractTokenBalanceChangeFromTransaction(meta, keyMap, destinationAddress);
sourceTokenBalanceChange = inputMint.equals(WRAPPED_SOL_MINT) && !hasWrappedSOL ? extractSOLChangeFromTransaction(meta, keyMap, user) : extractTokenBalanceChangeFromTransaction(meta, user, inputMint);
destinationTokenBalanceChange = outputMint.equals(WRAPPED_SOL_MINT) && !hasWrappedSOL ? extractSOLChangeFromTransaction(meta, keyMap, user) : extractTokenBalanceChangeFromTransaction(meta, user, outputMint);
}

@@ -1370,3 +1625,3 @@ }

function getUnixTs() {
return new Date().getTime();
return (/* @__PURE__ */ new Date()).getTime();
}

@@ -1384,4 +1639,3 @@ function getSignature(transaction) {

} else {
if (!transaction.recentBlockhash)
throw new Error("Missing blockhash");
if (!transaction.recentBlockhash) throw new Error("Missing blockhash");
return transaction.recentBlockhash;

@@ -1430,4 +1684,3 @@ }

} else {
if (!wallet)
throw new Error("Signer wallet not found");
if (!wallet) throw new Error("Signer wallet not found");
swapTransaction = transformIntoJsTransaction(swapTransaction);

@@ -1469,4 +1722,2 @@ swapTransaction = await wallet.signTransaction(swapTransaction);

user: owner.publicKey,
sourceAddress,
destinationAddress,
transactionResponse,

@@ -1515,3 +1766,4 @@ hasWrappedSOL: !wrapUnwrapSOL

// src/utils/Owner.ts
var Owner = class {
var Owner = class _Owner {
constructor(owner) {

@@ -1521,3 +1773,3 @@ this._owner = owner;

get publicKey() {
if (Owner.isKeyPair(this._owner)) {
if (_Owner.isKeyPair(this._owner)) {
return this._owner.publicKey;

@@ -1528,9 +1780,9 @@ }

get signer() {
return Owner.isKeyPair(this._owner) ? this._owner : void 0;
return _Owner.isKeyPair(this._owner) ? this._owner : void 0;
}
get isKeyPair() {
return Owner.isKeyPair(this._owner);
return _Owner.isKeyPair(this._owner);
}
get isPublicKey() {
return Owner.isPublicKey(this._owner);
return _Owner.isPublicKey(this._owner);
}

@@ -1541,3 +1793,3 @@ static isKeyPair(owner) {

static isPublicKey(owner) {
return !Owner.isKeyPair(owner);
return !_Owner.isKeyPair(owner);
}

@@ -1608,2 +1860,6 @@ };

var TransactionBuilder = class {
constructor(connection, feePayer, owner) {

@@ -1684,4 +1940,4 @@ this.connection = connection;

var _spltoken = require('@solana/spl-token');
var _jsbi = require('jsbi'); var _jsbi2 = _interopRequireDefault(_jsbi);

@@ -1712,2 +1968,3 @@ async function createAndCloseWSOLAccount({

result.setupInstructions.push(
// This is not exposed by the types, but indeed it exists
_spltoken.Token.createSyncNativeInstruction(_spltoken.TOKEN_PROGRAM_ID, toAccount)

@@ -1857,9 +2114,6 @@ );

const accountInfo = await connection.getAccountInfo(referralTokenAccountAddress);
if (!accountInfo)
return null;
if (!accountInfo) return null;
const tokenAccount = _optimist.deserializeAccount.call(void 0, accountInfo.data);
if (!tokenAccount)
return null;
if (tokenAccount.isFrozen)
return null;
if (!tokenAccount) return null;
if (tokenAccount.isFrozen) return null;
return referralTokenAccountAddress;

@@ -1954,3 +2208,3 @@ };

exports.ALDRIN_SWAP_PROGRAM_ID = ALDRIN_SWAP_PROGRAM_ID; exports.ALDRIN_SWAP_V2_PROGRAM_ID = ALDRIN_SWAP_V2_PROGRAM_ID; exports.BALANSOL_PROGRAM_ID = BALANSOL_PROGRAM_ID; exports.BONK_SWAP_PROGRAM_AUTHORITY = BONK_SWAP_PROGRAM_AUTHORITY; exports.BONK_SWAP_PROGRAM_ID = BONK_SWAP_PROGRAM_ID; exports.BONK_SWAP_STATE_ID = BONK_SWAP_STATE_ID; exports.CREMA_PARTNER_ACCOUNT = CREMA_PARTNER_ACCOUNT; exports.CREMA_PROGRAM_ID = CREMA_PROGRAM_ID; exports.CROPPER_PROGRAM_ID = CROPPER_PROGRAM_ID; exports.CYKURA_FACTORY_STATE_ADDRESS = CYKURA_FACTORY_STATE_ADDRESS; exports.CYKURA_PROGRAM_ID = CYKURA_PROGRAM_ID; exports.DELTA_FI_PROGRAM_ID = DELTA_FI_PROGRAM_ID; exports.DELTA_FI_USER_ID = DELTA_FI_USER_ID; exports.DEVNET_SERUM_DEX_PROGRAM = DEVNET_SERUM_DEX_PROGRAM; exports.DRADEX_DEX_USER = DRADEX_DEX_USER; exports.DRADEX_LOGGER_PROGRAM_ID = DRADEX_LOGGER_PROGRAM_ID; exports.DRADEX_MASTER_ID = DRADEX_MASTER_ID; exports.DRADEX_PROGRAM_ID = DRADEX_PROGRAM_ID; exports.GOOSE_FX_CONTROLLER_ID = GOOSE_FX_CONTROLLER_ID; exports.GOOSE_FX_PROGRAM_ID = GOOSE_FX_PROGRAM_ID; exports.IDL_V6 = IDL_V6; exports.INDEXED_ROUTE_MAP_URL = INDEXED_ROUTE_MAP_URL; exports.INVARIANT_PROGRAM_AUTHORITY_ID = INVARIANT_PROGRAM_AUTHORITY_ID; exports.INVARIANT_PROGRAM_ID = INVARIANT_PROGRAM_ID; exports.INVARIANT_STATE_ID = INVARIANT_STATE_ID; exports.JUPITER_COMMON_ERRORS = JUPITER_COMMON_ERRORS; exports.JUPITER_FEE_OWNER = JUPITER_FEE_OWNER; exports.JUPITER_PROGRAM_ID_DEVNET = JUPITER_PROGRAM_ID_DEVNET; exports.JUPITER_PROGRAM_ID_STAGING = JUPITER_PROGRAM_ID_STAGING; exports.JUPITER_PROGRAM_V4_ID = JUPITER_PROGRAM_V4_ID; exports.JUPITER_PROGRAM_V6_ID = JUPITER_PROGRAM_V6_ID; exports.JUPITER_V6_ERRORS = JUPITER_V6_ERRORS; exports.LAMPORTS_PER_SIGNATURE = LAMPORTS_PER_SIGNATURE; exports.LIFINITY_PROGRAM_ID = LIFINITY_PROGRAM_ID; exports.LIFINITY_V2_PROGRAM_ID = LIFINITY_V2_PROGRAM_ID; exports.MAINNET_SERUM_DEX_PROGRAM = MAINNET_SERUM_DEX_PROGRAM; exports.MARCO_POLO_PROGRAM_AUTHORITY = MARCO_POLO_PROGRAM_AUTHORITY; exports.MARCO_POLO_PROGRAM_ID = MARCO_POLO_PROGRAM_ID; exports.MARCO_POLO_STATE_ID = MARCO_POLO_STATE_ID; exports.MARINADE_PROGRAM_ID = MARINADE_PROGRAM_ID; exports.MARKETS_URL = MARKETS_URL; exports.MERCURIAL_SWAP_PROGRAM_ID = MERCURIAL_SWAP_PROGRAM_ID; exports.METEORA_PROGRAM_ID = METEORA_PROGRAM_ID; exports.METEORA_VAULT_PROGRAM_ID = METEORA_VAULT_PROGRAM_ID; exports.OPENBOOK_PROGRAM_ID = OPENBOOK_PROGRAM_ID; exports.ORCA_V1_PROGRAM_ID = ORCA_V1_PROGRAM_ID; exports.ORCA_V2_PROGRAM_ID = ORCA_V2_PROGRAM_ID; exports.Owner = Owner; exports.PENGUIN_PROGRAM_ID = PENGUIN_PROGRAM_ID; exports.PHOENIX_PROGRAM_ID = PHOENIX_PROGRAM_ID; exports.RAYDIUM_AMM_V4_PROGRAM_ID = RAYDIUM_AMM_V4_PROGRAM_ID; exports.RAYDIUM_CLMM_PROGRAM_ID = RAYDIUM_CLMM_PROGRAM_ID; exports.SABER_ADD_DECIMALS_PROGRAM_ID = SABER_ADD_DECIMALS_PROGRAM_ID; exports.SAROS_PROGRAM_ID = SAROS_PROGRAM_ID; exports.SENCHA_PROGRAM_ID = SENCHA_PROGRAM_ID; exports.STEPN_PROGRAM_ID = STEPN_PROGRAM_ID; exports.STEP_TOKEN_SWAP_PROGRAM_ID = STEP_TOKEN_SWAP_PROGRAM_ID; exports.SYMMETRY_PROGRAM_ID = SYMMETRY_PROGRAM_ID; exports.SwapMode = SwapMode; exports.TOKEN_LIST_URL = TOKEN_LIST_URL; exports.TransactionBuilder = TransactionBuilder; exports.WHIRLPOOL_PROGRAM_ID = WHIRLPOOL_PROGRAM_ID; exports.WRAPPED_SOL_MINT = WRAPPED_SOL_MINT; exports.calculateTransactionDepositAndFee = calculateTransactionDepositAndFee; exports.calculateTransactionDepositAndFeeV2 = calculateTransactionDepositAndFeeV2; exports.createAndCloseWSOLAccount = createAndCloseWSOLAccount; exports.createAssociatedTokenAccountIdempotentInstruction = createAssociatedTokenAccountIdempotentInstruction; exports.executeTransaction = executeTransaction; exports.extractSOLChangeFromTransaction = extractSOLChangeFromTransaction; exports.extractTokenBalanceChangeFromTransaction = extractTokenBalanceChangeFromTransaction; exports.extractTokenBalanceChangesFromEvents = extractTokenBalanceChangesFromEvents; exports.fetchSourceAddressAndDestinationAddress = fetchSourceAddressAndDestinationAddress; exports.findAssociatedTokenAddress = findAssociatedTokenAddress; exports.findOrCreateAssociatedAccountByMint = findOrCreateAssociatedAccountByMint; exports.getEmptyInstruction = getEmptyInstruction; exports.getReferralTokenAccount = getReferralTokenAccount; exports.getRemoteRouteMap = getRemoteRouteMap; exports.getSignature = getSignature; exports.getTokenBalanceChangesFromTransactionResponse = getTokenBalanceChangesFromTransactionResponse; exports.getTransactionBlockhash = getTransactionBlockhash; exports.getUnixTs = getUnixTs; exports.indexedRouteMapToRouteMap = indexedRouteMapToRouteMap; exports.mapCommonErrorToJupiterError = mapCommonErrorToJupiterError; exports.routeMapToIndexedRouteMap = routeMapToIndexedRouteMap; exports.signTransaction = signTransaction; exports.wait = wait;
exports.ALDRIN_SWAP_PROGRAM_ID = ALDRIN_SWAP_PROGRAM_ID; exports.ALDRIN_SWAP_V2_PROGRAM_ID = ALDRIN_SWAP_V2_PROGRAM_ID; exports.BALANSOL_PROGRAM_ID = BALANSOL_PROGRAM_ID; exports.BONK_SWAP_PROGRAM_AUTHORITY = BONK_SWAP_PROGRAM_AUTHORITY; exports.BONK_SWAP_PROGRAM_ID = BONK_SWAP_PROGRAM_ID; exports.BONK_SWAP_STATE_ID = BONK_SWAP_STATE_ID; exports.CREMA_PARTNER_ACCOUNT = CREMA_PARTNER_ACCOUNT; exports.CREMA_PROGRAM_ID = CREMA_PROGRAM_ID; exports.CROPPER_PROGRAM_ID = CROPPER_PROGRAM_ID; exports.CYKURA_FACTORY_STATE_ADDRESS = CYKURA_FACTORY_STATE_ADDRESS; exports.CYKURA_PROGRAM_ID = CYKURA_PROGRAM_ID; exports.DELTA_FI_PROGRAM_ID = DELTA_FI_PROGRAM_ID; exports.DELTA_FI_USER_ID = DELTA_FI_USER_ID; exports.DEVNET_SERUM_DEX_PROGRAM = DEVNET_SERUM_DEX_PROGRAM; exports.DRADEX_DEX_USER = DRADEX_DEX_USER; exports.DRADEX_LOGGER_PROGRAM_ID = DRADEX_LOGGER_PROGRAM_ID; exports.DRADEX_MASTER_ID = DRADEX_MASTER_ID; exports.DRADEX_PROGRAM_ID = DRADEX_PROGRAM_ID; exports.GOOSE_FX_CONTROLLER_ID = GOOSE_FX_CONTROLLER_ID; exports.GOOSE_FX_PROGRAM_ID = GOOSE_FX_PROGRAM_ID; exports.IDL_V6 = IDL_V6; exports.INDEXED_ROUTE_MAP_URL = INDEXED_ROUTE_MAP_URL; exports.INVARIANT_PROGRAM_AUTHORITY_ID = INVARIANT_PROGRAM_AUTHORITY_ID; exports.INVARIANT_PROGRAM_ID = INVARIANT_PROGRAM_ID; exports.INVARIANT_STATE_ID = INVARIANT_STATE_ID; exports.JUPITER_COMMON_ERRORS = JUPITER_COMMON_ERRORS; exports.JUPITER_FEE_OWNER = JUPITER_FEE_OWNER; exports.JUPITER_PROGRAM_ID_DEVNET = JUPITER_PROGRAM_ID_DEVNET; exports.JUPITER_PROGRAM_ID_STAGING = JUPITER_PROGRAM_ID_STAGING; exports.JUPITER_PROGRAM_V4_ID = JUPITER_PROGRAM_V4_ID; exports.JUPITER_PROGRAM_V6_ID = JUPITER_PROGRAM_V6_ID; exports.JUPITER_V6_ERRORS = JUPITER_V6_ERRORS; exports.LAMPORTS_PER_SIGNATURE = LAMPORTS_PER_SIGNATURE; exports.LIFINITY_PROGRAM_ID = LIFINITY_PROGRAM_ID; exports.LIFINITY_V2_PROGRAM_ID = LIFINITY_V2_PROGRAM_ID; exports.MAINNET_SERUM_DEX_PROGRAM = MAINNET_SERUM_DEX_PROGRAM; exports.MARCO_POLO_PROGRAM_AUTHORITY = MARCO_POLO_PROGRAM_AUTHORITY; exports.MARCO_POLO_PROGRAM_ID = MARCO_POLO_PROGRAM_ID; exports.MARCO_POLO_STATE_ID = MARCO_POLO_STATE_ID; exports.MARINADE_PROGRAM_ID = MARINADE_PROGRAM_ID; exports.MARKETS_URL = MARKETS_URL; exports.MERCURIAL_SWAP_PROGRAM_ID = MERCURIAL_SWAP_PROGRAM_ID; exports.METEORA_PROGRAM_ID = METEORA_PROGRAM_ID; exports.METEORA_VAULT_PROGRAM_ID = METEORA_VAULT_PROGRAM_ID; exports.OPENBOOK_PROGRAM_ID = OPENBOOK_PROGRAM_ID; exports.ORCA_V1_PROGRAM_ID = ORCA_V1_PROGRAM_ID; exports.ORCA_V2_PROGRAM_ID = ORCA_V2_PROGRAM_ID; exports.Owner = Owner; exports.PENGUIN_PROGRAM_ID = PENGUIN_PROGRAM_ID; exports.PHOENIX_PROGRAM_ID = PHOENIX_PROGRAM_ID; exports.RAYDIUM_AMM_V4_PROGRAM_ID = RAYDIUM_AMM_V4_PROGRAM_ID; exports.RAYDIUM_CLMM_PROGRAM_ID = RAYDIUM_CLMM_PROGRAM_ID; exports.SABER_ADD_DECIMALS_PROGRAM_ID = SABER_ADD_DECIMALS_PROGRAM_ID; exports.SAROS_PROGRAM_ID = SAROS_PROGRAM_ID; exports.SENCHA_PROGRAM_ID = SENCHA_PROGRAM_ID; exports.STEPN_PROGRAM_ID = STEPN_PROGRAM_ID; exports.STEP_TOKEN_SWAP_PROGRAM_ID = STEP_TOKEN_SWAP_PROGRAM_ID; exports.SYMMETRY_PROGRAM_ID = SYMMETRY_PROGRAM_ID; exports.SwapMode = SwapMode; exports.TOKEN_LIST_URL = TOKEN_LIST_URL; exports.TransactionBuilder = TransactionBuilder; exports.WHIRLPOOL_PROGRAM_ID = WHIRLPOOL_PROGRAM_ID; exports.WRAPPED_SOL_MINT = WRAPPED_SOL_MINT; exports.calculateTransactionDepositAndFee = calculateTransactionDepositAndFee; exports.calculateTransactionDepositAndFeeV2 = calculateTransactionDepositAndFeeV2; exports.createAndCloseWSOLAccount = createAndCloseWSOLAccount; exports.createAssociatedTokenAccountIdempotentInstruction = createAssociatedTokenAccountIdempotentInstruction; exports.executeTransaction = executeTransaction; exports.extractSOLChangeFromTransaction = extractSOLChangeFromTransaction; exports.extractTokenBalanceChangeFromTransaction = extractTokenBalanceChangeFromTransaction; exports.extractTokenBalanceChangesFromEvents = extractTokenBalanceChangesFromEvents; exports.findAssociatedTokenAddress = findAssociatedTokenAddress; exports.findOrCreateAssociatedAccountByMint = findOrCreateAssociatedAccountByMint; exports.getEmptyInstruction = getEmptyInstruction; exports.getEvents = getEvents; exports.getReferralTokenAccount = getReferralTokenAccount; exports.getRemoteRouteMap = getRemoteRouteMap; exports.getSignature = getSignature; exports.getTokenBalanceChangesFromTransactionResponse = getTokenBalanceChangesFromTransactionResponse; exports.getTransactionBlockhash = getTransactionBlockhash; exports.getUnixTs = getUnixTs; exports.indexedRouteMapToRouteMap = indexedRouteMapToRouteMap; exports.mapCommonErrorToJupiterError = mapCommonErrorToJupiterError; exports.routeMapToIndexedRouteMap = routeMapToIndexedRouteMap; exports.signTransaction = signTransaction; exports.wait = wait;
//# sourceMappingURL=index.js.map

4

package.json
{
"version": "6.0.0-beta.9",
"version": "6.1.0",
"license": "MIT",

@@ -38,3 +38,3 @@ "main": "dist/index.js",

"@types/bs58": "^4.0.1",
"tsup": "~6.4.0",
"tsup": "8.2.4",
"tslib": "^2.3.1"

@@ -41,0 +41,0 @@ },

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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