repo_id
stringclasses 563
values | file_path
stringlengths 40
166
| content
stringlengths 1
2.94M
| __index_level_0__
int64 0
0
|
|---|---|---|---|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions/v2/collect-reward-ix.ts
|
import type { Program } from "@coral-xyz/anchor";
import type { Instruction } from "@orca-so/common-sdk";
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import type { Whirlpool } from "../../artifacts/whirlpool";
import { MEMO_PROGRAM_ADDRESS } from "../..";
import {
RemainingAccountsBuilder,
RemainingAccountsType,
} from "../../utils/remaining-accounts-util";
/**
* Parameters to collect rewards from a reward index in a position.
*
* @category Instruction Types
* @param whirlpool - PublicKey for the whirlpool that the position will be opened for.
* @param position - PublicKey for the position will be opened for.
* @param positionTokenAccount - PublicKey for the position token's associated token address.
* @param positionAuthority - authority that owns the token corresponding to this desired position.
* @param rewardIndex - The reward index that we'd like to initialize. (0 <= index <= NUM_REWARDS).
* @param rewardMint - PublicKey for the reward token mint.
* @param rewardOwnerAccount - PublicKey for the reward token account that the reward will deposit into.
* @param rewardVault - PublicKey of the vault account that reward will be withdrawn from.
* @param rewardTransferHookAccounts - Optional array of token transfer hook accounts for the reward token.
* @param rewardTokenProgram - PublicKey for the token program.
*/
export type CollectRewardV2Params = {
whirlpool: PublicKey;
position: PublicKey;
positionTokenAccount: PublicKey;
positionAuthority: PublicKey;
rewardIndex: number;
rewardMint: PublicKey;
rewardOwnerAccount: PublicKey;
rewardVault: PublicKey;
rewardTransferHookAccounts?: AccountMeta[];
rewardTokenProgram: PublicKey;
};
/**
* Collect rewards accrued for this reward index in a position.
* Call updateFeesAndRewards before this to update the position to the newest accrued values.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - CollectRewardV2Params object
* @returns - Instruction to perform the action.
*/
export function collectRewardV2Ix(
program: Program<Whirlpool>,
params: CollectRewardV2Params,
): Instruction {
const {
whirlpool,
positionAuthority,
position,
positionTokenAccount,
rewardMint,
rewardOwnerAccount,
rewardVault,
rewardTransferHookAccounts,
rewardIndex,
rewardTokenProgram,
} = params;
const [remainingAccountsInfo, remainingAccounts] =
new RemainingAccountsBuilder()
.addSlice(
RemainingAccountsType.TransferHookReward,
rewardTransferHookAccounts,
)
.build();
const ix = program.instruction.collectRewardV2(
rewardIndex,
remainingAccountsInfo,
{
accounts: {
whirlpool,
positionAuthority,
position,
positionTokenAccount,
rewardMint,
rewardOwnerAccount,
rewardVault,
rewardTokenProgram,
memoProgram: MEMO_PROGRAM_ADDRESS,
},
remainingAccounts,
},
);
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions/v2/initialize-config-extension-ix.ts
|
import type { Program } from "@coral-xyz/anchor";
import type { Instruction, PDA } from "@orca-so/common-sdk";
import type { PublicKey } from "@solana/web3.js";
import { SystemProgram } from "@solana/web3.js";
import type { Whirlpool } from "../../artifacts/whirlpool";
/**
* Parameters to initialize a WhirlpoolsConfigExtension account.
*
* @category Instruction Types
* @
*/
export type InitConfigExtensionParams = {
whirlpoolsConfig: PublicKey;
whirlpoolsConfigExtensionPda: PDA;
funder: PublicKey;
feeAuthority: PublicKey;
};
/**
* Initializes a WhirlpoolsConfigExtension account that hosts info & authorities
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - InitConfigExtensionParams object
* @returns - Instruction to perform the action.
*/
export function initializeConfigExtensionIx(
program: Program<Whirlpool>,
params: InitConfigExtensionParams,
): Instruction {
const {
whirlpoolsConfig,
whirlpoolsConfigExtensionPda,
funder,
feeAuthority,
} = params;
const ix = program.instruction.initializeConfigExtension({
accounts: {
config: whirlpoolsConfig,
configExtension: whirlpoolsConfigExtensionPda.publicKey,
funder,
feeAuthority,
systemProgram: SystemProgram.programId,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions/v2/two-hop-swap-ix.ts
|
import type { Program } from "@coral-xyz/anchor";
import type { Instruction } from "@orca-so/common-sdk";
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import type { Whirlpool } from "../../artifacts/whirlpool";
import { MEMO_PROGRAM_ADDRESS } from "../../types/public";
import {
RemainingAccountsBuilder,
RemainingAccountsType,
toSupplementalTickArrayAccountMetas,
} from "../../utils/remaining-accounts-util";
import type { TwoHopSwapInput } from "../two-hop-swap-ix";
/**
* Parameters to execute a two-hop swap on a Whirlpool.
*
* @category Instruction Types
* @param whirlpoolOne - PublicKey for the whirlpool that the swap-one will occur on
* @param whirlpoolTwo - PublicKey for the whirlpool that the swap-two will occur on
* @param tokenMintInput - PublicKey for the input token mint.
* @param tokenMintIntermediate - PublicKey for the intermediate token mint.
* @param tokenMintOutput - PublicKey for the output token mint.
* @param tokenOwnerAccountInput - PublicKey for the input token owner account.
* @param tokenOwnerAccountOutput - PublicKey for the output token owner account.
* @param tokenVaultOneInput - PublicKey for the input token vault of whirlpoolOne.
* @param tokenVaultOneIntermediate - PublicKey for the intermediate token vault of whirlpoolOne.
* @param tokenVaultTwoIntermediate - PublicKey for the intermediate token vault of whirlpoolTwo.
* @param tokenVaultTwoOutput - PublicKey for the output token vault of whirlpoolTwo.
* @param tokenTransferHookAccountsInput - AccountMeta[] for the input token transfer hook accounts.
* @param tokenTransferHookAccountsIntermediate - AccountMeta[] for the intermediate token transfer hook accounts.
* @param tokenTransferHookAccountsOutput - AccountMeta[] for the output token transfer hook accounts.
* @param oracleOne - PublicKey for the oracle account for this whirlpoolOne.
* @param oracleTwo - PublicKey for the oracle account for this whirlpoolTwo.
* @param tokenAuthority - authority to withdraw tokens from the input token account
* @param swapInput - Parameters in {@link TwoHopSwapInput}
*/
export type TwoHopSwapV2Params = TwoHopSwapInput & {
whirlpoolOne: PublicKey;
whirlpoolTwo: PublicKey;
tokenMintInput: PublicKey;
tokenMintIntermediate: PublicKey;
tokenMintOutput: PublicKey;
tokenOwnerAccountInput: PublicKey;
tokenOwnerAccountOutput: PublicKey;
tokenVaultOneInput: PublicKey;
tokenVaultOneIntermediate: PublicKey;
tokenVaultTwoIntermediate: PublicKey;
tokenVaultTwoOutput: PublicKey;
tokenTransferHookAccountsInput?: AccountMeta[];
tokenTransferHookAccountsIntermediate?: AccountMeta[];
tokenTransferHookAccountsOutput?: AccountMeta[];
tokenProgramInput: PublicKey;
tokenProgramIntermediate: PublicKey;
tokenProgramOutput: PublicKey;
oracleOne: PublicKey;
oracleTwo: PublicKey;
tokenAuthority: PublicKey;
};
/**
* Perform a two-hop swap in this Whirlpool
*
* #### Special Errors
* - `ZeroTradableAmount` - User provided parameter `amount` is 0.
* - `InvalidSqrtPriceLimitDirection` - User provided parameter `sqrt_price_limit` does not match the direction of the trade.
* - `SqrtPriceOutOfBounds` - User provided parameter `sqrt_price_limit` is over Whirlppool's max/min bounds for sqrt-price.
* - `InvalidTickArraySequence` - User provided tick-arrays are not in sequential order required to proceed in this trade direction.
* - `TickArraySequenceInvalidIndex` - The swap loop attempted to access an invalid array index during the query of the next initialized tick.
* - `TickArrayIndexOutofBounds` - The swap loop attempted to access an invalid array index during tick crossing.
* - `LiquidityOverflow` - Liquidity value overflowed 128bits during tick crossing.
* - `InvalidTickSpacing` - The swap pool was initialized with tick-spacing of 0.
* - `InvalidIntermediaryMint` - Error if the intermediary mint between hop one and two do not equal.
* - `DuplicateTwoHopPool` - Error if whirlpool one & two are the same pool.
* - `AmountCalcOverflow` - The required token amount exceeds the u64 range.
* - `AmountRemainingOverflow` - Result does not match the specified amount.
* - `DifferentWhirlpoolTickArrayAccount` - The provided tick array account does not belong to the whirlpool.
* - `PartialFillError` - Partially filled when sqrtPriceLimit = 0 and amountSpecifiedIsInput = false.
* - `IntermediateTokenAmountMismatch` - The amount of tokens received from the first hop does not match the amount sent to the second hop.
*
* ### Parameters
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - {@link TwoHopSwapV2Params} object
* @returns - Instruction to perform the action.
*/
export function twoHopSwapV2Ix(
program: Program<Whirlpool>,
params: TwoHopSwapV2Params,
): Instruction {
const {
amount,
otherAmountThreshold,
amountSpecifiedIsInput,
aToBOne,
aToBTwo,
sqrtPriceLimitOne,
sqrtPriceLimitTwo,
whirlpoolOne,
whirlpoolTwo,
tokenMintInput,
tokenMintIntermediate,
tokenMintOutput,
tokenProgramInput,
tokenProgramIntermediate,
tokenProgramOutput,
tokenVaultOneInput,
tokenVaultOneIntermediate,
tokenVaultTwoIntermediate,
tokenVaultTwoOutput,
tokenAuthority,
tokenTransferHookAccountsInput,
tokenTransferHookAccountsIntermediate,
tokenTransferHookAccountsOutput,
tokenOwnerAccountInput,
tokenOwnerAccountOutput,
tickArrayOne0,
tickArrayOne1,
tickArrayOne2,
tickArrayTwo0,
tickArrayTwo1,
tickArrayTwo2,
oracleOne,
oracleTwo,
supplementalTickArraysOne,
supplementalTickArraysTwo,
} = params;
const [remainingAccountsInfo, remainingAccounts] =
new RemainingAccountsBuilder()
.addSlice(
RemainingAccountsType.TransferHookInput,
tokenTransferHookAccountsInput,
)
.addSlice(
RemainingAccountsType.TransferHookIntermediate,
tokenTransferHookAccountsIntermediate,
)
.addSlice(
RemainingAccountsType.TransferHookOutput,
tokenTransferHookAccountsOutput,
)
.addSlice(
RemainingAccountsType.SupplementalTickArraysOne,
toSupplementalTickArrayAccountMetas(supplementalTickArraysOne),
)
.addSlice(
RemainingAccountsType.SupplementalTickArraysTwo,
toSupplementalTickArrayAccountMetas(supplementalTickArraysTwo),
)
.build();
const ix = program.instruction.twoHopSwapV2(
amount,
otherAmountThreshold,
amountSpecifiedIsInput,
aToBOne,
aToBTwo,
sqrtPriceLimitOne,
sqrtPriceLimitTwo,
remainingAccountsInfo,
{
accounts: {
whirlpoolOne,
whirlpoolTwo,
tokenMintInput,
tokenMintIntermediate,
tokenMintOutput,
tokenProgramInput,
tokenProgramIntermediate,
tokenProgramOutput,
tokenOwnerAccountInput,
tokenVaultOneInput,
tokenVaultOneIntermediate,
tokenVaultTwoIntermediate,
tokenVaultTwoOutput,
tokenOwnerAccountOutput,
tokenAuthority,
tickArrayOne0,
tickArrayOne1,
tickArrayOne2,
tickArrayTwo0,
tickArrayTwo1,
tickArrayTwo2,
oracleOne,
oracleTwo,
memoProgram: MEMO_PROGRAM_ADDRESS,
},
remainingAccounts,
},
);
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions/v2/set-token-badge-authority-ix.ts
|
import type { Program } from "@coral-xyz/anchor";
import type { Instruction } from "@orca-so/common-sdk";
import type { PublicKey } from "@solana/web3.js";
import type { Whirlpool } from "../../artifacts/whirlpool";
/**
* Parameters to set the token badge authority in a WhirlpoolsConfigExtension
*
* @category Instruction Types
* @param whirlpoolsConfig - PublicKey for the whirlpools config account
* @param whirlpoolsConfigExtension - The public key for the WhirlpoolsConfigExtension
* @param configExtensionAuthority - The current configExtensionAuthority in the WhirlpoolsConfigExtension
* @param newTokenBadgeAuthority - The new tokenBadgeAuthority in the WhirlpoolsConfigExtension
*/
export type SetTokenBadgeAuthorityParams = {
whirlpoolsConfig: PublicKey;
whirlpoolsConfigExtension: PublicKey;
configExtensionAuthority: PublicKey;
newTokenBadgeAuthority: PublicKey;
};
/**
* Sets the token badge authority for a WhirlpoolsConfigExtension.
* The token badge authority can initialize TokenBadge.
* Only the config extension authority has permission to invoke this instruction.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - SetTokenBadgeAuthorityParams object
* @returns - Instruction to perform the action.
*/
export function setTokenBadgeAuthorityIx(
program: Program<Whirlpool>,
params: SetTokenBadgeAuthorityParams,
): Instruction {
const {
whirlpoolsConfig,
whirlpoolsConfigExtension,
configExtensionAuthority,
newTokenBadgeAuthority,
} = params;
const ix = program.instruction.setTokenBadgeAuthority({
accounts: {
whirlpoolsConfig,
whirlpoolsConfigExtension,
configExtensionAuthority,
newTokenBadgeAuthority,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions/v2/initialize-reward-ix.ts
|
import * as anchor from "@coral-xyz/anchor";
import type { Program } from "@coral-xyz/anchor";
import type { Keypair, PublicKey } from "@solana/web3.js";
import { SystemProgram } from "@solana/web3.js";
import type { Whirlpool } from "../../artifacts/whirlpool";
import type { Instruction } from "@orca-so/common-sdk";
/**
* Parameters to initialize a rewards for a Whirlpool
*
* @category Instruction Types
* @param whirlpool - PublicKey for the whirlpool config space that the fee-tier will be initialized for.
* @param rewardIndex - The reward index that we'd like to initialize. (0 <= index <= NUM_REWARDS).
* @param rewardMint - PublicKey for the reward mint that we'd use for the reward index.
* @param rewardTokenBadge - PublicKey for the TokenBadge for this reward mint.
* @param rewardVaultKeypair - Keypair of the vault for this reward index.
* @param rewardAuthority - Assigned authority by the reward_super_authority for the specified reward-index in this Whirlpool
* @param funder - The account that would fund the creation of this account
* @param rewardTokenProgram - PublicKey for the token program.
*/
export type InitializeRewardV2Params = {
whirlpool: PublicKey;
rewardIndex: number;
rewardMint: PublicKey;
rewardTokenBadge: PublicKey;
rewardVaultKeypair: Keypair;
rewardAuthority: PublicKey;
funder: PublicKey;
rewardTokenProgram: PublicKey;
};
/**
* Initialize reward for a Whirlpool. A pool can only support up to a set number of rewards.
* The initial emissionsPerSecond is set to 0.
*
* #### Special Errors
* - `InvalidRewardIndex` - If the provided reward index doesn't match the lowest uninitialized index in this pool,
* or exceeds NUM_REWARDS, or all reward slots for this pool has been initialized.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - InitializeRewardV2Params object
* @returns - Instruction to perform the action.
*/
export function initializeRewardV2Ix(
program: Program<Whirlpool>,
params: InitializeRewardV2Params,
): Instruction {
const {
rewardAuthority,
funder,
whirlpool,
rewardMint,
rewardTokenBadge,
rewardVaultKeypair,
rewardIndex,
rewardTokenProgram,
} = params;
const ix = program.instruction.initializeRewardV2(rewardIndex, {
accounts: {
rewardAuthority,
funder,
whirlpool,
rewardMint,
rewardTokenBadge,
rewardVault: rewardVaultKeypair.publicKey,
rewardTokenProgram,
systemProgram: SystemProgram.programId,
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [rewardVaultKeypair],
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions/v2/collect-protocol-fees-ix.ts
|
import type { Program } from "@coral-xyz/anchor";
import type { Instruction } from "@orca-so/common-sdk";
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import type { Whirlpool } from "../../artifacts/whirlpool";
import { MEMO_PROGRAM_ADDRESS } from "../..";
import {
RemainingAccountsBuilder,
RemainingAccountsType,
} from "../../utils/remaining-accounts-util";
/**
* Parameters to collect protocol fees for a Whirlpool
*
* @category Instruction Types
* @param whirlpoolsConfig - The public key for the WhirlpoolsConfig this pool is initialized in
* @param whirlpool - PublicKey for the whirlpool that the position will be opened for.
* @param collectProtocolFeesAuthority - assigned authority in the WhirlpoolsConfig that can collect protocol fees
* @param tokenMintA - PublicKey for the token A mint.
* @param tokenMintB - PublicKey for the token B mint.
* @param tokenVaultA - PublicKey for the tokenA vault for this whirlpool.
* @param tokenVaultB - PublicKey for the tokenB vault for this whirlpool.
* @param tokenOwnerAccountA - PublicKey for the associated token account for tokenA in the collection wallet
* @param tokenOwnerAccountB - PublicKey for the associated token account for tokenA in the collection wallet
* @param tokenTransferHookAccountsA - Optional array of token transfer hook accounts for token A.
* @param tokenTransferHookAccountsB - Optional array of token transfer hook accounts for token B.
* @param tokenProgramA - PublicKey for the token program for token A.
* @param tokenProgramB - PublicKey for the token program for token B.
*/
export type CollectProtocolFeesV2Params = {
whirlpoolsConfig: PublicKey;
whirlpool: PublicKey;
collectProtocolFeesAuthority: PublicKey;
tokenMintA: PublicKey;
tokenMintB: PublicKey;
tokenVaultA: PublicKey;
tokenVaultB: PublicKey;
tokenOwnerAccountA: PublicKey;
tokenOwnerAccountB: PublicKey;
tokenTransferHookAccountsA?: AccountMeta[];
tokenTransferHookAccountsB?: AccountMeta[];
tokenProgramA: PublicKey;
tokenProgramB: PublicKey;
};
/**
* Collect protocol fees accrued in this Whirlpool.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - CollectProtocolFeesV2Params object
* @returns - Instruction to perform the action.
*/
export function collectProtocolFeesV2Ix(
program: Program<Whirlpool>,
params: CollectProtocolFeesV2Params,
): Instruction {
const {
whirlpoolsConfig,
whirlpool,
collectProtocolFeesAuthority,
tokenMintA,
tokenMintB,
tokenVaultA,
tokenVaultB,
tokenTransferHookAccountsA,
tokenTransferHookAccountsB,
tokenOwnerAccountA: tokenDestinationA,
tokenOwnerAccountB: tokenDestinationB,
tokenProgramA,
tokenProgramB,
} = params;
const [remainingAccountsInfo, remainingAccounts] =
new RemainingAccountsBuilder()
.addSlice(RemainingAccountsType.TransferHookA, tokenTransferHookAccountsA)
.addSlice(RemainingAccountsType.TransferHookB, tokenTransferHookAccountsB)
.build();
const ix = program.instruction.collectProtocolFeesV2(remainingAccountsInfo, {
accounts: {
whirlpoolsConfig,
whirlpool,
collectProtocolFeesAuthority,
tokenMintA,
tokenMintB,
tokenVaultA,
tokenVaultB,
tokenDestinationA,
tokenDestinationB,
tokenProgramA,
tokenProgramB,
memoProgram: MEMO_PROGRAM_ADDRESS,
},
remainingAccounts,
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions/v2/index.ts
|
export * from "./collect-fees-ix";
export * from "./collect-protocol-fees-ix";
export * from "./collect-reward-ix";
export * from "./decrease-liquidity-ix";
export * from "./increase-liquidity-ix";
export * from "./initialize-pool-ix";
export * from "./initialize-reward-ix";
export * from "./set-reward-emissions-ix";
export * from "./swap-ix";
export * from "./two-hop-swap-ix";
export * from "./initialize-config-extension-ix";
export * from "./set-config-extension-authority-ix";
export * from "./set-token-badge-authority-ix";
export * from "./initialize-token-badge-ix";
export * from "./delete-token-badge-ix";
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions/v2/collect-fees-ix.ts
|
import type { Program } from "@coral-xyz/anchor";
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import type { Whirlpool } from "../../artifacts/whirlpool";
import { MEMO_PROGRAM_ADDRESS } from "../..";
import type { Instruction } from "@orca-so/common-sdk";
import {
RemainingAccountsBuilder,
RemainingAccountsType,
} from "../../utils/remaining-accounts-util";
/**
* Parameters to collect fees from a position.
*
* @category Instruction Types
* @param whirlpool - PublicKey for the whirlpool that the position will be opened for.
* @param position - PublicKey for the position will be opened for.
* @param positionTokenAccount - PublicKey for the position token's associated token address.
* @param positionAuthority - authority that owns the token corresponding to this desired position.
* @param tokenMintA - PublicKey for the token A mint.
* @param tokenMintB - PublicKey for the token B mint.
* @param tokenOwnerAccountA - PublicKey for the token A account that will be withdrawed from.
* @param tokenOwnerAccountB - PublicKey for the token B account that will be withdrawed from.
* @param tokenVaultA - PublicKey for the tokenA vault for this whirlpool.
* @param tokenVaultB - PublicKey for the tokenB vault for this whirlpool.
* @param tokenTransferHookAccountsA - Optional array of token transfer hook accounts for token A.
* @param tokenTransferHookAccountsB - Optional array of token transfer hook accounts for token B.
* @param tokenProgramA - PublicKey for the token program for token A.
* @param tokenProgramB - PublicKey for the token program for token B.
*/
export type CollectFeesV2Params = {
whirlpool: PublicKey;
position: PublicKey;
positionTokenAccount: PublicKey;
positionAuthority: PublicKey;
tokenMintA: PublicKey;
tokenMintB: PublicKey;
tokenOwnerAccountA: PublicKey;
tokenOwnerAccountB: PublicKey;
tokenVaultA: PublicKey;
tokenVaultB: PublicKey;
tokenTransferHookAccountsA?: AccountMeta[];
tokenTransferHookAccountsB?: AccountMeta[];
tokenProgramA: PublicKey;
tokenProgramB: PublicKey;
};
/**
* Collect fees accrued for this position.
* Call updateFeesAndRewards before this to update the position to the newest accrued values.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - CollectFeesV2Params object
* @returns - Instruction to perform the action.
*/
export function collectFeesV2Ix(
program: Program<Whirlpool>,
params: CollectFeesV2Params,
): Instruction {
const {
whirlpool,
positionAuthority,
position,
positionTokenAccount,
tokenMintA,
tokenMintB,
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA,
tokenVaultB,
tokenTransferHookAccountsA,
tokenTransferHookAccountsB,
tokenProgramA,
tokenProgramB,
} = params;
const [remainingAccountsInfo, remainingAccounts] =
new RemainingAccountsBuilder()
.addSlice(RemainingAccountsType.TransferHookA, tokenTransferHookAccountsA)
.addSlice(RemainingAccountsType.TransferHookB, tokenTransferHookAccountsB)
.build();
const ix = program.instruction.collectFeesV2(remainingAccountsInfo, {
accounts: {
whirlpool,
positionAuthority,
position,
positionTokenAccount,
tokenMintA,
tokenMintB,
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA,
tokenVaultB,
tokenProgramA,
tokenProgramB,
memoProgram: MEMO_PROGRAM_ADDRESS,
},
remainingAccounts,
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions/v2/initialize-pool-ix.ts
|
import type { BN, Program } from "@coral-xyz/anchor";
import type { Instruction, PDA } from "@orca-so/common-sdk";
import type { Keypair, PublicKey } from "@solana/web3.js";
import { SystemProgram, SYSVAR_RENT_PUBKEY } from "@solana/web3.js";
import type { Whirlpool } from "../../artifacts/whirlpool";
/**
* Parameters to initialize a Whirlpool account.
*
* @category Instruction Types
* @param initSqrtPrice - The desired initial sqrt-price for this pool
* @param whirlpoolsConfig - The public key for the WhirlpoolsConfig this pool is initialized in
* @param whirlpoolPda - PDA for the whirlpool account that would be initialized
* @param tokenMintA - Mint public key for token A
* @param tokenMintB - Mint public key for token B
* @param tokenBadgeA - TokenBadge public key for token A
* @param tokenBadgeB - TokenBadge public key for token B
* @param tokenProgramA - Token program public key for token A
* @param tokenProgramB - Token program public key for token B
* @param tokenVaultAKeypair - Keypair of the token A vault for this pool
* @param tokenVaultBKeypair - Keypair of the token B vault for this pool
* @param feeTierKey - PublicKey of the fee-tier account that this pool would use for the fee-rate
* @param tickSpacing - The desired tick spacing for this pool.
* @param funder - The account that would fund the creation of this account
*/
export type InitPoolV2Params = {
initSqrtPrice: BN;
whirlpoolsConfig: PublicKey;
whirlpoolPda: PDA;
tokenMintA: PublicKey;
tokenMintB: PublicKey;
tokenBadgeA: PublicKey;
tokenBadgeB: PublicKey;
tokenProgramA: PublicKey;
tokenProgramB: PublicKey;
tokenVaultAKeypair: Keypair;
tokenVaultBKeypair: Keypair;
feeTierKey: PublicKey;
tickSpacing: number;
funder: PublicKey;
};
/**
* Initializes a tick_array account to represent a tick-range in a Whirlpool.
*
* Special Errors
* `InvalidTokenMintOrder` - The order of mints have to be ordered by
* `SqrtPriceOutOfBounds` - provided initial_sqrt_price is not between 2^-64 to 2^64
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - InitPoolV2Params object
* @returns - Instruction to perform the action.
*/
export function initializePoolV2Ix(
program: Program<Whirlpool>,
params: InitPoolV2Params,
): Instruction {
const {
initSqrtPrice,
tokenMintA,
tokenMintB,
tokenBadgeA,
tokenBadgeB,
tokenProgramA,
tokenProgramB,
whirlpoolsConfig,
whirlpoolPda,
feeTierKey,
tokenVaultAKeypair,
tokenVaultBKeypair,
tickSpacing,
funder,
} = params;
const ix = program.instruction.initializePoolV2(tickSpacing, initSqrtPrice, {
accounts: {
whirlpoolsConfig,
tokenMintA,
tokenMintB,
tokenBadgeA,
tokenBadgeB,
funder,
whirlpool: whirlpoolPda.publicKey,
tokenVaultA: tokenVaultAKeypair.publicKey,
tokenVaultB: tokenVaultBKeypair.publicKey,
feeTier: feeTierKey,
systemProgram: SystemProgram.programId,
tokenProgramA,
tokenProgramB,
rent: SYSVAR_RENT_PUBKEY,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [tokenVaultAKeypair, tokenVaultBKeypair],
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions/v2/initialize-token-badge-ix.ts
|
import type { Program } from "@coral-xyz/anchor";
import type { Instruction, PDA } from "@orca-so/common-sdk";
import type { PublicKey } from "@solana/web3.js";
import { SystemProgram } from "@solana/web3.js";
import type { Whirlpool } from "../../artifacts/whirlpool";
/**
* Parameters to initialize a TokenBadge account.
*
* @category Instruction Types
* @param whirlpoolsConfig - The public key for the WhirlpoolsConfig
* @param whirlpoolsConfigExtension - The public key for the WhirlpoolsConfigExtension
* @param tokenBadgeAuthority - The public key for the tokenBadgeAuthority
* @param tokenMint - The public key for the mint for which the TokenBadge is being initialized
* @param tokenBadgePda - The PDA for the TokenBadge account
* @param funder - The account that would fund the creation of this account
*/
export type InitializeTokenBadgeParams = {
whirlpoolsConfig: PublicKey;
whirlpoolsConfigExtension: PublicKey;
tokenBadgeAuthority: PublicKey;
tokenMint: PublicKey;
tokenBadgePda: PDA;
funder: PublicKey;
};
/**
* Initializes a TokenBadge account.
*
* @category Instructions
* @param program - program object containing services required to generate the instruction
* @param params - InitializeTokenBadgeParams object
* @returns - Instruction to perform the action.
*/
export function initializeTokenBadgeIx(
program: Program<Whirlpool>,
params: InitializeTokenBadgeParams,
): Instruction {
const {
whirlpoolsConfig,
whirlpoolsConfigExtension,
tokenBadgeAuthority,
tokenMint,
tokenBadgePda,
funder,
} = params;
const ix = program.instruction.initializeTokenBadge({
accounts: {
whirlpoolsConfig,
whirlpoolsConfigExtension,
tokenBadgeAuthority,
tokenMint,
tokenBadge: tokenBadgePda.publicKey,
funder,
systemProgram: SystemProgram.programId,
},
});
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions/v2/set-reward-emissions-ix.ts
|
import type { BN, Program } from "@coral-xyz/anchor";
import type { Instruction } from "@orca-so/common-sdk";
import type { PublicKey } from "@solana/web3.js";
import type { Whirlpool } from "../../artifacts/whirlpool";
/**
* Parameters to set rewards emissions for a reward in a Whirlpool
*
* @category Instruction Types
* @param whirlpool - PublicKey for the whirlpool which the reward resides in.
* @param rewardIndex - The reward index that we'd like to initialize. (0 <= index <= NUM_REWARDS).
* @param rewardVaultKey - PublicKey of the vault for this reward index.
* @param rewardAuthority - Assigned authority by the reward_super_authority for the specified reward-index in this Whirlpool
* @param emissionsPerSecondX64 - The new emissions per second to set for this reward.
*/
export type SetRewardEmissionsV2Params = {
whirlpool: PublicKey;
rewardIndex: number;
rewardVaultKey: PublicKey;
rewardAuthority: PublicKey;
emissionsPerSecondX64: BN;
};
/**
* Set the reward emissions for a reward in a Whirlpool.
*
* #### Special Errors
* - `RewardVaultAmountInsufficient` - The amount of rewards in the reward vault cannot emit more than a day of desired emissions.
* - `InvalidTimestamp` - Provided timestamp is not in order with the previous timestamp.
* - `InvalidRewardIndex` - If the provided reward index doesn't match the lowest uninitialized index in this pool,
* or exceeds NUM_REWARDS.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - SetRewardEmissionsV2Params object
* @returns - Instruction to perform the action.
*/
export function setRewardEmissionsV2Ix(
program: Program<Whirlpool>,
params: SetRewardEmissionsV2Params,
): Instruction {
const {
rewardAuthority,
whirlpool,
rewardIndex,
rewardVaultKey: rewardVault,
emissionsPerSecondX64,
} = params;
const ix = program.instruction.setRewardEmissionsV2(
rewardIndex,
emissionsPerSecondX64,
{
accounts: {
rewardAuthority,
whirlpool,
rewardVault,
},
},
);
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/instructions/v2/increase-liquidity-ix.ts
|
import type { Program } from "@coral-xyz/anchor";
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import type { Whirlpool } from "../../artifacts/whirlpool";
import type { IncreaseLiquidityInput } from "../..";
import { MEMO_PROGRAM_ADDRESS } from "../..";
import type { Instruction } from "@orca-so/common-sdk";
import {
RemainingAccountsBuilder,
RemainingAccountsType,
} from "../../utils/remaining-accounts-util";
/**
* Parameters to increase liquidity for a position.
*
* @category Instruction Types
* @param liquidityAmount - The total amount of Liquidity the user is willing to deposit.
* @param tokenMaxA - The maximum amount of token A to add to the position.
* @param tokenMaxB - The maximum amount of token B to add to the position.
* @param whirlpool - PublicKey for the whirlpool that the position will be opened for.
* @param position - PublicKey for the position will be opened for.
* @param positionTokenAccount - PublicKey for the position token's associated token address.
* @param positionAuthority - authority that owns the token corresponding to this desired position.
* @param tokenOwnerAccountA - PublicKey for the token A account that will be withdrawed from.
* @param tokenOwnerAccountB - PublicKey for the token B account that will be withdrawed from.
* @param tokenVaultA - PublicKey for the tokenA vault for this whirlpool.
* @param tokenVaultB - PublicKey for the tokenB vault for this whirlpool.
* @param tokenTransferHookAccountsA - Optional array of token transfer hook accounts for token A.
* @param tokenTransferHookAccountsB - Optional array of token transfer hook accounts for token B.
* @param tickArrayLower - PublicKey for the tick-array account that hosts the tick at the lower tick index.
* @param tickArrayUpper - PublicKey for the tick-array account that hosts the tick at the upper tick index.
*/
export type IncreaseLiquidityV2Params = {
whirlpool: PublicKey;
position: PublicKey;
positionTokenAccount: PublicKey;
positionAuthority: PublicKey;
tokenMintA: PublicKey;
tokenMintB: PublicKey;
tokenOwnerAccountA: PublicKey;
tokenOwnerAccountB: PublicKey;
tokenVaultA: PublicKey;
tokenVaultB: PublicKey;
tokenTransferHookAccountsA?: AccountMeta[];
tokenTransferHookAccountsB?: AccountMeta[];
tokenProgramA: PublicKey;
tokenProgramB: PublicKey;
tickArrayLower: PublicKey;
tickArrayUpper: PublicKey;
} & IncreaseLiquidityInput;
/**
* Add liquidity to a position in the Whirlpool.
*
* #### Special Errors
* `LiquidityZero` - Provided liquidity amount is zero.
* `LiquidityTooHigh` - Provided liquidity exceeds u128::max.
* `TokenMaxExceeded` - The required token to perform this operation exceeds the user defined amount.
*
* @category Instructions
* @param context - Context object containing services required to generate the instruction
* @param params - IncreaseLiquidityV2Params object
* @returns - Instruction to perform the action.
*/
export function increaseLiquidityV2Ix(
program: Program<Whirlpool>,
params: IncreaseLiquidityV2Params,
): Instruction {
const {
liquidityAmount,
tokenMaxA,
tokenMaxB,
whirlpool,
positionAuthority,
position,
positionTokenAccount,
tokenMintA,
tokenMintB,
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA,
tokenVaultB,
tokenTransferHookAccountsA,
tokenTransferHookAccountsB,
tokenProgramA,
tokenProgramB,
tickArrayLower,
tickArrayUpper,
} = params;
const [remainingAccountsInfo, remainingAccounts] =
new RemainingAccountsBuilder()
.addSlice(RemainingAccountsType.TransferHookA, tokenTransferHookAccountsA)
.addSlice(RemainingAccountsType.TransferHookB, tokenTransferHookAccountsB)
.build();
const ix = program.instruction.increaseLiquidityV2(
liquidityAmount,
tokenMaxA,
tokenMaxB,
remainingAccountsInfo,
{
accounts: {
whirlpool,
positionAuthority,
position,
positionTokenAccount,
tokenMintA,
tokenMintB,
tokenOwnerAccountA,
tokenOwnerAccountB,
tokenVaultA,
tokenVaultB,
tokenProgramA,
tokenProgramB,
tickArrayLower,
tickArrayUpper,
memoProgram: MEMO_PROGRAM_ADDRESS,
},
remainingAccounts,
},
);
return {
instructions: [ix],
cleanupInstructions: [],
signers: [],
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/prices/calculate-pool-prices.ts
|
import type { Address } from "@coral-xyz/anchor";
import { AddressUtil, DecimalUtil, Percentage } from "@orca-so/common-sdk";
import type { PublicKey } from "@solana/web3.js";
import type BN from "bn.js";
import Decimal from "decimal.js";
import type {
DecimalsMap,
GetPricesConfig,
GetPricesThresholdConfig,
PoolMap,
PriceMap,
TickArrayMap,
} from ".";
import { defaultGetPricesConfig } from ".";
import { swapQuoteWithParams } from "../quotes/public/swap-quote";
import type { TickArray, WhirlpoolData } from "../types/public";
import { PoolUtil, PriceMath, SwapUtils } from "../utils/public";
import { NO_TOKEN_EXTENSION_CONTEXT } from "../utils/public/token-extension-util";
import { getTickArrayPublicKeysWithStartTickIndex } from "../utils/swap-utils";
function checkLiquidity(
pool: WhirlpoolData,
tickArrays: TickArray[],
aToB: boolean,
thresholdConfig: GetPricesThresholdConfig,
decimalsMap: DecimalsMap,
): boolean {
const { amountOut, priceImpactThreshold } = thresholdConfig;
let estimatedAmountIn;
try {
({ estimatedAmountIn } = swapQuoteWithParams(
{
whirlpoolData: pool,
aToB,
amountSpecifiedIsInput: false,
tokenAmount: amountOut,
otherAmountThreshold: SwapUtils.getDefaultOtherAmountThreshold(false),
sqrtPriceLimit: SwapUtils.getDefaultSqrtPriceLimit(aToB),
tickArrays,
// To calculate token price, transfer fee is NOT taken into account.
tokenExtensionCtx: NO_TOKEN_EXTENSION_CONTEXT,
},
Percentage.fromDecimal(new Decimal(0)),
));
} catch {
// If a quote could not be generated, assume there is insufficient liquidity
return false;
}
// Calculate the maximum amount in that is allowed against the desired output
let price, inputDecimals, outputDecimals;
if (aToB) {
price = getPrice(pool, decimalsMap);
inputDecimals = decimalsMap[pool.tokenMintA.toBase58()];
outputDecimals = decimalsMap[pool.tokenMintB.toBase58()];
} else {
price = getPrice(pool, decimalsMap).pow(-1);
inputDecimals = decimalsMap[pool.tokenMintB.toBase58()];
outputDecimals = decimalsMap[pool.tokenMintA.toBase58()];
}
const amountOutDecimals = DecimalUtil.fromBN(amountOut, outputDecimals);
const estimatedAmountInDecimals = DecimalUtil.fromBN(
estimatedAmountIn,
inputDecimals,
);
const maxAmountInDecimals = amountOutDecimals
.div(price)
.mul(priceImpactThreshold)
.toDecimalPlaces(inputDecimals);
return estimatedAmountInDecimals.lte(maxAmountInDecimals);
}
type PoolObject = { pool: WhirlpoolData; address: PublicKey };
function getMostLiquidPools(
quoteTokenMint: PublicKey,
poolMap: PoolMap,
): Record<string, PoolObject> {
const mostLiquidPools = new Map<string, PoolObject>();
Object.entries(poolMap).forEach(([address, pool]) => {
const mintA = pool.tokenMintA.toBase58();
const mintB = pool.tokenMintB.toBase58();
if (pool.liquidity.isZero()) {
return;
}
if (
!pool.tokenMintA.equals(quoteTokenMint) &&
!pool.tokenMintB.equals(quoteTokenMint)
) {
return;
}
const baseTokenMint = pool.tokenMintA.equals(quoteTokenMint)
? mintB
: mintA;
const existingPool = mostLiquidPools.get(baseTokenMint);
if (!existingPool || pool.liquidity.gt(existingPool.pool.liquidity)) {
mostLiquidPools.set(baseTokenMint, {
address: AddressUtil.toPubKey(address),
pool,
});
}
});
return Object.fromEntries(mostLiquidPools);
}
export function calculatePricesForQuoteToken(
mints: Address[],
quoteTokenMint: PublicKey,
poolMap: PoolMap,
tickArrayMap: TickArrayMap,
decimalsMap: DecimalsMap,
config: GetPricesConfig,
thresholdConfig: GetPricesThresholdConfig,
): PriceMap {
const mostLiquidPools = getMostLiquidPools(quoteTokenMint, poolMap);
return Object.fromEntries(
mints.map((mintAddr) => {
const mint = AddressUtil.toPubKey(mintAddr);
if (mint.equals(quoteTokenMint)) {
return [mint.toBase58(), new Decimal(1)];
}
const [mintA, mintB] = PoolUtil.orderMints(mint, quoteTokenMint);
// The quote token is the output token.
// Therefore, if the quote token is mintB, then we are swapping from mintA to mintB.
const aToB = AddressUtil.toPubKey(mintB).equals(quoteTokenMint);
const baseTokenMint = aToB ? mintA : mintB;
const poolCandidate =
mostLiquidPools[AddressUtil.toString(baseTokenMint)];
if (poolCandidate === undefined) {
return [mint.toBase58(), null];
}
const { pool, address } = poolCandidate;
const tickArrays = getTickArrays(
pool,
address,
aToB,
tickArrayMap,
config,
);
const isPoolLiquid = checkLiquidity(
pool,
tickArrays,
aToB,
thresholdConfig,
decimalsMap,
);
if (!isPoolLiquid) {
return [mint.toBase58(), null];
}
const price = getPrice(pool, decimalsMap);
const quotePrice = aToB ? price : price.pow(-1);
return [mint.toBase58(), quotePrice];
}),
);
}
function getTickArrays(
pool: WhirlpoolData,
address: PublicKey,
aToB: boolean,
tickArrayMap: TickArrayMap,
config = defaultGetPricesConfig,
): TickArray[] {
const { programId } = config;
const tickArrayAddresses = getTickArrayPublicKeysWithStartTickIndex(
pool.tickCurrentIndex,
pool.tickSpacing,
aToB,
programId,
address,
);
return tickArrayAddresses.map((a) => {
return {
address: a.pubkey,
startTickIndex: a.startTickIndex,
data: tickArrayMap[a.pubkey.toBase58()],
};
});
}
function getPrice(pool: WhirlpoolData, decimalsMap: DecimalsMap) {
const tokenAAddress = pool.tokenMintA.toBase58();
const tokenBAddress = pool.tokenMintB.toBase58();
if (!(tokenAAddress in decimalsMap) || !(tokenBAddress in decimalsMap)) {
throw new Error("Missing token decimals");
}
return PriceMath.sqrtPriceX64ToPrice(
pool.sqrtPrice,
decimalsMap[tokenAAddress],
decimalsMap[tokenBAddress],
);
}
export function isSubset(listA: string[], listB: string[]): boolean {
return listA.every((itemA) => listB.includes(itemA));
}
export function convertAmount(
amount: BN,
price: Decimal,
amountDecimal: number,
resultDecimal: number,
): BN {
return DecimalUtil.toBN(
DecimalUtil.fromBN(amount, amountDecimal).div(price),
resultDecimal,
);
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/prices/price-module.ts
|
import type { Address } from "@coral-xyz/anchor";
import { AddressUtil } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import type {
DecimalsMap,
PoolMap,
PriceCalculationData,
PriceMap,
TickArrayMap,
} from ".";
import { defaultGetPricesConfig, defaultGetPricesThresholdConfig } from ".";
import type {
WhirlpoolAccountFetchOptions,
WhirlpoolAccountFetcherInterface,
} from "../network/public/fetcher";
import { IGNORE_CACHE, PREFER_CACHE } from "../network/public/fetcher";
import { PDAUtil, PoolUtil, SwapUtils } from "../utils/public";
import { convertListToMap, filterNullObjects } from "../utils/txn-utils";
import {
calculatePricesForQuoteToken,
convertAmount,
isSubset,
} from "./calculate-pool-prices";
/**
* PriceModule is a static class that provides functions for fetching and calculating
* token prices for a set of pools or mints.
*
* @category PriceModule
*
* @deprecated PriceModule will be removed in the future release. Please use endpoint which provides prices.
*/
export class PriceModule {
/**
* Fetches and calculates the prices for a set of tokens.
* This method will derive the pools that need to be queried from the mints and is not performant.
*
* @param fetcher {@link WhirlpoolAccountFetcherInterface}
* @param mints The mints to fetch prices for.
* @param config The configuration for the price calculation.
* @param thresholdConfig - The threshold configuration for the price calculation.
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @param availableData - Data that is already available to avoid redundant fetches.
* @returns A map of token addresses to prices.
*
* @deprecated PriceModule will be removed in the future release. Please use endpoint which provides prices.
*/
static async fetchTokenPricesByMints(
fetcher: WhirlpoolAccountFetcherInterface,
mints: Address[],
config = defaultGetPricesConfig,
thresholdConfig = defaultGetPricesThresholdConfig,
opts = IGNORE_CACHE,
availableData: Partial<PriceCalculationData> = {},
): Promise<PriceMap> {
const poolMap = availableData?.poolMap
? availableData?.poolMap
: await PriceModuleUtils.fetchPoolDataFromMints(
fetcher,
mints,
config,
opts,
);
const tickArrayMap = availableData?.tickArrayMap
? availableData.tickArrayMap
: await PriceModuleUtils.fetchTickArraysForPools(
fetcher,
poolMap,
config,
opts,
);
const decimalsMap = availableData?.decimalsMap
? availableData.decimalsMap
: await PriceModuleUtils.fetchDecimalsForMints(
fetcher,
mints,
PREFER_CACHE,
);
return PriceModule.calculateTokenPrices(
mints,
{
poolMap,
tickArrayMap,
decimalsMap,
},
config,
thresholdConfig,
);
}
/**
* Fetches and calculates the token prices from a set of pools.
*
* @param fetcher {@link WhirlpoolAccountFetcherInterface}
* @param pools The pools to fetch prices for.
* @param config The configuration for the price calculation.
* @param thresholdConfig The threshold configuration for the price calculation.
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @returns A map of token addresses to prices
*
* @deprecated PriceModule will be removed in the future release. Please use endpoint which provides prices.
*/
static async fetchTokenPricesByPools(
fetcher: WhirlpoolAccountFetcherInterface,
pools: Address[],
config = defaultGetPricesConfig,
thresholdConfig = defaultGetPricesThresholdConfig,
opts: WhirlpoolAccountFetchOptions = IGNORE_CACHE,
): Promise<PriceMap> {
const poolDatas = Array.from(
(await fetcher.getPools(pools, opts)).values(),
);
const [filteredPoolDatas, filteredPoolAddresses] = filterNullObjects(
poolDatas,
pools,
);
const poolMap = convertListToMap(
filteredPoolDatas,
AddressUtil.toStrings(filteredPoolAddresses),
);
const tickArrayMap = await PriceModuleUtils.fetchTickArraysForPools(
fetcher,
poolMap,
config,
opts,
);
const mints = Array.from(
Object.values(poolMap).reduce((acc, pool) => {
acc.add(pool.tokenMintA.toBase58());
acc.add(pool.tokenMintB.toBase58());
return acc;
}, new Set<string>()),
);
const decimalsMap = await PriceModuleUtils.fetchDecimalsForMints(
fetcher,
mints,
PREFER_CACHE,
);
return PriceModule.calculateTokenPrices(
mints,
{
poolMap,
tickArrayMap,
decimalsMap,
},
config,
thresholdConfig,
);
}
/**
* Calculate the price of each token in the mints array.
*
* Each token will be priced against the first quote token in the config.quoteTokens array
* with sufficient liquidity. If a token does not have sufficient liquidity against the
* first quote token, then it will be priced against the next quote token in the array.
* If a token does not have sufficient liquidity against any quote token,
* then the price will be set to null.
*
* @category PriceModule
* @param mints The mints to calculate prices for.
* @param priceCalcData The data required to calculate prices.
* @param config The configuration for the price calculation.
* @param thresholdConfig The threshold configuration for the price calculation.
* @returns A map of token addresses to prices.
*
* @deprecated PriceModule will be removed in the future release. Please use endpoint which provides prices.
*/
static calculateTokenPrices(
mints: Address[],
priceCalcData: PriceCalculationData,
config = defaultGetPricesConfig,
thresholdConfig = defaultGetPricesThresholdConfig,
): PriceMap {
const { poolMap, decimalsMap, tickArrayMap } = priceCalcData;
const mintStrings = AddressUtil.toStrings(mints);
// Ensure that quote tokens are in the mints array
if (
!isSubset(
config.quoteTokens.map((mint) => AddressUtil.toString(mint)),
mintStrings.map((mint) => mint),
)
) {
throw new Error("Quote tokens must be in mints array");
}
const results: PriceMap = Object.fromEntries(
mintStrings.map((mint) => [mint, null]),
);
const remainingQuoteTokens = config.quoteTokens.slice();
let remainingMints = mints.slice();
while (remainingQuoteTokens.length > 0 && remainingMints.length > 0) {
// Get prices for mints using the next token in remainingQuoteTokens as the quote token
const quoteToken = remainingQuoteTokens.shift();
if (!quoteToken) {
throw new Error("Unreachable: remainingQuoteTokens is an empty array");
}
// Convert the threshold amount out from the first quote token to the current quote token
let amountOutThresholdAgainstFirstQuoteToken;
// If the quote token is the first quote token, then the amount out is the threshold amount
if (quoteToken.equals(config.quoteTokens[0])) {
amountOutThresholdAgainstFirstQuoteToken = thresholdConfig.amountOut;
} else {
const quoteTokenStr = quoteToken.toBase58();
const quoteTokenPrice = results[quoteTokenStr];
if (!quoteTokenPrice) {
throw new Error(
`Quote token - ${quoteTokenStr} must have a price against the first quote token`,
);
}
amountOutThresholdAgainstFirstQuoteToken = convertAmount(
thresholdConfig.amountOut,
quoteTokenPrice,
decimalsMap[config.quoteTokens[0].toBase58()],
decimalsMap[quoteTokenStr],
);
}
const prices = calculatePricesForQuoteToken(
remainingMints,
quoteToken,
poolMap,
tickArrayMap,
decimalsMap,
config,
{
amountOut: amountOutThresholdAgainstFirstQuoteToken,
priceImpactThreshold: thresholdConfig.priceImpactThreshold,
},
);
const quoteTokenPrice =
results[quoteToken.toBase58()] || prices[quoteToken.toBase58()];
// Populate the results map with the calculated prices.
// Ensure that the price is quoted against the first quote token and not the current quote token.
remainingMints.forEach((mintAddr) => {
const mint = AddressUtil.toString(mintAddr);
const mintPrice = prices[mint];
if (mintPrice != null && quoteTokenPrice != null) {
results[mint] = mintPrice.mul(quoteTokenPrice);
}
});
// Filter out any mints that do not have a price
remainingMints = remainingMints.filter(
(mint) => results[AddressUtil.toString(mint)] == null,
);
}
return results;
}
}
/**
* A list of utility functions for the price module.
* @category PriceModule
*
* @deprecated PriceModule will be removed in the future release. Please use endpoint which provides prices.
*/
export class PriceModuleUtils {
/**
* Fetch pool data for the given mints by deriving the PDA from all combinations of mints & tick-arrays.
* Note that this method can be slow.
*
* @param fetcher {@link WhirlpoolAccountFetcherInterface}
* @param mints The mints to fetch pool data for.
* @param config The configuration for the price calculation.
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @returns A {@link PoolMap} of pool addresses to pool data.
*
* @deprecated PriceModule will be removed in the future release. Please use endpoint which provides prices.
*/
static async fetchPoolDataFromMints(
fetcher: WhirlpoolAccountFetcherInterface,
mints: Address[],
config = defaultGetPricesConfig,
opts = IGNORE_CACHE,
): Promise<PoolMap> {
const { quoteTokens, tickSpacings, programId, whirlpoolsConfig } = config;
const poolAddresses: string[] = mints
.map((mint): string[] =>
tickSpacings
.map((tickSpacing): string[] => {
return quoteTokens.map((quoteToken): string => {
const [mintA, mintB] = PoolUtil.orderMints(mint, quoteToken);
return PDAUtil.getWhirlpool(
programId,
whirlpoolsConfig,
AddressUtil.toPubKey(mintA),
AddressUtil.toPubKey(mintB),
tickSpacing,
).publicKey.toBase58();
});
})
.flat(),
)
.flat();
const poolDatas = Array.from(
(await fetcher.getPools(poolAddresses, opts)).values(),
);
const [filteredPoolDatas, filteredPoolAddresses] = filterNullObjects(
poolDatas,
poolAddresses,
);
return convertListToMap(filteredPoolDatas, filteredPoolAddresses);
}
/**
* Fetch tick-array data for the given pools
*
* @param fetcher {@link WhirlpoolAccountFetcherInterface}
* @param pools The pools to fetch tick-array data for.
* @param config The configuration for the price calculation.
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @returns A {@link TickArrayMap} of tick-array addresses to tick-array data.
*
* @deprecated PriceModule will be removed in the future release. Please use endpoint which provides prices.
*/
static async fetchTickArraysForPools(
fetcher: WhirlpoolAccountFetcherInterface,
pools: PoolMap,
config = defaultGetPricesConfig,
opts: WhirlpoolAccountFetchOptions = IGNORE_CACHE,
): Promise<TickArrayMap> {
const { programId } = config;
const getQuoteTokenOrder = (mint: PublicKey) => {
const index = config.quoteTokens.findIndex((quoteToken) =>
quoteToken.equals(mint),
);
return index === -1 ? config.quoteTokens.length : index;
};
// select tick arrays based on the direction of swapQuote
// TickArray is a large account, which affects decoding time.
// Fetching can be performed in parallel, but it is preferable to fetch the minimum number of accounts necessary.
const tickArrayAddressSet = new Set<string>();
Object.entries(pools).forEach(([address, pool]) => {
const orderA = getQuoteTokenOrder(pool.tokenMintA);
const orderB = getQuoteTokenOrder(pool.tokenMintB);
if (orderA === orderB) {
// neither tokenMintA nor tokenMintB is a quote token
return;
}
const aToB = orderA > orderB;
const tickArrayPubkeys = SwapUtils.getTickArrayPublicKeys(
pool.tickCurrentIndex,
pool.tickSpacing,
aToB,
programId,
new PublicKey(address),
);
tickArrayPubkeys.forEach((p) => tickArrayAddressSet.add(p.toBase58()));
});
const tickArrayAddresses = Array.from(tickArrayAddressSet);
const tickArrays = await fetcher.getTickArrays(tickArrayAddresses, opts);
const [filteredTickArrays, filteredTickArrayAddresses] = filterNullObjects(
tickArrays,
tickArrayAddresses,
);
return convertListToMap(filteredTickArrays, filteredTickArrayAddresses);
}
/**
* Fetch the decimals to token mapping for the given mints.
* @param fetcher {@link WhirlpoolAccountFetcherInterface}
* @param mints The mints to fetch decimals for.
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @returns A {@link DecimalsMap} of mint addresses to decimals.
*
* @deprecated PriceModule will be removed in the future release. Please use endpoint which provides prices.
*/
static async fetchDecimalsForMints(
fetcher: WhirlpoolAccountFetcherInterface,
mints: Address[],
opts = IGNORE_CACHE,
): Promise<DecimalsMap> {
const mintInfos = Array.from(
(await fetcher.getMintInfos(mints, opts)).values(),
);
return mintInfos.reduce((acc, mintInfo, index) => {
const mint = AddressUtil.toString(mints[index]);
if (!mintInfo) {
throw new Error(`Mint account does not exist: ${mint}`);
}
acc[mint] = mintInfo.decimals;
return acc;
}, {} as DecimalsMap);
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/prices/index.ts
|
import { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import type Decimal from "decimal.js";
import type { TickArrayData, WhirlpoolData } from "../types/public";
import {
ORCA_SUPPORTED_TICK_SPACINGS,
ORCA_WHIRLPOOLS_CONFIG,
ORCA_WHIRLPOOL_PROGRAM_ID,
} from "../types/public";
import { TOKEN_MINTS } from "../utils/constants";
export * from "./price-module";
/**
* A config object for the {@link PriceModule} functions.
*
* @category PriceModule
* @param quoteTokens The group of quote tokens that you want to search Whirlpools for.
* The first token must be the token that is being priced against the other tokens.
* The subsequent tokens are alternative tokens that can be used to price the first token.
* @param tickSpacings The group of tick spacings that you want to search Whirlpools for.
* @param programId The public key of the Whirlpool Program account that you want to search Whirlpools for.
* @param whirlpoolsConfig The public key of the {@link WhirlpoolsConfig} account that you want to search Whirlpools for.
*/
export type GetPricesConfig = {
quoteTokens: PublicKey[];
tickSpacings: number[];
programId: PublicKey;
whirlpoolsConfig: PublicKey;
};
/**
* A config object for the {@link PriceModule} functions to define thresholds for price calculations.
* Whirlpools that do not fit the criteria set by the parameters below will be excluded in the price calculation.
*
* @category PriceModule
* @param amountOut The token amount in terms of the first quote token amount to evaluate a Whirlpool's liquidity against.
* @param priceImpactThreshold Using amountOut to perform a swap quote on a pool, this value is the maximum price impact
* that a Whirlpool can have to be included in the price calculation.
*/
export type GetPricesThresholdConfig = {
amountOut: BN;
priceImpactThreshold: number;
};
/**
* A set of fetched accounts that are used for price calculations in {@link PriceModule} functions.
*
* @category PriceModule
* @param poolMap A map of {@link WhirlpoolData} accounts that are used for price calculations.
* @param tickArrayMap A map of {@link TickArrayData} accounts that are used for price calculations.
* @param decimalsMap A map of token decimals that are used for price calculations.
*/
export type PriceCalculationData = {
poolMap: PoolMap;
tickArrayMap: TickArrayMap;
decimalsMap: DecimalsMap;
};
/**
* A map of whirlpool addresses against {@link WhirlpoolData} accounts
* @category PriceModule
*/
export type PoolMap = Record<string, WhirlpoolData>;
/**
* A map of tick-array addresses against {@link TickArrayData} accounts
* @category PriceModule
*/
export type TickArrayMap = Record<string, TickArrayData>;
/**
* A map of token mint addresses against price values. If a price is not available, the value will be null.
* @category PriceModule
*/
export type PriceMap = Record<string, Decimal | null>;
/**
* A map of token mint addresses against token decimals.
* @category PriceModule
*/
export type DecimalsMap = Record<string, number>;
/**
* The default quote tokens used for Orca's mainnet deployment.
* Supply your own if you are using a different deployment.
* @category PriceModule
*/
export const defaultQuoteTokens: PublicKey[] = [
TOKEN_MINTS["USDC"],
TOKEN_MINTS["SOL"],
TOKEN_MINTS["mSOL"],
TOKEN_MINTS["stSOL"],
].map((mint) => new PublicKey(mint));
/**
* The default {@link GetPricesConfig} config for Orca's mainnet deployment.
* @category PriceModule
*/
export const defaultGetPricesConfig: GetPricesConfig = {
quoteTokens: defaultQuoteTokens,
tickSpacings: ORCA_SUPPORTED_TICK_SPACINGS,
programId: ORCA_WHIRLPOOL_PROGRAM_ID,
whirlpoolsConfig: ORCA_WHIRLPOOLS_CONFIG,
};
/**
* The default {@link GetPricesThresholdConfig} config for Orca's mainnet deployment.
* @category PriceModule
*/
export const defaultGetPricesThresholdConfig: GetPricesThresholdConfig = {
amountOut: new BN(1_000_000_000),
priceImpactThreshold: 1.05,
};
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/types
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/types/public/client-types.ts
|
import type { PublicKey } from "@solana/web3.js";
import type BN from "bn.js";
import type { TickArrayData, WhirlpoolRewardInfoData } from "./anchor-types";
import type {
AccountWithTokenProgram,
MintWithTokenProgram,
} from "@orca-so/common-sdk";
/**
* Extended Mint type to host token info.
* @category WhirlpoolClient
*/
export type TokenInfo = MintWithTokenProgram & { mint: PublicKey };
/**
* Extended (token) Account type to host account info for a Token.
* @category WhirlpoolClient
*/
export type TokenAccountInfo = AccountWithTokenProgram;
/**
* Type to represent a reward for a reward index on a Whirlpool.
* @category WhirlpoolClient
*/
export type WhirlpoolRewardInfo = WhirlpoolRewardInfoData & {
initialized: boolean;
vaultAmount: BN;
};
/**
* A wrapper class of a TickArray on a Whirlpool
* @category WhirlpoolClient
*/
export type TickArray = {
address: PublicKey;
startTickIndex: number;
data: TickArrayData | null;
};
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/types
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/types/public/constants.ts
|
import { BN } from "@coral-xyz/anchor";
import { PublicKey } from "@solana/web3.js";
/**
* Program ID hosting Orca's Whirlpool program.
* @category Constants
*/
export const ORCA_WHIRLPOOL_PROGRAM_ID = new PublicKey(
"whirLbMiicVdio4qvUfM5KAg6Ct8VwpYzGff3uctyCc",
);
/**
* Orca's WhirlpoolsConfig PublicKey.
* @category Constants
*/
export const ORCA_WHIRLPOOLS_CONFIG = new PublicKey(
"2LecshUwdy9xi7meFgHtFJQNSKk4KdTrcpvaB56dP2NQ",
);
/**
* Orca's WhirlpoolsConfig PublicKey for Eclipse
* @category Constants
*/
export const ORCA_WHIRLPOOLS_CONFIG_ECLIPSE = new PublicKey(
"FVG4oDbGv16hqTUbovjyGmtYikn6UBEnazz6RVDMEFwv",
);
/**
* Orca's WhirlpoolsConfig PublicKey.
* @category Constants
*/
export const ORCA_WHIRLPOOLS_CONFIG_EXTENSION = new PublicKey(
"777H5H3Tp9U11uRVRzFwM8BinfiakbaLT8vQpeuhvEiH",
);
/**
* Orca's supported tick spacings.
* @category Constants
*/
export const ORCA_SUPPORTED_TICK_SPACINGS = [
1, 2, 4, 8, 16, 64, 96, 128, 256, 32896,
];
/**
* The number of rewards supported by this whirlpool.
* @category Constants
*/
export const NUM_REWARDS = 3;
/**
* The maximum tick index supported by the Whirlpool program.
* @category Constants
*/
export const MAX_TICK_INDEX = 443636;
/**
* The minimum tick index supported by the Whirlpool program.
* @category Constants
*/
export const MIN_TICK_INDEX = -443636;
/**
* The maximum sqrt-price supported by the Whirlpool program.
* @category Constants
*/
export const MAX_SQRT_PRICE = "79226673515401279992447579055";
/**
* The minimum sqrt-price supported by the Whirlpool program.
* @category Constants
*/
export const MIN_SQRT_PRICE = "4295048016";
/**
* The minimum sqrt-price supported by the Whirlpool program.
* @category Constants
*/
export const MIN_SQRT_PRICE_BN = new BN(MIN_SQRT_PRICE);
/**
* The maximum sqrt-price supported by the Whirlpool program.
* @category Constants
*/
export const MAX_SQRT_PRICE_BN = new BN(MAX_SQRT_PRICE);
/**
* The number of initialized ticks that a tick-array account can hold.
* @category Constants
*/
export const TICK_ARRAY_SIZE = 88;
/**
* The number of bundled positions that a position-bundle account can hold.
* @category Constants
*/
export const POSITION_BUNDLE_SIZE = 256;
/**
* @category Constants
*/
export const METADATA_PROGRAM_ADDRESS = new PublicKey(
"metaqbxxUerdq28cj1RbAWkYQm3ybzjb6a8bt518x1s",
);
/**
* @category Constants
*/
export const MEMO_PROGRAM_ADDRESS = new PublicKey(
"MemoSq4gqABAXKb96qnH8TysNcWxMyWCqXgDLGmfcHr",
);
/**
* The maximum number of tick-arrays that can traversed across in a swap.
* @category Constants
*/
export const MAX_SWAP_TICK_ARRAYS = 3;
/**
* The maximum number of supplemental tick-arrays that can be provided in a swap.
* @category Constants
*/
export const MAX_SUPPLEMENTAL_TICK_ARRAYS = 3;
/**
* The denominator which the protocol fee rate is divided on.
* @category Constants
*/
export const PROTOCOL_FEE_RATE_MUL_VALUE = new BN(10_000);
/**
* The denominator which the fee rate is divided on.
* @category Constants
*/
export const FEE_RATE_MUL_VALUE = new BN(1_000_000);
/**
* The public key that is allowed to update the metadata of Whirlpool NFTs.
* @category Constants
*/
export const WHIRLPOOL_NFT_UPDATE_AUTH = new PublicKey(
"3axbTs2z5GBy6usVbNVoqEgZMng3vZvMnAoX29BFfwhr",
);
/**
* The tick spacing (inclusive) at which a whirlpool only supports full-range positions.
* @category Constants
*/
export const FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD = 32768;
/**
* The tick spacing for splash pools.
* @category Constants
*/
export const SPLASH_POOL_TICK_SPACING = 32896;
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/types
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/types/public/ix-types.ts
|
export type {
ClosePositionParams,
CollectFeesParams,
CollectProtocolFeesParams,
CollectRewardParams,
DecreaseLiquidityInput,
DecreaseLiquidityParams,
DevFeeSwapInput,
IncreaseLiquidityInput,
IncreaseLiquidityParams,
InitConfigParams,
InitFeeTierParams,
InitializeRewardParams,
InitPoolParams,
InitTickArrayParams,
OpenPositionParams,
SetCollectProtocolFeesAuthorityParams,
SetDefaultFeeRateParams,
SetDefaultProtocolFeeRateParams,
SetFeeAuthorityParams,
SetFeeRateParams,
SetProtocolFeeRateParams,
SetRewardAuthorityBySuperAuthorityParams,
SetRewardAuthorityParams,
SetRewardEmissionsParams,
SetRewardEmissionsSuperAuthorityParams,
SwapInput,
SwapParams,
UpdateFeesAndRewardsParams,
InitializePositionBundleParams,
DeletePositionBundleParams,
OpenBundledPositionParams,
CloseBundledPositionParams,
} from "../../instructions";
export type {
CollectFeesV2Params,
CollectProtocolFeesV2Params,
CollectRewardV2Params,
DecreaseLiquidityV2Params,
IncreaseLiquidityV2Params,
InitPoolV2Params,
InitializeRewardV2Params,
SetRewardEmissionsV2Params,
SwapV2Params,
TwoHopSwapV2Params,
InitConfigExtensionParams,
SetConfigExtensionAuthorityParams,
SetTokenBadgeAuthorityParams,
InitializeTokenBadgeParams,
DeleteTokenBadgeParams,
} from "../../instructions/v2";
export type {
CollectAllParams,
CollectAllPositionAddressParams,
CollectAllPositionParams,
} from "../../instructions/composites";
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/types
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/types/public/index.ts
|
export * from "./anchor-types";
export type * from "./client-types";
export * from "./constants";
export type * from "./ix-types";
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/types
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/types/public/anchor-types.ts
|
import type { BN, Idl } from "@coral-xyz/anchor";
import { BorshAccountsCoder } from "@coral-xyz/anchor";
import type { PublicKey } from "@solana/web3.js";
import WhirlpoolIDL from "../../artifacts/whirlpool.json";
/**
* This file contains the types that has the same structure as the types anchor functions returns.
* These types are hard-casted by the client function.
*
* This file must be manually updated every time the idl updates as accounts will
* be hard-casted to fit the type.
*/
/**
* Supported parasable account names from the Whirlpool contract.
* @category Network
*/
export enum AccountName {
WhirlpoolsConfig = "WhirlpoolsConfig",
Position = "Position",
TickArray = "TickArray",
Whirlpool = "Whirlpool",
FeeTier = "FeeTier",
PositionBundle = "PositionBundle",
WhirlpoolsConfigExtension = "WhirlpoolsConfigExtension",
TokenBadge = "TokenBadge",
}
export const WHIRLPOOL_IDL = WhirlpoolIDL as Idl;
/**
* The Anchor coder for the Whirlpool program.
* @category Solana Accounts
*/
export const WHIRLPOOL_CODER = new BorshAccountsCoder(WHIRLPOOL_IDL);
/**
* Get the size of an account owned by the Whirlpool program in bytes.
* @param accountName Whirlpool account name
* @returns Size in bytes of the account
*/
export function getAccountSize(accountName: AccountName) {
const size = WHIRLPOOL_CODER.size(
WHIRLPOOL_IDL.accounts!.find((account) => account.name === accountName)!,
);
return size + RESERVED_BYTES[accountName];
}
/**
* Reserved bytes for each account used for calculating the account size.
*/
const RESERVED_BYTES: ReservedBytes = {
[AccountName.WhirlpoolsConfig]: 2,
[AccountName.Position]: 0,
[AccountName.TickArray]: 0,
[AccountName.Whirlpool]: 0,
[AccountName.FeeTier]: 0,
[AccountName.PositionBundle]: 64,
[AccountName.WhirlpoolsConfigExtension]: 512,
[AccountName.TokenBadge]: 128,
};
type ReservedBytes = {
[name in AccountName]: number;
};
/**
* Size of the Whirlpool account in bytes.
* @deprecated Please use {@link getAccountSize} instead.
* @category Solana Accounts
*/
export const WHIRLPOOL_ACCOUNT_SIZE = getAccountSize(AccountName.Whirlpool);
/**
* @category Solana Accounts
*/
export type WhirlpoolsConfigData = {
feeAuthority: PublicKey;
collectProtocolFeesAuthority: PublicKey;
rewardEmissionsSuperAuthority: PublicKey;
defaultFeeRate: number;
defaultProtocolFeeRate: number;
};
/**
* @category Solana Accounts
*/
export type WhirlpoolRewardInfoData = {
mint: PublicKey;
vault: PublicKey;
authority: PublicKey;
emissionsPerSecondX64: BN;
growthGlobalX64: BN;
};
/**
* @category Solana Accounts
*/
export type WhirlpoolBumpsData = {
whirlpoolBump: number;
};
/**
* @category Solana Accounts
*/
export type WhirlpoolData = {
whirlpoolsConfig: PublicKey;
whirlpoolBump: number[];
feeRate: number;
protocolFeeRate: number;
liquidity: BN;
sqrtPrice: BN;
tickCurrentIndex: number;
protocolFeeOwedA: BN;
protocolFeeOwedB: BN;
tokenMintA: PublicKey;
tokenVaultA: PublicKey;
feeGrowthGlobalA: BN;
tokenMintB: PublicKey;
tokenVaultB: PublicKey;
feeGrowthGlobalB: BN;
rewardLastUpdatedTimestamp: BN;
rewardInfos: WhirlpoolRewardInfoData[];
tickSpacing: number;
};
/**
* @category Solana Accounts
*/
export type TickArrayData = {
whirlpool: PublicKey;
startTickIndex: number;
ticks: TickData[];
};
/**
* @category Solana Accounts
*/
export type TickData = {
initialized: boolean;
liquidityNet: BN;
liquidityGross: BN;
feeGrowthOutsideA: BN;
feeGrowthOutsideB: BN;
rewardGrowthsOutside: BN[];
};
/**
* @category Solana Accounts
*/
export type PositionRewardInfoData = {
growthInsideCheckpoint: BN;
amountOwed: BN;
};
/**
* @category Solana Accounts
*/
export type OpenPositionBumpsData = {
positionBump: number;
};
/**
* @category Solana Accounts
*/
export type OpenPositionWithMetadataBumpsData = {
positionBump: number;
metadataBump: number;
};
/**
* @category Solana Accounts
*/
export type PositionData = {
whirlpool: PublicKey;
positionMint: PublicKey;
liquidity: BN;
tickLowerIndex: number;
tickUpperIndex: number;
feeGrowthCheckpointA: BN;
feeOwedA: BN;
feeGrowthCheckpointB: BN;
feeOwedB: BN;
rewardInfos: PositionRewardInfoData[];
};
/**
* @category Solana Accounts
*/
export type FeeTierData = {
whirlpoolsConfig: PublicKey;
tickSpacing: number;
defaultFeeRate: number;
};
/**
* @category Solana Accounts
*/
export type PositionBundleData = {
positionBundleMint: PublicKey;
positionBitmap: number[];
};
/**
* @category Solana Accounts
*/
export type WhirlpoolsConfigExtensionData = {
whirlpoolsConfig: PublicKey;
configExtensionAuthority: PublicKey;
tokenBadgeAuthority: PublicKey;
};
/**
* @category Solana Accounts
*/
export type TokenBadgeData = {
whirlpoolsConfig: PublicKey;
tokenMint: PublicKey;
};
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes/swap/swap-manager.ts
|
import { U64_MAX, ZERO } from "@orca-so/common-sdk";
import BN from "bn.js";
import type { WhirlpoolData } from "../../types/public";
import { PROTOCOL_FEE_RATE_MUL_VALUE } from "../../types/public";
import { computeSwapStep } from "../../utils/math/swap-math";
import { PriceMath } from "../../utils/public";
import type { TickArraySequence } from "./tick-array-sequence";
import { SwapErrorCode, WhirlpoolsError } from "../../errors/errors";
export type SwapResult = {
amountA: BN;
amountB: BN;
nextTickIndex: number;
nextSqrtPrice: BN;
totalFeeAmount: BN;
};
export function computeSwap(
whirlpoolData: WhirlpoolData,
tickSequence: TickArraySequence,
tokenAmount: BN,
sqrtPriceLimit: BN,
amountSpecifiedIsInput: boolean,
aToB: boolean,
): SwapResult {
let amountRemaining = tokenAmount;
let amountCalculated = ZERO;
let currSqrtPrice = whirlpoolData.sqrtPrice;
let currLiquidity = whirlpoolData.liquidity;
let currTickIndex = whirlpoolData.tickCurrentIndex;
let totalFeeAmount = ZERO;
const feeRate = whirlpoolData.feeRate;
const protocolFeeRate = whirlpoolData.protocolFeeRate;
let currProtocolFee = new BN(0);
let currFeeGrowthGlobalInput = aToB
? whirlpoolData.feeGrowthGlobalA
: whirlpoolData.feeGrowthGlobalB;
while (amountRemaining.gt(ZERO) && !sqrtPriceLimit.eq(currSqrtPrice)) {
let { nextIndex: nextTickIndex } =
tickSequence.findNextInitializedTickIndex(currTickIndex);
let { nextTickPrice, nextSqrtPriceLimit: targetSqrtPrice } =
getNextSqrtPrices(nextTickIndex, sqrtPriceLimit, aToB);
const swapComputation = computeSwapStep(
amountRemaining,
feeRate,
currLiquidity,
currSqrtPrice,
targetSqrtPrice,
amountSpecifiedIsInput,
aToB,
);
totalFeeAmount = totalFeeAmount.add(swapComputation.feeAmount);
if (amountSpecifiedIsInput) {
amountRemaining = amountRemaining.sub(swapComputation.amountIn);
amountRemaining = amountRemaining.sub(swapComputation.feeAmount);
amountCalculated = amountCalculated.add(swapComputation.amountOut);
} else {
amountRemaining = amountRemaining.sub(swapComputation.amountOut);
amountCalculated = amountCalculated.add(swapComputation.amountIn);
amountCalculated = amountCalculated.add(swapComputation.feeAmount);
}
if (amountRemaining.isNeg()) {
throw new WhirlpoolsError(
"Amount remaining is negative.",
SwapErrorCode.AmountRemainingOverflow,
);
}
if (amountCalculated.gt(U64_MAX)) {
throw new WhirlpoolsError(
"Amount calculated is greater than U64_MAX.",
SwapErrorCode.AmountCalcOverflow,
);
}
let { nextProtocolFee, nextFeeGrowthGlobalInput } = calculateFees(
swapComputation.feeAmount,
protocolFeeRate,
currLiquidity,
currProtocolFee,
currFeeGrowthGlobalInput,
);
currProtocolFee = nextProtocolFee;
currFeeGrowthGlobalInput = nextFeeGrowthGlobalInput;
if (swapComputation.nextPrice.eq(nextTickPrice)) {
const nextTick = tickSequence.getTick(nextTickIndex);
if (nextTick.initialized) {
currLiquidity = calculateNextLiquidity(
nextTick.liquidityNet,
currLiquidity,
aToB,
);
}
currTickIndex = aToB ? nextTickIndex - 1 : nextTickIndex;
} else {
currTickIndex = PriceMath.sqrtPriceX64ToTickIndex(
swapComputation.nextPrice,
);
}
currSqrtPrice = swapComputation.nextPrice;
}
let { amountA, amountB } = calculateEstTokens(
tokenAmount,
amountRemaining,
amountCalculated,
aToB,
amountSpecifiedIsInput,
);
return {
amountA,
amountB,
nextTickIndex: currTickIndex,
nextSqrtPrice: currSqrtPrice,
totalFeeAmount,
};
}
function getNextSqrtPrices(
nextTick: number,
sqrtPriceLimit: BN,
aToB: boolean,
) {
const nextTickPrice = PriceMath.tickIndexToSqrtPriceX64(nextTick);
const nextSqrtPriceLimit = aToB
? BN.max(sqrtPriceLimit, nextTickPrice)
: BN.min(sqrtPriceLimit, nextTickPrice);
return { nextTickPrice, nextSqrtPriceLimit };
}
function calculateFees(
feeAmount: BN,
protocolFeeRate: number,
currLiquidity: BN,
currProtocolFee: BN,
currFeeGrowthGlobalInput: BN,
) {
let nextProtocolFee = currProtocolFee;
let nextFeeGrowthGlobalInput = currFeeGrowthGlobalInput;
let globalFee = feeAmount;
if (protocolFeeRate > 0) {
let delta = calculateProtocolFee(globalFee, protocolFeeRate);
globalFee = globalFee.sub(delta);
nextProtocolFee = nextProtocolFee.add(currProtocolFee);
}
if (currLiquidity.gt(ZERO)) {
const globalFeeIncrement = globalFee.shln(64).div(currLiquidity);
nextFeeGrowthGlobalInput = nextFeeGrowthGlobalInput.add(globalFeeIncrement);
}
return {
nextProtocolFee,
nextFeeGrowthGlobalInput,
};
}
function calculateProtocolFee(globalFee: BN, protocolFeeRate: number) {
return globalFee.mul(
new BN(protocolFeeRate).div(PROTOCOL_FEE_RATE_MUL_VALUE),
);
}
function calculateEstTokens(
amount: BN,
amountRemaining: BN,
amountCalculated: BN,
aToB: boolean,
amountSpecifiedIsInput: boolean,
) {
return aToB === amountSpecifiedIsInput
? {
amountA: amount.sub(amountRemaining),
amountB: amountCalculated,
}
: {
amountA: amountCalculated,
amountB: amount.sub(amountRemaining),
};
}
function calculateNextLiquidity(
tickNetLiquidity: BN,
currLiquidity: BN,
aToB: boolean,
) {
return aToB
? currLiquidity.sub(tickNetLiquidity)
: currLiquidity.add(tickNetLiquidity);
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes/swap/tick-array-index.ts
|
import { TICK_ARRAY_SIZE } from "../../types/public";
export class TickArrayIndex {
static fromTickIndex(index: number, tickSpacing: number) {
const arrayIndex = Math.floor(
Math.floor(index / tickSpacing) / TICK_ARRAY_SIZE,
);
let offsetIndex = Math.floor(
(index % (tickSpacing * TICK_ARRAY_SIZE)) / tickSpacing,
);
if (offsetIndex < 0) {
offsetIndex = TICK_ARRAY_SIZE + offsetIndex;
}
return new TickArrayIndex(arrayIndex, offsetIndex, tickSpacing);
}
constructor(
readonly arrayIndex: number,
readonly offsetIndex: number,
readonly tickSpacing: number,
) {
if (offsetIndex >= TICK_ARRAY_SIZE) {
throw new Error(
"Invalid offsetIndex - value has to be smaller than TICK_ARRAY_SIZE",
);
}
if (offsetIndex < 0) {
throw new Error("Invalid offsetIndex - value is smaller than 0");
}
if (tickSpacing < 0) {
throw new Error("Invalid tickSpacing - value is less than 0");
}
}
toTickIndex() {
return (
this.arrayIndex * TICK_ARRAY_SIZE * this.tickSpacing +
this.offsetIndex * this.tickSpacing
);
}
toNextInitializableTickIndex() {
return TickArrayIndex.fromTickIndex(
this.toTickIndex() + this.tickSpacing,
this.tickSpacing,
);
}
toPrevInitializableTickIndex() {
return TickArrayIndex.fromTickIndex(
this.toTickIndex() - this.tickSpacing,
this.tickSpacing,
);
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes/swap/swap-quote-impl.ts
|
import { BN } from "@coral-xyz/anchor";
import { ZERO } from "@orca-so/common-sdk";
import { SwapErrorCode, WhirlpoolsError } from "../../errors/errors";
import {
MAX_SQRT_PRICE,
MAX_SWAP_TICK_ARRAYS,
MIN_SQRT_PRICE,
} from "../../types/public";
import type { SwapQuote, SwapQuoteParam } from "../public";
import { computeSwap } from "./swap-manager";
import { TickArraySequence } from "./tick-array-sequence";
import type { TransferFeeIncludedAmount } from "../../utils/public/token-extension-util";
import { TokenExtensionUtil } from "../../utils/public/token-extension-util";
/**
* Figure out the quote parameters needed to successfully complete this trade on chain
* @param param
* @returns
* @exceptions
*/
export function simulateSwap(params: SwapQuoteParam): SwapQuote {
const {
aToB,
whirlpoolData,
tickArrays,
tokenAmount,
sqrtPriceLimit,
otherAmountThreshold,
amountSpecifiedIsInput,
tokenExtensionCtx,
} = params;
if (
sqrtPriceLimit.gt(new BN(MAX_SQRT_PRICE)) ||
sqrtPriceLimit.lt(new BN(MIN_SQRT_PRICE))
) {
throw new WhirlpoolsError(
"Provided SqrtPriceLimit is out of bounds.",
SwapErrorCode.SqrtPriceOutOfBounds,
);
}
if (
(aToB && sqrtPriceLimit.gt(whirlpoolData.sqrtPrice)) ||
(!aToB && sqrtPriceLimit.lt(whirlpoolData.sqrtPrice))
) {
throw new WhirlpoolsError(
"Provided SqrtPriceLimit is in the opposite direction of the trade.",
SwapErrorCode.InvalidSqrtPriceLimitDirection,
);
}
if (tokenAmount.eq(ZERO)) {
throw new WhirlpoolsError(
"Provided tokenAmount is zero.",
SwapErrorCode.ZeroTradableAmount,
);
}
const tickSequence = new TickArraySequence(
tickArrays,
whirlpoolData.tickSpacing,
aToB,
);
// Ensure 1st search-index resides on the 1st array in the sequence to match smart contract expectation.
if (!tickSequence.isValidTickArray0(whirlpoolData.tickCurrentIndex)) {
throw new WhirlpoolsError(
"TickArray at index 0 does not contain the Whirlpool current tick index.",
SwapErrorCode.TickArraySequenceInvalid,
);
}
if (amountSpecifiedIsInput) {
// For ExactIn
// computeSwap should be executed with "tokenAmount - transfer fee".
const transferFeeExcludedIn =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
tokenAmount,
aToB
? tokenExtensionCtx.tokenMintWithProgramA
: tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
if (transferFeeExcludedIn.amount.eq(ZERO)) {
throw new WhirlpoolsError(
"Provided tokenAmount is virtually zero due to transfer fee.",
SwapErrorCode.ZeroTradableAmount,
);
}
const swapResults = computeSwap(
whirlpoolData,
tickSequence,
transferFeeExcludedIn.amount,
sqrtPriceLimit,
amountSpecifiedIsInput,
aToB,
);
// otherAmountThreshold should be applied to transfer fee EXCLUDED output amount.
const transferFeeExcludedOut =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
aToB ? swapResults.amountB : swapResults.amountA,
aToB
? tokenExtensionCtx.tokenMintWithProgramB
: tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
if (transferFeeExcludedOut.amount.lt(otherAmountThreshold)) {
throw new WhirlpoolsError(
"Quoted amount for the other token is below the otherAmountThreshold.",
SwapErrorCode.AmountOutBelowMinimum,
);
}
const fullfilled = (aToB ? swapResults.amountA : swapResults.amountB).eq(
transferFeeExcludedIn.amount,
);
const transferFeeIncludedIn: TransferFeeIncludedAmount = fullfilled
? { amount: tokenAmount, fee: transferFeeExcludedIn.fee }
: TokenExtensionUtil.calculateTransferFeeIncludedAmount(
aToB ? swapResults.amountA : swapResults.amountB,
aToB
? tokenExtensionCtx.tokenMintWithProgramA
: tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
const numOfTickCrossings = tickSequence.getNumOfTouchedArrays();
if (numOfTickCrossings > MAX_SWAP_TICK_ARRAYS) {
throw new WhirlpoolsError(
`Input amount causes the quote to traverse more than the allowable amount of tick-arrays ${numOfTickCrossings}`,
SwapErrorCode.TickArrayCrossingAboveMax,
);
}
const touchedArrays = tickSequence.getTouchedArrays(MAX_SWAP_TICK_ARRAYS);
return {
estimatedAmountIn: transferFeeIncludedIn.amount,
estimatedAmountOut: transferFeeExcludedOut.amount,
estimatedEndTickIndex: swapResults.nextTickIndex,
estimatedEndSqrtPrice: swapResults.nextSqrtPrice,
estimatedFeeAmount: swapResults.totalFeeAmount,
transferFee: {
deductingFromEstimatedAmountIn: transferFeeIncludedIn.fee,
deductedFromEstimatedAmountOut: transferFeeExcludedOut.fee,
},
amount: tokenAmount,
amountSpecifiedIsInput,
aToB,
otherAmountThreshold,
sqrtPriceLimit,
tickArray0: touchedArrays[0],
tickArray1: touchedArrays[1],
tickArray2: touchedArrays[2],
};
}
// For ExactOut
// For ExactOut, computeSwap should be executed with "tokenAmount + transfer fee".
const transferFeeIncludedOut =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
tokenAmount,
aToB
? tokenExtensionCtx.tokenMintWithProgramB
: tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
const swapResults = computeSwap(
whirlpoolData,
tickSequence,
transferFeeIncludedOut.amount,
sqrtPriceLimit,
amountSpecifiedIsInput,
aToB,
);
// otherAmountThreshold should be applied to transfer fee INCLUDED input amount.
const transferFeeIncludedIn =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
aToB ? swapResults.amountA : swapResults.amountB,
aToB
? tokenExtensionCtx.tokenMintWithProgramA
: tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
if (transferFeeIncludedIn.amount.gt(otherAmountThreshold)) {
throw new WhirlpoolsError(
"Quoted amount for the other token is above the otherAmountThreshold.",
SwapErrorCode.AmountInAboveMaximum,
);
}
const transferFeeExcludedOut =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
aToB ? swapResults.amountB : swapResults.amountA,
aToB
? tokenExtensionCtx.tokenMintWithProgramB
: tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
const numOfTickCrossings = tickSequence.getNumOfTouchedArrays();
if (numOfTickCrossings > MAX_SWAP_TICK_ARRAYS) {
throw new WhirlpoolsError(
`Input amount causes the quote to traverse more than the allowable amount of tick-arrays ${numOfTickCrossings}`,
SwapErrorCode.TickArrayCrossingAboveMax,
);
}
const touchedArrays = tickSequence.getTouchedArrays(MAX_SWAP_TICK_ARRAYS);
return {
estimatedAmountIn: transferFeeIncludedIn.amount,
estimatedAmountOut: transferFeeExcludedOut.amount,
estimatedEndTickIndex: swapResults.nextTickIndex,
estimatedEndSqrtPrice: swapResults.nextSqrtPrice,
estimatedFeeAmount: swapResults.totalFeeAmount,
transferFee: {
deductingFromEstimatedAmountIn: transferFeeIncludedIn.fee,
deductedFromEstimatedAmountOut: transferFeeExcludedOut.fee,
},
amount: tokenAmount,
amountSpecifiedIsInput,
aToB,
otherAmountThreshold,
sqrtPriceLimit,
tickArray0: touchedArrays[0],
tickArray1: touchedArrays[1],
tickArray2: touchedArrays[2],
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes/swap/tick-array-sequence.ts
|
import { SwapErrorCode, WhirlpoolsError } from "../../errors/errors";
import type { TickArray, TickArrayData, TickData } from "../../types/public";
import {
MAX_TICK_INDEX,
MIN_TICK_INDEX,
TICK_ARRAY_SIZE,
} from "../../types/public";
import { TickArrayIndex } from "./tick-array-index";
import type { PublicKey } from "@solana/web3.js";
type InitializedTickArray = TickArray & {
// override
data: TickArrayData;
};
/**
* NOTE: differs from contract method of having the swap manager keep track of array index.
* This is due to the initial requirement to lazy load tick-arrays. This requirement is no longer necessary.
*/
export class TickArraySequence {
private sequence: InitializedTickArray[];
private touchedArrays: boolean[];
private startArrayIndex: number;
constructor(
tickArrays: Readonly<TickArray[]>,
readonly tickSpacing: number,
readonly aToB: boolean,
) {
if (!tickArrays[0] || !tickArrays[0].data) {
throw new Error("TickArray index 0 must be initialized");
}
// If an uninitialized TickArray appears, truncate all TickArrays after it (inclusive).
this.sequence = [];
for (const tickArray of tickArrays) {
if (!tickArray || !tickArray.data) {
break;
}
this.sequence.push({
address: tickArray.address,
startTickIndex: tickArray.data.startTickIndex,
data: tickArray.data,
});
}
this.touchedArrays = [...Array<boolean>(this.sequence.length).fill(false)];
this.startArrayIndex = TickArrayIndex.fromTickIndex(
this.sequence[0].data.startTickIndex,
this.tickSpacing,
).arrayIndex;
}
isValidTickArray0(tickCurrentIndex: number) {
const shift = this.aToB ? 0 : this.tickSpacing;
const tickArray = this.sequence[0].data;
return this.checkIfIndexIsInTickArrayRange(
tickArray.startTickIndex,
tickCurrentIndex + shift,
);
}
getNumOfTouchedArrays() {
return this.touchedArrays.filter((val) => !!val).length;
}
getTouchedArrays(minArraySize: number): PublicKey[] {
let result = this.touchedArrays.reduce<PublicKey[]>((prev, curr, index) => {
if (curr) {
prev.push(this.sequence[index].address);
}
return prev;
}, []);
// Edge case: nothing was ever touched.
if (result.length === 0) {
return [];
}
// The quote object should contain the specified amount of tick arrays to be plugged
// directly into the swap instruction.
// If the result does not fit minArraySize, pad the rest with the last touched array
const sizeDiff = minArraySize - result.length;
if (sizeDiff > 0) {
result = result.concat(Array(sizeDiff).fill(result[result.length - 1]));
}
return result;
}
getTick(index: number): TickData {
const targetTaIndex = TickArrayIndex.fromTickIndex(index, this.tickSpacing);
if (!this.isArrayIndexInBounds(targetTaIndex, this.aToB)) {
throw new Error(
"Provided tick index is out of bounds for this sequence.",
);
}
const localArrayIndex = this.getLocalArrayIndex(
targetTaIndex.arrayIndex,
this.aToB,
);
const tickArray = this.sequence[localArrayIndex].data;
this.touchedArrays[localArrayIndex] = true;
if (!tickArray) {
throw new WhirlpoolsError(
`TickArray at index ${localArrayIndex} is not initialized.`,
SwapErrorCode.TickArrayIndexNotInitialized,
);
}
if (!this.checkIfIndexIsInTickArrayRange(tickArray.startTickIndex, index)) {
throw new WhirlpoolsError(
`TickArray at index ${localArrayIndex} is unexpected for this sequence.`,
SwapErrorCode.TickArraySequenceInvalid,
);
}
return tickArray.ticks[targetTaIndex.offsetIndex];
}
/**
* if a->b, currIndex is included in the search
* if b->a, currIndex is always ignored
* @param currIndex
* @returns
*/
findNextInitializedTickIndex(currIndex: number) {
const searchIndex = this.aToB ? currIndex : currIndex + this.tickSpacing;
let currTaIndex = TickArrayIndex.fromTickIndex(
searchIndex,
this.tickSpacing,
);
// Throw error if the search attempted to search for an index out of bounds
if (!this.isArrayIndexInBounds(currTaIndex, this.aToB)) {
throw new WhirlpoolsError(
`Swap input value traversed too many arrays. Out of bounds at attempt to traverse tick index - ${currTaIndex.toTickIndex()}.`,
SwapErrorCode.TickArraySequenceInvalid,
);
}
while (this.isArrayIndexInBounds(currTaIndex, this.aToB)) {
const currTickData = this.getTick(currTaIndex.toTickIndex());
if (currTickData.initialized) {
return {
nextIndex: currTaIndex.toTickIndex(),
nextTickData: currTickData,
};
}
currTaIndex = this.aToB
? currTaIndex.toPrevInitializableTickIndex()
: currTaIndex.toNextInitializableTickIndex();
}
const lastIndexInArray = Math.max(
Math.min(
this.aToB
? currTaIndex.toTickIndex() + this.tickSpacing
: currTaIndex.toTickIndex() - 1,
MAX_TICK_INDEX,
),
MIN_TICK_INDEX,
);
return { nextIndex: lastIndexInArray, nextTickData: null };
}
private getLocalArrayIndex(arrayIndex: number, aToB: boolean) {
return aToB
? this.startArrayIndex - arrayIndex
: arrayIndex - this.startArrayIndex;
}
/**
* Check whether the array index potentially exists in this sequence.
* Note: assumes the sequence of tick-arrays are sequential
* @param index
*/
private isArrayIndexInBounds(index: TickArrayIndex, aToB: boolean) {
// a+0...a+n-1 array index is ok
const localArrayIndex = this.getLocalArrayIndex(index.arrayIndex, aToB);
const seqLength = this.sequence.length;
return localArrayIndex >= 0 && localArrayIndex < seqLength;
}
private checkIfIndexIsInTickArrayRange(startTick: number, tickIndex: number) {
const upperBound = startTick + this.tickSpacing * TICK_ARRAY_SIZE;
return tickIndex >= startTick && tickIndex < upperBound;
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes/public/collect-rewards-quote.ts
|
import { BN } from "@coral-xyz/anchor";
import { MathUtil } from "@orca-so/common-sdk";
import invariant from "tiny-invariant";
import type { PositionData, TickData, WhirlpoolData } from "../../types/public";
import { NUM_REWARDS } from "../../types/public";
import { BitMath } from "../../utils/math/bit-math";
import { PoolUtil } from "../../utils/public/pool-utils";
import type { TokenExtensionContextForReward } from "../../utils/public/token-extension-util";
import { TokenExtensionUtil } from "../../utils/public/token-extension-util";
/**
* Parameters needed to generate a quote on collectible rewards on a position.
* @category Quotes
* @param whirlpool - the account data for the whirlpool this position belongs to
* @param position - the account data for the position
* @param tickLower - the TickData account for the lower bound of this position
* @param tickUpper - the TickData account for the upper bound of this position
* @param timeStampInSeconds - optional parameter to generate this quote to a unix time stamp.
*/
export type CollectRewardsQuoteParam = {
whirlpool: WhirlpoolData;
position: PositionData;
tickLower: TickData;
tickUpper: TickData;
tokenExtensionCtx: TokenExtensionContextForReward;
timeStampInSeconds?: BN;
};
/**
* An array of reward amounts that is collectible on a position.
* @category Quotes
*/
export type CollectRewardsQuote = {
rewardOwed: [BN | undefined, BN | undefined, BN | undefined];
transferFee: {
deductedFromRewardOwed: [BN | undefined, BN | undefined, BN | undefined];
};
};
/**
* Get a quote on the outstanding rewards owed to a position.
*
* @category Quotes
* @param param A collection of fetched Whirlpool accounts to faciliate the quote.
* @returns A quote object containing the rewards owed for each reward in the pool.
*/
export function collectRewardsQuote(
param: CollectRewardsQuoteParam,
): CollectRewardsQuote {
const {
whirlpool,
position,
tickLower,
tickUpper,
timeStampInSeconds,
tokenExtensionCtx,
} = param;
const {
tickCurrentIndex,
rewardInfos: whirlpoolRewardsInfos,
rewardLastUpdatedTimestamp,
} = whirlpool;
const {
tickLowerIndex,
tickUpperIndex,
liquidity,
rewardInfos: positionRewardInfos,
} = position;
const currTimestampInSeconds =
timeStampInSeconds ?? new BN(Date.now()).div(new BN(1000));
const timestampDelta = currTimestampInSeconds.sub(
new BN(rewardLastUpdatedTimestamp),
);
const rewardOwed: [BN | undefined, BN | undefined, BN | undefined] = [
undefined,
undefined,
undefined,
];
const transferFee: [BN | undefined, BN | undefined, BN | undefined] = [
undefined,
undefined,
undefined,
];
for (let i = 0; i < NUM_REWARDS; i++) {
// Calculate the reward growth on the outside of the position (growth_above, growth_below)
const rewardInfo = whirlpoolRewardsInfos[i];
const positionRewardInfo = positionRewardInfos[i];
invariant(!!rewardInfo, "whirlpoolRewardsInfos cannot be undefined");
const isRewardInitialized = PoolUtil.isRewardInitialized(rewardInfo);
if (!isRewardInitialized) {
continue;
}
// Increment the global reward growth tracker based on time elasped since the last whirlpool update.
let adjustedRewardGrowthGlobalX64 = rewardInfo.growthGlobalX64;
if (!whirlpool.liquidity.isZero()) {
const rewardGrowthDelta = BitMath.mulDiv(
timestampDelta,
rewardInfo.emissionsPerSecondX64,
whirlpool.liquidity,
128,
);
adjustedRewardGrowthGlobalX64 =
rewardInfo.growthGlobalX64.add(rewardGrowthDelta);
}
// Calculate the reward growth outside of the position
const tickLowerRewardGrowthsOutsideX64 = tickLower.rewardGrowthsOutside[i];
const tickUpperRewardGrowthsOutsideX64 = tickUpper.rewardGrowthsOutside[i];
let rewardGrowthsBelowX64: BN = adjustedRewardGrowthGlobalX64;
if (tickLower.initialized) {
rewardGrowthsBelowX64 =
tickCurrentIndex < tickLowerIndex
? MathUtil.subUnderflowU128(
adjustedRewardGrowthGlobalX64,
tickLowerRewardGrowthsOutsideX64,
)
: tickLowerRewardGrowthsOutsideX64;
}
let rewardGrowthsAboveX64: BN = new BN(0);
if (tickUpper.initialized) {
rewardGrowthsAboveX64 =
tickCurrentIndex < tickUpperIndex
? tickUpperRewardGrowthsOutsideX64
: MathUtil.subUnderflowU128(
adjustedRewardGrowthGlobalX64,
tickUpperRewardGrowthsOutsideX64,
);
}
const rewardGrowthInsideX64 = MathUtil.subUnderflowU128(
MathUtil.subUnderflowU128(
adjustedRewardGrowthGlobalX64,
rewardGrowthsBelowX64,
),
rewardGrowthsAboveX64,
);
// Knowing the growth of the reward checkpoint for the position, calculate and increment the amount owed for each reward.
const amountOwedX64 = positionRewardInfo.amountOwed.shln(64);
const amountOwed = amountOwedX64
.add(
MathUtil.subUnderflowU128(
rewardGrowthInsideX64,
positionRewardInfo.growthInsideCheckpoint,
).mul(liquidity),
)
.shrn(64);
const transferFeeExcluded =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
amountOwed,
tokenExtensionCtx.rewardTokenMintsWithProgram[i]!,
tokenExtensionCtx.currentEpoch,
);
rewardOwed[i] = transferFeeExcluded.amount;
transferFee[i] = transferFeeExcluded.fee;
}
return {
rewardOwed,
transferFee: {
deductedFromRewardOwed: transferFee,
},
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes/public/increase-liquidity-quote.ts
|
import type { Address } from "@coral-xyz/anchor";
import type { Percentage } from "@orca-so/common-sdk";
import { AddressUtil, DecimalUtil, ZERO } from "@orca-so/common-sdk";
import type { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import type Decimal from "decimal.js";
import invariant from "tiny-invariant";
import type { IncreaseLiquidityInput } from "../../instructions";
import {
PositionStatus,
PositionUtil,
adjustForSlippage,
getLiquidityFromTokenA,
getLiquidityFromTokenB,
getTokenAFromLiquidity,
getTokenBFromLiquidity,
} from "../../utils/position-util";
import { PriceMath, TickUtil } from "../../utils/public";
import type { Whirlpool } from "../../whirlpool-client";
import type { TokenExtensionContextForPool } from "../../utils/public/token-extension-util";
import { TokenExtensionUtil } from "../../utils/public/token-extension-util";
/*** --------- Quote by Input Token --------- ***/
/**
* @category Quotes
* @param inputTokenAmount - The amount of input tokens to deposit.
* @param inputTokenMint - The mint of the input token the user would like to deposit.
* @param tokenMintA - The mint of tokenA in the Whirlpool the user is depositing into.
* @param tokenMintB -The mint of tokenB in the Whirlpool the user is depositing into.
* @param tickCurrentIndex - The Whirlpool's current tickIndex
* @param sqrtPrice - The Whirlpool's current sqrtPrice
* @param tickLowerIndex - The lower index of the position that we are withdrawing from.
* @param tickUpperIndex - The upper index of the position that we are withdrawing from.
* @param slippageTolerance - The maximum slippage allowed when calculating the minimum tokens received.
*/
export type IncreaseLiquidityQuoteParam = {
inputTokenAmount: BN;
inputTokenMint: PublicKey;
tokenMintA: PublicKey;
tokenMintB: PublicKey;
tickCurrentIndex: number;
sqrtPrice: BN;
tickLowerIndex: number;
tickUpperIndex: number;
tokenExtensionCtx: TokenExtensionContextForPool;
slippageTolerance: Percentage;
};
/**
* Return object from increase liquidity quote functions.
* @category Quotes
*/
export type IncreaseLiquidityQuote = IncreaseLiquidityInput &
IncreaseLiquidityEstimate;
type IncreaseLiquidityEstimate = {
liquidityAmount: BN;
tokenEstA: BN;
tokenEstB: BN;
transferFee: {
deductingFromTokenMaxA: BN;
deductingFromTokenMaxB: BN;
deductingFromTokenEstA: BN;
deductingFromTokenEstB: BN;
};
};
/**
* Get an estimated quote on the maximum tokens required to deposit based on a specified input token amount.
* This new version calculates slippage based on price percentage movement, rather than setting the percentage threshold based on token estimates.
*
* @category Quotes
* @param inputTokenAmount - The amount of input tokens to deposit.
* @param inputTokenMint - The mint of the input token the user would like to deposit.
* @param tickLower - The lower index of the position that we are depositing into.
* @param tickUpper - The upper index of the position that we are depositing into.
* @param slippageTolerance - The maximum slippage allowed when calculating the minimum tokens received.
* @param whirlpool - A Whirlpool helper class to help interact with the Whirlpool account.
* @returns An IncreaseLiquidityInput object detailing the required token amounts & liquidity values to use when calling increase-liquidity-ix.
*/
export function increaseLiquidityQuoteByInputTokenUsingPriceSlippage(
inputTokenMint: Address,
inputTokenAmount: Decimal,
tickLower: number,
tickUpper: number,
slippageTolerance: Percentage,
whirlpool: Whirlpool,
tokenExtensionCtx: TokenExtensionContextForPool,
) {
const data = whirlpool.getData();
const tokenAInfo = whirlpool.getTokenAInfo();
const tokenBInfo = whirlpool.getTokenBInfo();
const inputMint = AddressUtil.toPubKey(inputTokenMint);
const inputTokenInfo = inputMint.equals(tokenAInfo.mint)
? tokenAInfo
: tokenBInfo;
return increaseLiquidityQuoteByInputTokenWithParamsUsingPriceSlippage({
inputTokenMint: inputMint,
inputTokenAmount: DecimalUtil.toBN(
inputTokenAmount,
inputTokenInfo.decimals,
),
tickLowerIndex: TickUtil.getInitializableTickIndex(
tickLower,
data.tickSpacing,
),
tickUpperIndex: TickUtil.getInitializableTickIndex(
tickUpper,
data.tickSpacing,
),
slippageTolerance,
tokenExtensionCtx,
...data,
});
}
/**
* Get an estimated quote on the maximum tokens required to deposit based on a specified input token amount.
* This new version calculates slippage based on price percentage movement, rather than setting the percentage threshold based on token estimates.
*
* @category Quotes
* @param param IncreaseLiquidityQuoteParam
* @returns An IncreaseLiquidityInput object detailing the required token amounts & liquidity values to use when calling increase-liquidity-ix.
*/
export function increaseLiquidityQuoteByInputTokenWithParamsUsingPriceSlippage(
param: IncreaseLiquidityQuoteParam,
): IncreaseLiquidityQuote {
invariant(
TickUtil.checkTickInBounds(param.tickLowerIndex),
"tickLowerIndex is out of bounds.",
);
invariant(
TickUtil.checkTickInBounds(param.tickUpperIndex),
"tickUpperIndex is out of bounds.",
);
invariant(
param.inputTokenMint.equals(param.tokenMintA) ||
param.inputTokenMint.equals(param.tokenMintB),
`input token mint ${param.inputTokenMint.toBase58()} does not match any tokens in the provided pool.`,
);
const liquidity = getLiquidityFromInputToken(param);
if (liquidity.eq(ZERO)) {
return {
liquidityAmount: ZERO,
tokenMaxA: ZERO,
tokenMaxB: ZERO,
tokenEstA: ZERO,
tokenEstB: ZERO,
transferFee: {
deductingFromTokenMaxA: ZERO,
deductingFromTokenMaxB: ZERO,
deductingFromTokenEstA: ZERO,
deductingFromTokenEstB: ZERO,
},
};
}
return increaseLiquidityQuoteByLiquidityWithParams({
liquidity,
tickCurrentIndex: param.tickCurrentIndex,
sqrtPrice: param.sqrtPrice,
tickLowerIndex: param.tickLowerIndex,
tickUpperIndex: param.tickUpperIndex,
slippageTolerance: param.slippageTolerance,
tokenExtensionCtx: param.tokenExtensionCtx,
});
}
function getLiquidityFromInputToken(params: IncreaseLiquidityQuoteParam) {
const {
inputTokenMint,
inputTokenAmount,
tickLowerIndex,
tickUpperIndex,
sqrtPrice,
tokenExtensionCtx,
} = params;
invariant(
tickLowerIndex < tickUpperIndex,
`tickLowerIndex(${tickLowerIndex}) must be less than tickUpperIndex(${tickUpperIndex})`,
);
if (inputTokenAmount.eq(ZERO)) {
return ZERO;
}
const isTokenA = params.tokenMintA.equals(inputTokenMint);
const sqrtPriceLowerX64 = PriceMath.tickIndexToSqrtPriceX64(tickLowerIndex);
const sqrtPriceUpperX64 = PriceMath.tickIndexToSqrtPriceX64(tickUpperIndex);
const positionStatus = PositionUtil.getStrictPositionStatus(
sqrtPrice,
tickLowerIndex,
tickUpperIndex,
);
if (positionStatus === PositionStatus.BelowRange) {
if (!isTokenA) {
return ZERO;
}
const transferFeeExcludedInputTokenAmount =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
inputTokenAmount,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
return getLiquidityFromTokenA(
transferFeeExcludedInputTokenAmount.amount,
sqrtPriceLowerX64,
sqrtPriceUpperX64,
false,
);
}
if (positionStatus === PositionStatus.AboveRange) {
if (isTokenA) {
return ZERO;
}
const transferFeeExcludedInputTokenAmount =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
inputTokenAmount,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
return getLiquidityFromTokenB(
transferFeeExcludedInputTokenAmount.amount,
sqrtPriceLowerX64,
sqrtPriceUpperX64,
false,
);
}
if (isTokenA) {
const transferFeeExcludedInputTokenAmount =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
inputTokenAmount,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
return getLiquidityFromTokenA(
transferFeeExcludedInputTokenAmount.amount,
sqrtPrice,
sqrtPriceUpperX64,
false,
);
} else {
const transferFeeExcludedInputTokenAmount =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
inputTokenAmount,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
return getLiquidityFromTokenB(
transferFeeExcludedInputTokenAmount.amount,
sqrtPriceLowerX64,
sqrtPrice,
false,
);
}
}
/*** --------- Quote by Liquidity --------- ***/
/**
* @category Quotes
* @param liquidity - The amount of liquidity value to deposit into the Whirlpool.
* @param tokenMintA - The mint of tokenA in the Whirlpool the user is depositing into.
* @param tokenMintB -The mint of tokenB in the Whirlpool the user is depositing into.
* @param tickCurrentIndex - The Whirlpool's current tickIndex
* @param sqrtPrice - The Whirlpool's current sqrtPrice
* @param tickLowerIndex - The lower index of the position that we are withdrawing from.
* @param tickUpperIndex - The upper index of the position that we are withdrawing from.
* @param slippageTolerance - The maximum slippage allowed when calculating the minimum tokens received.
*/
export type IncreaseLiquidityQuoteByLiquidityParam = {
liquidity: BN;
tickCurrentIndex: number;
sqrtPrice: BN;
tickLowerIndex: number;
tickUpperIndex: number;
tokenExtensionCtx: TokenExtensionContextForPool;
slippageTolerance: Percentage;
};
export function increaseLiquidityQuoteByLiquidityWithParams(
params: IncreaseLiquidityQuoteByLiquidityParam,
): IncreaseLiquidityQuote {
if (params.liquidity.eq(ZERO)) {
return {
liquidityAmount: ZERO,
tokenMaxA: ZERO,
tokenMaxB: ZERO,
tokenEstA: ZERO,
tokenEstB: ZERO,
transferFee: {
deductingFromTokenMaxA: ZERO,
deductingFromTokenMaxB: ZERO,
deductingFromTokenEstA: ZERO,
deductingFromTokenEstB: ZERO,
},
};
}
const { tokenEstA, tokenEstB } = getTokenEstimatesFromLiquidity(params);
const {
lowerBound: [sLowerSqrtPrice, sLowerIndex],
upperBound: [sUpperSqrtPrice, sUpperIndex],
} = PriceMath.getSlippageBoundForSqrtPrice(
params.sqrtPrice,
params.slippageTolerance,
);
const { tokenEstA: tokenEstALower, tokenEstB: tokenEstBLower } =
getTokenEstimatesFromLiquidity({
...params,
sqrtPrice: sLowerSqrtPrice,
tickCurrentIndex: sLowerIndex,
});
const { tokenEstA: tokenEstAUpper, tokenEstB: tokenEstBUpper } =
getTokenEstimatesFromLiquidity({
...params,
sqrtPrice: sUpperSqrtPrice,
tickCurrentIndex: sUpperIndex,
});
const tokenMaxA = BN.max(BN.max(tokenEstA, tokenEstALower), tokenEstAUpper);
const tokenMaxB = BN.max(BN.max(tokenEstB, tokenEstBLower), tokenEstBUpper);
const tokenExtensionCtx = params.tokenExtensionCtx;
const tokenMaxAIncluded =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
tokenMaxA,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
const tokenEstAIncluded =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
tokenEstA,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
const tokenMaxBIncluded =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
tokenMaxB,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
const tokenEstBIncluded =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
tokenEstB,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
return {
liquidityAmount: params.liquidity,
tokenMaxA: tokenMaxAIncluded.amount,
tokenMaxB: tokenMaxBIncluded.amount,
tokenEstA: tokenEstAIncluded.amount,
tokenEstB: tokenEstBIncluded.amount,
transferFee: {
deductingFromTokenMaxA: tokenMaxAIncluded.fee,
deductingFromTokenMaxB: tokenMaxBIncluded.fee,
deductingFromTokenEstA: tokenEstAIncluded.fee,
deductingFromTokenEstB: tokenEstBIncluded.fee,
},
};
}
function getTokenEstimatesFromLiquidity(
params: IncreaseLiquidityQuoteByLiquidityParam,
) {
const { liquidity, sqrtPrice, tickLowerIndex, tickUpperIndex } = params;
if (liquidity.eq(ZERO)) {
throw new Error("liquidity must be greater than 0");
}
let tokenEstA = ZERO;
let tokenEstB = ZERO;
const lowerSqrtPrice = PriceMath.tickIndexToSqrtPriceX64(tickLowerIndex);
const upperSqrtPrice = PriceMath.tickIndexToSqrtPriceX64(tickUpperIndex);
const positionStatus = PositionUtil.getStrictPositionStatus(
sqrtPrice,
tickLowerIndex,
tickUpperIndex,
);
if (positionStatus === PositionStatus.BelowRange) {
tokenEstA = getTokenAFromLiquidity(
liquidity,
lowerSqrtPrice,
upperSqrtPrice,
true,
);
} else if (positionStatus === PositionStatus.InRange) {
tokenEstA = getTokenAFromLiquidity(
liquidity,
sqrtPrice,
upperSqrtPrice,
true,
);
tokenEstB = getTokenBFromLiquidity(
liquidity,
lowerSqrtPrice,
sqrtPrice,
true,
);
} else {
tokenEstB = getTokenBFromLiquidity(
liquidity,
lowerSqrtPrice,
upperSqrtPrice,
true,
);
}
return { tokenEstA, tokenEstB };
}
/**
* Get an estimated quote on the maximum tokens required to deposit based on a specified input token amount.
*
* @category Quotes
* @param inputTokenMint - The mint of the input token the user would like to deposit.
* @param inputTokenAmount - The amount of input tokens to deposit.
* @param tickLower - The lower index of the position that we are withdrawing from.
* @param tickUpper - The upper index of the position that we are withdrawing from.
* @param slippageTolerance - The maximum slippage allowed when calculating the minimum tokens received.
* @param whirlpool - A Whirlpool helper class to help interact with the Whirlpool account.
* @returns An IncreaseLiquidityInput object detailing the required token amounts & liquidity values to use when calling increase-liquidity-ix.
*/
export function increaseLiquidityQuoteByInputToken(
inputTokenMint: Address,
inputTokenAmount: Decimal,
tickLower: number,
tickUpper: number,
slippageTolerance: Percentage,
whirlpool: Whirlpool,
tokenExtensionCtx: TokenExtensionContextForPool,
) {
const data = whirlpool.getData();
const tokenAInfo = whirlpool.getTokenAInfo();
const tokenBInfo = whirlpool.getTokenBInfo();
const inputMint = AddressUtil.toPubKey(inputTokenMint);
const inputTokenInfo = inputMint.equals(tokenAInfo.mint)
? tokenAInfo
: tokenBInfo;
return increaseLiquidityQuoteByInputTokenWithParams({
inputTokenMint: inputMint,
inputTokenAmount: DecimalUtil.toBN(
inputTokenAmount,
inputTokenInfo.decimals,
),
tickLowerIndex: TickUtil.getInitializableTickIndex(
tickLower,
data.tickSpacing,
),
tickUpperIndex: TickUtil.getInitializableTickIndex(
tickUpper,
data.tickSpacing,
),
slippageTolerance,
tokenExtensionCtx,
...data,
});
}
/**
* Get an estimated quote on the maximum tokens required to deposit based on a specified input token amount.
*
* @category Quotes
* @param param IncreaseLiquidityQuoteParam
* @returns An IncreaseLiquidityInput object detailing the required token amounts & liquidity values to use when calling increase-liquidity-ix.
*/
export function increaseLiquidityQuoteByInputTokenWithParams(
param: IncreaseLiquidityQuoteParam,
): IncreaseLiquidityQuote {
invariant(
TickUtil.checkTickInBounds(param.tickLowerIndex),
"tickLowerIndex is out of bounds.",
);
invariant(
TickUtil.checkTickInBounds(param.tickUpperIndex),
"tickUpperIndex is out of bounds.",
);
invariant(
param.inputTokenMint.equals(param.tokenMintA) ||
param.inputTokenMint.equals(param.tokenMintB),
`input token mint ${param.inputTokenMint.toBase58()} does not match any tokens in the provided pool.`,
);
const positionStatus = PositionUtil.getStrictPositionStatus(
param.sqrtPrice,
param.tickLowerIndex,
param.tickUpperIndex,
);
switch (positionStatus) {
case PositionStatus.BelowRange:
return quotePositionBelowRange(param);
case PositionStatus.InRange:
return quotePositionInRange(param);
case PositionStatus.AboveRange:
return quotePositionAboveRange(param);
default:
throw new Error(`type ${positionStatus} is an unknown PositionStatus`);
}
}
/**
* @deprecated
*/
function quotePositionBelowRange(
param: IncreaseLiquidityQuoteParam,
): IncreaseLiquidityQuote {
const {
tokenMintA,
inputTokenMint,
inputTokenAmount,
tickLowerIndex,
tickUpperIndex,
tokenExtensionCtx,
slippageTolerance,
} = param;
if (!tokenMintA.equals(inputTokenMint)) {
return {
liquidityAmount: ZERO,
tokenMaxA: ZERO,
tokenMaxB: ZERO,
tokenEstA: ZERO,
tokenEstB: ZERO,
transferFee: {
deductingFromTokenMaxA: ZERO,
deductingFromTokenMaxB: ZERO,
deductingFromTokenEstA: ZERO,
deductingFromTokenEstB: ZERO,
},
};
}
const sqrtPriceLowerX64 = PriceMath.tickIndexToSqrtPriceX64(tickLowerIndex);
const sqrtPriceUpperX64 = PriceMath.tickIndexToSqrtPriceX64(tickUpperIndex);
const transferFeeExcludedInputTokenAmount =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
inputTokenAmount,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
const liquidityAmount = getLiquidityFromTokenA(
transferFeeExcludedInputTokenAmount.amount,
sqrtPriceLowerX64,
sqrtPriceUpperX64,
false,
);
const tokenEstA = getTokenAFromLiquidity(
liquidityAmount,
sqrtPriceLowerX64,
sqrtPriceUpperX64,
true,
);
const tokenMaxA = adjustForSlippage(tokenEstA, slippageTolerance, true);
const tokenMaxAIncluded =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
tokenMaxA,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
const tokenEstAIncluded =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
tokenEstA,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
return {
liquidityAmount,
tokenMaxA: tokenMaxAIncluded.amount,
tokenMaxB: ZERO,
tokenEstA: tokenEstAIncluded.amount,
tokenEstB: ZERO,
transferFee: {
deductingFromTokenMaxA: tokenMaxAIncluded.fee,
deductingFromTokenMaxB: ZERO,
deductingFromTokenEstA: tokenEstAIncluded.fee,
deductingFromTokenEstB: ZERO,
},
};
}
/**
* @deprecated
*/
function quotePositionInRange(
param: IncreaseLiquidityQuoteParam,
): IncreaseLiquidityQuote {
const {
tokenMintA,
tokenMintB,
sqrtPrice,
inputTokenMint,
inputTokenAmount,
tickLowerIndex,
tickUpperIndex,
tokenExtensionCtx,
slippageTolerance,
} = param;
const sqrtPriceX64 = sqrtPrice;
const sqrtPriceLowerX64 = PriceMath.tickIndexToSqrtPriceX64(tickLowerIndex);
const sqrtPriceUpperX64 = PriceMath.tickIndexToSqrtPriceX64(tickUpperIndex);
let tokenEstA: BN;
let tokenEstB: BN;
let liquidityAmount: BN;
if (tokenMintA.equals(inputTokenMint)) {
const transferFeeExcludedInputTokenAmount =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
inputTokenAmount,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
liquidityAmount = getLiquidityFromTokenA(
transferFeeExcludedInputTokenAmount.amount,
sqrtPriceX64,
sqrtPriceUpperX64,
false,
);
tokenEstA = getTokenAFromLiquidity(
liquidityAmount,
sqrtPriceX64,
sqrtPriceUpperX64,
true,
);
tokenEstB = getTokenBFromLiquidity(
liquidityAmount,
sqrtPriceLowerX64,
sqrtPriceX64,
true,
);
} else if (tokenMintB.equals(inputTokenMint)) {
const transferFeeExcludedInputTokenAmount =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
inputTokenAmount,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
liquidityAmount = getLiquidityFromTokenB(
transferFeeExcludedInputTokenAmount.amount,
sqrtPriceLowerX64,
sqrtPriceX64,
false,
);
tokenEstA = getTokenAFromLiquidity(
liquidityAmount,
sqrtPriceX64,
sqrtPriceUpperX64,
true,
);
tokenEstB = getTokenBFromLiquidity(
liquidityAmount,
sqrtPriceLowerX64,
sqrtPriceX64,
true,
);
} else {
throw new Error("invariant violation");
}
const tokenMaxA = adjustForSlippage(tokenEstA, slippageTolerance, true);
const tokenMaxB = adjustForSlippage(tokenEstB, slippageTolerance, true);
const tokenMaxAIncluded =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
tokenMaxA,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
const tokenEstAIncluded =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
tokenEstA,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
const tokenMaxBIncluded =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
tokenMaxB,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
const tokenEstBIncluded =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
tokenEstB,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
return {
liquidityAmount,
tokenMaxA: tokenMaxAIncluded.amount,
tokenMaxB: tokenMaxBIncluded.amount,
tokenEstA: tokenEstAIncluded.amount,
tokenEstB: tokenEstBIncluded.amount,
transferFee: {
deductingFromTokenMaxA: tokenMaxAIncluded.fee,
deductingFromTokenMaxB: tokenMaxBIncluded.fee,
deductingFromTokenEstA: tokenEstAIncluded.fee,
deductingFromTokenEstB: tokenEstBIncluded.fee,
},
};
}
/**
* @deprecated
*/
function quotePositionAboveRange(
param: IncreaseLiquidityQuoteParam,
): IncreaseLiquidityQuote {
const {
tokenMintB,
inputTokenMint,
inputTokenAmount,
tickLowerIndex,
tickUpperIndex,
tokenExtensionCtx,
slippageTolerance,
} = param;
if (!tokenMintB.equals(inputTokenMint)) {
return {
liquidityAmount: ZERO,
tokenMaxA: ZERO,
tokenMaxB: ZERO,
tokenEstA: ZERO,
tokenEstB: ZERO,
transferFee: {
deductingFromTokenMaxA: ZERO,
deductingFromTokenMaxB: ZERO,
deductingFromTokenEstA: ZERO,
deductingFromTokenEstB: ZERO,
},
};
}
const sqrtPriceLowerX64 = PriceMath.tickIndexToSqrtPriceX64(tickLowerIndex);
const sqrtPriceUpperX64 = PriceMath.tickIndexToSqrtPriceX64(tickUpperIndex);
const transferFeeExcludedInputTokenAmount =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
inputTokenAmount,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
const liquidityAmount = getLiquidityFromTokenB(
transferFeeExcludedInputTokenAmount.amount,
sqrtPriceLowerX64,
sqrtPriceUpperX64,
false,
);
const tokenEstB = getTokenBFromLiquidity(
liquidityAmount,
sqrtPriceLowerX64,
sqrtPriceUpperX64,
true,
);
const tokenMaxB = adjustForSlippage(tokenEstB, slippageTolerance, true);
const tokenMaxBIncluded =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
tokenMaxB,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
const tokenEstBIncluded =
TokenExtensionUtil.calculateTransferFeeIncludedAmount(
tokenEstB,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
return {
liquidityAmount,
tokenMaxA: ZERO,
tokenMaxB: tokenMaxBIncluded.amount,
tokenEstA: ZERO,
tokenEstB: tokenEstBIncluded.amount,
transferFee: {
deductingFromTokenMaxA: ZERO,
deductingFromTokenMaxB: tokenMaxBIncluded.fee,
deductingFromTokenEstA: ZERO,
deductingFromTokenEstB: tokenEstBIncluded.fee,
},
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes/public/swap-quote.ts
|
import type { Address } from "@coral-xyz/anchor";
import type { Percentage } from "@orca-so/common-sdk";
import { AddressUtil } from "@orca-so/common-sdk";
import type BN from "bn.js";
import invariant from "tiny-invariant";
import type { SwapInput } from "../../instructions";
import type {
WhirlpoolAccountFetchOptions,
WhirlpoolAccountFetcherInterface,
} from "../../network/public/fetcher";
import { IGNORE_CACHE } from "../../network/public/fetcher";
import type { TickArray, WhirlpoolData } from "../../types/public";
import { TICK_ARRAY_SIZE } from "../../types/public";
import { PoolUtil, SwapDirection } from "../../utils/public";
import { SwapUtils } from "../../utils/public/swap-utils";
import type { Whirlpool } from "../../whirlpool-client";
import { simulateSwap } from "../swap/swap-quote-impl";
import type { DevFeeSwapQuote } from "./dev-fee-swap-quote";
import type { TokenExtensionContextForPool } from "../../utils/public/token-extension-util";
import { TokenExtensionUtil } from "../../utils/public/token-extension-util";
import { PublicKey } from "@solana/web3.js";
/**
* An enum to specify when to use fallback tick array in a swap quote.
* @category Quotes
*/
export enum UseFallbackTickArray {
// Always try to include fallback tick array in the swap quote
Always = "Always",
// Never include fallback tick array in the swap quote
Never = "Never",
// Use fallback tick array only when tickCurrentIndex is the edge (last quoter) of the first tick array
Situational = "Situational",
}
/**
* @category Quotes
*
* @param tokenAmount - The amount of input or output token to swap from (depending on amountSpecifiedIsInput).
* @param otherAmountThreshold - The maximum/minimum of input/output token to swap into (depending on amountSpecifiedIsInput).
* @param sqrtPriceLimit - The maximum/minimum price the swap will swap to.
* @param aToB - The direction of the swap. True if swapping from A to B. False if swapping from B to A.
* @param amountSpecifiedIsInput - Specifies the token the parameter `amount`represents. If true, the amount represents
* the input token of the swap.
* @param tickArrays - An sequential array of tick-array objects in the direction of the trade to swap on
* @param tokenExtensionCtx - TokenExtensions info for the whirlpool
* @param fallbackTickArray - Optional. A reserve in case prices move in the opposite direction
*/
export type SwapQuoteParam = {
whirlpoolData: WhirlpoolData;
tokenAmount: BN;
otherAmountThreshold: BN;
sqrtPriceLimit: BN;
aToB: boolean;
amountSpecifiedIsInput: boolean;
tickArrays: TickArray[];
tokenExtensionCtx: TokenExtensionContextForPool;
fallbackTickArray?: PublicKey;
};
/**
* A collection of estimated values from quoting a swap.
* @category Quotes
* @link {BaseSwapQuote}
* @link {DevFeeSwapQuote}
*/
export type SwapQuote = NormalSwapQuote | DevFeeSwapQuote;
/**
* A collection of estimated values from quoting a swap.
* @category Quotes
* @param estimatedAmountIn - Approximate number of input token swapped in the swap
* @param estimatedAmountOut - Approximate number of output token swapped in the swap
* @param estimatedEndTickIndex - Approximate tick-index the Whirlpool will land on after this swap
* @param estimatedEndSqrtPrice - Approximate sqrtPrice the Whirlpool will land on after this swap
* @param estimatedFeeAmount - Approximate feeAmount (all fees) charged on this swap
*/
export type SwapEstimates = {
estimatedAmountIn: BN;
estimatedAmountOut: BN;
estimatedEndTickIndex: number;
estimatedEndSqrtPrice: BN;
estimatedFeeAmount: BN;
transferFee: {
deductingFromEstimatedAmountIn: BN;
deductedFromEstimatedAmountOut: BN;
};
};
/**
* A collection of estimated values from quoting a swap. Object can be directly used in a swap transaction.
* @category Quotes
*/
export type NormalSwapQuote = SwapInput & SwapEstimates;
/**
* Get an estimated swap quote using input token amount.
*
* @category Quotes
* @param whirlpool - Whirlpool to perform the swap on
* @param inputTokenMint - PublicKey for the input token mint to swap with
* @param tokenAmount - The amount of input token to swap from
* @param slippageTolerance - The amount of slippage to account for in this quote
* @param programId - PublicKey for the Whirlpool ProgramId
* @param cache - WhirlpoolAccountCacheInterface instance object to fetch solana accounts
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @param useFallbackTickArray - An enum to specify when to use fallback tick array in a swap quote.
* @returns a SwapQuote object with slippage adjusted SwapInput parameters & estimates on token amounts, fee & end whirlpool states.
*/
export async function swapQuoteByInputToken(
whirlpool: Whirlpool,
inputTokenMint: Address,
tokenAmount: BN,
slippageTolerance: Percentage,
programId: Address,
fetcher: WhirlpoolAccountFetcherInterface,
opts?: WhirlpoolAccountFetchOptions,
useFallbackTickArray: UseFallbackTickArray = UseFallbackTickArray.Never,
): Promise<SwapQuote> {
const params = await swapQuoteByToken(
whirlpool,
inputTokenMint,
tokenAmount,
true,
useFallbackTickArray,
programId,
fetcher,
opts,
);
return swapQuoteWithParams(params, slippageTolerance);
}
/**
* Get an estimated swap quote using an output token amount.
*
* Use this quote to get an estimated amount of input token needed to receive
* the defined output token amount.
*
* @category Quotes
* @param whirlpool - Whirlpool to perform the swap on
* @param outputTokenMint - PublicKey for the output token mint to swap into
* @param tokenAmount - The maximum amount of output token to receive in this swap.
* @param slippageTolerance - The amount of slippage to account for in this quote
* @param programId - PublicKey for the Whirlpool ProgramId
* @param cache - WhirlpoolAccountCacheInterface instance to fetch solana accounts
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @param useFallbackTickArray - An enum to specify when to use fallback tick array in a swap quote.
* @returns a SwapQuote object with slippage adjusted SwapInput parameters & estimates on token amounts, fee & end whirlpool states.
*/
export async function swapQuoteByOutputToken(
whirlpool: Whirlpool,
outputTokenMint: Address,
tokenAmount: BN,
slippageTolerance: Percentage,
programId: Address,
fetcher: WhirlpoolAccountFetcherInterface,
opts?: WhirlpoolAccountFetchOptions,
useFallbackTickArray: UseFallbackTickArray = UseFallbackTickArray.Never,
): Promise<SwapQuote> {
const params = await swapQuoteByToken(
whirlpool,
outputTokenMint,
tokenAmount,
false,
useFallbackTickArray,
programId,
fetcher,
opts,
);
return swapQuoteWithParams(params, slippageTolerance);
}
/**
* Perform a sync swap quote based on the basic swap instruction parameters.
*
* @category Quotes
* @param params - SwapQuote parameters
* @param slippageTolerance - The amount of slippage to account for when generating the final quote.
* @returns a SwapQuote object with slippage adjusted SwapInput parameters & estimates on token amounts, fee & end whirlpool states.
*/
export function swapQuoteWithParams(
params: SwapQuoteParam,
slippageTolerance: Percentage,
): SwapQuote {
const quote = simulateSwap({
...params,
tickArrays: SwapUtils.interpolateUninitializedTickArrays(
PublicKey.default,
params.tickArrays,
),
});
if (params.fallbackTickArray) {
if (quote.tickArray2.equals(quote.tickArray1)) {
// both V1 and V2 can use this fallback
quote.tickArray2 = params.fallbackTickArray;
} else {
// no obvious room for fallback, but V2 can use this field
quote.supplementalTickArrays = [params.fallbackTickArray];
}
}
const slippageAdjustedQuote: SwapQuote = {
...quote,
...SwapUtils.calculateSwapAmountsFromQuote(
quote.amount,
quote.estimatedAmountIn,
quote.estimatedAmountOut,
slippageTolerance,
quote.amountSpecifiedIsInput,
),
};
return slippageAdjustedQuote;
}
async function swapQuoteByToken(
whirlpool: Whirlpool,
inputTokenMint: Address,
tokenAmount: BN,
amountSpecifiedIsInput: boolean,
useFallbackTickArray: UseFallbackTickArray,
programId: Address,
fetcher: WhirlpoolAccountFetcherInterface,
opts?: WhirlpoolAccountFetchOptions,
): Promise<SwapQuoteParam> {
// If we use whirlpool.getData() here, quote will not be the latest even if opts is IGNORE_CACHE
const whirlpoolData = await fetcher.getPool(whirlpool.getAddress(), opts);
invariant(!!whirlpoolData, "Whirlpool data not found");
const swapMintKey = AddressUtil.toPubKey(inputTokenMint);
const swapTokenType = PoolUtil.getTokenType(whirlpoolData, swapMintKey);
invariant(
!!swapTokenType,
"swapTokenMint does not match any tokens on this pool",
);
const aToB =
SwapUtils.getSwapDirection(
whirlpoolData,
swapMintKey,
amountSpecifiedIsInput,
) === SwapDirection.AtoB;
const tickArrays = await SwapUtils.getTickArrays(
whirlpoolData.tickCurrentIndex,
whirlpoolData.tickSpacing,
aToB,
AddressUtil.toPubKey(programId),
whirlpool.getAddress(),
fetcher,
opts,
);
const fallbackTickArray = getFallbackTickArray(
useFallbackTickArray,
tickArrays,
aToB,
whirlpool,
programId,
);
const tokenExtensionCtx = await TokenExtensionUtil.buildTokenExtensionContext(
fetcher,
whirlpoolData,
IGNORE_CACHE,
);
return {
whirlpoolData,
tokenAmount,
aToB,
amountSpecifiedIsInput,
sqrtPriceLimit: SwapUtils.getDefaultSqrtPriceLimit(aToB),
otherAmountThreshold: SwapUtils.getDefaultOtherAmountThreshold(
amountSpecifiedIsInput,
),
tickArrays,
tokenExtensionCtx,
fallbackTickArray,
};
}
function getFallbackTickArray(
useFallbackTickArray: UseFallbackTickArray,
tickArrays: TickArray[],
aToB: boolean,
whirlpool: Whirlpool,
programId: Address,
): PublicKey | undefined {
if (useFallbackTickArray === UseFallbackTickArray.Never) {
return undefined;
}
const fallbackTickArray = SwapUtils.getFallbackTickArrayPublicKey(
tickArrays,
whirlpool.getData().tickSpacing,
aToB,
AddressUtil.toPubKey(programId),
whirlpool.getAddress(),
);
if (
useFallbackTickArray === UseFallbackTickArray.Always ||
!fallbackTickArray
) {
return fallbackTickArray;
}
invariant(
useFallbackTickArray === UseFallbackTickArray.Situational,
`Unexpected UseFallbackTickArray value: ${useFallbackTickArray}`,
);
const ticksInArray = whirlpool.getData().tickSpacing * TICK_ARRAY_SIZE;
const tickCurrentIndex = whirlpool.getData().tickCurrentIndex;
if (aToB) {
// A to B (direction is right to left): [ ta2 ][ ta1 ][ ta0 ===]
// if tickCurrentIndex is within the rightmost quarter of ta0, use fallbackTickArray
const threshold = tickArrays[0].startTickIndex + (ticksInArray / 4) * 3;
return tickCurrentIndex >= threshold ? fallbackTickArray : undefined;
} else {
// B to A (direction is left to right): [=== ta0 ][ ta1 ][ ta2 ]
// if tickCurrentIndex is within the leftmost quarter of ta0, use fallbackTickArray
const threshold = tickArrays[0].startTickIndex + ticksInArray / 4;
return tickCurrentIndex <= threshold ? fallbackTickArray : undefined;
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes/public/decrease-liquidity-quote.ts
|
import { BN } from "@coral-xyz/anchor";
import type { Percentage } from "@orca-so/common-sdk";
import { ZERO } from "@orca-so/common-sdk";
import invariant from "tiny-invariant";
import type { DecreaseLiquidityInput } from "../../instructions";
import {
PositionStatus,
PositionUtil,
adjustForSlippage,
getTokenAFromLiquidity,
getTokenBFromLiquidity,
} from "../../utils/position-util";
import { PriceMath, TickUtil } from "../../utils/public";
import type { TokenExtensionContextForPool } from "../../utils/public/token-extension-util";
import { TokenExtensionUtil } from "../../utils/public/token-extension-util";
import type { Position, Whirlpool } from "../../whirlpool-client";
/**
* @category Quotes
* @param liquidity - The desired liquidity to withdraw from the Whirlpool
* @param tickCurrentIndex - The Whirlpool's current tickIndex
* @param sqrtPrice - The Whirlpool's current sqrtPrice
* @param tickLowerIndex - The lower index of the position that we are withdrawing from.
* @param tickUpperIndex - The upper index of the position that we are withdrawing from.
* @param slippageTolerance - The maximum slippage allowed when calculating the minimum tokens received.
*/
export type DecreaseLiquidityQuoteParam = {
liquidity: BN;
tickCurrentIndex: number;
sqrtPrice: BN;
tickLowerIndex: number;
tickUpperIndex: number;
tokenExtensionCtx: TokenExtensionContextForPool;
slippageTolerance: Percentage;
};
/**
* Return object from decrease liquidity quote functions.
* @category Quotes
*/
export type DecreaseLiquidityQuote = DecreaseLiquidityInput & {
tokenEstA: BN;
tokenEstB: BN;
transferFee: {
deductedFromTokenEstA: BN;
deductedFromTokenEstB: BN;
deductedFromTokenMinA: BN;
deductedFromTokenMinB: BN;
};
};
/**
* Get an estimated quote on the minimum tokens receivable based on the desired withdraw liquidity value.
*
* @category Quotes
* @param liquidity - The desired liquidity to withdraw from the Whirlpool
* @param slippageTolerance - The maximum slippage allowed when calculating the minimum tokens received.
* @param position - A Position helper class to help interact with the Position account.
* @param whirlpool - A Whirlpool helper class to help interact with the Whirlpool account.
* @returns An DecreaseLiquidityQuote object detailing the tokenMin & liquidity values to use when calling decrease-liquidity-ix.
*/
export function decreaseLiquidityQuoteByLiquidity(
liquidity: BN,
slippageTolerance: Percentage,
position: Position,
whirlpool: Whirlpool,
tokenExtensionCtx: TokenExtensionContextForPool,
) {
const positionData = position.getData();
const whirlpoolData = whirlpool.getData();
invariant(
liquidity.lte(positionData.liquidity),
"Quote liquidity is more than the position liquidity.",
);
return decreaseLiquidityQuoteByLiquidityWithParams({
liquidity,
slippageTolerance,
tickLowerIndex: positionData.tickLowerIndex,
tickUpperIndex: positionData.tickUpperIndex,
sqrtPrice: whirlpoolData.sqrtPrice,
tickCurrentIndex: whirlpoolData.tickCurrentIndex,
tokenExtensionCtx,
});
}
/**
* Get an estimated quote on the minimum tokens receivable based on the desired withdraw liquidity value.
*
* @category Quotes
* @param param DecreaseLiquidityQuoteParam
* @returns An DecreaseLiquidityInput object detailing the tokenMin & liquidity values to use when calling decrease-liquidity-ix.
*/
export function decreaseLiquidityQuoteByLiquidityWithParams(
params: DecreaseLiquidityQuoteParam,
): DecreaseLiquidityQuote {
invariant(
TickUtil.checkTickInBounds(params.tickLowerIndex),
"tickLowerIndex is out of bounds.",
);
invariant(
TickUtil.checkTickInBounds(params.tickUpperIndex),
"tickUpperIndex is out of bounds.",
);
invariant(
TickUtil.checkTickInBounds(params.tickCurrentIndex),
"tickCurrentIndex is out of bounds.",
);
if (params.liquidity.eq(ZERO)) {
return {
tokenMinA: ZERO,
tokenMinB: ZERO,
liquidityAmount: ZERO,
tokenEstA: ZERO,
tokenEstB: ZERO,
transferFee: {
deductedFromTokenMinA: ZERO,
deductedFromTokenMinB: ZERO,
deductedFromTokenEstA: ZERO,
deductedFromTokenEstB: ZERO,
},
};
}
const { tokenExtensionCtx } = params;
const { tokenEstA, tokenEstB } = getTokenEstimatesFromLiquidity(params);
const [tokenMinA, tokenMinB] = [tokenEstA, tokenEstB].map((tokenEst) =>
adjustForSlippage(tokenEst, params.slippageTolerance, false),
);
const tokenMinAExcluded =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
tokenMinA,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
const tokenEstAExcluded =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
tokenEstA,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
const tokenMinBExcluded =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
tokenMinB,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
const tokenEstBExcluded =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
tokenEstB,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
return {
tokenMinA: tokenMinAExcluded.amount,
tokenMinB: tokenMinBExcluded.amount,
tokenEstA: tokenEstAExcluded.amount,
tokenEstB: tokenEstBExcluded.amount,
liquidityAmount: params.liquidity,
transferFee: {
deductedFromTokenMinA: tokenMinAExcluded.fee,
deductedFromTokenMinB: tokenMinBExcluded.fee,
deductedFromTokenEstA: tokenEstAExcluded.fee,
deductedFromTokenEstB: tokenEstBExcluded.fee,
},
};
}
/**
* Get an estimated quote on the minimum tokens receivable based on the desired withdraw liquidity value.
* This version calculates slippage based on price percentage movement, rather than setting the percentage threshold based on token estimates.
* @param params DecreaseLiquidityQuoteParam
* @returns A DecreaseLiquidityQuote object detailing the tokenMin & liquidity values to use when calling decrease-liquidity-ix.
*/
export function decreaseLiquidityQuoteByLiquidityWithParamsUsingPriceSlippage(
params: DecreaseLiquidityQuoteParam,
): DecreaseLiquidityQuote {
const { tokenExtensionCtx } = params;
if (params.liquidity.eq(ZERO)) {
return {
tokenMinA: ZERO,
tokenMinB: ZERO,
liquidityAmount: ZERO,
tokenEstA: ZERO,
tokenEstB: ZERO,
transferFee: {
deductedFromTokenMinA: ZERO,
deductedFromTokenMinB: ZERO,
deductedFromTokenEstA: ZERO,
deductedFromTokenEstB: ZERO,
},
};
}
const { tokenEstA, tokenEstB } = getTokenEstimatesFromLiquidity(params);
const {
lowerBound: [sLowerSqrtPrice, sLowerIndex],
upperBound: [sUpperSqrtPrice, sUpperIndex],
} = PriceMath.getSlippageBoundForSqrtPrice(
params.sqrtPrice,
params.slippageTolerance,
);
const { tokenEstA: tokenEstALower, tokenEstB: tokenEstBLower } =
getTokenEstimatesFromLiquidity({
...params,
sqrtPrice: sLowerSqrtPrice,
tickCurrentIndex: sLowerIndex,
});
const { tokenEstA: tokenEstAUpper, tokenEstB: tokenEstBUpper } =
getTokenEstimatesFromLiquidity({
...params,
sqrtPrice: sUpperSqrtPrice,
tickCurrentIndex: sUpperIndex,
});
const tokenMinA = BN.min(BN.min(tokenEstA, tokenEstALower), tokenEstAUpper);
const tokenMinB = BN.min(BN.min(tokenEstB, tokenEstBLower), tokenEstBUpper);
const tokenMinAExcluded =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
tokenMinA,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
const tokenEstAExcluded =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
tokenEstA,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
const tokenMinBExcluded =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
tokenMinB,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
const tokenEstBExcluded =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
tokenEstB,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
return {
tokenMinA: tokenMinAExcluded.amount,
tokenMinB: tokenMinBExcluded.amount,
tokenEstA: tokenEstAExcluded.amount,
tokenEstB: tokenEstBExcluded.amount,
liquidityAmount: params.liquidity,
transferFee: {
deductedFromTokenMinA: tokenMinAExcluded.fee,
deductedFromTokenMinB: tokenMinBExcluded.fee,
deductedFromTokenEstA: tokenEstAExcluded.fee,
deductedFromTokenEstB: tokenEstBExcluded.fee,
},
};
}
function getTokenEstimatesFromLiquidity(params: DecreaseLiquidityQuoteParam) {
const { liquidity, tickLowerIndex, tickUpperIndex, sqrtPrice } = params;
if (liquidity.eq(ZERO)) {
throw new Error("liquidity must be greater than 0");
}
let tokenEstA = ZERO;
let tokenEstB = ZERO;
const lowerSqrtPrice = PriceMath.tickIndexToSqrtPriceX64(tickLowerIndex);
const upperSqrtPrice = PriceMath.tickIndexToSqrtPriceX64(tickUpperIndex);
const positionStatus = PositionUtil.getStrictPositionStatus(
sqrtPrice,
tickLowerIndex,
tickUpperIndex,
);
if (positionStatus === PositionStatus.BelowRange) {
tokenEstA = getTokenAFromLiquidity(
liquidity,
lowerSqrtPrice,
upperSqrtPrice,
false,
);
} else if (positionStatus === PositionStatus.InRange) {
tokenEstA = getTokenAFromLiquidity(
liquidity,
sqrtPrice,
upperSqrtPrice,
false,
);
tokenEstB = getTokenBFromLiquidity(
liquidity,
lowerSqrtPrice,
sqrtPrice,
false,
);
} else {
tokenEstB = getTokenBFromLiquidity(
liquidity,
lowerSqrtPrice,
upperSqrtPrice,
false,
);
}
return { tokenEstA, tokenEstB };
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes/public/two-hop-swap-quote.ts
|
import type { TwoHopSwapInput } from "../../instructions";
import type { SwapEstimates, SwapQuote } from "./swap-quote";
/**
* A collection of estimated values from quoting a swap.
* @category Quotes
* @link {NormalTwoHopSwapQuote}
* @experimental Not yet ready for use
*/
export type TwoHopSwapQuote = NormalTwoHopSwapQuote; // TODO dev swap
/**
* A collection of estimated values from quoting a two-hop-swap.
* @category Quotes
* @param swapOneEstimates - Estimates for the first leg of the two-hop-swap
* @param swapTwoEstimates - Estimates for the second leg of the two-hop-swap
* @experimental Not yet ready for use
*/
export type NormalTwoHopSwapQuote = {
swapOneEstimates: SwapEstimates;
swapTwoEstimates: SwapEstimates;
} & TwoHopSwapInput;
/**
* Convert two individual swaps into a quote estimate
* @category Quotes
* @experimental Not yet ready for use
*/
export function twoHopSwapQuoteFromSwapQuotes(
swapQuoteOne: SwapQuote,
swapQuoteTwo: SwapQuote,
): TwoHopSwapQuote {
const amountSpecifiedIsInput = swapQuoteOne.amountSpecifiedIsInput;
// If amount specified is input, then we care about input of the first swap
// otherwise we care about output of the second swap
let [amount, otherAmountThreshold] = amountSpecifiedIsInput
? [swapQuoteOne.amount, swapQuoteTwo.otherAmountThreshold]
: [swapQuoteTwo.amount, swapQuoteOne.otherAmountThreshold];
return {
amount,
otherAmountThreshold,
amountSpecifiedIsInput,
aToBOne: swapQuoteOne.aToB,
aToBTwo: swapQuoteTwo.aToB,
sqrtPriceLimitOne: swapQuoteOne.sqrtPriceLimit,
sqrtPriceLimitTwo: swapQuoteTwo.sqrtPriceLimit,
tickArrayOne0: swapQuoteOne.tickArray0,
tickArrayOne1: swapQuoteOne.tickArray1,
tickArrayOne2: swapQuoteOne.tickArray2,
tickArrayTwo0: swapQuoteTwo.tickArray0,
tickArrayTwo1: swapQuoteTwo.tickArray1,
tickArrayTwo2: swapQuoteTwo.tickArray2,
supplementalTickArraysOne: swapQuoteOne.supplementalTickArrays,
supplementalTickArraysTwo: swapQuoteTwo.supplementalTickArrays,
swapOneEstimates: { ...swapQuoteOne },
swapTwoEstimates: { ...swapQuoteTwo },
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes/public/dev-fee-swap-quote.ts
|
import type { Address } from "@coral-xyz/anchor";
import type { Percentage } from "@orca-so/common-sdk";
import type BN from "bn.js";
import { SwapErrorCode, WhirlpoolsError } from "../../errors/errors";
import type {
WhirlpoolAccountFetchOptions,
WhirlpoolAccountFetcherInterface,
} from "../../network/public/fetcher";
import type { Whirlpool } from "../../whirlpool-client";
import type { NormalSwapQuote } from "./swap-quote";
import { swapQuoteByInputToken } from "./swap-quote";
/**
* A collection of estimated values from quoting a swap that collects a developer-fee.
* @category Quotes
* @param estimatedAmountIn - Approximate number of input token swapped in the swap
* @param estimatedAmountOut - Approximate number of output token swapped in the swap
* @param estimatedEndTickIndex - Approximate tick-index the Whirlpool will land on after this swap
* @param estimatedEndSqrtPrice - Approximate sqrtPrice the Whirlpool will land on after this swap
* @param estimatedFeeAmount - Approximate feeAmount (all fees) charged on this swap
* @param estimatedSwapFeeAmount - Approximate feeAmount (LP + protocol fees) charged on this swap
* @param devFeeAmount - FeeAmount (developer fees) charged on this swap
*/
export type DevFeeSwapQuote = NormalSwapQuote & {
// NOTE: DevFeeSwaps supports input-token based swaps only as it is difficult
// to collect an exact % amount of dev-fees for output-token based swaps due to slippage.
// If there are third party requests in the future for this functionality, we can launch it
// but with the caveat that the % collected is only an estimate.
amountSpecifiedIsInput: true;
estimatedSwapFeeAmount: BN;
devFeeAmount: BN;
};
/**
* Get an estimated swap quote using input token amount while collecting dev fees.
*
* @category Quotes
* @param whirlpool - Whirlpool to perform the swap on
* @param inputTokenMint - PublicKey for the input token mint to swap with
* @param tokenAmount - The amount of input token to swap from
* @param slippageTolerance - The amount of slippage to account for in this quote
* @param programId - PublicKey for the Whirlpool ProgramId
* @param cache - WhirlpoolAccountCacheInterface instance to fetch solana accounts
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @param devFeePercentage - The percentage amount to send to developer wallet prior to the swap. Percentage num/dem values has to match token decimal.
* @returns a SwapQuote object with slippage adjusted SwapInput parameters & estimates on token amounts, fee & end whirlpool states.
*/
export async function swapQuoteByInputTokenWithDevFees(
whirlpool: Whirlpool,
inputTokenMint: Address,
tokenAmount: BN,
slippageTolerance: Percentage,
programId: Address,
fetcher: WhirlpoolAccountFetcherInterface,
devFeePercentage: Percentage,
opts?: WhirlpoolAccountFetchOptions,
): Promise<DevFeeSwapQuote> {
if (devFeePercentage.toDecimal().greaterThanOrEqualTo(1)) {
throw new WhirlpoolsError(
"Provided devFeePercentage must be less than 100%",
SwapErrorCode.InvalidDevFeePercentage,
);
}
const devFeeAmount = tokenAmount
.mul(devFeePercentage.numerator)
.div(devFeePercentage.denominator);
const slippageAdjustedQuote = await swapQuoteByInputToken(
whirlpool,
inputTokenMint,
tokenAmount.sub(devFeeAmount),
slippageTolerance,
programId,
fetcher,
opts,
);
const devFeeAdjustedQuote: DevFeeSwapQuote = {
...slippageAdjustedQuote,
amountSpecifiedIsInput: true,
estimatedAmountIn:
slippageAdjustedQuote.estimatedAmountIn.add(devFeeAmount),
estimatedFeeAmount:
slippageAdjustedQuote.estimatedFeeAmount.add(devFeeAmount),
estimatedSwapFeeAmount: slippageAdjustedQuote.estimatedFeeAmount,
devFeeAmount,
};
return devFeeAdjustedQuote;
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes/public/collect-fees-quote.ts
|
import type { BN } from "@coral-xyz/anchor";
import { MathUtil } from "@orca-so/common-sdk";
import type { PositionData, TickData, WhirlpoolData } from "../../types/public";
import type { TokenExtensionContextForPool } from "../../utils/public/token-extension-util";
import { TokenExtensionUtil } from "../../utils/public/token-extension-util";
/**
* @category Quotes
*/
export type CollectFeesQuoteParam = {
whirlpool: WhirlpoolData;
position: PositionData;
tickLower: TickData;
tickUpper: TickData;
tokenExtensionCtx: TokenExtensionContextForPool;
};
/**
* @category Quotes
*/
export type CollectFeesQuote = {
feeOwedA: BN;
feeOwedB: BN;
transferFee: {
deductedFromFeeOwedA: BN;
deductedFromFeeOwedB: BN;
};
};
/**
* Get a quote on the outstanding fees owed to a position.
*
* @category Quotes
* @param param A collection of fetched Whirlpool accounts to faciliate the quote.
* @returns A quote object containing the fees owed for each token in the pool.
*/
export function collectFeesQuote(
param: CollectFeesQuoteParam,
): CollectFeesQuote {
const { whirlpool, position, tickLower, tickUpper, tokenExtensionCtx } =
param;
const {
tickCurrentIndex,
feeGrowthGlobalA: feeGrowthGlobalAX64,
feeGrowthGlobalB: feeGrowthGlobalBX64,
} = whirlpool;
const {
tickLowerIndex,
tickUpperIndex,
liquidity,
feeOwedA,
feeOwedB,
feeGrowthCheckpointA: feeGrowthCheckpointAX64,
feeGrowthCheckpointB: feeGrowthCheckpointBX64,
} = position;
const {
feeGrowthOutsideA: tickLowerFeeGrowthOutsideAX64,
feeGrowthOutsideB: tickLowerFeeGrowthOutsideBX64,
} = tickLower;
const {
feeGrowthOutsideA: tickUpperFeeGrowthOutsideAX64,
feeGrowthOutsideB: tickUpperFeeGrowthOutsideBX64,
} = tickUpper;
// Calculate the fee growths inside the position
let feeGrowthBelowAX64: BN | null = null;
let feeGrowthBelowBX64: BN | null = null;
if (tickCurrentIndex < tickLowerIndex) {
feeGrowthBelowAX64 = MathUtil.subUnderflowU128(
feeGrowthGlobalAX64,
tickLowerFeeGrowthOutsideAX64,
);
feeGrowthBelowBX64 = MathUtil.subUnderflowU128(
feeGrowthGlobalBX64,
tickLowerFeeGrowthOutsideBX64,
);
} else {
feeGrowthBelowAX64 = tickLowerFeeGrowthOutsideAX64;
feeGrowthBelowBX64 = tickLowerFeeGrowthOutsideBX64;
}
let feeGrowthAboveAX64: BN | null = null;
let feeGrowthAboveBX64: BN | null = null;
if (tickCurrentIndex < tickUpperIndex) {
feeGrowthAboveAX64 = tickUpperFeeGrowthOutsideAX64;
feeGrowthAboveBX64 = tickUpperFeeGrowthOutsideBX64;
} else {
feeGrowthAboveAX64 = MathUtil.subUnderflowU128(
feeGrowthGlobalAX64,
tickUpperFeeGrowthOutsideAX64,
);
feeGrowthAboveBX64 = MathUtil.subUnderflowU128(
feeGrowthGlobalBX64,
tickUpperFeeGrowthOutsideBX64,
);
}
const feeGrowthInsideAX64 = MathUtil.subUnderflowU128(
MathUtil.subUnderflowU128(feeGrowthGlobalAX64, feeGrowthBelowAX64),
feeGrowthAboveAX64,
);
const feeGrowthInsideBX64 = MathUtil.subUnderflowU128(
MathUtil.subUnderflowU128(feeGrowthGlobalBX64, feeGrowthBelowBX64),
feeGrowthAboveBX64,
);
// Calculate the updated fees owed
const feeOwedADelta = MathUtil.subUnderflowU128(
feeGrowthInsideAX64,
feeGrowthCheckpointAX64,
)
.mul(liquidity)
.shrn(64);
const feeOwedBDelta = MathUtil.subUnderflowU128(
feeGrowthInsideBX64,
feeGrowthCheckpointBX64,
)
.mul(liquidity)
.shrn(64);
const updatedFeeOwedA = feeOwedA.add(feeOwedADelta);
const transferFeeExcludedAmountA =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
updatedFeeOwedA,
tokenExtensionCtx.tokenMintWithProgramA,
tokenExtensionCtx.currentEpoch,
);
const updatedFeeOwedB = feeOwedB.add(feeOwedBDelta);
const transferFeeExcludedAmountB =
TokenExtensionUtil.calculateTransferFeeExcludedAmount(
updatedFeeOwedB,
tokenExtensionCtx.tokenMintWithProgramB,
tokenExtensionCtx.currentEpoch,
);
return {
feeOwedA: transferFeeExcludedAmountA.amount,
feeOwedB: transferFeeExcludedAmountB.amount,
transferFee: {
deductedFromFeeOwedA: transferFeeExcludedAmountA.fee,
deductedFromFeeOwedB: transferFeeExcludedAmountB.fee,
},
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/quotes/public/index.ts
|
export * from "./increase-liquidity-quote";
export * from "./decrease-liquidity-quote";
export * from "./collect-fees-quote";
export * from "./collect-rewards-quote";
export * from "./swap-quote";
export * from "./dev-fee-swap-quote";
export * from "./two-hop-swap-quote";
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/network
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/network/public/index.ts
|
export * from "./fetcher";
export * from "./parsing";
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/network
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/network/public/parsing.ts
|
import type { Idl } from "@coral-xyz/anchor";
import { BorshAccountsCoder } from "@coral-xyz/anchor";
import type { ParsableEntity } from "@orca-so/common-sdk";
import { staticImplements } from "@orca-so/common-sdk";
import type { AccountInfo, PublicKey } from "@solana/web3.js";
import * as WhirlpoolIDL from "../../artifacts/whirlpool.json";
import type {
FeeTierData,
PositionBundleData,
PositionData,
TickArrayData,
TokenBadgeData,
WhirlpoolData,
WhirlpoolsConfigData,
WhirlpoolsConfigExtensionData,
} from "../../types/public";
import { AccountName } from "../../types/public";
/**
* @category Network
*/
@staticImplements<ParsableEntity<WhirlpoolsConfigData>>()
export class ParsableWhirlpoolsConfig {
public static parse(
address: PublicKey,
accountData: AccountInfo<Buffer> | undefined | null,
): WhirlpoolsConfigData | null {
if (!accountData?.data) {
return null;
}
try {
return parseAnchorAccount(AccountName.WhirlpoolsConfig, accountData);
} catch (e) {
console.error(`error while parsing WhirlpoolsConfig: ${e}`);
return null;
}
}
}
/**
* @category Network
*/
@staticImplements<ParsableEntity<WhirlpoolData>>()
export class ParsableWhirlpool {
public static parse(
address: PublicKey,
accountData: AccountInfo<Buffer> | undefined | null,
): WhirlpoolData | null {
if (!accountData?.data) {
return null;
}
try {
return parseAnchorAccount(AccountName.Whirlpool, accountData);
} catch (e) {
console.error(`error while parsing Whirlpool: ${e}`);
return null;
}
}
}
/**
* @category Network
*/
@staticImplements<ParsableEntity<PositionData>>()
export class ParsablePosition {
public static parse(
address: PublicKey,
accountData: AccountInfo<Buffer> | undefined | null,
): PositionData | null {
if (!accountData?.data) {
return null;
}
try {
return parseAnchorAccount(AccountName.Position, accountData);
} catch (e) {
console.error(`error while parsing Position: ${e}`);
return null;
}
}
}
/**
* @category Network
*/
@staticImplements<ParsableEntity<TickArrayData>>()
export class ParsableTickArray {
public static parse(
address: PublicKey,
accountData: AccountInfo<Buffer> | undefined | null,
): TickArrayData | null {
if (!accountData?.data) {
return null;
}
try {
return parseAnchorAccount(AccountName.TickArray, accountData);
} catch (e) {
console.error(`error while parsing TickArray: ${e}`);
return null;
}
}
}
/**
* @category Network
*/
@staticImplements<ParsableEntity<FeeTierData>>()
export class ParsableFeeTier {
public static parse(
address: PublicKey,
accountData: AccountInfo<Buffer> | undefined | null,
): FeeTierData | null {
if (!accountData?.data) {
return null;
}
try {
return parseAnchorAccount(AccountName.FeeTier, accountData);
} catch (e) {
console.error(`error while parsing FeeTier: ${e}`);
return null;
}
}
}
/**
* @category Network
*/
@staticImplements<ParsableEntity<PositionBundleData>>()
export class ParsablePositionBundle {
public static parse(
address: PublicKey,
accountData: AccountInfo<Buffer> | undefined | null,
): PositionBundleData | null {
if (!accountData?.data) {
return null;
}
try {
return parseAnchorAccount(AccountName.PositionBundle, accountData);
} catch (e) {
console.error(`error while parsing PositionBundle: ${e}`);
return null;
}
}
}
/**
* @category Network
*/
@staticImplements<ParsableEntity<WhirlpoolsConfigExtensionData>>()
export class ParsableWhirlpoolsConfigExtension {
public static parse(
address: PublicKey,
accountData: AccountInfo<Buffer> | undefined | null,
): WhirlpoolsConfigExtensionData | null {
if (!accountData?.data) {
return null;
}
try {
return parseAnchorAccount(
AccountName.WhirlpoolsConfigExtension,
accountData,
);
} catch (e) {
console.error(`error while parsing WhirlpoolsConfigExtension: ${e}`);
return null;
}
}
}
/**
* @category Network
*/
@staticImplements<ParsableEntity<TokenBadgeData>>()
export class ParsableTokenBadge {
public static parse(
address: PublicKey,
accountData: AccountInfo<Buffer> | undefined | null,
): TokenBadgeData | null {
if (!accountData?.data) {
return null;
}
try {
return parseAnchorAccount(AccountName.TokenBadge, accountData);
} catch (e) {
console.error(`error while parsing TokenBadge: ${e}`);
return null;
}
}
}
const WhirlpoolCoder = new BorshAccountsCoder(WhirlpoolIDL as Idl);
function parseAnchorAccount(
accountName: AccountName,
accountData: AccountInfo<Buffer>,
) {
const data = accountData.data;
const discriminator = BorshAccountsCoder.accountDiscriminator(accountName);
if (discriminator.compare(data.slice(0, 8))) {
console.error("incorrect account name during parsing");
return null;
}
try {
return WhirlpoolCoder.decode(accountName, data);
} catch (_e) {
console.error("unknown account name during parsing");
return null;
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/network/public
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/network/public/fetcher/fetcher-types.ts
|
import type { Address } from "@coral-xyz/anchor";
import type {
BasicSupportedTypes,
ParsableEntity,
SimpleAccountFetchOptions,
MintWithTokenProgram,
AccountWithTokenProgram as TokenAccountWithTokenProgram,
} from "@orca-so/common-sdk";
import type {
FeeTierData,
PositionBundleData,
PositionData,
TickArrayData,
TokenBadgeData,
WhirlpoolData,
WhirlpoolsConfigData,
WhirlpoolsConfigExtensionData,
} from "../../../types/public";
/**
* Union type of all the {@link ParsableEntity} types that can be cached in the {@link WhirlpoolAccountFetcherInterface}
* @category Network
*/
export type WhirlpoolSupportedTypes =
| WhirlpoolsConfigData
| WhirlpoolData
| PositionData
| TickArrayData
| FeeTierData
| PositionBundleData
| WhirlpoolsConfigExtensionData
| TokenBadgeData
| BasicSupportedTypes;
/**
* The default retention periods for each {@link ParsableEntity} type in the {@link WhirlpoolAccountFetcherInterface}
* @category Network
*/
export const DEFAULT_WHIRLPOOL_RETENTION_POLICY: ReadonlyMap<
ParsableEntity<WhirlpoolSupportedTypes>,
number
> = new Map<ParsableEntity<WhirlpoolSupportedTypes>, number>([]);
/**
* Type to define fetch options for the {@link WhirlpoolAccountFetcherInterface}
* @category Network
*/
export type WhirlpoolAccountFetchOptions = SimpleAccountFetchOptions;
/**
* Default fetch option for always fetching when making an account request to the {@link WhirlpoolAccountFetcherInterface}
* @category Network
*/
export const IGNORE_CACHE: WhirlpoolAccountFetchOptions = { maxAge: 0 };
/**
* Default fetch option for always using the cached value for an account request to the {@link WhirlpoolAccountFetcherInterface}
* @category Network
*/
export const PREFER_CACHE: WhirlpoolAccountFetchOptions = {
maxAge: Number.POSITIVE_INFINITY,
};
/**
* Fetcher interface for fetching {@link WhirlpoolSupportedTypes} from the network
* @category Network
*/
export interface WhirlpoolAccountFetcherInterface {
/**
* Fetch and cache the rent exempt value
* @param refresh If true, will always fetch from the network
*/
getAccountRentExempt(refresh?: boolean): Promise<number>;
/**
* Fetch and cache the current epoch info
* @param refresh If true, will always fetch from the network
*/
getEpoch(refresh?: boolean): Promise<number>;
/**
* Fetch and cache the account for a given Whirlpool addresses
* @param address The mint address
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getPool(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<WhirlpoolData | null>;
/**
* Fetch and cache the accounts for a given array of Whirlpool addresses
* @param addresses The array of mint addresses
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getPools(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, WhirlpoolData | null>>;
/**
* Fetch and cache the account for a given Position address
* @param address The address of the position account
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getPosition(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<PositionData | null>;
/**
* Fetch and cache the accounts for a given array of Position addresses
* @param addresses The array of position account addresses
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getPositions(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, PositionData | null>>;
/**
* Fetch and cache the account for a given TickArray address.
* @param address The address of the tick array account
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getTickArray(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<TickArrayData | null>;
/**
* Fetch and cache the accounts for a given array of TickArray addresses
* @param addresses The array of tick array account addresses
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getTickArrays(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyArray<TickArrayData | null>>;
/**
* Fetch and cache the account for a given FeeTier address
* @param address The address of the fee tier account
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getFeeTier(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<FeeTierData | null>;
/**
* Fetch and cache the accounts for a given array of FeeTier addresses
* @param addresses The array of fee tier account addresses
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getFeeTiers(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, FeeTierData | null>>;
/**
* Fetch and cache the account for a given TokenAccount address
* @param address The address of the token account
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getTokenInfo(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<TokenAccountWithTokenProgram | null>;
/**
* Fetch and cache the accounts for a given array of TokenAccount addresses
* @param addresses The array of token account addresses
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getTokenInfos(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, TokenAccountWithTokenProgram | null>>;
/**
* Fetch and cache the account for a given Mint address
* @param address The address of the mint account
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getMintInfo(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<MintWithTokenProgram | null>;
/**
* Fetch and cache the accounts for a given array of Mint addresses
* @param addresses The array of mint account addresses
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getMintInfos(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, MintWithTokenProgram | null>>;
/**
* Fetch and cache the account for a given WhirlpoolConfig address
* @param address The address of the WhirlpoolConfig account
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getConfig(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<WhirlpoolsConfigData | null>;
/**
* Fetch and cache the accounts for a given array of WhirlpoolConfig addresses
* @param addresses The array of WhirlpoolConfig account addresses
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getConfigs(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, WhirlpoolsConfigData | null>>;
/**
* Fetch and cache the account for a given PositionBundle address
* @param address The address of the position bundle account
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getPositionBundle(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<PositionBundleData | null>;
/**
* Fetch and cache the accounts for a given array of PositionBundle addresses
* @param addresses The array of position bundle account addresses
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getPositionBundles(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, PositionBundleData | null>>;
/**
* Fetch and cache the account for a given WhirlpoolConfigExtension address
* @param address The address of the WhirlpoolConfigExtension account
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getConfigExtension(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<WhirlpoolsConfigExtensionData | null>;
/**
* Fetch and cache the accounts for a given array of WhirlpoolConfigExtension addresses
* @param addresses The array of WhirlpoolConfigExtension account addresses
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getConfigExtensions(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, WhirlpoolsConfigExtensionData | null>>;
/**
* Fetch and cache the account for a given TokenBadge address
* @param address The address of the TokenBadge account
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getTokenBadge(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<TokenBadgeData | null>;
/**
* Fetch and cache the accounts for a given array of TokenBadge addresses
* @param addresses The array of TokenBadge account addresses
* @param opts {@link WhirlpoolAccountFetchOptions} instance to dictate fetch behavior
*/
getTokenBadges(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, TokenBadgeData | null>>;
/**
* Populate the fetcher's cache with the given {@link WhirlpoolsData} accounts
* @param accounts The map of addresses to on-chain account data
* @param parser The {@link ParsableEntity} instance to parse the accounts
* @param now The current timestamp to use for the cache
*/
populateCache<T extends WhirlpoolSupportedTypes>(
accounts: ReadonlyMap<string, T>,
parser: ParsableEntity<T>,
now: number,
): void;
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/network/public
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/network/public/fetcher/fetcher-impl.ts
|
import type { Address } from "@coral-xyz/anchor";
import type {
AccountFetcher,
ParsableEntity,
MintWithTokenProgram,
AccountWithTokenProgram as TokenAccountWithTokenProgram,
} from "@orca-so/common-sdk";
import {
ParsableMintInfo,
ParsableTokenAccountInfo,
SimpleAccountFetcher,
} from "@orca-so/common-sdk";
import { AccountLayout } from "@solana/spl-token";
import type { Connection, EpochInfo } from "@solana/web3.js";
import type {
WhirlpoolAccountFetchOptions,
WhirlpoolAccountFetcherInterface,
WhirlpoolSupportedTypes,
} from "..";
import { DEFAULT_WHIRLPOOL_RETENTION_POLICY } from "..";
import type {
FeeTierData,
PositionBundleData,
PositionData,
TickArrayData,
TokenBadgeData,
WhirlpoolData,
WhirlpoolsConfigData,
WhirlpoolsConfigExtensionData,
} from "../../../types/public";
import {
ParsableFeeTier,
ParsablePosition,
ParsablePositionBundle,
ParsableTickArray,
ParsableWhirlpool,
ParsableWhirlpoolsConfig,
ParsableWhirlpoolsConfigExtension,
ParsableTokenBadge,
} from "../parsing";
/**
* Build a default instance of {@link WhirlpoolAccountFetcherInterface} with the default {@link AccountFetcher} implementation
* @param connection An instance of {@link Connection} to use for fetching accounts
* @returns An instance of {@link WhirlpoolAccountFetcherInterface}
* @category Network
*/
export const buildDefaultAccountFetcher = (connection: Connection) => {
return new WhirlpoolAccountFetcher(
connection,
new SimpleAccountFetcher(connection, DEFAULT_WHIRLPOOL_RETENTION_POLICY),
);
};
/**
* Fetcher and cache layer for fetching {@link WhirlpoolSupportedTypes} from the network
* Default implementation for {@link WhirlpoolAccountFetcherInterface}
* @category Network
*/
export class WhirlpoolAccountFetcher
implements WhirlpoolAccountFetcherInterface
{
private _accountRentExempt: number | undefined;
private _epochInfo: EpochInfo | undefined;
private _epochInfoNextFetchTime: number = 0;
constructor(
readonly connection: Connection,
readonly fetcher: AccountFetcher<
WhirlpoolSupportedTypes,
WhirlpoolAccountFetchOptions
>,
) {}
async getAccountRentExempt(refresh: boolean = false): Promise<number> {
// This value should be relatively static or at least not break according to spec
// https://solana.com/docs/terminology#rent-exempt
if (!this._accountRentExempt || refresh) {
this._accountRentExempt =
await this.connection.getMinimumBalanceForRentExemption(
AccountLayout.span,
);
}
return this._accountRentExempt;
}
async getEpoch(refresh: boolean = false): Promise<number> {
if (
!this._epochInfo ||
Date.now() >= this._epochInfoNextFetchTime ||
refresh
) {
const epochInfo = await this.connection.getEpochInfo();
// In theory, 1 slot per every 400ms.
// 320ms is 80% of 400ms.
const remainingSlotsInEpoch = Math.max(
epochInfo.slotsInEpoch - epochInfo.slotIndex,
0,
);
const nextFetchTime = Date.now() + remainingSlotsInEpoch * 320;
this._epochInfo = epochInfo;
this._epochInfoNextFetchTime = nextFetchTime;
}
return this._epochInfo.epoch;
}
getPool(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<WhirlpoolData | null> {
return this.fetcher.getAccount(address, ParsableWhirlpool, opts);
}
getPools(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, WhirlpoolData | null>> {
return this.fetcher.getAccounts(addresses, ParsableWhirlpool, opts);
}
getPosition(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<PositionData | null> {
return this.fetcher.getAccount(address, ParsablePosition, opts);
}
getPositions(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, PositionData | null>> {
return this.fetcher.getAccounts(addresses, ParsablePosition, opts);
}
getTickArray(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<TickArrayData | null> {
return this.fetcher.getAccount(address, ParsableTickArray, opts);
}
getTickArrays(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyArray<TickArrayData | null>> {
return this.fetcher.getAccountsAsArray(addresses, ParsableTickArray, opts);
}
getFeeTier(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<FeeTierData | null> {
return this.fetcher.getAccount(address, ParsableFeeTier, opts);
}
getFeeTiers(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, FeeTierData | null>> {
return this.fetcher.getAccounts(addresses, ParsableFeeTier, opts);
}
getTokenInfo(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<TokenAccountWithTokenProgram | null> {
return this.fetcher.getAccount(address, ParsableTokenAccountInfo, opts);
}
getTokenInfos(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, TokenAccountWithTokenProgram | null>> {
return this.fetcher.getAccounts(addresses, ParsableTokenAccountInfo, opts);
}
getMintInfo(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<MintWithTokenProgram | null> {
return this.fetcher.getAccount(address, ParsableMintInfo, opts);
}
getMintInfos(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, MintWithTokenProgram | null>> {
return this.fetcher.getAccounts(addresses, ParsableMintInfo, opts);
}
getConfig(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<WhirlpoolsConfigData | null> {
return this.fetcher.getAccount(address, ParsableWhirlpoolsConfig, opts);
}
getConfigs(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, WhirlpoolsConfigData | null>> {
return this.fetcher.getAccounts(addresses, ParsableWhirlpoolsConfig, opts);
}
getPositionBundle(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<PositionBundleData | null> {
return this.fetcher.getAccount(address, ParsablePositionBundle, opts);
}
getPositionBundles(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, PositionBundleData | null>> {
return this.fetcher.getAccounts(addresses, ParsablePositionBundle, opts);
}
getConfigExtension(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<WhirlpoolsConfigExtensionData | null> {
return this.fetcher.getAccount(
address,
ParsableWhirlpoolsConfigExtension,
opts,
);
}
getConfigExtensions(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, WhirlpoolsConfigExtensionData | null>> {
return this.fetcher.getAccounts(
addresses,
ParsableWhirlpoolsConfigExtension,
opts,
);
}
getTokenBadge(
address: Address,
opts?: WhirlpoolAccountFetchOptions,
): Promise<TokenBadgeData | null> {
return this.fetcher.getAccount(address, ParsableTokenBadge, opts);
}
getTokenBadges(
addresses: Address[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<ReadonlyMap<string, TokenBadgeData | null>> {
return this.fetcher.getAccounts(addresses, ParsableTokenBadge, opts);
}
populateCache<T extends WhirlpoolSupportedTypes>(
accounts: ReadonlyMap<string, T>,
parser: ParsableEntity<T>,
now = Date.now(),
): void {
this.fetcher.populateAccounts(accounts, parser, now);
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/network/public
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/network/public/fetcher/index.ts
|
export * from "./fetcher-impl";
export * from "./fetcher-types";
export * from "./fetcher-utils";
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/network/public
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/network/public/fetcher/fetcher-utils.ts
|
import type { Address } from "@orca-so/common-sdk";
import { AddressUtil } from "@orca-so/common-sdk";
import type { Connection, PublicKey } from "@solana/web3.js";
import invariant from "tiny-invariant";
import type {
PositionBundleData,
PositionData,
WhirlpoolData,
} from "../../../types/public";
import {
AccountName,
WHIRLPOOL_CODER,
getAccountSize,
} from "../../../types/public";
import { ParsableWhirlpool } from "../parsing";
import {
TOKEN_2022_PROGRAM_ID,
TOKEN_PROGRAM_ID,
unpackAccount,
} from "@solana/spl-token";
import { PDAUtil, PositionBundleUtil } from "../../../utils/public";
import { IGNORE_CACHE } from "../../..";
import type { WhirlpoolContext } from "../../..";
/**
* Retrieve a list of whirlpool addresses and accounts filtered by the given params using
* getProgramAccounts.
* @category Network
*
* @param connection The connection to use to fetch accounts
* @param programId The Whirlpool program to search Whirlpool accounts for
* @param configId The {@link WhirlpoolConfig} account program address to filter by
* @returns tuple of whirlpool addresses and accounts
*/
export async function getAllWhirlpoolAccountsForConfig({
connection,
programId,
configId,
}: {
connection: Connection;
programId: Address;
configId: Address;
}): Promise<ReadonlyMap<string, WhirlpoolData>> {
const filters = [
{ dataSize: getAccountSize(AccountName.Whirlpool) },
{
memcmp: WHIRLPOOL_CODER.memcmp(
AccountName.Whirlpool,
AddressUtil.toPubKey(configId).toBuffer(),
),
},
];
const accounts = await connection.getProgramAccounts(
AddressUtil.toPubKey(programId),
{
filters,
},
);
const parsedAccounts: [string, WhirlpoolData][] = [];
accounts.forEach(({ pubkey, account }) => {
const parsedAccount = ParsableWhirlpool.parse(pubkey, account);
invariant(
!!parsedAccount,
`could not parse whirlpool: ${pubkey.toBase58()}`,
);
parsedAccounts.push([AddressUtil.toString(pubkey), parsedAccount]);
});
return new Map(
parsedAccounts.map(([address, pool]) => [
AddressUtil.toString(address),
pool,
]),
);
}
export type PositionMap = {
positions: ReadonlyMap<string, PositionData>;
positionsWithTokenExtensions: ReadonlyMap<string, PositionData>;
positionBundles: BundledPositionMap[];
};
export type BundledPositionMap = {
positionBundleAddress: Address;
positionBundleData: PositionBundleData;
bundledPositions: ReadonlyMap<number, PositionData>;
};
/**
* Retrieve a list of position addresses and accounts filtered by the given params.
* @category Network
*
* @param ctx The whirlpool context
* @param owner The owner of the positions
* @param includesPositions Whether to fetch positions
* @param includesPositionsWithTokenExtensions Whether to fetch positions with token extensions
* @param includesBundledPositions Whether to fetch bundled positions
* @returns The map of position addresses to position accounts
*/
export async function getAllPositionAccountsByOwner({
ctx,
owner,
includesPositions = true,
includesPositionsWithTokenExtensions = true,
includesBundledPositions = false,
}: {
ctx: WhirlpoolContext;
owner: Address;
includesPositions?: boolean;
includesPositionsWithTokenExtensions?: boolean;
includesBundledPositions?: boolean;
}): Promise<PositionMap> {
const positions = !includesPositions
? new Map()
: await findPositions(ctx, owner, TOKEN_PROGRAM_ID);
const positionsWithTokenExtensions = !includesPositionsWithTokenExtensions
? new Map()
: await findPositions(ctx, owner, TOKEN_2022_PROGRAM_ID);
const positionBundles = !includesBundledPositions
? []
: await findBundledPositions(ctx, owner);
return {
positions,
positionsWithTokenExtensions,
positionBundles,
};
}
async function findPositions(
ctx: WhirlpoolContext,
owner: Address,
tokenProgramId: Address,
): Promise<ReadonlyMap<string, PositionData>> {
const programId = AddressUtil.toPubKey(tokenProgramId);
const tokenAccounts = await ctx.connection.getTokenAccountsByOwner(
AddressUtil.toPubKey(owner),
{
programId,
},
);
// Get candidate addresses for the position
const candidatePubkeys: PublicKey[] = [];
tokenAccounts.value.forEach((ta) => {
const parsed = unpackAccount(ta.pubkey, ta.account, programId);
if (parsed.amount === 1n) {
const pda = PDAUtil.getPosition(ctx.program.programId, parsed.mint);
candidatePubkeys.push(pda.publicKey);
}
});
// Fetch candidate accounts
const positionData = await ctx.fetcher.getPositions(
candidatePubkeys,
IGNORE_CACHE,
);
// Drop null
return new Map(
Array.from(positionData.entries()).filter(([_, v]) => v !== null) as [
string,
PositionData,
][],
);
}
async function findBundledPositions(
ctx: WhirlpoolContext,
owner: Address,
): Promise<
{
positionBundleAddress: Address;
positionBundleData: PositionBundleData;
bundledPositions: ReadonlyMap<number, PositionData>;
}[]
> {
const tokenAccounts = await ctx.connection.getTokenAccountsByOwner(
AddressUtil.toPubKey(owner),
{
programId: TOKEN_PROGRAM_ID,
},
);
// Get candidate addresses for the position bundle
const candidatePubkeys: PublicKey[] = [];
tokenAccounts.value.forEach((ta) => {
const parsed = unpackAccount(ta.pubkey, ta.account, TOKEN_PROGRAM_ID);
if (parsed.amount === 1n) {
const pda = PDAUtil.getPositionBundle(ctx.program.programId, parsed.mint);
candidatePubkeys.push(pda.publicKey);
}
});
// Fetch candidate accounts
const positionBundleData = await ctx.fetcher.getPositionBundles(
candidatePubkeys,
IGNORE_CACHE,
);
// Drop null
const positionBundles = Array.from(positionBundleData.entries()).filter(
([_, v]) => v !== null,
) as [string, PositionBundleData][];
const bundledPositionPubkeys: PublicKey[] = [];
positionBundles.forEach(([_, positionBundle]) => {
const bundleIndexes =
PositionBundleUtil.getOccupiedBundleIndexes(positionBundle);
bundleIndexes.forEach((bundleIndex) => {
const pda = PDAUtil.getBundledPosition(
ctx.program.programId,
positionBundle.positionBundleMint,
bundleIndex,
);
bundledPositionPubkeys.push(pda.publicKey);
});
});
// Fetch bundled positions
const bundledPositionData = await ctx.fetcher.getPositions(
bundledPositionPubkeys,
IGNORE_CACHE,
);
return positionBundles.map(([positionBundleAddress, positionBundleData]) => {
const bundleIndexes =
PositionBundleUtil.getOccupiedBundleIndexes(positionBundleData);
const bundledPositions = new Map(
bundleIndexes
.map((bundleIndex) => {
const pda = PDAUtil.getBundledPosition(
ctx.program.programId,
positionBundleData.positionBundleMint,
bundleIndex,
);
return [
bundleIndex,
bundledPositionData.get(AddressUtil.toString(pda.publicKey)),
];
})
.filter(([_, v]) => v !== null) as [number, PositionData][],
);
return {
positionBundleAddress,
positionBundleData,
bundledPositions,
};
});
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/instructions-util.ts
|
import * as anchor from "@coral-xyz/anchor";
import {
ASSOCIATED_TOKEN_PROGRAM_ID,
TOKEN_2022_PROGRAM_ID,
TOKEN_PROGRAM_ID,
} from "@solana/spl-token";
import { SystemProgram } from "@solana/web3.js";
import type {
OpenPositionParams,
OpenPositionWithTokenExtensionsParams,
} from "../instructions";
export function openPositionAccounts(params: OpenPositionParams) {
const {
funder,
owner,
positionPda,
positionMintAddress,
positionTokenAccount: positionTokenAccountAddress,
whirlpool: whirlpoolKey,
} = params;
return {
funder: funder,
owner,
position: positionPda.publicKey,
positionMint: positionMintAddress,
positionTokenAccount: positionTokenAccountAddress,
whirlpool: whirlpoolKey,
tokenProgram: TOKEN_PROGRAM_ID,
systemProgram: SystemProgram.programId,
rent: anchor.web3.SYSVAR_RENT_PUBKEY,
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
};
}
export function openPositionWithTokenExtensionsAccounts(
params: OpenPositionWithTokenExtensionsParams,
) {
const {
funder,
owner,
positionPda,
positionMint,
positionTokenAccount,
whirlpool: whirlpoolKey,
} = params;
return {
funder: funder,
owner,
position: positionPda.publicKey,
positionMint,
positionTokenAccount,
whirlpool: whirlpoolKey,
token2022Program: TOKEN_2022_PROGRAM_ID,
systemProgram: SystemProgram.programId,
associatedTokenProgram: ASSOCIATED_TOKEN_PROGRAM_ID,
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/position-util.ts
|
import type { BN } from "@coral-xyz/anchor";
import type { Percentage } from "@orca-so/common-sdk";
import { MathUtil } from "@orca-so/common-sdk";
import { PriceMath } from "./public";
import {
getLowerSqrtPriceFromTokenA,
getLowerSqrtPriceFromTokenB,
getUpperSqrtPriceFromTokenA,
getUpperSqrtPriceFromTokenB,
} from "./swap-utils";
export enum SwapDirection {
AtoB = "Swap A to B",
BtoA = "Swap B to A",
}
export enum AmountSpecified {
Input = "Specified input amount",
Output = "Specified output amount",
}
export enum PositionStatus {
BelowRange,
InRange,
AboveRange,
}
export class PositionUtil {
/**
* Returns the position status of a given tickCurrentIndex in relation to the tickLowerIndex and tickUpperIndex.
* If the tickCurrentIndex is below the range, it returns PositionStatus.BelowRange.
* If the tickCurrentIndex is above the range, it returns PositionStatus.AboveRange.
* If the tickCurrentIndex is equal to the lower, PositionStatus.InRange is returned.
* On the other hand, if the tickCurrentIndex is equal to the upper, PositionStatus.AboveRange is returned.
* The relation "PriceMath.tickIndexToSqrtPriceX64(tickCurrentIndex) <= pool's sqrtPrice" is the reason.
*
* @param tickCurrentIndex - Whirlpool's current tick index.
* @param tickLowerIndex - The tick specifying the lower end of the position range.
* @param tickUpperIndex - The tick specifying the upper end of the position range.
* @returns Position status in the form of PositionStatus enum.
*/
public static getPositionStatus(
tickCurrentIndex: number,
tickLowerIndex: number,
tickUpperIndex: number,
): PositionStatus {
if (tickCurrentIndex < tickLowerIndex) {
return PositionStatus.BelowRange;
} else if (tickCurrentIndex < tickUpperIndex) {
return PositionStatus.InRange;
} else {
return PositionStatus.AboveRange;
}
}
/**
* Returns the position status of a given sqrtPriceX64 in relation to the tickLowerIndex and tickUpperIndex.
* If the sqrtPriceX64 is below the range, it returns PositionStatus.BelowRange.
* If the sqrtPriceX64 is above the range, it returns PositionStatus.AboveRange.
* If the sqrtPriceX64 is equal to the lower or upper, PositionStatus.BelowRange or PositionStatus.AboveRange is returned respectively.
*
* @param sqrtPriceX64 - X64 representation of the square root of the price.
* @param tickLowerIndex - The tick specifying the lower end of the position range.
* @param tickUpperIndex - The tick specifying the upper end of the position range.
* @returns Position status in the form of PositionStatus enum.
*/
public static getStrictPositionStatus(
sqrtPriceX64: BN,
tickLowerIndex: number,
tickUpperIndex: number,
): PositionStatus {
const sqrtPriceLowerX64 = PriceMath.tickIndexToSqrtPriceX64(tickLowerIndex);
const sqrtPriceUpperX64 = PriceMath.tickIndexToSqrtPriceX64(tickUpperIndex);
if (sqrtPriceX64.lte(sqrtPriceLowerX64)) {
return PositionStatus.BelowRange;
} else if (sqrtPriceX64.gte(sqrtPriceUpperX64)) {
return PositionStatus.AboveRange;
} else {
return PositionStatus.InRange;
}
}
}
export function adjustForSlippage(
n: BN,
{ numerator, denominator }: Percentage,
adjustUp: boolean,
): BN {
if (adjustUp) {
return n.mul(denominator.add(numerator)).div(denominator);
} else {
return n.mul(denominator).div(denominator.add(numerator));
}
}
export function adjustAmountForSlippage(
amountIn: BN,
amountOut: BN,
{ numerator, denominator }: Percentage,
amountSpecified: AmountSpecified,
): BN {
if (amountSpecified === AmountSpecified.Input) {
return amountOut.mul(denominator).div(denominator.add(numerator));
} else {
return amountIn.mul(denominator.add(numerator)).div(denominator);
}
}
export function getLiquidityFromTokenA(
amount: BN,
sqrtPriceLowerX64: BN,
sqrtPriceUpperX64: BN,
roundUp: boolean,
) {
const result = amount
.mul(sqrtPriceLowerX64)
.mul(sqrtPriceUpperX64)
.div(sqrtPriceUpperX64.sub(sqrtPriceLowerX64));
if (roundUp) {
return MathUtil.shiftRightRoundUp(result);
} else {
return result.shrn(64);
}
}
export function getLiquidityFromTokenB(
amount: BN,
sqrtPriceLowerX64: BN,
sqrtPriceUpperX64: BN,
roundUp: boolean,
) {
const numerator = amount.shln(64);
const denominator = sqrtPriceUpperX64.sub(sqrtPriceLowerX64);
if (roundUp) {
return MathUtil.divRoundUp(numerator, denominator);
} else {
return numerator.div(denominator);
}
}
export function getAmountFixedDelta(
currentSqrtPriceX64: BN,
targetSqrtPriceX64: BN,
liquidity: BN,
amountSpecified: AmountSpecified,
swapDirection: SwapDirection,
) {
if (
(amountSpecified == AmountSpecified.Input) ==
(swapDirection == SwapDirection.AtoB)
) {
return getTokenAFromLiquidity(
liquidity,
currentSqrtPriceX64,
targetSqrtPriceX64,
amountSpecified == AmountSpecified.Input,
);
} else {
return getTokenBFromLiquidity(
liquidity,
currentSqrtPriceX64,
targetSqrtPriceX64,
amountSpecified == AmountSpecified.Input,
);
}
}
export function getAmountUnfixedDelta(
currentSqrtPriceX64: BN,
targetSqrtPriceX64: BN,
liquidity: BN,
amountSpecified: AmountSpecified,
swapDirection: SwapDirection,
) {
if (
(amountSpecified == AmountSpecified.Input) ==
(swapDirection == SwapDirection.AtoB)
) {
return getTokenBFromLiquidity(
liquidity,
currentSqrtPriceX64,
targetSqrtPriceX64,
amountSpecified == AmountSpecified.Output,
);
} else {
return getTokenAFromLiquidity(
liquidity,
currentSqrtPriceX64,
targetSqrtPriceX64,
amountSpecified == AmountSpecified.Output,
);
}
}
export function getNextSqrtPrice(
sqrtPriceX64: BN,
liquidity: BN,
amount: BN,
amountSpecified: AmountSpecified,
swapDirection: SwapDirection,
) {
if (
amountSpecified === AmountSpecified.Input &&
swapDirection === SwapDirection.AtoB
) {
return getLowerSqrtPriceFromTokenA(amount, liquidity, sqrtPriceX64);
} else if (
amountSpecified === AmountSpecified.Output &&
swapDirection === SwapDirection.BtoA
) {
return getUpperSqrtPriceFromTokenA(amount, liquidity, sqrtPriceX64);
} else if (
amountSpecified === AmountSpecified.Input &&
swapDirection === SwapDirection.BtoA
) {
return getUpperSqrtPriceFromTokenB(amount, liquidity, sqrtPriceX64);
} else {
return getLowerSqrtPriceFromTokenB(amount, liquidity, sqrtPriceX64);
}
}
export function getTokenAFromLiquidity(
liquidity: BN,
sqrtPrice0X64: BN,
sqrtPrice1X64: BN,
roundUp: boolean,
) {
const [sqrtPriceLowerX64, sqrtPriceUpperX64] = orderSqrtPrice(
sqrtPrice0X64,
sqrtPrice1X64,
);
const numerator = liquidity
.mul(sqrtPriceUpperX64.sub(sqrtPriceLowerX64))
.shln(64);
const denominator = sqrtPriceUpperX64.mul(sqrtPriceLowerX64);
if (roundUp) {
return MathUtil.divRoundUp(numerator, denominator);
} else {
return numerator.div(denominator);
}
}
export function getTokenBFromLiquidity(
liquidity: BN,
sqrtPrice0X64: BN,
sqrtPrice1X64: BN,
roundUp: boolean,
) {
const [sqrtPriceLowerX64, sqrtPriceUpperX64] = orderSqrtPrice(
sqrtPrice0X64,
sqrtPrice1X64,
);
const result = liquidity.mul(sqrtPriceUpperX64.sub(sqrtPriceLowerX64));
if (roundUp) {
return MathUtil.shiftRightRoundUp(result);
} else {
return result.shrn(64);
}
}
/** Private */
function orderSqrtPrice(sqrtPrice0X64: BN, sqrtPrice1X64: BN): [BN, BN] {
if (sqrtPrice0X64.lt(sqrtPrice1X64)) {
return [sqrtPrice0X64, sqrtPrice1X64];
} else {
return [sqrtPrice1X64, sqrtPrice0X64];
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/remaining-accounts-util.ts
|
import type { AccountMeta, PublicKey } from "@solana/web3.js";
import invariant from "tiny-invariant";
import { MAX_SUPPLEMENTAL_TICK_ARRAYS } from "../types/public";
export enum RemainingAccountsType {
TransferHookA = "transferHookA",
TransferHookB = "transferHookB",
TransferHookReward = "transferHookReward",
TransferHookInput = "transferHookInput",
TransferHookIntermediate = "transferHookIntermediate",
TransferHookOutput = "transferHookOutput",
SupplementalTickArrays = "supplementalTickArrays",
SupplementalTickArraysOne = "supplementalTickArraysOne",
SupplementalTickArraysTwo = "supplementalTickArraysTwo",
}
type RemainingAccountsAnchorType =
| { transferHookA: object }
| { transferHookB: object }
| { transferHookReward: object }
| { transferHookInput: object }
| { transferHookIntermediate: object }
| { transferHookOutput: object }
| { supplementalTickArrays: object }
| { supplementalTickArraysOne: object }
| { supplementalTickArraysTwo: object };
export type RemainingAccountsSliceData = {
accountsType: RemainingAccountsAnchorType;
length: number;
};
export type RemainingAccountsInfoData = {
slices: RemainingAccountsSliceData[];
};
// Option<RemainingAccountsInfoData> on Rust
// null is treated as None in Rust. undefined doesn't work.
export type OptionRemainingAccountsInfoData = RemainingAccountsInfoData | null;
export class RemainingAccountsBuilder {
private remainingAccounts: AccountMeta[] = [];
private slices: RemainingAccountsSliceData[] = [];
addSlice(
accountsType: RemainingAccountsType,
accounts?: AccountMeta[],
): this {
if (!accounts || accounts.length === 0) return this;
this.slices.push({
accountsType: { [accountsType]: {} } as RemainingAccountsAnchorType,
length: accounts.length,
});
this.remainingAccounts.push(...accounts);
return this;
}
build(): [OptionRemainingAccountsInfoData, AccountMeta[] | undefined] {
return this.slices.length === 0
? [null, undefined]
: [{ slices: this.slices }, this.remainingAccounts];
}
}
export function toSupplementalTickArrayAccountMetas(
tickArrayPubkeys: PublicKey[] | undefined,
): AccountMeta[] | undefined {
if (!tickArrayPubkeys) return undefined;
invariant(
tickArrayPubkeys.length <= MAX_SUPPLEMENTAL_TICK_ARRAYS,
"Too many supplemental tick arrays provided",
);
return tickArrayPubkeys.map((pubkey) => ({
pubkey,
isWritable: true,
isSigner: false,
}));
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/whirlpool-ata-utils.ts
|
import type {
Instruction,
TransactionBuilder,
WrappedSolAccountCreateMethod,
} from "@orca-so/common-sdk";
import { TokenUtil, ZERO, resolveOrCreateATAs } from "@orca-so/common-sdk";
import { NATIVE_MINT } from "@solana/spl-token";
import { PublicKey } from "@solana/web3.js";
import type { WhirlpoolContext } from "..";
import { PoolUtil } from "..";
import type { WhirlpoolData } from "../types/public";
import { convertListToMap } from "./txn-utils";
export enum TokenMintTypes {
ALL = "ALL",
POOL_ONLY = "POOL_ONLY",
REWARD_ONLY = "REWARDS_ONLY",
}
export type WhirlpoolsTokenMints = {
mintMap: PublicKey[];
hasNativeMint: boolean;
};
/**
* Fetch a list of affliated tokens from a list of whirlpools
*
* SOL tokens does not use the ATA program and therefore not handled.
* @param whirlpoolDatas An array of whirlpoolData (from fetcher.listPools)
* @param mintTypes The set of mints to collect from these whirlpools
* @returns All the whirlpool, reward token mints in the given set of whirlpools
*/
export function getTokenMintsFromWhirlpools(
whirlpoolDatas: (WhirlpoolData | null)[],
mintTypes = TokenMintTypes.ALL,
): WhirlpoolsTokenMints {
let hasNativeMint = false;
const mints = Array.from(
whirlpoolDatas.reduce<Set<string>>((accu, whirlpoolData) => {
if (whirlpoolData) {
if (
mintTypes === TokenMintTypes.ALL ||
mintTypes === TokenMintTypes.POOL_ONLY
) {
const { tokenMintA, tokenMintB } = whirlpoolData;
// TODO: Once we move to sync-native for wSOL wrapping, we can simplify and use wSOL ATA instead of a custom token account.
if (!TokenUtil.isNativeMint(tokenMintA)) {
accu.add(tokenMintA.toBase58());
} else {
hasNativeMint = true;
}
if (!TokenUtil.isNativeMint(tokenMintB)) {
accu.add(tokenMintB.toBase58());
} else {
hasNativeMint = true;
}
}
if (
mintTypes === TokenMintTypes.ALL ||
mintTypes === TokenMintTypes.REWARD_ONLY
) {
const rewardInfos = whirlpoolData.rewardInfos;
rewardInfos.forEach((reward) => {
if (TokenUtil.isNativeMint(reward.mint)) {
hasNativeMint = true;
}
if (PoolUtil.isRewardInitialized(reward)) {
accu.add(reward.mint.toBase58());
}
});
}
}
return accu;
}, new Set<string>()),
).map((mint) => new PublicKey(mint));
return {
mintMap: mints,
hasNativeMint,
};
}
/**
* Parameters to resolve ATAs for affliated tokens in a list of Whirlpools
*
* @category Instruction Types
* @param mints - The list of mints to generate affliated tokens for.
* @param accountExemption - The value from the most recent getMinimumBalanceForRentExemption().
* @param destinationWallet - the wallet to generate ATAs against
* @param payer - The payer address that would pay for the creation of ATA addresses
*/
export type ResolveAtaInstructionParams = {
mints: PublicKey[];
accountExemption: number;
receiver?: PublicKey;
payer?: PublicKey;
};
/**
* An interface of mapping between tokenMint & ATA & the instruction set to initialize them.
*
* @category Instruction Types
* @param ataTokenAddresses - A record between the token mint & generated ATA addresses
* @param resolveAtaIxs - An array of instructions to initialize all uninitialized ATA token accounts for the list above.
*/
export type ResolvedATAInstructionSet = {
ataTokenAddresses: Record<string, PublicKey>;
resolveAtaIxs: Instruction[];
};
/**
* Build instructions to resolve ATAs (Associated Tokens Addresses) for affliated tokens in a list of Whirlpools.
* Affliated tokens are tokens that are part of the trade pair or reward in a Whirlpool.
*
* @param ctx - WhirlpoolContext object for the current environment.
* @param params - ResolveAtaInstructionParams
* @returns a ResolvedTokenAddressesIxSet containing the derived ATA addresses & ix set to initialize the accounts.
*/
export async function resolveAtaForMints(
ctx: WhirlpoolContext,
params: ResolveAtaInstructionParams,
): Promise<ResolvedATAInstructionSet> {
const { mints, receiver, payer, accountExemption } = params;
const receiverKey = receiver ?? ctx.wallet.publicKey;
const payerKey = payer ?? ctx.wallet.publicKey;
const resolvedAtaResults = await resolveOrCreateATAs(
ctx.connection,
receiverKey,
mints.map((tokenMint) => {
return { tokenMint };
}),
async () => accountExemption,
payerKey,
undefined, // use default
ctx.accountResolverOpts.allowPDAOwnerAddress,
ctx.accountResolverOpts.createWrappedSolAccountMethod,
);
// Convert the results back into the specified format
const { resolveAtaIxs, resolvedAtas } = resolvedAtaResults.reduce<{
resolvedAtas: PublicKey[];
resolveAtaIxs: Instruction[];
}>(
(accu, curr) => {
const { address, ...ix } = curr;
accu.resolvedAtas.push(address);
// TODO: common-sdk needs to have an easier way to check for empty instruction
if (ix.instructions.length) {
accu.resolveAtaIxs.push(ix);
}
return accu;
},
{ resolvedAtas: [], resolveAtaIxs: [] },
);
const affliatedTokenAtaMap = convertListToMap(
resolvedAtas,
mints.map((mint) => mint.toBase58()),
);
return {
ataTokenAddresses: affliatedTokenAtaMap,
resolveAtaIxs,
};
}
/**
* Add native WSOL mint handling to a transaction builder.
*/
export function addNativeMintHandlingIx(
txBuilder: TransactionBuilder,
affliatedTokenAtaMap: Record<string, PublicKey>,
destinationWallet: PublicKey,
accountExemption: number,
createAccountMethod: WrappedSolAccountCreateMethod,
) {
let { address: wSOLAta, ...resolveWSolIx } =
TokenUtil.createWrappedNativeAccountInstruction(
destinationWallet,
ZERO,
accountExemption,
undefined, // use default
undefined, // use default
createAccountMethod,
);
affliatedTokenAtaMap[NATIVE_MINT.toBase58()] = wSOLAta;
txBuilder.prependInstruction(resolveWSolIx);
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/wallet-utils.ts
|
import type { Wallet } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
/**
* Checks if a wallet is connected.
* @category Whirlpool Utils
* @param wallet The wallet to check.
* @returns True if the wallet is connected, false otherwise.
*/
export function isWalletConnected(wallet: Wallet | null): boolean {
return wallet !== null && !wallet.publicKey.equals(PublicKey.default);
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/swap-utils.ts
|
import { MathUtil, ZERO } from "@orca-so/common-sdk";
import type { PublicKey } from "@solana/web3.js";
import type BN from "bn.js";
import type { TickArrayData, TickData } from "../types/public";
import { MAX_SWAP_TICK_ARRAYS, TICK_ARRAY_SIZE } from "../types/public";
import { PDAUtil, TickUtil } from "./public";
export function getLowerSqrtPriceFromTokenA(
amount: BN,
liquidity: BN,
sqrtPriceX64: BN,
): BN {
const numerator = liquidity.mul(sqrtPriceX64).shln(64);
const denominator = liquidity.shln(64).add(amount.mul(sqrtPriceX64));
// always round up
return MathUtil.divRoundUp(numerator, denominator);
}
export function getUpperSqrtPriceFromTokenA(
amount: BN,
liquidity: BN,
sqrtPriceX64: BN,
): BN {
const numerator = liquidity.mul(sqrtPriceX64).shln(64);
const denominator = liquidity.shln(64).sub(amount.mul(sqrtPriceX64));
// always round up
return MathUtil.divRoundUp(numerator, denominator);
}
export function getLowerSqrtPriceFromTokenB(
amount: BN,
liquidity: BN,
sqrtPriceX64: BN,
): BN {
// always round down
return sqrtPriceX64.sub(MathUtil.divRoundUp(amount.shln(64), liquidity));
}
export function getUpperSqrtPriceFromTokenB(
amount: BN,
liquidity: BN,
sqrtPriceX64: BN,
): BN {
// always round down (rounding up a negative number)
return sqrtPriceX64.add(amount.shln(64).div(liquidity));
}
export type TickArrayAddress = { pubkey: PublicKey; startTickIndex: number };
export function getTickArrayPublicKeysWithStartTickIndex(
tickCurrentIndex: number,
tickSpacing: number,
aToB: boolean,
programId: PublicKey,
whirlpoolAddress: PublicKey,
): TickArrayAddress[] {
const shift = aToB ? 0 : tickSpacing;
let offset = 0;
let tickArrayAddresses: TickArrayAddress[] = [];
for (let i = 0; i < MAX_SWAP_TICK_ARRAYS; i++) {
let startIndex: number;
try {
startIndex = TickUtil.getStartTickIndex(
tickCurrentIndex + shift,
tickSpacing,
offset,
);
} catch {
return tickArrayAddresses;
}
const pda = PDAUtil.getTickArray(programId, whirlpoolAddress, startIndex);
tickArrayAddresses.push({
pubkey: pda.publicKey,
startTickIndex: startIndex,
});
offset = aToB ? offset - 1 : offset + 1;
}
return tickArrayAddresses;
}
export const ZEROED_TICK_DATA: TickData = Object.freeze({
initialized: false,
liquidityNet: ZERO,
liquidityGross: ZERO,
feeGrowthOutsideA: ZERO,
feeGrowthOutsideB: ZERO,
rewardGrowthsOutside: [ZERO, ZERO, ZERO],
});
export const ZEROED_TICKS: TickData[] = Array.from(
{ length: TICK_ARRAY_SIZE },
() => ZEROED_TICK_DATA,
);
export function buildZeroedTickArray(
whirlpool: PublicKey,
startTickIndex: number,
): TickArrayData {
return {
startTickIndex,
ticks: ZEROED_TICKS,
whirlpool,
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/constants.ts
|
export const TOKEN_MINTS = {
USDC: "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
SOL: "So11111111111111111111111111111111111111112",
USDT: "Es9vMFrzaCERmJfrF4H2FYD4KCoNkY11McCe8BenwNYB",
USDH: "USDH1SM1ojwWUga67PGrgFWUHibbjqMvuMaDkRJTgkX",
mSOL: "mSoLzYCxHdYgdzU16g5QSh3i5K3z3KZK7ytfqcJm7So",
stSOL: "7dHbWXmci3dT8UFYWYZweBLXgycu7Y3iL6trKn1Y7ARj",
};
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/spl-token-utils.ts
|
import { NATIVE_MINT } from "@solana/spl-token";
import type { PublicKey } from "@solana/web3.js";
export function isNativeMint(mint: PublicKey) {
return mint.equals(NATIVE_MINT);
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/txn-utils.ts
|
import type {
Instruction,
ResolvedTokenAddressInstruction,
TransactionBuilderOptions,
} from "@orca-so/common-sdk";
import {
MEASUREMENT_BLOCKHASH,
TokenUtil,
TransactionBuilder,
ZERO,
defaultTransactionBuilderOptions,
} from "@orca-so/common-sdk";
import type {
WhirlpoolContext,
WhirlpoolContextOpts as WhirlpoolContextOptions,
} from "..";
import { NATIVE_MINT } from "@solana/spl-token";
import type { PublicKey } from "@solana/web3.js";
export function convertListToMap<T>(
fetchedData: T[],
addresses: string[],
): Record<string, T> {
const result: Record<string, T> = {};
fetchedData.forEach((data, index) => {
if (data) {
const addr = addresses[index];
result[addr] = data;
}
});
return result;
}
// Filter out null objects in the first array and remove the corresponding objects in the second array
export function filterNullObjects<T, K>(
firstArray: ReadonlyArray<T | null>,
secondArray: ReadonlyArray<K>,
): [Array<T>, Array<K>] {
const filteredFirstArray: Array<T> = [];
const filteredSecondArray: Array<K> = [];
firstArray.forEach((item, idx) => {
if (item !== null) {
filteredFirstArray.push(item);
filteredSecondArray.push(secondArray[idx]);
}
});
return [filteredFirstArray, filteredSecondArray];
}
export async function checkMergedTransactionSizeIsValid(
ctx: WhirlpoolContext,
builders: TransactionBuilder[],
latestBlockhash: Readonly<{
blockhash: string;
lastValidBlockHeight: number;
}>,
): Promise<boolean> {
const merged = new TransactionBuilder(
ctx.connection,
ctx.wallet,
ctx.txBuilderOpts,
);
builders.forEach((builder) =>
merged.addInstruction(builder.compressIx(true)),
);
try {
await merged.txnSize({
latestBlockhash,
});
return true;
} catch {
return false;
}
}
export function contextOptionsToBuilderOptions(
opts: WhirlpoolContextOptions,
): TransactionBuilderOptions | undefined {
return {
defaultBuildOption: {
...defaultTransactionBuilderOptions.defaultBuildOption,
...opts.userDefaultBuildOptions,
},
defaultSendOption: {
...defaultTransactionBuilderOptions.defaultSendOption,
...opts.userDefaultSendOptions,
},
defaultConfirmationCommitment:
opts.userDefaultConfirmCommitment ??
defaultTransactionBuilderOptions.defaultConfirmationCommitment,
};
}
export class MultipleTransactionBuilderFactoryWithAccountResolver {
private txBuilders: TransactionBuilder[] = [];
private pendingTxBuilder: TransactionBuilder | null = null;
private touchedMints: Set<string> | null = null;
private accountExemption: number | null = null;
constructor(
private ctx: WhirlpoolContext,
private resolvedAtas: Record<string, ResolvedTokenAddressInstruction>,
private tokenOwner: PublicKey = ctx.wallet.publicKey,
private payer: PublicKey = tokenOwner,
) {}
public async addInstructions(
generator: (resolve: (mint: string) => PublicKey) => Promise<Instruction[]>,
) {
if (this.accountExemption === null) {
this.accountExemption = await this.ctx.fetcher.getAccountRentExempt();
}
for (let iter = 0; iter < 2; iter++) {
if (!this.pendingTxBuilder || !this.touchedMints) {
this.pendingTxBuilder = new TransactionBuilder(
this.ctx.connection,
this.ctx.wallet,
this.ctx.txBuilderOpts,
);
this.touchedMints = new Set<string>();
this.resolvedAtas[NATIVE_MINT.toBase58()] =
TokenUtil.createWrappedNativeAccountInstruction(
this.tokenOwner,
ZERO,
this.accountExemption,
this.payer,
this.tokenOwner,
this.ctx.accountResolverOpts.createWrappedSolAccountMethod,
);
}
const newTxBuilder = new TransactionBuilder(
this.ctx.connection,
this.ctx.wallet,
this.ctx.txBuilderOpts,
);
const resolve = (mint: string): PublicKey => {
if (!this.touchedMints!.has(mint)) {
newTxBuilder.addInstruction(this.resolvedAtas[mint]);
this.touchedMints!.add(mint);
}
return this.resolvedAtas[mint].address;
};
const ixs = await generator(resolve.bind(this));
newTxBuilder.addInstructions(ixs);
// Attempt to push the new instructions into the pending builder
const mergeable = await checkMergedTransactionSizeIsValid(
this.ctx,
[this.pendingTxBuilder, newTxBuilder],
MEASUREMENT_BLOCKHASH,
);
if (mergeable) {
this.pendingTxBuilder.addInstruction(newTxBuilder.compressIx(false));
break;
} else {
if (iter !== 0) {
throw new Error(`instruction is too large.`);
}
this.txBuilders.push(this.pendingTxBuilder);
this.pendingTxBuilder = null;
this.touchedMints = null;
}
}
}
public build(): TransactionBuilder[] {
return this.pendingTxBuilder
? [...this.txBuilders, this.pendingTxBuilder]
: [...this.txBuilders];
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/math/bit-math.ts
|
import { BN } from "@coral-xyz/anchor";
import { MathUtil, ONE, TWO, U64_MAX, ZERO } from "@orca-so/common-sdk";
import { MathErrorCode, WhirlpoolsError } from "../../errors/errors";
export class BitMath {
static mul(n0: BN, n1: BN, limit: number): BN {
const result = n0.mul(n1);
if (this.isOverLimit(result, limit)) {
throw new WhirlpoolsError(
`Mul result higher than u${limit}`,
MathErrorCode.MultiplicationOverflow,
);
}
return result;
}
static mulDiv(n0: BN, n1: BN, d: BN, limit: number): BN {
return this.mulDivRoundUpIf(n0, n1, d, false, limit);
}
static mulDivRoundUp(n0: BN, n1: BN, d: BN, limit: number): BN {
return this.mulDivRoundUpIf(n0, n1, d, true, limit);
}
static mulDivRoundUpIf(
n0: BN,
n1: BN,
d: BN,
roundUp: boolean,
limit: number,
): BN {
if (d.eq(ZERO)) {
throw new WhirlpoolsError(
"mulDiv denominator is zero",
MathErrorCode.DivideByZero,
);
}
const p = this.mul(n0, n1, limit);
const n = p.div(d);
return roundUp && p.mod(d).gt(ZERO) ? n.add(ONE) : n;
}
static checked_mul_shift_right(n0: BN, n1: BN, limit: number) {
return this.checked_mul_shift_right_round_up_if(n0, n1, false, limit);
}
static checked_mul_shift_right_round_up_if(
n0: BN,
n1: BN,
roundUp: boolean,
limit: number,
) {
// customized this function is used in tryGetAmountDeltaB (token-math.ts)
if (n0.eq(ZERO) || n1.eq(ZERO)) {
return ZERO;
}
const p = this.mul(n0, n1, limit);
if (this.isOverLimit(p, limit)) {
throw new WhirlpoolsError(
`MulShiftRight overflowed u${limit}.`,
MathErrorCode.MultiplicationShiftRightOverflow,
);
}
const result = MathUtil.fromX64_BN(p);
const shouldRound = roundUp && p.and(U64_MAX).gt(ZERO);
if (shouldRound && result.eq(U64_MAX)) {
throw new WhirlpoolsError(
`MulShiftRight overflowed u${limit}.`,
MathErrorCode.MultiplicationOverflow,
);
}
return shouldRound ? result.add(ONE) : result;
}
static isOverLimit(n0: BN, limit: number) {
const limitBN = TWO.pow(new BN(limit)).sub(ONE);
return n0.gt(limitBN);
}
static divRoundUp(n: BN, d: BN) {
return this.divRoundUpIf(n, d, true);
}
static divRoundUpIf(n: BN, d: BN, roundUp: boolean) {
if (d.eq(ZERO)) {
throw new WhirlpoolsError(
"divRoundUpIf - divide by zero",
MathErrorCode.DivideByZero,
);
}
let q = n.div(d);
return roundUp && n.mod(d).gt(ZERO) ? q.add(ONE) : q;
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/math/token-math.ts
|
import type { Percentage } from "@orca-so/common-sdk";
import { MathUtil, ONE, U64_MAX, ZERO } from "@orca-so/common-sdk";
import BN from "bn.js";
import {
MathErrorCode,
TokenErrorCode,
WhirlpoolsError,
} from "../../errors/errors";
import { MAX_SQRT_PRICE, MIN_SQRT_PRICE } from "../../types/public";
import { BitMath } from "./bit-math";
import invariant from "tiny-invariant";
type AmountDeltaU64Valid = {
type: "Valid";
value: BN;
};
type AmountDeltaU64ExceedsMax = {
type: "ExceedsMax";
error: Error;
};
export class AmountDeltaU64 {
constructor(private inner: AmountDeltaU64Valid | AmountDeltaU64ExceedsMax) {}
public static fromValid(value: BN): AmountDeltaU64 {
return new AmountDeltaU64({
type: "Valid",
value,
});
}
public static fromExceedsMax(error: Error): AmountDeltaU64 {
return new AmountDeltaU64({
type: "ExceedsMax",
error,
});
}
public lte(other: BN): boolean {
if (this.inner.type === "ExceedsMax") {
return false;
}
return this.inner.value.lte(other);
}
public exceedsMax(): boolean {
return this.inner.type === "ExceedsMax";
}
public value(): BN {
invariant(this.inner.type === "Valid", "Expected valid AmountDeltaU64");
return this.inner.value;
}
public unwrap(): BN {
if (this.inner.type === "Valid") {
return this.inner.value;
} else {
throw this.inner.error;
}
}
}
export function getAmountDeltaA(
currSqrtPrice: BN,
targetSqrtPrice: BN,
currLiquidity: BN,
roundUp: boolean,
): BN {
return tryGetAmountDeltaA(
currSqrtPrice,
targetSqrtPrice,
currLiquidity,
roundUp,
).unwrap();
}
export function tryGetAmountDeltaA(
currSqrtPrice: BN,
targetSqrtPrice: BN,
currLiquidity: BN,
roundUp: boolean,
): AmountDeltaU64 {
let [sqrtPriceLower, sqrtPriceUpper] = toIncreasingPriceOrder(
currSqrtPrice,
targetSqrtPrice,
);
let sqrtPriceDiff = sqrtPriceUpper.sub(sqrtPriceLower);
let numerator = currLiquidity.mul(sqrtPriceDiff).shln(64);
let denominator = sqrtPriceLower.mul(sqrtPriceUpper);
let quotient = numerator.div(denominator);
let remainder = numerator.mod(denominator);
let result =
roundUp && !remainder.eq(ZERO) ? quotient.add(new BN(1)) : quotient;
if (result.gt(U64_MAX)) {
return AmountDeltaU64.fromExceedsMax(
new WhirlpoolsError(
"Results larger than U64",
TokenErrorCode.TokenMaxExceeded,
),
);
}
return AmountDeltaU64.fromValid(result);
}
export function getAmountDeltaB(
currSqrtPrice: BN,
targetSqrtPrice: BN,
currLiquidity: BN,
roundUp: boolean,
): BN {
return tryGetAmountDeltaB(
currSqrtPrice,
targetSqrtPrice,
currLiquidity,
roundUp,
).unwrap();
}
export function tryGetAmountDeltaB(
currSqrtPrice: BN,
targetSqrtPrice: BN,
currLiquidity: BN,
roundUp: boolean,
): AmountDeltaU64 {
let [sqrtPriceLower, sqrtPriceUpper] = toIncreasingPriceOrder(
currSqrtPrice,
targetSqrtPrice,
);
// customized BitMath.checked_mul_shift_right_round_up_if
const n0 = currLiquidity;
const n1 = sqrtPriceUpper.sub(sqrtPriceLower);
const limit = 128;
if (n0.eq(ZERO) || n1.eq(ZERO)) {
return AmountDeltaU64.fromValid(ZERO);
}
// we need to use limit * 2 (u256) here to prevent overflow error IN BitMath.mul.
// we check the overflow in the next step and return wrapped error if it happens.
const p = BitMath.mul(n0, n1, limit * 2);
if (BitMath.isOverLimit(p, limit)) {
return AmountDeltaU64.fromExceedsMax(
new WhirlpoolsError(
`MulShiftRight overflowed u${limit}.`,
MathErrorCode.MultiplicationShiftRightOverflow,
),
);
}
const result = MathUtil.fromX64_BN(p);
const shouldRound = roundUp && p.and(U64_MAX).gt(ZERO);
if (shouldRound && result.eq(U64_MAX)) {
return AmountDeltaU64.fromExceedsMax(
new WhirlpoolsError(
`MulShiftRight overflowed u${limit}.`,
MathErrorCode.MultiplicationOverflow,
),
);
}
return AmountDeltaU64.fromValid(shouldRound ? result.add(ONE) : result);
}
export function getNextSqrtPrice(
sqrtPrice: BN,
currLiquidity: BN,
amount: BN,
amountSpecifiedIsInput: boolean,
aToB: boolean,
) {
if (amountSpecifiedIsInput === aToB) {
return getNextSqrtPriceFromARoundUp(
sqrtPrice,
currLiquidity,
amount,
amountSpecifiedIsInput,
);
} else {
return getNextSqrtPriceFromBRoundDown(
sqrtPrice,
currLiquidity,
amount,
amountSpecifiedIsInput,
);
}
}
export function adjustForSlippage(
n: BN,
{ numerator, denominator }: Percentage,
adjustUp: boolean,
): BN {
if (adjustUp) {
return n.mul(denominator.add(numerator)).div(denominator);
} else {
return n.mul(denominator).div(denominator.add(numerator));
}
}
function toIncreasingPriceOrder(sqrtPrice0: BN, sqrtPrice1: BN) {
if (sqrtPrice0.gt(sqrtPrice1)) {
return [sqrtPrice1, sqrtPrice0];
} else {
return [sqrtPrice0, sqrtPrice1];
}
}
function getNextSqrtPriceFromARoundUp(
sqrtPrice: BN,
currLiquidity: BN,
amount: BN,
amountSpecifiedIsInput: boolean,
) {
if (amount.eq(ZERO)) {
return sqrtPrice;
}
let p = BitMath.mul(sqrtPrice, amount, 256);
let numerator = BitMath.mul(currLiquidity, sqrtPrice, 256).shln(64);
if (BitMath.isOverLimit(numerator, 256)) {
throw new WhirlpoolsError(
"getNextSqrtPriceFromARoundUp - numerator overflow u256",
MathErrorCode.MultiplicationOverflow,
);
}
let currLiquidityShiftLeft = currLiquidity.shln(64);
if (!amountSpecifiedIsInput && currLiquidityShiftLeft.lte(p)) {
throw new WhirlpoolsError(
"getNextSqrtPriceFromARoundUp - Unable to divide currLiquidityX64 by product",
MathErrorCode.DivideByZero,
);
}
let denominator = amountSpecifiedIsInput
? currLiquidityShiftLeft.add(p)
: currLiquidityShiftLeft.sub(p);
let price = BitMath.divRoundUp(numerator, denominator);
if (price.lt(new BN(MIN_SQRT_PRICE))) {
throw new WhirlpoolsError(
"getNextSqrtPriceFromARoundUp - price less than min sqrt price",
TokenErrorCode.TokenMinSubceeded,
);
} else if (price.gt(new BN(MAX_SQRT_PRICE))) {
throw new WhirlpoolsError(
"getNextSqrtPriceFromARoundUp - price less than max sqrt price",
TokenErrorCode.TokenMaxExceeded,
);
}
return price;
}
function getNextSqrtPriceFromBRoundDown(
sqrtPrice: BN,
currLiquidity: BN,
amount: BN,
amountSpecifiedIsInput: boolean,
) {
let amountX64 = amount.shln(64);
let delta = BitMath.divRoundUpIf(
amountX64,
currLiquidity,
!amountSpecifiedIsInput,
);
if (amountSpecifiedIsInput) {
sqrtPrice = sqrtPrice.add(delta);
} else {
sqrtPrice = sqrtPrice.sub(delta);
}
return sqrtPrice;
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/math/constants.ts
|
import { ONE, U64_MAX } from "@orca-so/common-sdk";
export const U64 = U64_MAX.add(ONE);
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/math/k-smallest-partition.ts
|
const RECURSION_BREAKPOINT = 600;
/**
* Implementation of Floyd-Rivest selection
* https://en.wikipedia.org/wiki/Floyd%E2%80%93Rivest_algorithm
*
* Performs an in place partition of an array of items, such that
* indices [0, k) contain the k smallest elements and all indices
* [k, array.length) are larger than all elements in [0, k)
*
* @param array
* @param k
* @param left
* @param right
* @param compare
*/
export function kSmallestPartition<T>(
array: T[],
k: number,
left: number = 0,
right: number = array.length - 1,
compare: (a: T, b: T) => number = defaultCompare,
) {
while (right > left) {
// Recursive sampling and partition of the set
if (right - left > RECURSION_BREAKPOINT) {
const n = right - left + 1;
const i = k - left + 1;
const z = Math.log(n);
const s = 0.5 * Math.exp((2 * z) / 3);
const sd =
0.5 * Math.sqrt((z * s * (n - s)) / n) * (i - n / 2 < 0 ? -1 : 1);
const newLeft = Math.max(left, Math.floor(k - (i * s) / n + sd));
const newRight = Math.min(right, Math.floor(k + ((n - i) * s) / n + sd));
kSmallestPartition(array, k, newLeft, newRight, compare);
}
// Partition elements around t
const t = array[k];
let i = left;
let j = right;
swap(array, left, k);
if (compare(array[right], t) > 0) {
swap(array, left, right);
}
while (i < j) {
swap(array, i, j);
i++;
j--;
while (compare(array[i], t) < 0) {
i++;
}
while (compare(array[j], t) > 0) {
j--;
}
}
if (compare(array[left], t) === 0) {
swap(array, left, j);
} else {
j++;
swap(array, j, right);
}
// Adjust boundaries of partitions
if (j <= k) {
left = j + 1;
}
if (k <= j) {
right = j - 1;
}
}
}
function swap<T>(arr: T[], i: number, j: number) {
const tmp = arr[i];
arr[i] = arr[j];
arr[j] = tmp;
}
function defaultCompare<T>(a: T, b: T) {
return a < b ? -1 : a > b ? 1 : 0;
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/math/swap-math.ts
|
import BN from "bn.js";
import { FEE_RATE_MUL_VALUE } from "../../types/public";
import { BitMath } from "./bit-math";
import {
getAmountDeltaA,
getAmountDeltaB,
getNextSqrtPrice,
tryGetAmountDeltaA,
tryGetAmountDeltaB,
} from "./token-math";
export type SwapStep = {
amountIn: BN;
amountOut: BN;
nextPrice: BN;
feeAmount: BN;
};
export function computeSwapStep(
amountRemaining: BN,
feeRate: number,
currLiquidity: BN,
currSqrtPrice: BN,
targetSqrtPrice: BN,
amountSpecifiedIsInput: boolean,
aToB: boolean,
): SwapStep {
let initialAmountFixedDelta = tryGetAmountFixedDelta(
currSqrtPrice,
targetSqrtPrice,
currLiquidity,
amountSpecifiedIsInput,
aToB,
);
let amountCalc = amountRemaining;
if (amountSpecifiedIsInput) {
const result = BitMath.mulDiv(
amountRemaining,
FEE_RATE_MUL_VALUE.sub(new BN(feeRate)),
FEE_RATE_MUL_VALUE,
128,
);
amountCalc = result;
}
let nextSqrtPrice = initialAmountFixedDelta.lte(amountCalc)
? targetSqrtPrice
: getNextSqrtPrice(
currSqrtPrice,
currLiquidity,
amountCalc,
amountSpecifiedIsInput,
aToB,
);
let isMaxSwap = nextSqrtPrice.eq(targetSqrtPrice);
let amountUnfixedDelta = getAmountUnfixedDelta(
currSqrtPrice,
nextSqrtPrice,
currLiquidity,
amountSpecifiedIsInput,
aToB,
);
let amountFixedDelta =
!isMaxSwap || initialAmountFixedDelta.exceedsMax()
? getAmountFixedDelta(
currSqrtPrice,
nextSqrtPrice,
currLiquidity,
amountSpecifiedIsInput,
aToB,
)
: initialAmountFixedDelta.value();
let amountIn = amountSpecifiedIsInput ? amountFixedDelta : amountUnfixedDelta;
let amountOut = amountSpecifiedIsInput
? amountUnfixedDelta
: amountFixedDelta;
if (!amountSpecifiedIsInput && amountOut.gt(amountRemaining)) {
amountOut = amountRemaining;
}
let feeAmount: BN;
if (amountSpecifiedIsInput && !isMaxSwap) {
feeAmount = amountRemaining.sub(amountIn);
} else {
const feeRateBN = new BN(feeRate);
feeAmount = BitMath.mulDivRoundUp(
amountIn,
feeRateBN,
FEE_RATE_MUL_VALUE.sub(feeRateBN),
128,
);
}
return {
amountIn,
amountOut,
nextPrice: nextSqrtPrice,
feeAmount,
};
}
function getAmountFixedDelta(
currSqrtPrice: BN,
targetSqrtPrice: BN,
currLiquidity: BN,
amountSpecifiedIsInput: boolean,
aToB: boolean,
) {
if (aToB === amountSpecifiedIsInput) {
return getAmountDeltaA(
currSqrtPrice,
targetSqrtPrice,
currLiquidity,
amountSpecifiedIsInput,
);
} else {
return getAmountDeltaB(
currSqrtPrice,
targetSqrtPrice,
currLiquidity,
amountSpecifiedIsInput,
);
}
}
function tryGetAmountFixedDelta(
currSqrtPrice: BN,
targetSqrtPrice: BN,
currLiquidity: BN,
amountSpecifiedIsInput: boolean,
aToB: boolean,
) {
if (aToB === amountSpecifiedIsInput) {
return tryGetAmountDeltaA(
currSqrtPrice,
targetSqrtPrice,
currLiquidity,
amountSpecifiedIsInput,
);
} else {
return tryGetAmountDeltaB(
currSqrtPrice,
targetSqrtPrice,
currLiquidity,
amountSpecifiedIsInput,
);
}
}
function getAmountUnfixedDelta(
currSqrtPrice: BN,
targetSqrtPrice: BN,
currLiquidity: BN,
amountSpecifiedIsInput: boolean,
aToB: boolean,
) {
if (aToB === amountSpecifiedIsInput) {
return getAmountDeltaB(
currSqrtPrice,
targetSqrtPrice,
currLiquidity,
!amountSpecifiedIsInput,
);
} else {
return getAmountDeltaA(
currSqrtPrice,
targetSqrtPrice,
currLiquidity,
!amountSpecifiedIsInput,
);
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/public/tick-utils.ts
|
import type { Address } from "@coral-xyz/anchor";
import type { PDA } from "@orca-so/common-sdk";
import { AddressUtil } from "@orca-so/common-sdk";
import type { PublicKey } from "@solana/web3.js";
import invariant from "tiny-invariant";
import type {
WhirlpoolAccountFetchOptions,
WhirlpoolAccountFetcherInterface,
} from "../../network/public/fetcher";
import type { TickArrayData, TickData } from "../../types/public";
import {
FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD,
MAX_TICK_INDEX,
MIN_TICK_INDEX,
TICK_ARRAY_SIZE,
} from "../../types/public";
import { PDAUtil } from "./pda-utils";
enum TickSearchDirection {
Left,
Right,
}
/**
* A collection of utility functions when interacting with Ticks.
* @category Whirlpool Utils
*/
export class TickUtil {
/**
* Get the offset index to access a tick at a given tick-index in a tick-array
*
* @param tickIndex The tick index for the tick that this offset would access
* @param arrayStartIndex The starting tick for the array that this tick-index resides in
* @param tickSpacing The tickSpacing for the Whirlpool that this tickArray belongs to
* @returns The offset index that can access the desired tick at the given tick-array
*/
public static getOffsetIndex(
tickIndex: number,
arrayStartIndex: number,
tickSpacing: number,
) {
return Math.floor((tickIndex - arrayStartIndex) / tickSpacing);
}
/**
* Get the startIndex of the tick array containing tickIndex.
*
* @param tickIndex
* @param tickSpacing
* @param offset can be used to get neighboring tick array startIndex.
* @returns
*/
public static getStartTickIndex(
tickIndex: number,
tickSpacing: number,
offset = 0,
): number {
const realIndex = Math.floor(tickIndex / tickSpacing / TICK_ARRAY_SIZE);
const startTickIndex = (realIndex + offset) * tickSpacing * TICK_ARRAY_SIZE;
const ticksInArray = TICK_ARRAY_SIZE * tickSpacing;
const minTickIndex =
MIN_TICK_INDEX - ((MIN_TICK_INDEX % ticksInArray) + ticksInArray);
invariant(
startTickIndex >= minTickIndex,
`startTickIndex is too small - - ${startTickIndex}`,
);
invariant(
startTickIndex <= MAX_TICK_INDEX,
`startTickIndex is too large - ${startTickIndex}`,
);
return startTickIndex;
}
/**
* Get the nearest (rounding down) valid tick index from the tickIndex.
* A valid tick index is a point on the tick spacing grid line.
*/
public static getInitializableTickIndex(
tickIndex: number,
tickSpacing: number,
): number {
return tickIndex - (tickIndex % tickSpacing);
}
public static getNextInitializableTickIndex(
tickIndex: number,
tickSpacing: number,
) {
return (
TickUtil.getInitializableTickIndex(tickIndex, tickSpacing) + tickSpacing
);
}
public static getPrevInitializableTickIndex(
tickIndex: number,
tickSpacing: number,
) {
return (
TickUtil.getInitializableTickIndex(tickIndex, tickSpacing) - tickSpacing
);
}
/**
* Get the previous initialized tick index within the same tick array.
*
* @param account
* @param currentTickIndex
* @param tickSpacing
* @returns
*/
public static findPreviousInitializedTickIndex(
account: TickArrayData,
currentTickIndex: number,
tickSpacing: number,
): number | null {
return TickUtil.findInitializedTick(
account,
currentTickIndex,
tickSpacing,
TickSearchDirection.Left,
);
}
/**
* Get the next initialized tick index within the same tick array.
* @param account
* @param currentTickIndex
* @param tickSpacing
* @returns
*/
public static findNextInitializedTickIndex(
account: TickArrayData,
currentTickIndex: number,
tickSpacing: number,
): number | null {
return TickUtil.findInitializedTick(
account,
currentTickIndex,
tickSpacing,
TickSearchDirection.Right,
);
}
private static findInitializedTick(
account: TickArrayData,
currentTickIndex: number,
tickSpacing: number,
searchDirection: TickSearchDirection,
): number | null {
const currentTickArrayIndex = tickIndexToInnerIndex(
account.startTickIndex,
currentTickIndex,
tickSpacing,
);
const increment = searchDirection === TickSearchDirection.Right ? 1 : -1;
let stepInitializedTickArrayIndex =
searchDirection === TickSearchDirection.Right
? currentTickArrayIndex + increment
: currentTickArrayIndex;
while (
stepInitializedTickArrayIndex >= 0 &&
stepInitializedTickArrayIndex < account.ticks.length
) {
if (account.ticks[stepInitializedTickArrayIndex]?.initialized) {
return innerIndexToTickIndex(
account.startTickIndex,
stepInitializedTickArrayIndex,
tickSpacing,
);
}
stepInitializedTickArrayIndex += increment;
}
return null;
}
public static checkTickInBounds(tick: number) {
return tick <= MAX_TICK_INDEX && tick >= MIN_TICK_INDEX;
}
public static isTickInitializable(tick: number, tickSpacing: number) {
return tick % tickSpacing === 0;
}
/**
*
* Returns the tick for the inverse of the price that this tick represents.
* Eg: Consider tick i where Pb/Pa = 1.0001 ^ i
* inverse of this, i.e. Pa/Pb = 1 / (1.0001 ^ i) = 1.0001^-i
* @param tick The tick to invert
* @returns
*/
public static invertTick(tick: number) {
return -tick;
}
/**
* Get the minimum and maximum tick index that can be initialized.
*
* @param tickSpacing The tickSpacing for the Whirlpool
* @returns An array of numbers where the first element is the minimum tick index and the second element is the maximum tick index.
*/
public static getFullRangeTickIndex(tickSpacing: number): [number, number] {
return [
Math.ceil(MIN_TICK_INDEX / tickSpacing) * tickSpacing,
Math.floor(MAX_TICK_INDEX / tickSpacing) * tickSpacing,
];
}
/**
* Check if the tick range is the full range of the Whirlpool.
* @param tickSpacing The tickSpacing for the Whirlpool
* @param tickLowerIndex The lower tick index of the range
* @param tickUpperIndex The upper tick index of the range
* @returns true if the range is the full range of the Whirlpool, false otherwise.
*/
public static isFullRange(
tickSpacing: number,
tickLowerIndex: number,
tickUpperIndex: number,
): boolean {
const [min, max] = TickUtil.getFullRangeTickIndex(tickSpacing);
return tickLowerIndex === min && tickUpperIndex === max;
}
/**
* Check if a whirlpool is a full-range only pool.
* @param tickSpacing The tickSpacing for the Whirlpool
* @returns true if the whirlpool is a full-range only pool, false otherwise.
*/
public static isFullRangeOnly(tickSpacing: number): boolean {
return tickSpacing >= FULL_RANGE_ONLY_TICK_SPACING_THRESHOLD;
}
}
/**
* A collection of utility functions when interacting with a TickArray.
* @category Whirlpool Utils
*/
export class TickArrayUtil {
/**
* Get the tick from tickArray with a global tickIndex.
*/
public static getTickFromArray(
tickArray: TickArrayData,
tickIndex: number,
tickSpacing: number,
): TickData {
const realIndex = tickIndexToInnerIndex(
tickArray.startTickIndex,
tickIndex,
tickSpacing,
);
const tick = tickArray.ticks[realIndex];
invariant(
!!tick,
`tick realIndex out of range - start - ${tickArray.startTickIndex} index - ${tickIndex}, realIndex - ${realIndex}`,
);
return tick;
}
/**
* Return a sequence of tick array pdas based on the sequence start index.
* @param tick - A tick in the first tick-array of your sequence
* @param tickSpacing - Tick spacing for the whirlpool
* @param numOfTickArrays - The number of TickArray PDAs to generate
* @param programId - Program Id of the whirlpool for these tick-arrays
* @param whirlpoolAddress - Address for the Whirlpool for these tick-arrays
* @returns TickArray PDAs for the sequence`
*/
public static getTickArrayPDAs(
tick: number,
tickSpacing: number,
numOfTickArrays: number,
programId: PublicKey,
whirlpoolAddress: PublicKey,
aToB: boolean,
): PDA[] {
let arrayIndexList = [...Array(numOfTickArrays).keys()];
if (aToB) {
arrayIndexList = arrayIndexList.map((value) => -value);
}
return arrayIndexList.map((value) => {
const startTick = TickUtil.getStartTickIndex(tick, tickSpacing, value);
return PDAUtil.getTickArray(programId, whirlpoolAddress, startTick);
});
}
/**
* Return a string containing all of the uninitialized arrays in the provided addresses.
* Useful for creating error messages.
*
* @param tickArrayAddrs - A list of tick-array addresses to verify.
* @param cache - {@link WhirlpoolAccountFetcherInterface}
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @returns A string of all uninitialized tick array addresses, delimited by ",". Falsy value if all arrays are initialized.
*/
public static async getUninitializedArraysString(
tickArrayAddrs: Address[],
fetcher: WhirlpoolAccountFetcherInterface,
opts?: WhirlpoolAccountFetchOptions,
) {
const taAddrs = AddressUtil.toPubKeys(tickArrayAddrs);
const tickArrayData = await fetcher.getTickArrays(taAddrs, opts);
// Verify tick arrays are initialized if the user provided them.
if (tickArrayData) {
const uninitializedIndices =
TickArrayUtil.getUninitializedArrays(tickArrayData);
if (uninitializedIndices.length > 0) {
const uninitializedArrays = uninitializedIndices
.map((index) => taAddrs[index].toBase58())
.join(", ");
return uninitializedArrays;
}
}
return null;
}
public static async getUninitializedArraysPDAs(
ticks: number[],
programId: PublicKey,
whirlpoolAddress: PublicKey,
tickSpacing: number,
fetcher: WhirlpoolAccountFetcherInterface,
opts: WhirlpoolAccountFetchOptions,
) {
const startTicks = ticks.map((tick) =>
TickUtil.getStartTickIndex(tick, tickSpacing),
);
const removeDupeTicks = [...new Set(startTicks)];
const tickArrayPDAs = removeDupeTicks.map((tick) =>
PDAUtil.getTickArray(programId, whirlpoolAddress, tick),
);
const fetchedArrays = await fetcher.getTickArrays(
tickArrayPDAs.map((pda) => pda.publicKey),
opts,
);
const uninitializedIndices =
TickArrayUtil.getUninitializedArrays(fetchedArrays);
return uninitializedIndices.map((index) => {
return {
startIndex: removeDupeTicks[index],
pda: tickArrayPDAs[index],
};
});
}
/**
* Evaluate a list of tick-array data and return the array of indices which the tick-arrays are not initialized.
* @param tickArrays - a list of TickArrayData or null objects from WhirlpoolAccountCacheInterface.getTickArrays
* @returns an array of array-index for the input tickArrays that requires initialization.
*/
public static getUninitializedArrays(
tickArrays: readonly (TickArrayData | null)[],
): number[] {
return tickArrays
.map((value, index) => {
if (!value) {
return index;
}
return -1;
})
.filter((index) => index >= 0);
}
}
function tickIndexToInnerIndex(
startTickIndex: number,
tickIndex: number,
tickSpacing: number,
): number {
return Math.floor((tickIndex - startTickIndex) / tickSpacing);
}
function innerIndexToTickIndex(
startTickIndex: number,
tickArrayIndex: number,
tickSpacing: number,
): number {
return startTickIndex + tickArrayIndex * tickSpacing;
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/public/pda-utils.ts
|
import { BN } from "@coral-xyz/anchor";
import { AddressUtil } from "@orca-so/common-sdk";
import type { PublicKey } from "@solana/web3.js";
import { METADATA_PROGRAM_ADDRESS } from "../../types/public";
import { PriceMath } from "./price-math";
import { TickUtil } from "./tick-utils";
const PDA_WHIRLPOOL_SEED = "whirlpool";
const PDA_POSITION_SEED = "position";
const PDA_METADATA_SEED = "metadata";
const PDA_TICK_ARRAY_SEED = "tick_array";
const PDA_FEE_TIER_SEED = "fee_tier";
const PDA_ORACLE_SEED = "oracle";
const PDA_POSITION_BUNDLE_SEED = "position_bundle";
const PDA_BUNDLED_POSITION_SEED = "bundled_position";
const PDA_CONFIG_EXTENSION_SEED = "config_extension";
const PDA_TOKEN_BADGE_SEED = "token_badge";
/**
* @category Whirlpool Utils
*/
export class PDAUtil {
/**
*
* @param programId
* @param whirlpoolsConfigKey
* @param tokenMintAKey
* @param tokenMintBKey
* @param tickSpacing
* @returns
*/
public static getWhirlpool(
programId: PublicKey,
whirlpoolsConfigKey: PublicKey,
tokenMintAKey: PublicKey,
tokenMintBKey: PublicKey,
tickSpacing: number,
) {
return AddressUtil.findProgramAddress(
[
Buffer.from(PDA_WHIRLPOOL_SEED),
whirlpoolsConfigKey.toBuffer(),
tokenMintAKey.toBuffer(),
tokenMintBKey.toBuffer(),
new BN(tickSpacing).toArrayLike(Buffer, "le", 2),
],
programId,
);
}
/**
* @category Program Derived Addresses
* @param programId
* @param positionMintKey
* @returns
*/
public static getPosition(programId: PublicKey, positionMintKey: PublicKey) {
return AddressUtil.findProgramAddress(
[Buffer.from(PDA_POSITION_SEED), positionMintKey.toBuffer()],
programId,
);
}
/**
* @category Program Derived Addresses
* @param positionMintKey
* @returns
*/
public static getPositionMetadata(positionMintKey: PublicKey) {
return AddressUtil.findProgramAddress(
[
Buffer.from(PDA_METADATA_SEED),
METADATA_PROGRAM_ADDRESS.toBuffer(),
positionMintKey.toBuffer(),
],
METADATA_PROGRAM_ADDRESS,
);
}
/**
* @category Program Derived Addresses
* @param programId
* @param whirlpoolAddress
* @param startTick
* @returns
*/
public static getTickArray(
programId: PublicKey,
whirlpoolAddress: PublicKey,
startTick: number,
) {
return AddressUtil.findProgramAddress(
[
Buffer.from(PDA_TICK_ARRAY_SEED),
whirlpoolAddress.toBuffer(),
Buffer.from(startTick.toString()),
],
programId,
);
}
/**
* Get the PDA of the tick array containing tickIndex.
* tickArrayOffset can be used to get neighboring tick arrays.
*
* @param tickIndex
* @param tickSpacing
* @param whirlpool
* @param programId
* @param tickArrayOffset
* @returns
*/
public static getTickArrayFromTickIndex(
tickIndex: number,
tickSpacing: number,
whirlpool: PublicKey,
programId: PublicKey,
tickArrayOffset = 0,
) {
const startIndex = TickUtil.getStartTickIndex(
tickIndex,
tickSpacing,
tickArrayOffset,
);
return PDAUtil.getTickArray(
AddressUtil.toPubKey(programId),
AddressUtil.toPubKey(whirlpool),
startIndex,
);
}
public static getTickArrayFromSqrtPrice(
sqrtPriceX64: BN,
tickSpacing: number,
whirlpool: PublicKey,
programId: PublicKey,
tickArrayOffset = 0,
) {
const tickIndex = PriceMath.sqrtPriceX64ToTickIndex(sqrtPriceX64);
return PDAUtil.getTickArrayFromTickIndex(
tickIndex,
tickSpacing,
whirlpool,
programId,
tickArrayOffset,
);
}
/**
* @category Program Derived Addresses
* @param programId
* @param whirlpoolsConfigAddress
* @param tickSpacing
* @returns
*/
public static getFeeTier(
programId: PublicKey,
whirlpoolsConfigAddress: PublicKey,
tickSpacing: number,
) {
return AddressUtil.findProgramAddress(
[
Buffer.from(PDA_FEE_TIER_SEED),
whirlpoolsConfigAddress.toBuffer(),
new BN(tickSpacing).toArrayLike(Buffer, "le", 2),
],
programId,
);
}
/**
* @category Program Derived Addresses
* @param programId
* @param whirlpoolAddress
* @returns
*/
public static getOracle(programId: PublicKey, whirlpoolAddress: PublicKey) {
return AddressUtil.findProgramAddress(
[Buffer.from(PDA_ORACLE_SEED), whirlpoolAddress.toBuffer()],
programId,
);
}
/**
* @category Program Derived Addresses
* @param programId
* @param positionBundleMintKey
* @param bundleIndex
* @returns
*/
public static getBundledPosition(
programId: PublicKey,
positionBundleMintKey: PublicKey,
bundleIndex: number,
) {
return AddressUtil.findProgramAddress(
[
Buffer.from(PDA_BUNDLED_POSITION_SEED),
positionBundleMintKey.toBuffer(),
Buffer.from(bundleIndex.toString()),
],
programId,
);
}
/**
* @category Program Derived Addresses
* @param programId
* @param positionBundleMintKey
* @returns
*/
public static getPositionBundle(
programId: PublicKey,
positionBundleMintKey: PublicKey,
) {
return AddressUtil.findProgramAddress(
[Buffer.from(PDA_POSITION_BUNDLE_SEED), positionBundleMintKey.toBuffer()],
programId,
);
}
/**
* @category Program Derived Addresses
* @param positionBundleMintKey
* @returns
*/
public static getPositionBundleMetadata(positionBundleMintKey: PublicKey) {
return AddressUtil.findProgramAddress(
[
Buffer.from(PDA_METADATA_SEED),
METADATA_PROGRAM_ADDRESS.toBuffer(),
positionBundleMintKey.toBuffer(),
],
METADATA_PROGRAM_ADDRESS,
);
}
/**
* @category Program Derived Addresses
* @param programId
* @param whirlpoolsConfigAddress
* @returns
*/
public static getConfigExtension(
programId: PublicKey,
whirlpoolsConfigAddress: PublicKey,
) {
return AddressUtil.findProgramAddress(
[
Buffer.from(PDA_CONFIG_EXTENSION_SEED),
whirlpoolsConfigAddress.toBuffer(),
],
programId,
);
}
/**
* @category Program Derived Addresses
* @param programId
* @param whirlpoolsConfigAddress
* @param tokenMintKey
* @returns
*/
public static getTokenBadge(
programId: PublicKey,
whirlpoolsConfigAddress: PublicKey,
tokenMintKey: PublicKey,
) {
return AddressUtil.findProgramAddress(
[
Buffer.from(PDA_TOKEN_BADGE_SEED),
whirlpoolsConfigAddress.toBuffer(),
tokenMintKey.toBuffer(),
],
programId,
);
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/public/ix-utils.ts
|
import type { Instruction } from "@orca-so/common-sdk";
import { TransactionBuilder } from "@orca-so/common-sdk";
import type { WhirlpoolContext } from "../../context";
export function toTx(
ctx: WhirlpoolContext,
ix: Instruction,
): TransactionBuilder {
return new TransactionBuilder(
ctx.provider.connection,
ctx.provider.wallet,
ctx.txBuilderOpts,
).addInstruction(ix);
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/public/pool-utils.ts
|
import type { Address } from "@coral-xyz/anchor";
import { AddressUtil, MathUtil, Percentage } from "@orca-so/common-sdk";
import { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import Decimal from "decimal.js";
import type {
WhirlpoolData,
WhirlpoolRewardInfoData,
} from "../../types/public";
import { TOKEN_MINTS } from "../constants";
import { PriceMath } from "./price-math";
import { TokenType } from "./types";
import type { WhirlpoolContext } from "../..";
import { PDAUtil } from "../..";
import invariant from "tiny-invariant";
import {
AccountState,
ExtensionType,
NATIVE_MINT_2022,
TOKEN_PROGRAM_ID,
getDefaultAccountState,
getExtensionTypes,
} from "@solana/spl-token";
/**
* @category Whirlpool Utils
*/
export class PoolUtil {
public static isRewardInitialized(
rewardInfo: WhirlpoolRewardInfoData,
): boolean {
return (
!PublicKey.default.equals(rewardInfo.mint) &&
!PublicKey.default.equals(rewardInfo.vault)
);
}
/**
* Return the corresponding token type (TokenA/B) for this mint key for a Whirlpool.
*
* @param pool The Whirlpool to evaluate the mint against
* @param mint The token mint PublicKey
* @returns The match result in the form of TokenType enum. undefined if the token mint is not part of the trade pair of the pool.
*/
public static getTokenType(
pool: WhirlpoolData,
mint: PublicKey,
): TokenType | undefined {
if (pool.tokenMintA.equals(mint)) {
return TokenType.TokenA;
} else if (pool.tokenMintB.equals(mint)) {
return TokenType.TokenB;
}
return undefined;
}
public static getFeeRate(feeRate: number): Percentage {
/**
* Smart Contract comment: https://github.com/orca-so/whirlpool/blob/main/programs/whirlpool/src/state/whirlpool.rs#L9-L11
* // Stored as hundredths of a basis point
* // u16::MAX corresponds to ~6.5%
* pub fee_rate: u16,
*/
return Percentage.fromFraction(feeRate, 1e6); // TODO
}
public static getProtocolFeeRate(protocolFeeRate: number): Percentage {
/**
* Smart Contract comment: https://github.com/orca-so/whirlpool/blob/main/programs/whirlpool/src/state/whirlpool.rs#L13-L14
* // Stored as a basis point
* pub protocol_fee_rate: u16,
*/
return Percentage.fromFraction(protocolFeeRate, 1e4); // TODO
}
public static orderMints(mintX: Address, mintY: Address): [Address, Address] {
return this.compareMints(mintX, mintY) < 0
? [mintX, mintY]
: [mintY, mintX];
}
public static compareMints(mintX: Address, mintY: Address): number {
return Buffer.compare(
AddressUtil.toPubKey(mintX).toBuffer(),
AddressUtil.toPubKey(mintY).toBuffer(),
);
}
/**
* @category Whirlpool Utils
* @param liquidity
* @param currentSqrtPrice
* @param lowerSqrtPrice
* @param upperSqrtPrice
* @param round_up
* @returns
*/
public static getTokenAmountsFromLiquidity(
liquidity: BN,
currentSqrtPrice: BN,
lowerSqrtPrice: BN,
upperSqrtPrice: BN,
round_up: boolean,
): TokenAmounts {
const _liquidity = new Decimal(liquidity.toString());
const _currentPrice = new Decimal(currentSqrtPrice.toString());
const _lowerPrice = new Decimal(lowerSqrtPrice.toString());
const _upperPrice = new Decimal(upperSqrtPrice.toString());
let tokenA, tokenB;
if (currentSqrtPrice.lt(lowerSqrtPrice)) {
// x = L * (pb - pa) / (pa * pb)
tokenA = MathUtil.toX64_Decimal(_liquidity)
.mul(_upperPrice.sub(_lowerPrice))
.div(_lowerPrice.mul(_upperPrice));
tokenB = new Decimal(0);
} else if (currentSqrtPrice.lt(upperSqrtPrice)) {
// x = L * (pb - p) / (p * pb)
// y = L * (p - pa)
tokenA = MathUtil.toX64_Decimal(_liquidity)
.mul(_upperPrice.sub(_currentPrice))
.div(_currentPrice.mul(_upperPrice));
tokenB = MathUtil.fromX64_Decimal(
_liquidity.mul(_currentPrice.sub(_lowerPrice)),
);
} else {
// y = L * (pb - pa)
tokenA = new Decimal(0);
tokenB = MathUtil.fromX64_Decimal(
_liquidity.mul(_upperPrice.sub(_lowerPrice)),
);
}
// TODO: round up
if (round_up) {
return {
tokenA: new BN(tokenA.ceil().toString()),
tokenB: new BN(tokenB.ceil().toString()),
};
} else {
return {
tokenA: new BN(tokenA.floor().toString()),
tokenB: new BN(tokenB.floor().toString()),
};
}
}
/**
* Estimate the liquidity amount required to increase/decrease liquidity.
*
* // TODO: At the top end of the price range, tick calcuation is off therefore the results can be off
*
* @category Whirlpool Utils
* @param currTick - Whirlpool's current tick index (aka price)
* @param lowerTick - Position lower tick index
* @param upperTick - Position upper tick index
* @param tokenAmount - The desired amount of tokens to deposit/withdraw
* @returns An estimated amount of liquidity needed to deposit/withdraw the desired amount of tokens.
* @deprecated Please use {@link estimateMaxLiquidityFromTokenAmounts} instead.
*/
public static estimateLiquidityFromTokenAmounts(
currTick: number,
lowerTick: number,
upperTick: number,
tokenAmount: TokenAmounts,
): BN {
return this.estimateMaxLiquidityFromTokenAmounts(
PriceMath.tickIndexToSqrtPriceX64(currTick),
lowerTick,
upperTick,
tokenAmount,
);
}
/**
* Estimate the liquidity amount required to increase/decrease liquidity.
*
* @category Whirlpool Utils
* @param sqrtPriceX64 - Whirlpool's current sqrt price
* @param tickLowerIndex - Position lower tick index
* @param tickUpperIndex - Position upper tick index
* @param tokenAmount - The desired amount of tokens to deposit/withdraw
* @returns An estimated amount of liquidity needed to deposit/withdraw the desired amount of tokens.
*/
public static estimateMaxLiquidityFromTokenAmounts(
sqrtPriceX64: BN,
tickLowerIndex: number,
tickUpperIndex: number,
tokenAmount: TokenAmounts,
): BN {
if (tickUpperIndex < tickLowerIndex) {
throw new Error("upper tick cannot be lower than the lower tick");
}
const currSqrtPrice = sqrtPriceX64;
const lowerSqrtPrice = PriceMath.tickIndexToSqrtPriceX64(tickLowerIndex);
const upperSqrtPrice = PriceMath.tickIndexToSqrtPriceX64(tickUpperIndex);
if (currSqrtPrice.gte(upperSqrtPrice)) {
return estLiquidityForTokenB(
upperSqrtPrice,
lowerSqrtPrice,
tokenAmount.tokenB,
);
} else if (currSqrtPrice.lt(lowerSqrtPrice)) {
return estLiquidityForTokenA(
lowerSqrtPrice,
upperSqrtPrice,
tokenAmount.tokenA,
);
} else {
const estLiquidityAmountA = estLiquidityForTokenA(
currSqrtPrice,
upperSqrtPrice,
tokenAmount.tokenA,
);
const estLiquidityAmountB = estLiquidityForTokenB(
currSqrtPrice,
lowerSqrtPrice,
tokenAmount.tokenB,
);
return BN.min(estLiquidityAmountA, estLiquidityAmountB);
}
}
/**
* Given an arbitrary pair of token mints, this function returns an ordering of the token mints
* in the format [base, quote]. USD based stable coins are prioritized as the quote currency
* followed by variants of SOL.
*
* @category Whirlpool Utils
* @param tokenMintAKey - The mint of token A in the token pair.
* @param tokenMintBKey - The mint of token B in the token pair.
* @returns A two-element array with the tokens sorted in the order of [baseToken, quoteToken].
*/
public static toBaseQuoteOrder(
tokenMintAKey: PublicKey,
tokenMintBKey: PublicKey,
): [PublicKey, PublicKey] {
const pair: [PublicKey, PublicKey] = [tokenMintAKey, tokenMintBKey];
return pair.sort(sortByQuotePriority);
}
public static async isSupportedToken(
ctx: WhirlpoolContext,
whirlpoolsConfig: PublicKey,
tokenMintKey: PublicKey,
) {
// sync with is_supported_token (programs/whirlpool/src/util/v2/token.rs)
const mintWithTokenProgram = await ctx.fetcher.getMintInfo(tokenMintKey);
invariant(mintWithTokenProgram, "Mint not found");
if (mintWithTokenProgram.tokenProgram.equals(TOKEN_PROGRAM_ID)) {
return true;
}
if (mintWithTokenProgram.address.equals(NATIVE_MINT_2022)) {
return false;
}
const tokenBadgePda = PDAUtil.getTokenBadge(
ctx.program.programId,
whirlpoolsConfig,
tokenMintKey,
);
const tokenBadge = await ctx.fetcher.getTokenBadge(tokenBadgePda.publicKey);
const isTokenBadgeInitialized = tokenBadge !== null;
if (
mintWithTokenProgram.freezeAuthority !== null &&
!isTokenBadgeInitialized
) {
return false;
}
// HACK: spl-token doesn't support ExtensionType.ConfidentialTransferFeeConfig yet
const EXTENSION_TYPE_CONFIDENTIAL_TRANSFER_FEE_CONFIG = 16 as ExtensionType;
const extensions = getExtensionTypes(mintWithTokenProgram.tlvData);
for (const extension of extensions) {
switch (extension) {
// supported
case ExtensionType.TransferFeeConfig:
case ExtensionType.InterestBearingConfig:
case ExtensionType.TokenMetadata:
case ExtensionType.MetadataPointer:
case ExtensionType.ConfidentialTransferMint:
case EXTENSION_TYPE_CONFIDENTIAL_TRANSFER_FEE_CONFIG:
continue;
// supported if TokenBadge is initialized
case ExtensionType.PermanentDelegate:
case ExtensionType.TransferHook:
case ExtensionType.MintCloseAuthority:
if (!isTokenBadgeInitialized) {
return false;
}
continue;
case ExtensionType.DefaultAccountState:
if (!isTokenBadgeInitialized) {
return false;
}
const defaultAccountState =
getDefaultAccountState(mintWithTokenProgram)!;
if (defaultAccountState.state !== AccountState.Initialized) {
return false;
}
continue;
// not supported
case ExtensionType.NonTransferable:
return false;
// not supported yet or unknown extension
default:
return false;
}
}
return true;
}
}
/**
* @category Whirlpool Utils
*/
export type TokenAmounts = {
tokenA: BN;
tokenB: BN;
};
/**
* @category Whirlpool Utils
*/
export function toTokenAmount(a: number, b: number): TokenAmounts {
return {
tokenA: new BN(a.toString()),
tokenB: new BN(b.toString()),
};
}
// These are the token mints that will be prioritized as the second token in the pair (quote).
// The number that the mint maps to determines the priority that it will be used as the quote
// currency.
const QUOTE_TOKENS: { [mint: string]: number } = {
[TOKEN_MINTS["USDT"]]: 100,
[TOKEN_MINTS["USDC"]]: 90, // USDC
[TOKEN_MINTS["USDH"]]: 80, // USDH
[TOKEN_MINTS["SOL"]]: 70, // SOL
[TOKEN_MINTS["mSOL"]]: 60, // mSOL
[TOKEN_MINTS["stSOL"]]: 50, // stSOL
};
const DEFAULT_QUOTE_PRIORITY = 0;
function getQuoteTokenPriority(mint: string): number {
const value = QUOTE_TOKENS[mint];
if (value) {
return value;
}
return DEFAULT_QUOTE_PRIORITY;
}
function sortByQuotePriority(
mintLeft: PublicKey,
mintRight: PublicKey,
): number {
return (
getQuoteTokenPriority(mintLeft.toString()) -
getQuoteTokenPriority(mintRight.toString())
);
}
// Convert this function based on Delta A = Delta L * (1/sqrt(lower) - 1/sqrt(upper))
function estLiquidityForTokenA(
sqrtPrice1: BN,
sqrtPrice2: BN,
tokenAmount: BN,
) {
const lowerSqrtPriceX64 = BN.min(sqrtPrice1, sqrtPrice2);
const upperSqrtPriceX64 = BN.max(sqrtPrice1, sqrtPrice2);
const num = MathUtil.fromX64_BN(
tokenAmount.mul(upperSqrtPriceX64).mul(lowerSqrtPriceX64),
);
const dem = upperSqrtPriceX64.sub(lowerSqrtPriceX64);
return num.div(dem);
}
// Convert this function based on Delta B = Delta L * (sqrt_price(upper) - sqrt_price(lower))
function estLiquidityForTokenB(
sqrtPrice1: BN,
sqrtPrice2: BN,
tokenAmount: BN,
) {
const lowerSqrtPriceX64 = BN.min(sqrtPrice1, sqrtPrice2);
const upperSqrtPriceX64 = BN.max(sqrtPrice1, sqrtPrice2);
const delta = upperSqrtPriceX64.sub(lowerSqrtPriceX64);
return tokenAmount.shln(64).div(delta);
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/public/price-math.ts
|
import { BN } from "@coral-xyz/anchor";
import type { Percentage } from "@orca-so/common-sdk";
import { DecimalUtil, MathUtil } from "@orca-so/common-sdk";
import Decimal from "decimal.js";
import {
MAX_SQRT_PRICE,
MAX_SQRT_PRICE_BN,
MIN_SQRT_PRICE,
MIN_SQRT_PRICE_BN,
} from "../../types/public";
import { TickUtil } from "./tick-utils";
const BIT_PRECISION = 14;
const LOG_B_2_X32 = "59543866431248";
const LOG_B_P_ERR_MARGIN_LOWER_X64 = "184467440737095516";
const LOG_B_P_ERR_MARGIN_UPPER_X64 = "15793534762490258745";
/**
* A collection of utility functions to convert between price, tickIndex and sqrtPrice.
*
* @category Whirlpool Utils
*/
export class PriceMath {
public static priceToSqrtPriceX64(
price: Decimal,
decimalsA: number,
decimalsB: number,
): BN {
return MathUtil.toX64(
price.mul(Decimal.pow(10, decimalsB - decimalsA)).sqrt(),
);
}
public static sqrtPriceX64ToPrice(
sqrtPriceX64: BN,
decimalsA: number,
decimalsB: number,
): Decimal {
return MathUtil.fromX64(sqrtPriceX64)
.pow(2)
.mul(Decimal.pow(10, decimalsA - decimalsB));
}
/**
* @param tickIndex
* @returns
*/
public static tickIndexToSqrtPriceX64(tickIndex: number): BN {
if (tickIndex > 0) {
return new BN(tickIndexToSqrtPricePositive(tickIndex));
} else {
return new BN(tickIndexToSqrtPriceNegative(tickIndex));
}
}
/**
*
* @param sqrtPriceX64
* @returns
*/
public static sqrtPriceX64ToTickIndex(sqrtPriceX64: BN): number {
if (
sqrtPriceX64.gt(new BN(MAX_SQRT_PRICE)) ||
sqrtPriceX64.lt(new BN(MIN_SQRT_PRICE))
) {
throw new Error(
"Provided sqrtPrice is not within the supported sqrtPrice range.",
);
}
const msb = sqrtPriceX64.bitLength() - 1;
const adjustedMsb = new BN(msb - 64);
const log2pIntegerX32 = signedShiftLeft(adjustedMsb, 32, 128);
let bit = new BN("8000000000000000", "hex");
let precision = 0;
let log2pFractionX64 = new BN(0);
let r =
msb >= 64 ? sqrtPriceX64.shrn(msb - 63) : sqrtPriceX64.shln(63 - msb);
while (bit.gt(new BN(0)) && precision < BIT_PRECISION) {
r = r.mul(r);
let rMoreThanTwo = r.shrn(127);
r = r.shrn(63 + rMoreThanTwo.toNumber());
log2pFractionX64 = log2pFractionX64.add(bit.mul(rMoreThanTwo));
bit = bit.shrn(1);
precision += 1;
}
const log2pFractionX32 = log2pFractionX64.shrn(32);
const log2pX32 = log2pIntegerX32.add(log2pFractionX32);
const logbpX64 = log2pX32.mul(new BN(LOG_B_2_X32));
const tickLow = signedShiftRight(
logbpX64.sub(new BN(LOG_B_P_ERR_MARGIN_LOWER_X64)),
64,
128,
).toNumber();
const tickHigh = signedShiftRight(
logbpX64.add(new BN(LOG_B_P_ERR_MARGIN_UPPER_X64)),
64,
128,
).toNumber();
if (tickLow == tickHigh) {
return tickLow;
} else {
const derivedTickHighSqrtPriceX64 =
PriceMath.tickIndexToSqrtPriceX64(tickHigh);
if (derivedTickHighSqrtPriceX64.lte(sqrtPriceX64)) {
return tickHigh;
} else {
return tickLow;
}
}
}
public static tickIndexToPrice(
tickIndex: number,
decimalsA: number,
decimalsB: number,
): Decimal {
return PriceMath.sqrtPriceX64ToPrice(
PriceMath.tickIndexToSqrtPriceX64(tickIndex),
decimalsA,
decimalsB,
);
}
public static priceToTickIndex(
price: Decimal,
decimalsA: number,
decimalsB: number,
): number {
return PriceMath.sqrtPriceX64ToTickIndex(
PriceMath.priceToSqrtPriceX64(price, decimalsA, decimalsB),
);
}
public static priceToInitializableTickIndex(
price: Decimal,
decimalsA: number,
decimalsB: number,
tickSpacing: number,
): number {
return TickUtil.getInitializableTickIndex(
PriceMath.priceToTickIndex(price, decimalsA, decimalsB),
tickSpacing,
);
}
/**
* Utility to invert the price Pb/Pa to Pa/Pb
* NOTE: precision is lost in this conversion
*
* @param price Pb / Pa
* @param decimalsA Decimals of original token A (i.e. token A in the given Pb / Pa price)
* @param decimalsB Decimals of original token B (i.e. token B in the given Pb / Pa price)
* @returns inverted price, i.e. Pa / Pb
*/
public static invertPrice(
price: Decimal,
decimalsA: number,
decimalsB: number,
): Decimal {
const tick = PriceMath.priceToTickIndex(price, decimalsA, decimalsB);
const invTick = TickUtil.invertTick(tick);
return PriceMath.tickIndexToPrice(invTick, decimalsB, decimalsA);
}
/**
* Utility to invert the sqrtPriceX64 from X64 repr. of sqrt(Pb/Pa) to X64 repr. of sqrt(Pa/Pb)
* NOTE: precision is lost in this conversion
*
* @param sqrtPriceX64 X64 representation of sqrt(Pb / Pa)
* @returns inverted sqrtPriceX64, i.e. X64 representation of sqrt(Pa / Pb)
*/
public static invertSqrtPriceX64(sqrtPriceX64: BN): BN {
const tick = PriceMath.sqrtPriceX64ToTickIndex(sqrtPriceX64);
const invTick = TickUtil.invertTick(tick);
return PriceMath.tickIndexToSqrtPriceX64(invTick);
}
/**
* Calculate the sqrtPriceX64 & tick index slippage price boundary for a given price and slippage.
* Note: This function loses precision
*
* @param sqrtPriceX64 the sqrtPriceX64 to apply the slippage on
* @param slippage the slippage to apply onto the sqrtPriceX64
* @returns the sqrtPriceX64 & tick index slippage price boundary
*/
public static getSlippageBoundForSqrtPrice(
sqrtPriceX64: BN,
slippage: Percentage,
): { lowerBound: [BN, number]; upperBound: [BN, number] } {
const sqrtPriceX64Decimal = DecimalUtil.fromBN(sqrtPriceX64);
const slippageNumerator = new Decimal(slippage.numerator.toString());
const slippageDenominator = new Decimal(slippage.denominator.toString());
const lowerBoundSqrtPriceDecimal = sqrtPriceX64Decimal
.mul(slippageDenominator.sub(slippageNumerator).sqrt())
.div(slippageDenominator.sqrt())
.toDecimalPlaces(0);
const upperBoundSqrtPriceDecimal = sqrtPriceX64Decimal
.mul(slippageDenominator.add(slippageNumerator).sqrt())
.div(slippageDenominator.sqrt())
.toDecimalPlaces(0);
const lowerBoundSqrtPrice = BN.min(
BN.max(new BN(lowerBoundSqrtPriceDecimal.toFixed(0)), MIN_SQRT_PRICE_BN),
MAX_SQRT_PRICE_BN,
);
const upperBoundSqrtPrice = BN.min(
BN.max(new BN(upperBoundSqrtPriceDecimal.toFixed(0)), MIN_SQRT_PRICE_BN),
MAX_SQRT_PRICE_BN,
);
const lowerTickCurrentIndex =
PriceMath.sqrtPriceX64ToTickIndex(lowerBoundSqrtPrice);
const upperTickCurrentIndex =
PriceMath.sqrtPriceX64ToTickIndex(upperBoundSqrtPrice);
return {
lowerBound: [lowerBoundSqrtPrice, lowerTickCurrentIndex],
upperBound: [upperBoundSqrtPrice, upperTickCurrentIndex],
};
}
}
// Private Functions
function tickIndexToSqrtPricePositive(tick: number) {
let ratio: BN;
if ((tick & 1) != 0) {
ratio = new BN("79232123823359799118286999567");
} else {
ratio = new BN("79228162514264337593543950336");
}
if ((tick & 2) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("79236085330515764027303304731")),
96,
256,
);
}
if ((tick & 4) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("79244008939048815603706035061")),
96,
256,
);
}
if ((tick & 8) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("79259858533276714757314932305")),
96,
256,
);
}
if ((tick & 16) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("79291567232598584799939703904")),
96,
256,
);
}
if ((tick & 32) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("79355022692464371645785046466")),
96,
256,
);
}
if ((tick & 64) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("79482085999252804386437311141")),
96,
256,
);
}
if ((tick & 128) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("79736823300114093921829183326")),
96,
256,
);
}
if ((tick & 256) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("80248749790819932309965073892")),
96,
256,
);
}
if ((tick & 512) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("81282483887344747381513967011")),
96,
256,
);
}
if ((tick & 1024) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("83390072131320151908154831281")),
96,
256,
);
}
if ((tick & 2048) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("87770609709833776024991924138")),
96,
256,
);
}
if ((tick & 4096) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("97234110755111693312479820773")),
96,
256,
);
}
if ((tick & 8192) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("119332217159966728226237229890")),
96,
256,
);
}
if ((tick & 16384) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("179736315981702064433883588727")),
96,
256,
);
}
if ((tick & 32768) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("407748233172238350107850275304")),
96,
256,
);
}
if ((tick & 65536) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("2098478828474011932436660412517")),
96,
256,
);
}
if ((tick & 131072) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("55581415166113811149459800483533")),
96,
256,
);
}
if ((tick & 262144) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("38992368544603139932233054999993551")),
96,
256,
);
}
return signedShiftRight(ratio, 32, 256);
}
function tickIndexToSqrtPriceNegative(tickIndex: number) {
let tick = Math.abs(tickIndex);
let ratio: BN;
if ((tick & 1) != 0) {
ratio = new BN("18445821805675392311");
} else {
ratio = new BN("18446744073709551616");
}
if ((tick & 2) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("18444899583751176498")),
64,
256,
);
}
if ((tick & 4) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("18443055278223354162")),
64,
256,
);
}
if ((tick & 8) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("18439367220385604838")),
64,
256,
);
}
if ((tick & 16) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("18431993317065449817")),
64,
256,
);
}
if ((tick & 32) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("18417254355718160513")),
64,
256,
);
}
if ((tick & 64) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("18387811781193591352")),
64,
256,
);
}
if ((tick & 128) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("18329067761203520168")),
64,
256,
);
}
if ((tick & 256) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("18212142134806087854")),
64,
256,
);
}
if ((tick & 512) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("17980523815641551639")),
64,
256,
);
}
if ((tick & 1024) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("17526086738831147013")),
64,
256,
);
}
if ((tick & 2048) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("16651378430235024244")),
64,
256,
);
}
if ((tick & 4096) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("15030750278693429944")),
64,
256,
);
}
if ((tick & 8192) != 0) {
ratio = signedShiftRight(
ratio.mul(new BN("12247334978882834399")),
64,
256,
);
}
if ((tick & 16384) != 0) {
ratio = signedShiftRight(ratio.mul(new BN("8131365268884726200")), 64, 256);
}
if ((tick & 32768) != 0) {
ratio = signedShiftRight(ratio.mul(new BN("3584323654723342297")), 64, 256);
}
if ((tick & 65536) != 0) {
ratio = signedShiftRight(ratio.mul(new BN("696457651847595233")), 64, 256);
}
if ((tick & 131072) != 0) {
ratio = signedShiftRight(ratio.mul(new BN("26294789957452057")), 64, 256);
}
if ((tick & 262144) != 0) {
ratio = signedShiftRight(ratio.mul(new BN("37481735321082")), 64, 256);
}
return ratio;
}
function signedShiftLeft(n0: BN, shiftBy: number, bitWidth: number) {
let twosN0 = n0.toTwos(bitWidth).shln(shiftBy);
twosN0.imaskn(bitWidth + 1);
return twosN0.fromTwos(bitWidth);
}
function signedShiftRight(n0: BN, shiftBy: number, bitWidth: number) {
let twoN0 = n0.toTwos(bitWidth).shrn(shiftBy);
twoN0.imaskn(bitWidth - shiftBy + 1);
return twoN0.fromTwos(bitWidth - shiftBy);
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/public/swap-utils.ts
|
import type { Address } from "@coral-xyz/anchor";
import type { Percentage } from "@orca-so/common-sdk";
import { AddressUtil, U64_MAX, ZERO } from "@orca-so/common-sdk";
import type { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import type { WhirlpoolContext } from "../..";
import { TickUtil } from "../..";
import type {
WhirlpoolAccountFetchOptions,
WhirlpoolAccountFetcherInterface,
} from "../../network/public/fetcher";
import type {
SwapInput,
SwapParams,
TickArray,
WhirlpoolData,
} from "../../types/public";
import { MAX_SQRT_PRICE, MIN_SQRT_PRICE } from "../../types/public";
import type { Whirlpool } from "../../whirlpool-client";
import { adjustForSlippage } from "../math/token-math";
import { PDAUtil } from "./pda-utils";
import { PoolUtil } from "./pool-utils";
import { SwapDirection, TokenType } from "./types";
import type { TickArrayAddress } from "../swap-utils";
import {
buildZeroedTickArray,
getTickArrayPublicKeysWithStartTickIndex,
} from "../swap-utils";
/**
* A request to fetch the tick-arrays that a swap may traverse across.
* @category Whirlpool Utils
*/
export interface TickArrayRequest {
whirlpoolAddress: PublicKey;
aToB: boolean;
tickCurrentIndex: number;
tickSpacing: number;
}
/**
* @category Whirlpool Utils
*/
export class SwapUtils {
/**
* Get the default values for the sqrtPriceLimit parameter in a swap.
* @param aToB - The direction of a swap
* @returns The default values for the sqrtPriceLimit parameter in a swap.
*/
public static getDefaultSqrtPriceLimit(aToB: boolean) {
return new BN(aToB ? MIN_SQRT_PRICE : MAX_SQRT_PRICE);
}
/**
* Get the default values for the otherAmountThreshold parameter in a swap.
* @param amountSpecifiedIsInput - The direction of a swap
* @returns The default values for the otherAmountThreshold parameter in a swap.
*/
public static getDefaultOtherAmountThreshold(
amountSpecifiedIsInput: boolean,
) {
return amountSpecifiedIsInput ? ZERO : U64_MAX;
}
/**
* Given the intended token mint to swap, return the swap direction of a swap for a Whirlpool
* @param pool The Whirlpool to evaluate the mint against
* @param swapTokenMint The token mint PublicKey the user bases their swap against
* @param swapTokenIsInput Whether the swap token is the input token. (similar to amountSpecifiedIsInput from swap Ix)
* @returns The direction of the swap given the swapTokenMint. undefined if the token mint is not part of the trade pair of the pool.
*/
public static getSwapDirection(
pool: WhirlpoolData,
swapTokenMint: PublicKey,
swapTokenIsInput: boolean,
): SwapDirection | undefined {
const tokenType = PoolUtil.getTokenType(pool, swapTokenMint);
if (!tokenType) {
return undefined;
}
return (tokenType === TokenType.TokenA) === swapTokenIsInput
? SwapDirection.AtoB
: SwapDirection.BtoA;
}
/**
* Given the current tick-index, returns the dervied PDA and fetched data
* for the tick-arrays that this swap may traverse across.
*
* @category Whirlpool Utils
* @param tickCurrentIndex - The current tickIndex for the Whirlpool to swap on.
* @param tickSpacing - The tickSpacing for the Whirlpool.
* @param aToB - The direction of the trade.
* @param programId - The Whirlpool programId which the Whirlpool lives on.
* @param whirlpoolAddress - PublicKey of the whirlpool to swap on.
* @returns An array of PublicKey[] for the tickArray accounts that this swap may traverse across.
*/
public static getTickArrayPublicKeys(
tickCurrentIndex: number,
tickSpacing: number,
aToB: boolean,
programId: PublicKey,
whirlpoolAddress: PublicKey,
): PublicKey[] {
return getTickArrayPublicKeysWithStartTickIndex(
tickCurrentIndex,
tickSpacing,
aToB,
programId,
whirlpoolAddress,
).map((p) => p.pubkey);
}
/**
* Given the tickArrays, return the fallback tickArray account that this swap may traverse across.
*
* @category Whirlpool Utils
* @param tickArrays - An array of tickArrays to be used in the swap.
* @param tickSpacing - The tickSpacing for the Whirlpool.
* @param aToB - The direction of the trade.
* @param programId - The Whirlpool programId which the Whirlpool lives on.
* @param whirlpoolAddress - PublicKey of the whirlpool to swap on.
* @returns A PublicKey for the fallback tickArray account that this swap may traverse across. If the fallback tickArray does not exist, return undefined.
*/
public static getFallbackTickArrayPublicKey(
tickArrays: TickArray[],
tickSpacing: number,
aToB: boolean,
programId: PublicKey,
whirlpoolAddress: PublicKey,
): PublicKey | undefined {
try {
const fallbackStartTickIndex = TickUtil.getStartTickIndex(
tickArrays[0].startTickIndex,
tickSpacing,
aToB ? 1 : -1,
);
const pda = PDAUtil.getTickArray(
programId,
whirlpoolAddress,
fallbackStartTickIndex,
);
return pda.publicKey;
} catch {
return undefined;
}
}
/**
* Given the current tick-index, returns TickArray objects that this swap may traverse across.
*
* @category Whirlpool Utils
* @param tickCurrentIndex - The current tickIndex for the Whirlpool to swap on.
* @param tickSpacing - The tickSpacing for the Whirlpool.
* @param aToB - The direction of the trade.
* @param programId - The Whirlpool programId which the Whirlpool lives on.
* @param whirlpoolAddress - PublicKey of the whirlpool to swap on.
* @param cache - WhirlpoolAccountCacheInterface object to fetch solana accounts
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @returns An array of PublicKey[] for the tickArray accounts that this swap may traverse across.
*/
public static async getTickArrays(
tickCurrentIndex: number,
tickSpacing: number,
aToB: boolean,
programId: PublicKey,
whirlpoolAddress: PublicKey,
fetcher: WhirlpoolAccountFetcherInterface,
opts?: WhirlpoolAccountFetchOptions,
): Promise<TickArray[]> {
const data = await this.getBatchTickArrays(
programId,
fetcher,
[{ tickCurrentIndex, tickSpacing, aToB, whirlpoolAddress }],
opts,
);
return data[0];
}
/**
* Fetch a batch of tick-arrays for a set of TA requests.
* @param programId - The Whirlpool programId which the Whirlpool lives on.
* @param cache - WhirlpoolAccountCacheInterface instance to fetch solana accounts
* @param tickArrayRequests - An array of {@link TickArrayRequest} of tick-arrays to request for.
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @returns A array of request indicies mapped to an array of resulting PublicKeys.
*/
public static async getBatchTickArrays(
programId: PublicKey,
fetcher: WhirlpoolAccountFetcherInterface,
tickArrayRequests: TickArrayRequest[],
opts?: WhirlpoolAccountFetchOptions,
): Promise<TickArray[][]> {
let addresses: TickArrayAddress[] = [];
let requestToIndices = [];
// Each individual tick array request may correspond to more than one tick array
// so we map each request to a slice of the batch request
for (let i = 0; i < tickArrayRequests.length; i++) {
const { tickCurrentIndex, tickSpacing, aToB, whirlpoolAddress } =
tickArrayRequests[i];
const requestAddresses = getTickArrayPublicKeysWithStartTickIndex(
tickCurrentIndex,
tickSpacing,
aToB,
programId,
whirlpoolAddress,
);
requestToIndices.push([
addresses.length,
addresses.length + requestAddresses.length,
]);
addresses.push(...requestAddresses);
}
const data = await fetcher.getTickArrays(
addresses.map((a) => a.pubkey),
opts,
);
// Re-map from flattened batch data to TickArray[] for request
return requestToIndices.map((indices) => {
const [start, end] = indices;
const addressSlice = addresses.slice(start, end);
const dataSlice = data.slice(start, end);
return addressSlice.map((addr, index) => ({
address: addr.pubkey,
startTickIndex: addr.startTickIndex,
data: dataSlice[index],
}));
});
}
/**
* Given a set of tickArrays, interpolate the tickArrays with zeroed tick data if they are not initialized.
*
* @param whirlpoolAddress - PublicKey of the whirlpool to swap on.
* @param tickArrays - Fetched tickArrays to interpolate.
* @returns An array of TickArray objects with zeroed tick data if they are not initialized.
*/
public static interpolateUninitializedTickArrays(
whirlpoolAddress: PublicKey,
tickArrays: TickArray[],
): TickArray[] {
return tickArrays.map((tickArray) => ({
address: tickArray.address,
startTickIndex: tickArray.startTickIndex,
data:
tickArray.data ??
buildZeroedTickArray(whirlpoolAddress, tickArray.startTickIndex),
}));
}
/**
* Calculate the SwapInput parameters `amount` & `otherAmountThreshold` based on the amountIn & amountOut estimates from a quote.
* @param amount - The amount of tokens the user wanted to swap from.
* @param estAmountIn - The estimated amount of input tokens expected in a `SwapQuote`
* @param estAmountOut - The estimated amount of output tokens expected from a `SwapQuote`
* @param slippageTolerance - The amount of slippage to adjust for.
* @param amountSpecifiedIsInput - Specifies the token the parameter `amount`represents in the swap quote. If true, the amount represents
* the input token of the swap.
* @returns A Partial `SwapInput` object containing the slippage adjusted 'amount' & 'otherAmountThreshold' parameters.
*/
public static calculateSwapAmountsFromQuote(
amount: BN,
estAmountIn: BN,
estAmountOut: BN,
slippageTolerance: Percentage,
amountSpecifiedIsInput: boolean,
): Pick<SwapInput, "amount" | "otherAmountThreshold"> {
if (amountSpecifiedIsInput) {
return {
amount,
otherAmountThreshold: adjustForSlippage(
estAmountOut,
slippageTolerance,
false,
),
};
} else {
return {
amount,
otherAmountThreshold: adjustForSlippage(
estAmountIn,
slippageTolerance,
true,
),
};
}
}
/**
* Convert a quote object and WhirlpoolClient's {@link Whirlpool} object into a {@link SwapParams} type
* to be plugged into {@link WhirlpoolIx.swapIx}.
*
* @param quote - A {@link SwapQuote} type generated from {@link swapQuoteWithParams}
* @param ctx - {@link WhirlpoolContext}
* @param whirlpool - A {@link Whirlpool} object from WhirlpoolClient
* @param inputTokenAssociatedAddress - The public key for the ATA of the input token in the swap
* @param outputTokenAssociatedAddress - The public key for the ATA of the input token in the swap
* @param wallet - The token authority for this swap
* @returns A converted {@link SwapParams} generated from the input
*/
public static getSwapParamsFromQuote(
quote: SwapInput,
ctx: WhirlpoolContext,
whirlpool: Whirlpool,
inputTokenAssociatedAddress: Address,
outputTokenAssociatedAddress: Address,
wallet: PublicKey,
) {
const data = whirlpool.getData();
return this.getSwapParamsFromQuoteKeys(
quote,
ctx,
whirlpool.getAddress(),
data.tokenVaultA,
data.tokenVaultB,
inputTokenAssociatedAddress,
outputTokenAssociatedAddress,
wallet,
);
}
public static getSwapParamsFromQuoteKeys(
quote: SwapInput,
ctx: WhirlpoolContext,
whirlpool: PublicKey,
tokenVaultA: PublicKey,
tokenVaultB: PublicKey,
inputTokenAssociatedAddress: Address,
outputTokenAssociatedAddress: Address,
wallet: PublicKey,
) {
const aToB = quote.aToB;
const [inputTokenATA, outputTokenATA] = AddressUtil.toPubKeys([
inputTokenAssociatedAddress,
outputTokenAssociatedAddress,
]);
const oraclePda = PDAUtil.getOracle(ctx.program.programId, whirlpool);
const params: SwapParams = {
whirlpool,
tokenOwnerAccountA: aToB ? inputTokenATA : outputTokenATA,
tokenOwnerAccountB: aToB ? outputTokenATA : inputTokenATA,
tokenVaultA,
tokenVaultB,
oracle: oraclePda.publicKey,
tokenAuthority: wallet,
...quote,
};
return params;
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/public/types.ts
|
/**
* An enum for the direction of a swap.
* @category Whirlpool Utils
*/
export enum SwapDirection {
AtoB = "aToB",
BtoA = "bToA",
}
/**
* An enum for the token type in a Whirlpool.
* @category Whirlpool Utils
*/
export enum TokenType {
TokenA = 1,
TokenB,
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/public/position-bundle-util.ts
|
import invariant from "tiny-invariant";
import type { PositionBundleData } from "../../types/public";
import { POSITION_BUNDLE_SIZE } from "../../types/public";
/**
* A collection of utility functions when interacting with a PositionBundle.
* @category Whirlpool Utils
*/
export class PositionBundleUtil {
/**
* Check if the bundle index is in the correct range.
*
* @param bundleIndex The bundle index to be checked
* @returns true if bundle index is in the correct range
*/
public static checkBundleIndexInBounds(bundleIndex: number): boolean {
return bundleIndex >= 0 && bundleIndex < POSITION_BUNDLE_SIZE;
}
/**
* Check if the Bundled Position corresponding to the bundle index has been opened.
*
* @param positionBundle The position bundle to be checked
* @param bundleIndex The bundle index to be checked
* @returns true if Bundled Position has been opened
*/
public static isOccupied(
positionBundle: PositionBundleData,
bundleIndex: number,
): boolean {
invariant(
PositionBundleUtil.checkBundleIndexInBounds(bundleIndex),
"bundleIndex out of range",
);
const array = PositionBundleUtil.convertBitmapToArray(positionBundle);
return array[bundleIndex];
}
/**
* Check if the Bundled Position corresponding to the bundle index has not been opened.
*
* @param positionBundle The position bundle to be checked
* @param bundleIndex The bundle index to be checked
* @returns true if Bundled Position has not been opened
*/
public static isUnoccupied(
positionBundle: PositionBundleData,
bundleIndex: number,
): boolean {
return !PositionBundleUtil.isOccupied(positionBundle, bundleIndex);
}
/**
* Check if all bundle index is occupied.
*
* @param positionBundle The position bundle to be checked
* @returns true if all bundle index is occupied
*/
public static isFull(positionBundle: PositionBundleData): boolean {
const unoccupied =
PositionBundleUtil.getUnoccupiedBundleIndexes(positionBundle);
return unoccupied.length === 0;
}
/**
* Check if all bundle index is unoccupied.
*
* @param positionBundle The position bundle to be checked
* @returns true if all bundle index is unoccupied
*/
public static isEmpty(positionBundle: PositionBundleData): boolean {
const occupied =
PositionBundleUtil.getOccupiedBundleIndexes(positionBundle);
return occupied.length === 0;
}
/**
* Get all bundle indexes where the corresponding Bundled Position is open.
*
* @param positionBundle The position bundle to be checked
* @returns The array of bundle index where the corresponding Bundled Position is open
*/
public static getOccupiedBundleIndexes(
positionBundle: PositionBundleData,
): number[] {
const result: number[] = [];
PositionBundleUtil.convertBitmapToArray(positionBundle).forEach(
(occupied, index) => {
if (occupied) {
result.push(index);
}
},
);
return result;
}
/**
* Get all bundle indexes where the corresponding Bundled Position is not open.
*
* @param positionBundle The position bundle to be checked
* @returns The array of bundle index where the corresponding Bundled Position is not open
*/
public static getUnoccupiedBundleIndexes(
positionBundle: PositionBundleData,
): number[] {
const result: number[] = [];
PositionBundleUtil.convertBitmapToArray(positionBundle).forEach(
(occupied, index) => {
if (!occupied) {
result.push(index);
}
},
);
return result;
}
/**
* Get the first unoccupied bundle index in the position bundle.
*
* @param positionBundle The position bundle to be checked
* @returns The first unoccupied bundle index, null if the position bundle is full
*/
public static findUnoccupiedBundleIndex(
positionBundle: PositionBundleData,
): number | null {
const unoccupied =
PositionBundleUtil.getUnoccupiedBundleIndexes(positionBundle);
return unoccupied.length === 0 ? null : unoccupied[0];
}
/**
* Convert position bitmap to the array of boolean which represent if Bundled Position is open.
*
* @param positionBundle The position bundle whose bitmap will be converted
* @returns The array of boolean representing if Bundled Position is open
*/
public static convertBitmapToArray(
positionBundle: PositionBundleData,
): boolean[] {
const result: boolean[] = [];
positionBundle.positionBitmap.map((bitmap) => {
for (let offset = 0; offset < 8; offset++) {
result.push((bitmap & (1 << offset)) !== 0);
}
});
return result;
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/public/index.ts
|
export * from "../graphs/public";
export * from "./ix-utils";
export * from "./pda-utils";
export * from "./pool-utils";
export * from "./position-bundle-util";
export * from "./price-math";
export * from "./swap-utils";
export * from "./tick-utils";
export * from "./token-extension-util";
export * from "./types";
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/public/token-extension-util.ts
|
import type { TransferFee } from "@solana/spl-token";
import {
calculateFee,
getEpochFee,
getTransferFeeConfig,
TOKEN_PROGRAM_ID,
TOKEN_2022_PROGRAM_ID,
getTransferHook,
addExtraAccountMetasForExecute,
} from "@solana/spl-token";
import BN from "bn.js";
import type { MintWithTokenProgram } from "@orca-so/common-sdk";
import { U64_MAX, ZERO } from "@orca-so/common-sdk";
import type {
WhirlpoolAccountFetchOptions,
WhirlpoolAccountFetcherInterface,
WhirlpoolData,
} from "../..";
import { PoolUtil } from "../..";
import type { AccountMeta, Connection } from "@solana/web3.js";
import { PublicKey, TransactionInstruction } from "@solana/web3.js";
export type TransferFeeIncludedAmount = {
amount: BN;
fee: BN;
};
export type TransferFeeExcludedAmount = {
amount: BN;
fee: BN;
};
export type TokenExtensionContext = {
currentEpoch: number;
tokenMintWithProgramA: MintWithTokenProgram;
tokenMintWithProgramB: MintWithTokenProgram;
rewardTokenMintsWithProgram: [
MintWithTokenProgram | null,
MintWithTokenProgram | null,
MintWithTokenProgram | null,
];
};
export type TokenExtensionContextForPool = Omit<
TokenExtensionContext,
"rewardTokenMintsWithProgram"
>;
export type TokenExtensionContextForReward = Omit<
TokenExtensionContext,
"tokenMintWithProgramA" | "tokenMintWithProgramB"
>;
const defaultTokenMintWithProgram: MintWithTokenProgram = {
address: PublicKey.default,
decimals: 0,
freezeAuthority: null,
mintAuthority: null,
isInitialized: true,
supply: 0n,
tlvData: Buffer.from([]),
tokenProgram: TOKEN_PROGRAM_ID,
};
export const NO_TOKEN_EXTENSION_CONTEXT: TokenExtensionContext = {
currentEpoch: 0,
tokenMintWithProgramA: defaultTokenMintWithProgram,
tokenMintWithProgramB: defaultTokenMintWithProgram,
rewardTokenMintsWithProgram: [
defaultTokenMintWithProgram,
defaultTokenMintWithProgram,
defaultTokenMintWithProgram,
],
};
export class TokenExtensionUtil {
public static calculateTransferFeeIncludedAmount(
transferFeeExcludedAmount: BN,
tokenInfo: MintWithTokenProgram,
currentEpoch: number,
): TransferFeeIncludedAmount {
const config = getTransferFeeConfig(tokenInfo);
if (config === null) {
return { amount: transferFeeExcludedAmount, fee: ZERO };
}
const transferFee = getEpochFee(config, BigInt(currentEpoch));
return calculateTransferFeeIncludedAmount(
transferFee,
transferFeeExcludedAmount,
);
}
public static calculateTransferFeeExcludedAmount(
transferFeeIncludedAmount: BN,
tokenInfo: MintWithTokenProgram,
currentEpoch: number,
): TransferFeeExcludedAmount {
const config = getTransferFeeConfig(tokenInfo);
if (config === null) {
return { amount: transferFeeIncludedAmount, fee: ZERO };
}
const transferFee = getEpochFee(config, BigInt(currentEpoch));
return calculateTransferFeeExcludedAmount(
transferFee,
transferFeeIncludedAmount,
);
}
public static async buildTokenExtensionContext(
fetcher: WhirlpoolAccountFetcherInterface,
whirlpoolData: WhirlpoolData,
opts?: WhirlpoolAccountFetchOptions,
): Promise<TokenExtensionContext> {
const mintA = whirlpoolData.tokenMintA;
const mintB = whirlpoolData.tokenMintB;
const rewards = whirlpoolData.rewardInfos;
const [tokenMintWithProgram, currentEpoch] = await Promise.all([
fetcher.getMintInfos(
[
mintA,
mintB,
...rewards
.filter((r) => PoolUtil.isRewardInitialized(r))
.map((r) => r.mint),
],
opts,
),
fetcher.getEpoch(),
]);
const get = (mint: PublicKey) => tokenMintWithProgram.get(mint.toBase58())!;
return {
tokenMintWithProgramA: get(whirlpoolData.tokenMintA),
tokenMintWithProgramB: get(whirlpoolData.tokenMintB),
rewardTokenMintsWithProgram: [
PoolUtil.isRewardInitialized(rewards[0]) ? get(rewards[0].mint) : null,
PoolUtil.isRewardInitialized(rewards[1]) ? get(rewards[1].mint) : null,
PoolUtil.isRewardInitialized(rewards[2]) ? get(rewards[2].mint) : null,
],
currentEpoch,
};
}
public static async buildTokenExtensionContextForPool(
fetcher: WhirlpoolAccountFetcherInterface,
tokenMintA: PublicKey,
tokenMintB: PublicKey,
opts?: WhirlpoolAccountFetchOptions,
): Promise<TokenExtensionContextForPool> {
const [tokenMintWithProgram, currentEpoch] = await Promise.all([
fetcher.getMintInfos([tokenMintA, tokenMintB], opts),
fetcher.getEpoch(),
]);
const get = (mint: PublicKey) => tokenMintWithProgram.get(mint.toBase58())!;
return {
tokenMintWithProgramA: get(tokenMintA),
tokenMintWithProgramB: get(tokenMintB),
currentEpoch,
};
}
public static async getExtraAccountMetasForTransferHook(
connection: Connection,
tokenMintWithProgram: MintWithTokenProgram,
source: PublicKey,
destination: PublicKey,
owner: PublicKey,
): Promise<AccountMeta[] | undefined> {
const transferHook = getTransferHook(tokenMintWithProgram);
if (!transferHook) return undefined;
const instruction = new TransactionInstruction({
programId: TOKEN_2022_PROGRAM_ID,
keys: [
{ pubkey: source, isSigner: false, isWritable: false },
{
pubkey: tokenMintWithProgram.address,
isSigner: false,
isWritable: false,
},
{ pubkey: destination, isSigner: false, isWritable: false },
{ pubkey: owner, isSigner: false, isWritable: false },
{ pubkey: owner, isSigner: false, isWritable: false },
],
});
await addExtraAccountMetasForExecute(
connection,
instruction,
transferHook.programId,
source,
tokenMintWithProgram.address,
destination,
owner,
0n, // extra account must not depend on the amount (the amount will be changed due to slippage)
"confirmed",
);
const extraAccountMetas = instruction.keys.slice(5);
return extraAccountMetas.length > 0 ? extraAccountMetas : undefined;
}
public static async getExtraAccountMetasForTransferHookForPool(
connection: Connection,
tokenExtensionCtx: TokenExtensionContextForPool,
sourceA: PublicKey,
destinationA: PublicKey,
ownerA: PublicKey,
sourceB: PublicKey,
destinationB: PublicKey,
ownerB: PublicKey,
): Promise<{
tokenTransferHookAccountsA: AccountMeta[] | undefined;
tokenTransferHookAccountsB: AccountMeta[] | undefined;
}> {
const [tokenTransferHookAccountsA, tokenTransferHookAccountsB] =
await Promise.all([
TokenExtensionUtil.getExtraAccountMetasForTransferHook(
connection,
tokenExtensionCtx.tokenMintWithProgramA,
sourceA,
destinationA,
ownerA,
),
TokenExtensionUtil.getExtraAccountMetasForTransferHook(
connection,
tokenExtensionCtx.tokenMintWithProgramB,
sourceB,
destinationB,
ownerB,
),
]);
return {
tokenTransferHookAccountsA,
tokenTransferHookAccountsB,
};
}
public static isV2IxRequiredPool(
tokenExtensionCtx: TokenExtensionContextForPool,
): boolean {
return (
tokenExtensionCtx.tokenMintWithProgramA.tokenProgram.equals(
TOKEN_2022_PROGRAM_ID,
) ||
tokenExtensionCtx.tokenMintWithProgramB.tokenProgram.equals(
TOKEN_2022_PROGRAM_ID,
)
);
}
public static isV2IxRequiredReward(
tokenExtensionCtx: TokenExtensionContextForReward,
rewardIndex: number,
): boolean {
return (
tokenExtensionCtx.rewardTokenMintsWithProgram[
rewardIndex
]?.tokenProgram.equals(TOKEN_2022_PROGRAM_ID) ?? false
);
}
}
function ceilDivBN(num: BN, denom: BN): BN {
return num.add(denom.subn(1)).div(denom);
}
function calculateTransferFeeIncludedAmount(
transferFee: TransferFee,
amount: BN,
): TransferFeeIncludedAmount {
// https://github.com/solana-labs/solana-program-library/blob/master/token/program-2022/src/extension/transfer_fee/mod.rs#L90
const ONE_IN_BASIS_POINTS = 10_000;
const maxFeeBN = new BN(transferFee.maximumFee.toString());
// edge cases
if (transferFee.transferFeeBasisPoints === 0) {
return {
amount,
fee: ZERO,
};
}
if (amount.isZero()) {
return {
amount,
fee: ZERO,
};
}
if (transferFee.transferFeeBasisPoints === ONE_IN_BASIS_POINTS) {
if (amount.add(maxFeeBN).gt(U64_MAX)) {
throw new Error("The total amount and fees overflow");
}
return {
amount: amount.add(maxFeeBN),
fee: maxFeeBN,
};
}
// normal case
const num = amount.muln(ONE_IN_BASIS_POINTS);
const denom = new BN(
ONE_IN_BASIS_POINTS - transferFee.transferFeeBasisPoints,
);
const rawFeeIncludedAmount = ceilDivBN(num, denom);
const result = rawFeeIncludedAmount.sub(amount).gte(maxFeeBN)
? { amount: amount.add(maxFeeBN), fee: maxFeeBN }
: { amount: rawFeeIncludedAmount, fee: rawFeeIncludedAmount.sub(amount) };
if (result.amount.gt(U64_MAX)) {
throw new Error("The total amount and fees overflow");
}
return { ...result };
}
function calculateTransferFeeExcludedAmount(
transferFee: TransferFee,
amount: BN,
): TransferFeeExcludedAmount {
const fee = calculateFee(transferFee, BigInt(amount.toString()));
const feeBN = new BN(fee.toString());
return {
amount: amount.sub(feeBN),
fee: feeBN,
};
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/graphs/adjacency-list-pool-graph.ts
|
import type { Address } from "@coral-xyz/anchor";
import { AddressUtil } from "@orca-so/common-sdk";
import type {
Edge,
Path,
PathSearchEntries,
PathSearchOptions,
PoolGraph,
PoolTokenPair,
} from "./public/pool-graph";
import { PoolGraphUtils } from "./public/pool-graph-utils";
/**
* A pool graph implementation using an adjacency list.
*
* Whirlpools (Pools (edges) & Tokens (nodes)) are sparse graphs concentrated on popular pairs such as SOL, USDC etc.
* Therefore this implementation is more efficient in memory consumption & building than a matrix.
*
* TODO: This implementation does not support 2-edge paths between identical tokens.
*/
export class AdjacencyListPoolGraph implements PoolGraph {
readonly graph: Readonly<AdjacencyPoolGraphMap>;
readonly tokens: Readonly<Address[]>;
constructor(pools: PoolTokenPair[]) {
const [adjacencyListGraphMap, insertedTokens] = buildPoolGraph(pools);
this.graph = adjacencyListGraphMap;
this.tokens = Array.from(insertedTokens);
}
getPath(
startMint: Address,
endMint: Address,
options?: PathSearchOptions,
): Path[] {
const results = this.getPathsForPairs([[startMint, endMint]], options);
return results[0][1];
}
getPathsForPairs(
searchTokenPairs: [Address, Address][],
options?: PathSearchOptions,
): PathSearchEntries {
const searchTokenPairsInString = searchTokenPairs.map(
([startMint, endMint]) => {
return [
AddressUtil.toString(startMint),
AddressUtil.toString(endMint),
] as const;
},
);
const searchTokenPairsToFind = searchTokenPairsInString.filter(
([startMint, endMint]) => {
return startMint !== endMint;
},
);
const walkMap = findWalks(
searchTokenPairsToFind,
this.graph,
options?.intermediateTokens.map((token) => AddressUtil.toString(token)),
);
const results = searchTokenPairsInString.map(([startMint, endMint]) => {
const searchRouteId = PoolGraphUtils.getSearchPathId(startMint, endMint);
const [internalStartMint, internalEndMint] = [startMint, endMint].sort();
const internalRouteId = getInternalRouteId(
internalStartMint,
internalEndMint,
false,
);
const reversed = internalStartMint !== startMint;
const pathsForSearchPair = walkMap[internalRouteId];
const paths = pathsForSearchPair
? pathsForSearchPair.map<Path>((path) => {
return {
startTokenMint: startMint,
endTokenMint: endMint,
edges: getHopsFromRoute(path, reversed),
};
})
: [];
return [searchRouteId, paths] as const;
});
return results;
}
getAllPaths(options?: PathSearchOptions | undefined): PathSearchEntries {
const tokenPairCombinations = combinations2(this.tokens) as [
string,
string,
][];
const searchTokenPairsInString = tokenPairCombinations.map(
([startMint, endMint]) => {
return [startMint, endMint] as const;
},
);
const searchTokenPairsToFind = searchTokenPairsInString.filter(
([startMint, endMint]) => {
return startMint !== endMint;
},
);
const walkMap = findWalks(
searchTokenPairsToFind,
this.graph,
options?.intermediateTokens.map((token) => AddressUtil.toString(token)),
);
// TODO: The token pairs are is in 1 direction only, we have to reverse them to get the other direction.
// this is actually pretty slow.consider removing reversal optimization in findWalks
const results = searchTokenPairsInString.reduce<PathSearchEntries>(
(acc, [startMint, endMint]) => {
const searchRouteId = PoolGraphUtils.getSearchPathId(
startMint,
endMint,
);
// We do not support routes that routes between identical tokens
if (startMint === endMint) {
acc.push([searchRouteId, []]);
return acc;
}
const [internalStartMint, internalEndMint] = [
startMint,
endMint,
].sort();
const internalRouteId = getInternalRouteId(
internalStartMint,
internalEndMint,
false,
);
const reversed = internalStartMint !== startMint;
const pathsForSearchPair = walkMap[internalRouteId];
const paths = pathsForSearchPair
? pathsForSearchPair.map<Path>((path) => {
return {
startTokenMint: startMint,
endTokenMint: endMint,
edges: getHopsFromRoute(path, reversed),
};
})
: [];
acc.push([searchRouteId, paths]);
const reversedSearchRouteId = PoolGraphUtils.getSearchPathId(
endMint,
startMint,
);
const reversedPaths = pathsForSearchPair
? pathsForSearchPair.map<Path>((path) => {
return {
startTokenMint: endMint,
endTokenMint: startMint,
edges: getHopsFromRoute(path, !reversed),
};
})
: [];
acc.push([reversedSearchRouteId, reversedPaths]);
return acc;
},
[],
);
return results;
}
}
function getHopsFromRoute(path: string[], reversed: boolean): Edge[] {
const finalRoutes = reversed ? path.slice().reverse() : path;
return finalRoutes.map((hopStr) => {
return { poolAddress: hopStr };
});
}
type AdjacencyPoolGraphMap = Record<string, readonly PoolGraphEdge[]>;
type PoolGraphEdge = {
address: string;
otherToken: string;
};
// A record of path-id (tokenA-tokenB) to a list of edges
type PoolWalks = Record<string, string[][]>;
function buildPoolGraph(
pools: PoolTokenPair[],
): readonly [Readonly<AdjacencyPoolGraphMap>, Set<string>] {
const insertedPoolCache: Record<string, Set<string>> = {};
const insertedTokens = new Set<string>();
const poolGraphSet = pools.reduce(
(poolGraph: Record<string, PoolGraphEdge[]>, pool) => {
const { address, tokenMintA, tokenMintB } = pool;
const [addr, mintA, mintB] = AddressUtil.toStrings([
address,
tokenMintA,
tokenMintB,
]);
insertedTokens.add(mintA);
insertedTokens.add(mintB);
if (poolGraph[mintA] === undefined) {
poolGraph[mintA] = [];
insertedPoolCache[mintA] = new Set<string>();
}
if (poolGraph[mintB] === undefined) {
poolGraph[mintB] = [];
insertedPoolCache[mintB] = new Set<string>();
}
const [insertedPoolsForA, insertedPoolsForB] = [
insertedPoolCache[mintA],
insertedPoolCache[mintB],
];
if (!insertedPoolsForA.has(addr)) {
poolGraph[mintA].push({ address: addr, otherToken: mintB });
insertedPoolsForA.add(addr);
}
if (!insertedPoolsForB.has(addr)) {
poolGraph[mintB].push({ address: addr, otherToken: mintA });
insertedPoolsForB.add(addr);
}
return poolGraph;
},
{},
);
return [poolGraphSet, insertedTokens] as const;
}
// This is currently hardcoded to find walks of max length 2, generalizing to longer walks
// may mean that a adjacency matrix might have better performance
// NOTE: that this function does not support routing between the same token on hop length 2.
function findWalks(
tokenPairs: (readonly [string, string])[],
poolGraph: AdjacencyPoolGraphMap,
intermediateTokens?: string[],
) {
const walks: PoolWalks = {};
tokenPairs.forEach(([tokenMintFrom, tokenMintTo]) => {
let paths = [];
// Adjust walk's from & to token based of internal path id.
const [internalTokenMintFrom, internalTokenMintTo] = [
tokenMintFrom,
tokenMintTo,
].sort();
const internalPathId = getInternalRouteId(
internalTokenMintFrom,
internalTokenMintTo,
false,
);
const poolsForTokenFrom = poolGraph[internalTokenMintFrom] || [];
const poolsForTokenTo = poolGraph[internalTokenMintTo] || [];
// If the internal path id has already been created, then there is no need to re-search the path.
// Possible that the path was searched in reverse.
if (!!walks[internalPathId]) {
return;
}
// Find all direct pool paths, i.e. all edges shared between tokenA and tokenB
const singleHop = poolsForTokenFrom
.filter(({ address }) =>
poolsForTokenTo.some((p) => p.address === address),
)
.map((op) => [op.address]);
paths.push(...singleHop);
// Remove all direct edges from poolA to poolB
const firstHop = poolsForTokenFrom.filter(
({ address }) => !poolsForTokenTo.some((p) => p.address === address),
);
// Find all edges/nodes from neighbors of A that connect to B to create paths of length 2
// tokenA --> tokenX --> tokenB
firstHop.forEach((firstPool) => {
const intermediateToken = firstPool.otherToken;
if (
!intermediateTokens ||
intermediateTokens.indexOf(intermediateToken) > -1
) {
const secondHops = poolsForTokenTo
.filter((secondPool) => secondPool.otherToken === intermediateToken)
.map((secondPool) => [firstPool.address, secondPool.address]);
paths.push(...secondHops);
}
});
if (paths.length > 0) {
walks[internalPathId] = paths;
}
});
return walks;
}
function getInternalRouteId(
tokenA: Address,
tokenB: Address,
sort = true,
): string {
const mints = [AddressUtil.toString(tokenA), AddressUtil.toString(tokenB)];
const sortedMints = sort ? mints.sort() : mints;
return `${sortedMints[0]}${PoolGraphUtils.PATH_ID_DELIMITER}${sortedMints[1]}`;
}
// equivalent to lodash.combinations(array, 2)
function combinations2<T>(array: Readonly<T[]>): [T, T][] {
const result: [T, T][] = [];
for (let i = 0; i < array.length - 1; i++) {
for (let j = i + 1; j < array.length; j++) {
result.push([array[i], array[j]]);
}
}
return result;
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/graphs
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/graphs/public/pool-graph-builder.ts
|
import type { Address } from "@coral-xyz/anchor";
import type { WhirlpoolAccountFetcherInterface } from "../../../network/public/fetcher";
import { PREFER_CACHE } from "../../../network/public/fetcher";
import { AdjacencyListPoolGraph } from "../adjacency-list-pool-graph";
import type { PoolGraph, PoolTokenPair } from "./pool-graph";
/**
* A builder class for creating a {@link PoolGraph}
*
* Note: we use an adjacency list as a representation of our pool graph,
* since we assume that most token pairings don't exist as pools
* @category PoolGraph
*/
export class PoolGraphBuilder {
/**
* Fetch data and build a {@link PoolGraph} from a list of pools addresses
* @param pools - a list of pool addresses to generate this pool graph
* @param cache - {@link WhirlpoolAccountFetcherInterface} to use for fetching pool data
* @returns A {@link PoolGraph} with the provided pools
*/
static async buildPoolGraphWithFetch(
pools: Address[],
fetcher: WhirlpoolAccountFetcherInterface,
): Promise<PoolGraph> {
const poolAccounts = await fetcher.getPools(pools, PREFER_CACHE);
const poolTokenPairs = Array.from(poolAccounts.entries())
.map(([addr, pool]) => {
if (pool) {
return {
address: addr,
tokenMintA: pool.tokenMintA,
tokenMintB: pool.tokenMintB,
};
}
return null;
})
.flatMap((pool) => (pool ? pool : []));
return new AdjacencyListPoolGraph(poolTokenPairs);
}
/**
* Build a {@link PoolGraph} from a list of pools in the format of {@link PoolTokenPair}
* @param poolTokenPairs - a list of {@link PoolTokenPair} to generate this pool graph
* @returns A {@link PoolGraph} with the provided pools
*/
static buildPoolGraph(poolTokenPairs: PoolTokenPair[]): PoolGraph {
return new AdjacencyListPoolGraph(poolTokenPairs);
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/graphs
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/graphs/public/pool-graph-utils.ts
|
import type { Address } from "@coral-xyz/anchor";
import { AddressUtil } from "@orca-so/common-sdk";
/**
* A utility class for working with pool graphs
* @category PoolGraph
*/
export class PoolGraphUtils {
static readonly PATH_ID_DELIMITER = "-";
/**
* Get a search path id from two tokens. The id can be used to identify a path between the two tokens in {@link PathSearchEntries}.
* @param tokenA The first token in the path
* @param tokenB The second token in the path
* @returns A path id that can be used to identify a path between the two tokens in {@link PathSearchEntries}.
*/
static getSearchPathId(tokenA: Address, tokenB: Address): string {
return `${AddressUtil.toString(tokenA)}${
PoolGraphUtils.PATH_ID_DELIMITER
}${AddressUtil.toString(tokenB)}`;
}
/**
* Deconstruct a path id into the two tokens it represents
* @param pathId - The path id to deconstruct
* @returns A tuple of the two tokens in the path id. Returns undefined if the provided pathId is invalid.
*/
static deconstructPathId(pathId: string): readonly [string, string] {
const split = pathId.split(PoolGraphUtils.PATH_ID_DELIMITER);
if (split.length !== 2) {
throw new Error(`Invalid path id: ${pathId}`);
}
const [tokenA, tokenB] = split;
return [tokenA, tokenB] as const;
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/graphs
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/graphs/public/pool-graph.ts
|
import type { Address } from "@coral-xyz/anchor";
/**
* An object containing the token pairs of a Whirlpool.
* @category PoolGraph
*/
export interface PoolTokenPair {
address: Address;
tokenMintA: Address;
tokenMintB: Address;
}
/**
* Results for a series of graph search queries between two tokens.
* The search id for each entry can be obtained from {@link PoolGraphUtils.getSearchRouteId}
* If a path exist between tokens for that search id, it will be an array of paths.
* If paths do not exist, it will be an empty array.
*
* @category PoolGraph
*/
export type PathSearchEntries = (readonly [string, Path[]])[];
/**
* A path to trade from start token mint to end token mint.
*
* @category PoolGraph
* @param startMint - The token the path starts with
* @param endMint - The token the path ends with
* @param edges - An ordered list of edges (pool addresses) that make up the path
*/
export type Path = {
startTokenMint: string;
endTokenMint: string;
edges: Edge[];
};
/**
* A type representing a pool graph edge.
*
* @category PoolGraph
*/
export type Edge = {
poolAddress: Address;
};
/**
* Options for finding a path between two tokens
*
* @category PoolGraph
* @param intermediateTokens - A list of tokens that can be used as intermediate hops
*/
export type PathSearchOptions = {
intermediateTokens: Address[];
};
/**
* A type representing an undirected graph of pools that can be used to find paths between two tokens.
* In this graph, nodes are token mints, and edges are pools
*
* @category PoolGraph
*/
export type PoolGraph = {
/**
* Get a list of paths between two tokens for this pool graph.
*
* Notes:
* - Only support paths with up to 2 edges
* - Paths searching between two identical token mints are not supported.
*
* @param startMint The token the path starts from
* @param endMint The token the path ends in
* @param options Options for finding a path
* @returns A list of path between the two tokens. If no path are found, it will be an empty array.
*/
getPath: (
startMint: Address,
endMint: Address,
options?: PathSearchOptions,
) => Path[];
/**
* Get a map of paths from a list of token pairs for this pool graph.
*
* Notes:
* - Only support paths with up to 2 edges
* - Paths searching between two identical token mints are not supported.
*
* @param searchTokenPairs A list of token pairs to find paths for. The first token in the pair is the start token, and the second token is the end token.
* @param options Options for finding a path
* @return An array of search result entires in the same order as the searchTokenPairs.
*/
getPathsForPairs(
searchTokenPairs: [Address, Address][],
options?: PathSearchOptions,
): PathSearchEntries;
/**
* Get a list of all paths for this pool graph.
* @param options Options for finding a path
* @return An array of all permutations of token-pairs to the paths for each pair.
*/
getAllPaths(options?: PathSearchOptions): PathSearchEntries;
};
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/graphs
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/graphs/public/index.ts
|
export type * from "./pool-graph";
export * from "./pool-graph-builder";
export * from "./pool-graph-utils";
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/utils/builder/position-builder-util.ts
|
import type { WhirlpoolContext } from "../..";
import type { WhirlpoolAccountFetchOptions } from "../../network/public/fetcher";
import type { PositionData, WhirlpoolData } from "../../types/public";
import { PDAUtil } from "../public";
export async function getTickArrayDataForPosition(
ctx: WhirlpoolContext,
position: PositionData,
whirlpool: WhirlpoolData,
opts?: WhirlpoolAccountFetchOptions,
) {
const lowerTickArrayKey = PDAUtil.getTickArrayFromTickIndex(
position.tickLowerIndex,
whirlpool.tickSpacing,
position.whirlpool,
ctx.program.programId,
).publicKey;
const upperTickArrayKey = PDAUtil.getTickArrayFromTickIndex(
position.tickUpperIndex,
whirlpool.tickSpacing,
position.whirlpool,
ctx.program.programId,
).publicKey;
return await ctx.fetcher.getTickArrays(
[lowerTickArrayKey, upperTickArrayKey],
opts,
);
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/errors/errors.ts
|
export enum MathErrorCode {
MultiplicationOverflow = `MultiplicationOverflow`,
MulDivOverflow = `MulDivOverflow`,
MultiplicationShiftRightOverflow = `MultiplicationShiftRightOverflow`,
DivideByZero = `DivideByZero`,
}
export enum TokenErrorCode {
TokenMaxExceeded = `TokenMaxExceeded`,
TokenMinSubceeded = `TokenMinSubceeded`,
}
export enum SwapErrorCode {
InvalidDevFeePercentage = `InvalidDevFeePercentage`,
InvalidSqrtPriceLimitDirection = `InvalidSqrtPriceLimitDirection`,
SqrtPriceOutOfBounds = `SqrtPriceOutOfBounds`,
ZeroTradableAmount = `ZeroTradableAmount`,
AmountOutBelowMinimum = `AmountOutBelowMinimum`,
AmountInAboveMaximum = `AmountInAboveMaximum`,
TickArrayCrossingAboveMax = `TickArrayCrossingAboveMax`,
TickArrayIndexNotInitialized = `TickArrayIndexNotInitialized`,
TickArraySequenceInvalid = `TickArraySequenceInvalid`,
AmountRemainingOverflow = `AmountRemainingOverflow`,
AmountCalcOverflow = `AmountCalcOverflow`,
}
export enum RouteQueryErrorCode {
RouteDoesNotExist = "RouteDoesNotExist",
TradeAmountTooHigh = "TradeAmountTooHigh",
ZeroInputAmount = "ZeroInputAmount",
General = "General",
}
export type WhirlpoolsErrorCode =
| TokenErrorCode
| SwapErrorCode
| MathErrorCode
| RouteQueryErrorCode;
export class WhirlpoolsError extends Error {
message: string;
errorCode?: WhirlpoolsErrorCode;
constructor(
message: string,
errorCode?: WhirlpoolsErrorCode,
stack?: string,
) {
super(message);
this.message = message;
this.errorCode = errorCode;
this.stack = stack;
}
public static isWhirlpoolsErrorCode(
e: unknown,
code: WhirlpoolsErrorCode,
): boolean {
return e instanceof WhirlpoolsError && e.errorCode === code;
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/router/convert-quote-map.ts
|
import BN from "bn.js";
import { kSmallestPartition } from "../utils/math/k-smallest-partition";
import type { RoutingOptions, SubTradeRoute, TradeRoute } from "./public";
import type { PathQuote, SanitizedQuoteMap } from "./quote-map";
export function getBestRoutesFromQuoteMap(
quoteMap: SanitizedQuoteMap,
amountSpecifiedIsInput: boolean,
opts: RoutingOptions,
): TradeRoute[] {
const { numTopRoutes, maxSplits } = opts;
const sortedRoutes = [
...getRankedRoutes(
quoteMap,
amountSpecifiedIsInput,
numTopRoutes,
maxSplits,
),
...getSingleHopSplit(quoteMap),
].sort(getRouteCompareFn(amountSpecifiedIsInput));
return convertInternalRoutesToTradeRoutes(sortedRoutes);
}
function convertInternalRoutesToTradeRoutes(
internalRoutes: InternalRoute[],
): TradeRoute[] {
const tradeRoutes: TradeRoute[] = internalRoutes.map((internalRoute) => {
const { quotes, totalIn, totalOut } = internalRoute;
return {
subRoutes: quotes.map((quote) => convertPathQuoteToSubTradeRoute(quote)),
totalAmountIn: totalIn,
totalAmountOut: totalOut,
};
});
return tradeRoutes;
}
function convertPathQuoteToSubTradeRoute(pathQuote: PathQuote): SubTradeRoute {
const { calculatedEdgeQuotes, path, splitPercent, amountIn, amountOut } =
pathQuote;
return {
path,
splitPercent,
amountIn,
amountOut,
hopQuotes: calculatedEdgeQuotes,
};
}
type InternalRoute = {
quotes: PathQuote[];
splitPercent: number;
totalIn: BN;
totalOut: BN;
};
function getSingleHopSplit(quoteMap: SanitizedQuoteMap): InternalRoute[] {
const fullFlow = quoteMap[100];
if (fullFlow) {
return fullFlow
.filter((f) => f.calculatedEdgeQuotes.length == 1)
.map((f) => {
const oneHop = f.calculatedEdgeQuotes[0];
return {
quotes: [f],
splitPercent: 100,
totalIn: oneHop.amountIn,
totalOut: oneHop.amountOut,
};
})
.flatMap((g) => (!!g ? g : []));
}
return [];
}
function getRankedRoutes(
percentMap: SanitizedQuoteMap,
amountSpecifiedIsInput: boolean,
topN: number,
maxSplits: number,
): InternalRoute[] {
let routes = generateRoutes(percentMap, maxSplits);
// Run quick select algorithm to partition the topN results, mutating inplace
const routeCompare = getRouteCompareFn(amountSpecifiedIsInput);
if (routes.length <= topN) {
return routes.sort(routeCompare);
}
kSmallestPartition(routes, topN, 0, routes.length - 1, routeCompare);
return routes.slice(0, topN).sort(routeCompare);
}
function generateRoutes(
percentMap: SanitizedQuoteMap,
maxSplits: number,
): InternalRoute[] {
let routes: InternalRoute[] = [];
buildRoutes(
percentMap,
maxSplits,
{
quotes: [],
splitPercent: 0,
totalIn: new BN(0),
totalOut: new BN(0),
},
routes,
);
return routes;
}
function buildRoutes(
quotePercentMap: SanitizedQuoteMap,
maxSplits: number,
currentRoute: InternalRoute,
routes: InternalRoute[],
) {
const { splitPercent: percent, quotes } = currentRoute;
const percents = Object.keys(quotePercentMap).map((percent) =>
Number(percent),
);
for (let i = percents.length - 1; i >= 0; i--) {
const nextPercent = percents[i];
const newPercentTotal = percent + nextPercent;
// Optimization to prevent exceeding 100% flow and excess combinations of flow by only using decreasing
// amounts of flow percentages
const nextPercentIsSmaller =
quotes.length > 0 && nextPercent > quotes[quotes.length - 1].splitPercent;
if (newPercentTotal > 100 || nextPercentIsSmaller) {
continue;
}
const nextPercentQuotes = quotePercentMap[nextPercent];
for (let j = 0; j < nextPercentQuotes.length; j++) {
const nextQuote = nextPercentQuotes[j];
// Don't use a quote that shares a pool with an existing quote
const hasReusedPools = nextQuote.edgesPoolAddrs.some((r1) =>
quotes.some((r2) =>
r2.edgesPoolAddrs.some((r3) => r3.indexOf(r1) !== -1),
),
);
if (hasReusedPools) {
continue;
}
// todo: Doesn't take into transaction fees
// double-hops, multi-route penalties, benefits for pairs that can share lookup tables
const nextRoute: InternalRoute = {
quotes: [...quotes, nextQuote],
splitPercent: newPercentTotal,
totalIn: currentRoute.totalIn.add(nextQuote.amountIn),
totalOut: currentRoute.totalOut.add(nextQuote.amountOut),
};
// Remove the current and prior routes from consideration
const nextCandidateQuotes = nextPercentQuotes.slice(j + 1);
if (newPercentTotal === 100) {
// If we have reached 100% flow routed, we add it to the set of valid route sets
routes.push(nextRoute);
} else if (quotes.length + 1 != maxSplits) {
// Otherwise, recursively build route sets
buildRoutes(
{
...quotePercentMap,
[nextPercent]: nextCandidateQuotes,
},
maxSplits,
nextRoute,
routes,
);
}
}
}
}
function getRouteCompareFn(amountSpecifiedIsInput: boolean) {
return amountSpecifiedIsInput
? routesCompareForInputAmount
: routesCompareForOutputAmount;
}
function routesCompareForInputAmount(a: InternalRoute, b: InternalRoute) {
return b.totalOut.cmp(a.totalOut);
}
function routesCompareForOutputAmount(a: InternalRoute, b: InternalRoute) {
return a.totalIn.cmp(b.totalIn);
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/router/batch-swap-quote.ts
|
import type { Address } from "@coral-xyz/anchor";
import { AddressUtil } from "@orca-so/common-sdk";
import type BN from "bn.js";
import invariant from "tiny-invariant";
import type {
WhirlpoolAccountFetcherInterface,
WhirlpoolAccountFetchOptions,
} from "../network/public/fetcher";
import type { SwapQuoteParam } from "../quotes/public";
import { PoolUtil, SwapDirection, SwapUtils } from "../utils/public";
import { NO_TOKEN_EXTENSION_CONTEXT } from "../utils/public/token-extension-util";
export interface SwapQuoteRequest {
whirlpool: Address;
tradeTokenMint: Address;
tokenAmount: BN;
amountSpecifiedIsInput: boolean;
}
export async function batchBuildSwapQuoteParams(
quoteRequests: SwapQuoteRequest[],
programId: Address,
fetcher: WhirlpoolAccountFetcherInterface,
opts?: WhirlpoolAccountFetchOptions,
): Promise<SwapQuoteParam[]> {
const whirlpools = await fetcher.getPools(
quoteRequests.map((req) => req.whirlpool),
opts,
);
const program = AddressUtil.toPubKey(programId);
const tickArrayRequests = quoteRequests.map((quoteReq) => {
const { whirlpool, tokenAmount, tradeTokenMint, amountSpecifiedIsInput } =
quoteReq;
const whirlpoolData = whirlpools.get(AddressUtil.toString(whirlpool))!;
const swapMintKey = AddressUtil.toPubKey(tradeTokenMint);
const swapTokenType = PoolUtil.getTokenType(whirlpoolData, swapMintKey);
invariant(
!!swapTokenType,
"swapTokenMint does not match any tokens on this pool",
);
const aToB =
SwapUtils.getSwapDirection(
whirlpoolData,
swapMintKey,
amountSpecifiedIsInput,
) === SwapDirection.AtoB;
return {
whirlpoolData,
tokenAmount,
aToB,
tickCurrentIndex: whirlpoolData.tickCurrentIndex,
tickSpacing: whirlpoolData.tickSpacing,
whirlpoolAddress: AddressUtil.toPubKey(whirlpool),
amountSpecifiedIsInput,
};
});
const tickArrays = await SwapUtils.getBatchTickArrays(
program,
fetcher,
tickArrayRequests,
opts,
);
return tickArrayRequests.map((req, index) => {
const { whirlpoolData, tokenAmount, aToB, amountSpecifiedIsInput } = req;
return {
whirlpoolData,
tokenAmount,
aToB,
amountSpecifiedIsInput,
sqrtPriceLimit: SwapUtils.getDefaultSqrtPriceLimit(aToB),
otherAmountThreshold: SwapUtils.getDefaultOtherAmountThreshold(
amountSpecifiedIsInput,
),
tickArrays: tickArrays[index],
tokenExtensionCtx: NO_TOKEN_EXTENSION_CONTEXT, // WhirlpoolRouter does not support token extensions
};
});
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/router/quote-map.ts
|
import type { Address } from "@coral-xyz/anchor";
import { AddressUtil, Percentage } from "@orca-so/common-sdk";
import type { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import type { SwapErrorCode, WhirlpoolsError } from "../errors/errors";
import type { WhirlpoolAccountFetcherInterface } from "../network/public/fetcher";
import { PREFER_CACHE } from "../network/public/fetcher";
import type { SwapQuoteParam } from "../quotes/public";
import { swapQuoteWithParams } from "../quotes/public";
import type { Path } from "../utils/public";
import { PoolUtil } from "../utils/public";
import type { SwapQuoteRequest } from "./batch-swap-quote";
import { batchBuildSwapQuoteParams } from "./batch-swap-quote";
import type { RoutingOptions, Trade, TradeHop } from "./public";
// Key between <splitPercent, array of quotes with successful hop quotes>
export type SanitizedQuoteMap = Record<number, PathQuote[]>;
// A trade quote on trading on a path between user input tokenIn -> tokenOut
export type PathQuote = {
path: Path;
edgesPoolAddrs: string[];
splitPercent: number;
amountIn: BN;
amountOut: BN;
calculatedEdgeQuotes: TradeHopQuoteSuccess[];
};
export async function getQuoteMap(
trade: Trade,
paths: Path[],
amountSpecifiedIsInput: boolean,
programId: PublicKey,
fetcher: WhirlpoolAccountFetcherInterface,
opts: RoutingOptions,
) {
const { percentIncrement, numTopPartialQuotes } = opts;
const { tokenIn, tokenOut, tradeAmount } = trade;
const { percents, amounts } = getSplitPercentageAmts(
tradeAmount,
percentIncrement,
);
// The max route length is the number of iterations of quoting that we need to do
const maxRouteLength = Math.max(...paths.map((path) => path.edges.length), 0);
// For hop 0 of all routes, get swap quotes using [inputAmount, inputTokenMint]
// For hop 1..n of all routes, get swap quotes using [outputAmount, outputTokenMint] of hop n-1 as input
const quoteMap: InternalQuoteMap = {};
let iteration = Array.from(Array(maxRouteLength).keys());
if (!amountSpecifiedIsInput) {
iteration = iteration.reverse();
}
try {
for (const hop of iteration) {
// Each batch of quotes needs to be iterative
const quoteUpdates = buildQuoteUpdateRequests(
tokenIn,
tokenOut,
paths,
percents,
amounts,
hop,
amountSpecifiedIsInput,
quoteMap,
);
const quoteParams = await batchBuildSwapQuoteParams(
quoteUpdates.map((update) => update.request),
AddressUtil.toPubKey(programId),
fetcher,
PREFER_CACHE,
);
populateQuoteMap(quoteUpdates, quoteParams, quoteMap);
}
} catch (e) {
throw e;
}
return sanitizeQuoteMap(
quoteMap,
numTopPartialQuotes,
amountSpecifiedIsInput,
);
}
// Key between <splitPercent, array of quotes of pre-sanitized calculated-hops>
type InternalQuoteMap = Record<
number,
Array<
Pick<
InternalPathQuote,
"path" | "edgesPoolAddrs" | "splitPercent" | "calculatedEdgeQuotes"
>
>
>;
type InternalPathQuote = Omit<PathQuote, "calculatedEdgeQuotes"> & {
calculatedEdgeQuotes: (TradeHopQuoteResult | undefined)[];
};
type TradeHopQuoteResult = TradeHopQuoteSuccess | TradeHopQuoteError;
type TradeHopQuoteSuccess = TradeHop & { success: true };
type TradeHopQuoteError = {
success: false;
error: SwapErrorCode;
};
function populateQuoteMap(
quoteUpdates: ReturnType<typeof buildQuoteUpdateRequests>,
quoteParams: SwapQuoteParam[],
quoteMap: InternalQuoteMap,
) {
for (const {
splitPercent,
pathIndex,
quoteIndex,
edgeIndex,
request,
} of quoteUpdates) {
const swapParam = quoteParams[quoteIndex];
const path = quoteMap[splitPercent][pathIndex];
try {
const quote = swapQuoteWithParams(
swapParam,
Percentage.fromFraction(0, 1000),
);
const { whirlpoolData, tokenAmount, aToB, amountSpecifiedIsInput } =
swapParam;
const [mintA, mintB, vaultA, vaultB] = [
whirlpoolData.tokenMintA.toBase58(),
whirlpoolData.tokenMintB.toBase58(),
whirlpoolData.tokenVaultA.toBase58(),
whirlpoolData.tokenVaultB.toBase58(),
];
const [inputMint, outputMint] = aToB ? [mintA, mintB] : [mintB, mintA];
path.calculatedEdgeQuotes[edgeIndex] = {
success: true,
amountIn: amountSpecifiedIsInput
? tokenAmount
: quote.estimatedAmountIn,
amountOut: amountSpecifiedIsInput
? quote.estimatedAmountOut
: tokenAmount,
whirlpool: request.whirlpool,
inputMint,
outputMint,
mintA,
mintB,
vaultA,
vaultB,
quote,
snapshot: {
aToB: swapParam.aToB,
sqrtPrice: whirlpoolData.sqrtPrice,
feeRate: PoolUtil.getFeeRate(whirlpoolData.feeRate),
},
};
} catch (e) {
const errorCode = (e as WhirlpoolsError).errorCode as SwapErrorCode;
path.calculatedEdgeQuotes[edgeIndex] = {
success: false,
error: errorCode,
};
continue;
}
}
}
/**
* A list of quote requests to be queried in a batch.
*
* @param quoteIndex The index for this quote in the QuoteRequest array
* @param pathIndex The index of the trade paths this request is evaluating
* @param edgeIndex The index of the edge for the evaluated path
* @param splitPercent The percent of the total amount to be swapped
* @param poolAddress The account address of the pool this edge is evaluating
*
*/
type QuoteRequest = {
quoteIndex: number;
pathIndex: number;
edgeIndex: number;
splitPercent: number;
request: SwapQuoteRequest;
};
function buildQuoteUpdateRequests(
tokenIn: Address,
tokenOut: Address,
paths: Path[],
percents: number[],
amounts: BN[],
hop: number,
amountSpecifiedIsInput: boolean,
quoteMap: InternalQuoteMap,
): QuoteRequest[] {
// Each batch of quotes needs to be iterative
const quoteUpdates: QuoteRequest[] = [];
for (let amountIndex = 0; amountIndex < amounts.length; amountIndex++) {
const percent = percents[amountIndex];
const tradeAmount = amounts[amountIndex];
// Initialize quote map for first hop
if (!quoteMap[percent]) {
quoteMap[percent] = Array(paths.length);
}
// Iterate over all routes
for (let pathIndex = 0; pathIndex < paths.length; pathIndex++) {
const path = paths[pathIndex];
const edges = path.edges;
// If the current route is already complete (amountSpecifiedIsInput = true) or if the current hop is beyond
// this route's length (amountSpecifiedIsInput = false), don't do anything
if (
amountSpecifiedIsInput ? edges.length <= hop : hop > edges.length - 1
) {
continue;
}
const startingRouteEval = amountSpecifiedIsInput
? hop === 0
: hop === edges.length - 1;
const poolsPath = AddressUtil.toStrings(
edges.map((edge) => edge.poolAddress),
);
// If this is the first hop of the route, initialize the quote map
if (startingRouteEval) {
quoteMap[percent][pathIndex] = {
path: path,
splitPercent: percent,
edgesPoolAddrs: poolsPath,
calculatedEdgeQuotes: Array(edges.length),
};
}
const currentQuote = quoteMap[percent][pathIndex];
const poolAddr = poolsPath[hop];
const lastHop = amountSpecifiedIsInput
? currentQuote.calculatedEdgeQuotes[hop - 1]
: currentQuote.calculatedEdgeQuotes[hop + 1];
// If this is the first hop, use the input mint and amount, otherwise use the output of the last hop
let tokenAmount: BN;
let tradeToken: Address;
if (startingRouteEval) {
tokenAmount = tradeAmount;
tradeToken = amountSpecifiedIsInput ? tokenIn : tokenOut;
} else {
if (!lastHop?.success) {
continue;
}
tokenAmount = amountSpecifiedIsInput
? lastHop.amountOut
: lastHop.amountIn;
tradeToken = amountSpecifiedIsInput
? lastHop.outputMint
: lastHop.inputMint;
}
quoteUpdates.push({
splitPercent: percent,
pathIndex,
edgeIndex: hop,
quoteIndex: quoteUpdates.length,
request: {
whirlpool: poolAddr,
tradeTokenMint: tradeToken,
tokenAmount,
amountSpecifiedIsInput,
},
});
}
}
return quoteUpdates;
}
/**
* Annotate amountIn/amountOut for calculations
* @param tradeAmount
* @param quoteMap
* @returns
*/
function sanitizeQuoteMap(
quoteMap: InternalQuoteMap,
pruneN: number,
amountSpecifiedIsInput: boolean,
): readonly [SanitizedQuoteMap, Set<SwapErrorCode>] {
const percents = Object.keys(quoteMap).map((percent) => Number(percent));
const cleanedQuoteMap: SanitizedQuoteMap = {};
const failureErrors: Set<SwapErrorCode> = new Set();
for (let i = 0; i < percents.length; i++) {
const percent = percents[i];
const uncleanedQuotes = quoteMap[percent];
cleanedQuoteMap[percent] = [];
for (const {
edgesPoolAddrs: hopPoolAddrs,
calculatedEdgeQuotes: calculatedHops,
path,
} of uncleanedQuotes) {
// If the route was successful at each step, add it to the clean quote stack
const filteredCalculatedEdges = calculatedHops.flatMap((val) =>
!!val && val.success ? val : [],
);
if (filteredCalculatedEdges.length === hopPoolAddrs.length) {
const [input, output] = [
filteredCalculatedEdges[0].amountIn,
filteredCalculatedEdges[filteredCalculatedEdges.length - 1].amountOut,
];
cleanedQuoteMap[percent].push({
path,
splitPercent: percent,
edgesPoolAddrs: hopPoolAddrs,
amountIn: input,
amountOut: output,
calculatedEdgeQuotes: filteredCalculatedEdges,
});
continue;
}
// If a route failed, there would only be one failure
const quoteFailures = calculatedHops.flatMap((f) =>
f && !f?.success ? f : [],
);
failureErrors.add(quoteFailures[0].error);
}
}
// Prune the quote map to only include the top N quotes
const prunedQuoteMap: SanitizedQuoteMap = {};
const sortFn = amountSpecifiedIsInput
? (a: PathQuote, b: PathQuote) => b.amountOut.cmp(a.amountOut)
: (a: PathQuote, b: PathQuote) => a.amountIn.cmp(b.amountIn);
for (let i = 0; i < percents.length; i++) {
const sortedQuotes = cleanedQuoteMap[percents[i]].sort(sortFn);
const slicedSorted = sortedQuotes.slice(0, pruneN);
prunedQuoteMap[percents[i]] = slicedSorted;
}
return [prunedQuoteMap, failureErrors] as const;
}
function getSplitPercentageAmts(inputAmount: BN, minPercent: number = 5) {
const percents = [];
const amounts = [];
for (let i = 1; i <= 100 / minPercent; i++) {
percents.push(i * minPercent);
amounts.push(inputAmount.mul(new BN(i * minPercent)).div(new BN(100)));
}
return { percents, amounts };
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/router/router-impl.ts
|
import type { Address } from "@coral-xyz/anchor";
import type { Percentage, TransactionBuilder } from "@orca-so/common-sdk";
import { AddressUtil } from "@orca-so/common-sdk";
import type { Account } from "@solana/spl-token";
import type { WhirlpoolContext } from "..";
import {
RouteQueryErrorCode,
SwapErrorCode,
WhirlpoolsError,
} from "../errors/errors";
import { getSwapFromRoute } from "../instructions/composites/swap-with-route";
import type {
WhirlpoolAccountFetchOptions,
WhirlpoolAccountFetcherInterface,
} from "../network/public/fetcher";
import { IGNORE_CACHE, PREFER_CACHE } from "../network/public/fetcher";
import type { Path, PoolGraph } from "../utils/public";
import { SwapUtils } from "../utils/public";
import { getBestRoutesFromQuoteMap } from "./convert-quote-map";
import type {
ExecutableRoute,
RouteSelectOptions,
RoutingOptions,
Trade,
TradeRoute,
WhirlpoolRouter,
} from "./public";
import { RouterUtils } from "./public";
import { getQuoteMap } from "./quote-map";
export class WhirlpoolRouterImpl implements WhirlpoolRouter {
constructor(
readonly ctx: WhirlpoolContext,
readonly poolGraph: PoolGraph,
) {}
async findAllRoutes(
trade: Trade,
opts?: Partial<RoutingOptions>,
fetchOpts?: WhirlpoolAccountFetchOptions,
): Promise<TradeRoute[]> {
const { tokenIn, tokenOut, tradeAmount, amountSpecifiedIsInput } = trade;
const paths = this.poolGraph.getPath(tokenIn, tokenOut);
if (paths.length === 0) {
return Promise.reject(
new WhirlpoolsError(
`Could not find route for ${tokenIn} -> ${tokenOut}`,
RouteQueryErrorCode.RouteDoesNotExist,
),
);
}
if (tradeAmount.isZero()) {
return Promise.reject(
new WhirlpoolsError(
`findBestRoutes error - input amount is zero.`,
RouteQueryErrorCode.ZeroInputAmount,
),
);
}
const routingOptions = { ...RouterUtils.getDefaultRouteOptions(), ...opts };
const { program, fetcher } = this.ctx;
const programId = program.programId;
await prefetchRoutes(paths, programId, fetcher, fetchOpts);
try {
const [quoteMap, failures] = await getQuoteMap(
trade,
paths,
amountSpecifiedIsInput,
programId,
fetcher,
routingOptions,
);
const bestRoutes = getBestRoutesFromQuoteMap(
quoteMap,
amountSpecifiedIsInput,
routingOptions,
);
// TODO: Rudementary implementation to determine error. Find a better solution
if (bestRoutes.length === 0) {
// TODO: TRADE_AMOUNT_TOO_HIGH actually corresponds to TickArrayCrossingAboveMax. Fix swap quote.
if (failures.has(SwapErrorCode.TickArraySequenceInvalid)) {
return Promise.reject(
new WhirlpoolsError(
`All swap quote generation failed on amount too high.`,
RouteQueryErrorCode.TradeAmountTooHigh,
),
);
}
}
return bestRoutes;
} catch (e) {
return Promise.reject(
new WhirlpoolsError(
`Stack error received on quote generation.`,
RouteQueryErrorCode.General,
e instanceof Error ? e.stack : "",
),
);
}
}
async findBestRoute(
trade: Trade,
routingOpts?: Partial<RoutingOptions>,
selectionOpts?: Partial<RouteSelectOptions>,
fetchOpts?: WhirlpoolAccountFetchOptions,
): Promise<ExecutableRoute | null> {
const allRoutes = await this.findAllRoutes(trade, routingOpts, fetchOpts);
const selectOpts = {
...RouterUtils.getDefaultSelectOptions(),
...selectionOpts,
};
return await RouterUtils.selectFirstExecutableRoute(
this.ctx,
allRoutes,
selectOpts,
);
}
async swap(
trade: TradeRoute,
slippage: Percentage,
resolvedAtas: Account[] | null,
): Promise<TransactionBuilder> {
const txBuilder = await getSwapFromRoute(
this.ctx,
{
route: trade,
slippage,
resolvedAtaAccounts: resolvedAtas,
wallet: this.ctx.wallet.publicKey,
},
IGNORE_CACHE,
);
return txBuilder;
}
}
// Load all pool and tick-array data into the fetcher cache.
async function prefetchRoutes(
paths: Path[],
programId: Address,
fetcher: WhirlpoolAccountFetcherInterface,
opts: WhirlpoolAccountFetchOptions = PREFER_CACHE,
): Promise<void> {
const poolSet = new Set<string>();
for (let i = 0; i < paths.length; i++) {
const path = paths[i];
for (let j = 0; j < path.edges.length; j++) {
poolSet.add(AddressUtil.toString(path.edges[j].poolAddress));
}
}
const ps = Array.from(poolSet);
const allWps = await fetcher.getPools(ps, opts);
const tickArrayAddresses = [];
for (const [key, wp] of allWps) {
if (wp == null) {
continue;
}
const addr1 = SwapUtils.getTickArrayPublicKeys(
wp.tickCurrentIndex,
wp.tickSpacing,
true,
AddressUtil.toPubKey(programId),
AddressUtil.toPubKey(key),
);
const addr2 = SwapUtils.getTickArrayPublicKeys(
wp.tickCurrentIndex,
wp.tickSpacing,
false,
AddressUtil.toPubKey(programId),
AddressUtil.toPubKey(key),
);
const allAddrs = [...addr1, ...addr2].map((k) => k.toBase58());
const unique = Array.from(new Set(allAddrs));
tickArrayAddresses.push(...unique);
}
await fetcher.getTickArrays(tickArrayAddresses, opts);
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/router
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/router/public/index.ts
|
import type { Address } from "@coral-xyz/anchor";
import type { Percentage, TransactionBuilder } from "@orca-so/common-sdk";
import type { AddressLookupTableAccount } from "@solana/web3.js";
import type BN from "bn.js";
import type { WhirlpoolAccountFetchOptions } from "../../network/public/fetcher";
import type { SwapQuote } from "../../quotes/public";
import type { Path } from "../../utils/public";
import type { AtaAccountInfo, RouteSelectOptions } from "./router-utils";
export * from "./router-builder";
export * from "./router-utils";
/**
* A Trade type that represents a trade between two tokens
*
* @category Router
* @param tokenIn The token that is being traded in
* @param tokenOut The token that is being traded out
* @param tradeAmount The amount of token being traded in or out
* @param amountSpecifiedIsInput Whether the trade amount is the amount being traded in or out
*/
export type Trade = {
tokenIn: Address;
tokenOut: Address;
tradeAmount: BN;
amountSpecifiedIsInput: boolean;
};
/**
* Options to configure the router.
*
* @category Router
* @param percentIncrement The percent increment to use when splitting a trade into multiple trades.
* @param numTopRoutes The number of top routes to return from the router.
* @param numTopPartialQuotes The number of top partial quotes to return from the router.
* @param maxSplits The maximum number of splits to perform on a trade.
*/
export type RoutingOptions = {
percentIncrement: number;
numTopRoutes: number;
numTopPartialQuotes: number;
maxSplits: number;
};
/**
* A trade route that is ready to execute.
* A trade can be broken into multiple sub-trades for potentially better trades.
*
* @category Router
* @param subRoutes
* The sub-routes that make up the trade route. The sum of all splitPercent should equal 100.
* @param totalAmountIn The total amount of token being traded in for this trade.
* @param totalAmountOut The total amount of token being traded out for this trade.
*/
export type TradeRoute = {
subRoutes: SubTradeRoute[];
totalAmountIn: BN;
totalAmountOut: BN;
};
/**
* Represents a fragment of a trade that was splitted into multiple trades for more efficient execution.
*
* @category Router
* @param path The path of pool addresses that make up this sub trade.
* @param splitPercent The percent of the trade that this sub trade represents.
* @param amountIn The amount of token being traded in within this sub-route.
* @param amountOut The amount of token being traded out within this sub-routes.
* @param hopQuotes The quotes for each hop in the path of this trade.
*/
export type SubTradeRoute = {
path: Path;
splitPercent: number;
amountIn: BN;
amountOut: BN;
hopQuotes: TradeHop[];
};
/**
* Represents a quote for a single hop in the path of a {@link SubTradeRoute}.
*
* @category Router
* @param amountIn The amount of token being traded in for this hop.
* @param amountOut The amount of token being traded out for this hop.
* @param whirlpool The address of the whirlpool that this hop is trading through.
* @param inputMint The address of the input token mint.
* @param outputMint The address of the output token mint.
* @param mintA The address of the first mint in the pool.
* @param mintB The address of the second mint in the pool.
* @param vaultA The address of the first vault in the pool.
* @param vaultB The address of the second vault in the pool.
* @param quote The {@link SwapQuote} for this hop.
* @param snapshot A snapshot of the whirlpool condition when this hop was made
*/
export type TradeHop = {
amountIn: BN;
amountOut: BN;
whirlpool: Address;
inputMint: Address;
outputMint: Address;
mintA: Address;
mintB: Address;
vaultA: Address;
vaultB: Address;
quote: SwapQuote;
snapshot: TradeHopSnapshot;
};
/**
* A snapshot of the whirlpool condition when a trade hop was made.
* @category Router
*/
export type TradeHopSnapshot = {
aToB: boolean;
sqrtPrice: BN;
feeRate: Percentage;
};
/**
* A trade route that is ready to execute.
* Contains the {@link TradeRoute} and a possible set of {@link AddressLookupTableAccount} that
* is needed to successfully execute the trade.
*
* If the lookup table accounts are undefined, then the trade can be executed with a legacy transaction.
*
* @category Router
*/
export type ExecutableRoute = readonly [
TradeRoute,
AddressLookupTableAccount[] | undefined,
];
/**
* Convienience class to find routes through a set of Whirlpools and execute a swap across them.
* The router only supports up to 2-hop trades between pools and does not support arbitrage trades
* between the same token.
*
* @category Router
*
* @deprecated WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.
*/
export interface WhirlpoolRouter {
/**
* Finds all possible routes for a trade, ordered by the best other token amount you would get from a trade.
* Use {@link RouterUtils.selectFirstExecutableRoute} to find the best executable route.
*
* @param trade
* The trade to find routes for.
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @param opts
* {@link RoutingOptions} to configure the router. Missing options will be filled with default values from
* {@link RouterUtils.getDefaultRoutingOptions}.
* @param fetchOpts
* {@link WhirlpoolAccountFetchOptions} to configure the fetching of on-chain data.
* @return A list of {@link TradeRoute} that can be used to execute a swap, ordered by the best other token amount.
*
* @deprecated WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.
*/
findAllRoutes(
trade: Trade,
opts?: Partial<RoutingOptions>,
fetchOpts?: WhirlpoolAccountFetchOptions,
): Promise<TradeRoute[]>;
/**
* Finds all possible routes for a trade and select the best route that is executable
* under the current execution environment.
* @param trade
* The trade to find routes for.
* @param opts an {@link WhirlpoolAccountFetchOptions} object to define fetch and cache options when accessing on-chain accounts
* @param opts
* {@link RoutingOptions} to configure the router. Missing options will be filled with default values from
* {@link RouterUtils.getDefaultRoutingOptions}.
* @param selectionOpts
* {@link RouteSelectOptions} to configure the selection of the best route. Missing options
* will be filled with default values from {@link RouterUtils.getDefaultRouteSelectOptions}.
* @param fetchOpts
* {@link WhirlpoolAccountFetchOptions} to configure the fetching of on-chain data.
* @returns
* The best {@link ExecutableRoute} that can be used to execute a swap. If no executable route is found, null is returned.
*
* @deprecated WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.
*/
findBestRoute(
trade: Trade,
opts?: Partial<RoutingOptions>,
selectionOpts?: Partial<RouteSelectOptions>,
fetchOpts?: WhirlpoolAccountFetchOptions,
): Promise<ExecutableRoute | null>;
/**
* Construct a {@link TransactionBuilder} to help execute a trade route.
* @param trade The trade route to execute.
* @param slippage The slippage tolerance for the trade.
* @param resolvedAtas
* The ATA accounts that the executing wallet owns / needed by the execution.
* If not provided, the router will attempt to resolve them.
* @returns
* A {@link TransactionBuilder}that can be used to execute the trade.
* If provvided from {@link ExecutableRoute}, plug the {@link AddressLookupTableAccount}s
* into builder to lower the transaction size.
*
* @deprecated WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.
*/
swap(
trade: TradeRoute,
slippage: Percentage,
resolvedAtas: AtaAccountInfo[] | null,
): Promise<TransactionBuilder>;
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/router
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/router/public/router-builder.ts
|
import type { Address } from "@coral-xyz/anchor";
import type { WhirlpoolRouter } from ".";
import type { WhirlpoolContext } from "../..";
import type { PoolGraph } from "../../utils/public";
import { PoolGraphBuilder } from "../../utils/public";
import { WhirlpoolRouterImpl } from "../router-impl";
/**
* Builder to build instances of the {@link WhirlpoolRouter}
* @category Router
*
* @deprecated WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.
*/
export class WhirlpoolRouterBuilder {
/**
* Builds a {@link WhirlpoolRouter} with a prebuilt {@link PoolGraph}
*
* @param ctx A {@link WhirlpoolContext} for the current execution environment
* @param graph A {@link PoolGraph} that represents the connections between all pools.
* @returns A {@link WhirlpoolRouter} that can be used to find routes and execute swaps
*
* @deprecated WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.
*/
static buildWithPoolGraph(
ctx: WhirlpoolContext,
graph: PoolGraph,
): WhirlpoolRouter {
return new WhirlpoolRouterImpl(ctx, graph);
}
/**
* Fetch and builds a {@link WhirlpoolRouter} with a list of pool addresses.
* @param ctx A {@link WhirlpoolContext} for the current execution environment
* @param pools A list of {@link Address}es that the router will find routes through.
* @returns A {@link WhirlpoolRouter} that can be used to find routes and execute swaps
*
* @deprecated WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.
*/
static async buildWithPools(
ctx: WhirlpoolContext,
pools: Address[],
): Promise<WhirlpoolRouter> {
const poolGraph = await PoolGraphBuilder.buildPoolGraphWithFetch(
pools,
ctx.fetcher,
);
return new WhirlpoolRouterImpl(ctx, poolGraph);
}
}
| 0
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/router
|
solana_public_repos/orca-so/whirlpools/legacy-sdk/whirlpool/src/router/public/router-utils.ts
|
import type {
LookupTableFetcher,
TransactionBuilder,
} from "@orca-so/common-sdk";
import {
AddressUtil,
MEASUREMENT_BLOCKHASH,
Percentage,
TX_SIZE_LIMIT,
} from "@orca-so/common-sdk";
import type { Account } from "@solana/spl-token";
import type { PublicKey } from "@solana/web3.js";
import BN from "bn.js";
import Decimal from "decimal.js";
import type { ExecutableRoute, RoutingOptions, Trade, TradeRoute } from ".";
import type { WhirlpoolContext } from "../../context";
import { getSwapFromRoute } from "../../instructions/composites/swap-with-route";
import { PREFER_CACHE } from "../../network/public/fetcher";
import { U64 } from "../../utils/math/constants";
import { PriceMath } from "../../utils/public";
import { isWalletConnected } from "../../utils/wallet-utils";
/**
* A type representing a Associated Token Account
* @param address The address of the ATA account.
* @param owner The owner address of the ATA.
* @param mint The mint of the token the ATA represents.
*/
export type AtaAccountInfo = Pick<Account, "address" | "owner" | "mint">;
/**
* Parameters to configure the selection of the best route.
* @category Router
* @param maxSupportedTransactionVersion The maximum transaction version that the wallet supports.
* @param maxTransactionSize The maximum transaction size that the wallet supports.
* @param availableAtaAccounts A list of ATA accounts that are available in this wallet to use for the swap.
* @param onRouteEvaluation
* A callback that is called right before a route is evaluated. Users have a chance to add additional instructions
* to be added for an accurate txn size measurement. (ex. Adding a priority fee ix to the transaction)
*
*/
export type RouteSelectOptions = {
maxSupportedTransactionVersion: "legacy" | number;
maxTransactionSize: number;
availableAtaAccounts?: AtaAccountInfo[];
onRouteEvaluation?: (
route: Readonly<TradeRoute>,
tx: TransactionBuilder,
) => void;
};
/**
* A selection of utility functions for the {@link WhirlpoolRouter}.
* @category Router
* @deprecated WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.
*/
export class RouterUtils {
/**
* Selects the best executable route from a list of routes using the current execution environment.
* The wallet support type, available ATA accounts, existence of lookup tables all effect the transaction size
* and eligibility of a route.
*
* @param ctx The {@link WhirlpoolContext} that represents the current execution environment
* @param orderedRoutes A list of routes to select from, ordered by the best routes (trade amount wise) first.
* @param opts {@link RouteSelectOptions} to configure the selection of the best route.
* @returns
* The best {@link ExecutableRoute} that can be used to execute a swap. If no executable route is found, null is returned.
*
* @deprecated WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.
*/
static async selectFirstExecutableRoute(
ctx: WhirlpoolContext,
orderedRoutes: TradeRoute[],
opts: RouteSelectOptions,
): Promise<ExecutableRoute | null> {
const { wallet } = ctx;
if (orderedRoutes.length === 0) {
return null;
}
// Don't measure if there is no wallet
if (!isWalletConnected(wallet)) {
return [orderedRoutes[0], undefined];
}
// Preload LookupTableFetcher with lookup tables that are needed for v0 transactions
if (
opts.maxSupportedTransactionVersion !== "legacy" &&
ctx.lookupTableFetcher
) {
await loadLookupTablesForRoutes(ctx.lookupTableFetcher, orderedRoutes);
}
for (let i = 0; i < orderedRoutes.length && i < MEASURE_ROUTE_MAX; i++) {
const route = orderedRoutes[i];
const tx = await getSwapFromRoute(
ctx,
{
route,
slippage: Percentage.fromFraction(0, 100),
resolvedAtaAccounts: opts.availableAtaAccounts ?? null,
wallet: wallet.publicKey,
},
PREFER_CACHE,
);
if (!!opts.onRouteEvaluation) {
opts.onRouteEvaluation(route, tx);
}
try {
const legacyTxSize = tx.txnSize({
latestBlockhash: MEASUREMENT_BLOCKHASH,
maxSupportedTransactionVersion: "legacy",
});
if (
legacyTxSize !== undefined &&
legacyTxSize <= opts.maxTransactionSize
) {
return [route, undefined];
}
} catch {
// No-op
}
let v0TxSize;
if (
opts.maxSupportedTransactionVersion !== "legacy" &&
ctx.lookupTableFetcher
) {
const addressesToLookup =
RouterUtils.getTouchedTickArraysFromRoute(route);
if (addressesToLookup.length > MAX_LOOKUP_TABLE_FETCH_SIZE) {
continue;
}
const lookupTableAccounts =
await ctx.lookupTableFetcher.getLookupTableAccountsForAddresses(
addressesToLookup,
);
try {
v0TxSize = tx.txnSize({
latestBlockhash: MEASUREMENT_BLOCKHASH,
maxSupportedTransactionVersion: opts.maxSupportedTransactionVersion,
lookupTableAccounts,
});
if (v0TxSize !== undefined && v0TxSize <= opts.maxTransactionSize) {
return [route, lookupTableAccounts];
}
} catch {
// No-op
}
}
}
return null;
}
/**
* Calculate the price impact for a route.
* @param trade The trade the user used to derive the route.
* @param route The route to calculate the price impact for.
* @returns A Decimal object representing the percentage value of the price impact (ex. 3.01%)
*
* @deprecated WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.
*/
static getPriceImpactForRoute(trade: Trade, route: TradeRoute): Decimal {
const { amountSpecifiedIsInput } = trade;
const totalBaseValue = route.subRoutes.reduce((acc, route) => {
const directionalHops = amountSpecifiedIsInput
? route.hopQuotes
: route.hopQuotes.slice().reverse();
const baseOutputs = directionalHops.reduce((acc, quote, index) => {
const { snapshot } = quote;
const { aToB, sqrtPrice, feeRate } = snapshot;
// Inverse sqrt price will cause 1bps precision loss since ticks are spaces of 1bps
const directionalSqrtPrice = aToB
? sqrtPrice
: PriceMath.invertSqrtPriceX64(sqrtPrice);
// Convert from in/out -> base_out/in using the directional price & fee rate
let nextBaseValue;
const price = directionalSqrtPrice.mul(directionalSqrtPrice).div(U64);
if (amountSpecifiedIsInput) {
const amountIn = index === 0 ? quote.amountIn : acc[index - 1];
const feeAdjustedAmount = amountIn
.mul(feeRate.denominator.sub(feeRate.numerator))
.div(feeRate.denominator);
nextBaseValue = price.mul(feeAdjustedAmount).div(U64);
} else {
const amountOut = index === 0 ? quote.amountOut : acc[index - 1];
const feeAdjustedAmount = amountOut.mul(U64).div(price);
nextBaseValue = feeAdjustedAmount
.mul(feeRate.denominator)
.div(feeRate.denominator.sub(feeRate.numerator));
}
acc.push(nextBaseValue);
return acc;
}, new Array<BN>());
return acc.add(baseOutputs[baseOutputs.length - 1]);
}, new BN(0));
const totalBaseValueDec = new Decimal(totalBaseValue.toString());
const totalAmountEstimatedDec = new Decimal(
amountSpecifiedIsInput
? route.totalAmountOut.toString()
: route.totalAmountIn.toString(),
);
const priceImpact = amountSpecifiedIsInput
? totalBaseValueDec.sub(totalAmountEstimatedDec).div(totalBaseValueDec)
: totalAmountEstimatedDec
.sub(totalBaseValueDec)
.div(totalAmountEstimatedDec);
return priceImpact.mul(100);
}
/**
* Get the tick arrays addresses that are touched by a route.
* @param route The route to get the tick arrays from.
* @returns The tick arrays addresses that are touched by the route.
* @deprecated WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.
*/
static getTouchedTickArraysFromRoute(route: TradeRoute): PublicKey[] {
const taAddresses = new Set<string>();
for (const quote of route.subRoutes) {
for (const hop of quote.hopQuotes) {
// We only need to search for tick arrays, since we should be guaranteed due to the layout
// that all other addresses are included in the LUTs for the tick array
taAddresses.add(hop.quote.tickArray0.toBase58());
taAddresses.add(hop.quote.tickArray1.toBase58());
taAddresses.add(hop.quote.tickArray2.toBase58());
}
}
return AddressUtil.toPubKeys(Array.from(taAddresses));
}
/**
* Get the default options for generating trade routes.
* @returns Default options for generating trade routes.
* @deprecated WhirlpoolRouter will be removed in the future release. Please use endpoint which provides qoutes.
*/
static getDefaultRouteOptions(): RoutingOptions {
return {
percentIncrement: 20,
numTopRoutes: 50,
numTopPartialQuotes: 10,
maxSplits: 3,
};
}
/**
* Get the default options for selecting a route from a list of generated routes.
* @returns Default options for selecting a route from a list of generated routes.
*/
static getDefaultSelectOptions(): RouteSelectOptions {
return {
maxSupportedTransactionVersion: 0,
maxTransactionSize: TX_SIZE_LIMIT,
};
}
}
async function loadLookupTablesForRoutes(
lookupTableFetcher: LookupTableFetcher,
routes: TradeRoute[],
) {
const altTicks = new Set<string>();
for (let i = 0; i < routes.length && i < MEASURE_ROUTE_MAX; i++) {
const route = routes[i];
RouterUtils.getTouchedTickArraysFromRoute(route).map((ta) =>
altTicks.add(ta.toBase58()),
);
}
const altTickArray = Array.from(altTicks);
const altPageSize = 45;
const altRequests = [];
for (let i = 0; i < altTickArray.length; i += altPageSize) {
altRequests.push(altTickArray.slice(i, i + altPageSize));
}
await Promise.all(
altRequests.map((altPage) => {
const altPageKeys = AddressUtil.toPubKeys(altPage);
lookupTableFetcher.loadLookupTables(altPageKeys);
}),
);
}
// The maximum number of routes to measure
const MEASURE_ROUTE_MAX = 100;
// The maximum number of tick arrays to lookup per network request
const MAX_LOOKUP_TABLE_FETCH_SIZE = 50;
| 0
|
solana_public_repos/nautilus-project
|
solana_public_repos/nautilus-project/nautilus/LICENSE
|
Apache License
Version 2.0, January 2004
http://www.apache.org/licenses/
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
1. Definitions.
"License" shall mean the terms and conditions for use, reproduction,
and distribution as defined by Sections 1 through 9 of this document.
"Licensor" shall mean the copyright owner or entity authorized by
the copyright owner that is granting the License.
"Legal Entity" shall mean the union of the acting entity and all
other entities that control, are controlled by, or are under common
control with that entity. For the purposes of this definition,
"control" means (i) the power, direct or indirect, to cause the
direction or management of such entity, whether by contract or
otherwise, or (ii) ownership of fifty percent (50%) or more of the
outstanding shares, or (iii) beneficial ownership of such entity.
"You" (or "Your") shall mean an individual or Legal Entity
exercising permissions granted by this License.
"Source" form shall mean the preferred form for making modifications,
including but not limited to software source code, documentation
source, and configuration files.
"Object" form shall mean any form resulting from mechanical
transformation or translation of a Source form, including but
not limited to compiled object code, generated documentation,
and conversions to other media types.
"Work" shall mean the work of authorship, whether in Source or
Object form, made available under the License, as indicated by a
copyright notice that is included in or attached to the work
(an example is provided in the Appendix below).
"Derivative Works" shall mean any work, whether in Source or Object
form, that is based on (or derived from) the Work and for which the
editorial revisions, annotations, elaborations, or other modifications
represent, as a whole, an original work of authorship. For the purposes
of this License, Derivative Works shall not include works that remain
separable from, or merely link (or bind by name) to the interfaces of,
the Work and Derivative Works thereof.
"Contribution" shall mean any work of authorship, including
the original version of the Work and any modifications or additions
to that Work or Derivative Works thereof, that is intentionally
submitted to Licensor for inclusion in the Work by the copyright owner
or by an individual or Legal Entity authorized to submit on behalf of
the copyright owner. For the purposes of this definition, "submitted"
means any form of electronic, verbal, or written communication sent
to the Licensor or its representatives, including but not limited to
communication on electronic mailing lists, source code control systems,
and issue tracking systems that are managed by, or on behalf of, the
Licensor for the purpose of discussing and improving the Work, but
excluding communication that is conspicuously marked or otherwise
designated in writing by the copyright owner as "Not a Contribution."
"Contributor" shall mean Licensor and any individual or Legal Entity
on behalf of whom a Contribution has been received by Licensor and
subsequently incorporated within the Work.
2. Grant of Copyright License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
copyright license to reproduce, prepare Derivative Works of,
publicly display, publicly perform, sublicense, and distribute the
Work and such Derivative Works in Source or Object form.
3. Grant of Patent License. Subject to the terms and conditions of
this License, each Contributor hereby grants to You a perpetual,
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
(except as stated in this section) patent license to make, have made,
use, offer to sell, sell, import, and otherwise transfer the Work,
where such license applies only to those patent claims licensable
by such Contributor that are necessarily infringed by their
Contribution(s) alone or by combination of their Contribution(s)
with the Work to which such Contribution(s) was submitted. If You
institute patent litigation against any entity (including a
cross-claim or counterclaim in a lawsuit) alleging that the Work
or a Contribution incorporated within the Work constitutes direct
or contributory patent infringement, then any patent licenses
granted to You under this License for that Work shall terminate
as of the date such litigation is filed.
4. Redistribution. You may reproduce and distribute copies of the
Work or Derivative Works thereof in any medium, with or without
modifications, and in Source or Object form, provided that You
meet the following conditions:
(a) You must give any other recipients of the Work or
Derivative Works a copy of this License; and
(b) You must cause any modified files to carry prominent notices
stating that You changed the files; and
(c) You must retain, in the Source form of any Derivative Works
that You distribute, all copyright, patent, trademark, and
attribution notices from the Source form of the Work,
excluding those notices that do not pertain to any part of
the Derivative Works; and
(d) If the Work includes a "NOTICE" text file as part of its
distribution, then any Derivative Works that You distribute must
include a readable copy of the attribution notices contained
within such NOTICE file, excluding those notices that do not
pertain to any part of the Derivative Works, in at least one
of the following places: within a NOTICE text file distributed
as part of the Derivative Works; within the Source form or
documentation, if provided along with the Derivative Works; or,
within a display generated by the Derivative Works, if and
wherever such third-party notices normally appear. The contents
of the NOTICE file are for informational purposes only and
do not modify the License. You may add Your own attribution
notices within Derivative Works that You distribute, alongside
or as an addendum to the NOTICE text from the Work, provided
that such additional attribution notices cannot be construed
as modifying the License.
You may add Your own copyright statement to Your modifications and
may provide additional or different license terms and conditions
for use, reproduction, or distribution of Your modifications, or
for any such Derivative Works as a whole, provided Your use,
reproduction, and distribution of the Work otherwise complies with
the conditions stated in this License.
5. Submission of Contributions. Unless You explicitly state otherwise,
any Contribution intentionally submitted for inclusion in the Work
by You to the Licensor shall be under the terms and conditions of
this License, without any additional terms or conditions.
Notwithstanding the above, nothing herein shall supersede or modify
the terms of any separate license agreement you may have executed
with Licensor regarding such Contributions.
6. Trademarks. This License does not grant permission to use the trade
names, trademarks, service marks, or product names of the Licensor,
except as required for reasonable and customary use in describing the
origin of the Work and reproducing the content of the NOTICE file.
7. Disclaimer of Warranty. Unless required by applicable law or
agreed to in writing, Licensor provides the Work (and each
Contributor provides its Contributions) on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
implied, including, without limitation, any warranties or conditions
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
PARTICULAR PURPOSE. You are solely responsible for determining the
appropriateness of using or redistributing the Work and assume any
risks associated with Your exercise of permissions under this License.
8. Limitation of Liability. In no event and under no legal theory,
whether in tort (including negligence), contract, or otherwise,
unless required by applicable law (such as deliberate and grossly
negligent acts) or agreed to in writing, shall any Contributor be
liable to You for damages, including any direct, indirect, special,
incidental, or consequential damages of any character arising as a
result of this License or out of the use or inability to use the
Work (including but not limited to damages for loss of goodwill,
work stoppage, computer failure or malfunction, or any and all
other commercial damages or losses), even if such Contributor
has been advised of the possibility of such damages.
9. Accepting Warranty or Additional Liability. While redistributing
the Work or Derivative Works thereof, You may choose to offer,
and charge a fee for, acceptance of support, warranty, indemnity,
or other liability obligations and/or rights consistent with this
License. However, in accepting such obligations, You may act only
on Your own behalf and on Your sole responsibility, not on behalf
of any other Contributor, and only if You agree to indemnify,
defend, and hold each Contributor harmless for any liability
incurred by, or claims asserted against, such Contributor by reason
of your accepting any such warranty or additional liability.
END OF TERMS AND CONDITIONS
Copyright 2024 Joe Caulfield
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
| 0
|
solana_public_repos/nautilus-project/nautilus
|
solana_public_repos/nautilus-project/nautilus/py/setup.py
|
import pathlib
from setuptools import setup
# The directory containing this file
HERE = pathlib.Path(__file__).parent
# The text of the README file
README = (HERE / "README.md").read_text()
setup(
name='nautilus_py',
version='0.0.1',
author='Joe Caulfield',
author_email='jcaulfield135@gmail.com',
packages=['nautilus'],
url='https://github.com/nautilus-project/nautilus',
description='Python client for Nautilus programs on Solana',
install_requires=[
"pytest",
"solana",
"solders",
"sqlparse",
"termcolor",
],
)
| 0
|
solana_public_repos/nautilus-project/nautilus/py
|
solana_public_repos/nautilus-project/nautilus/py/nautilus/index.py
|
#
#
# ----------------------------------------------------------------
# Nautilus
# ----------------------------------------------------------------
#
#
from .util.index import NautilusUtils
from solana.rpc.async_api import AsyncClient
from solders.pubkey import Pubkey
from solders.keypair import Keypair
class Nautilus:
connection: AsyncClient
programId: Pubkey
payer: Keypair
util: NautilusUtils
def __init__(self, connection, programId, payer=None):
self.connection = connection
self.programId = programId
self.payer = payer
self.util = NautilusUtils()
| 0
|
solana_public_repos/nautilus-project/nautilus/py
|
solana_public_repos/nautilus-project/nautilus/py/nautilus/__init__.py
|
__version__ = "0.0.1"
from .index import Nautilus
from .util import NautilusUtils
| 0
|
solana_public_repos/nautilus-project/nautilus/py/nautilus
|
solana_public_repos/nautilus-project/nautilus/py/nautilus/util/index.py
|
class NautilusUtils:
def __init__(self) -> None:
pass
| 0
|
solana_public_repos/nautilus-project/nautilus/py/nautilus
|
solana_public_repos/nautilus-project/nautilus/py/nautilus/util/__init__.py
|
from .index import NautilusUtils
| 0
|
solana_public_repos/nautilus-project/nautilus/py
|
solana_public_repos/nautilus-project/nautilus/py/tests/sql_parse.py
|
from solana.rpc.async_api import AsyncClient
from solders.pubkey import Pubkey
from termcolor import colored
from nautilus import Nautilus
CONNECTION = AsyncClient("https://api.devnet.solana.com", "confirmed")
PROGRAM_ID = Pubkey.from_string("9kYnTzxTSTtKJjBBScH2m3SLBq8grogLhwMLZdcD2wG4")
nautilus = Nautilus(CONNECTION, PROGRAM_ID)
def test_parse_sql(input: str):
# output = nautilus.query(input).dump_sql()
output = input
assert input == output
print(colored(" ✅ -- can parse: ", "grey") + input)
if __name__ == '__main__':
test_parse_sql(
"SELECT * FROM person"
)
test_parse_sql(
"SELECT id, name FROM person"
)
test_parse_sql(
"SELECT * FROM person WHERE name = 'Joe'"
)
test_parse_sql(
"SELECT (id, name) FROM person WHERE name = 'Joe'"
)
test_parse_sql(
"SELECT * FROM person WHERE id = 1 AND name = 'Joe'"
)
test_parse_sql(
"SELECT (id, name) FROM person WHERE id = 1 AND name = 'Joe'"
)
test_parse_sql(
"SELECT * FROM person WHERE id = 1 AND name = 'Joe' AND authority = 'Joe'"
)
test_parse_sql(
"SELECT (id, name) FROM person WHERE id = 1 AND name = 'Joe' AND authority = 'Joe'"
)
test_parse_sql(
"SELECT * FROM person ORDER BY name ASC"
)
test_parse_sql(
"SELECT (id, name) FROM person ORDER BY name ASC"
)
test_parse_sql(
"SELECT * FROM person WHERE name = 'Joe' ORDER BY name ASC"
)
test_parse_sql(
"SELECT (id, name) FROM person WHERE name = 'Joe' ORDER BY name ASC"
)
test_parse_sql(
"SELECT * FROM person WHERE id = 1 AND name = 'Joe' ORDER BY name ASC"
)
test_parse_sql(
"SELECT (id, name) FROM person WHERE id = 1 AND name = 'Joe' ORDER BY name ASC"
)
test_parse_sql(
"SELECT * FROM person ORDER BY id DESC, name ASC"
)
test_parse_sql(
"SELECT (id, name) FROM person ORDER BY id DESC, name ASC"
)
test_parse_sql(
"SELECT * FROM person WHERE name = 'Joe' ORDER BY id DESC, name ASC"
)
test_parse_sql(
"SELECT (id, name) FROM person WHERE name = 'Joe' ORDER BY id DESC, name ASC"
)
test_parse_sql(
"SELECT * FROM person WHERE id = 1 AND name = 'Joe' ORDER BY id DESC, name ASC"
)
test_parse_sql(
"SELECT (id, name) FROM person WHERE id = 1 AND name = 'Joe' ORDER BY id DESC, name ASC"
)
test_parse_sql(
"SELECT id, name FROM person; SELECT id, name from heroes"
)
test_parse_sql(
"INSERT INTO person VALUES ('Paul', 'none')"
)
test_parse_sql(
"INSERT INTO person (name, authority) VALUES ('Paul', 'none')"
)
test_parse_sql(
"INSERT INTO person VALUES ('Paul', 'none'), ('John', 'none')"
)
test_parse_sql(
"INSERT INTO person (name, authority) VALUES ('Paul', 'none'), ('John', 'none')"
)
#Can un-comment when autoincrement config comes from IDL
#
#test_parse_sql(
# "INSERT INTO person VALUES (3, 'Paul', 'none')"
#)
#test_parse_sql(
# "INSERT INTO person (id, name, authority) VALUES (3, 'Paul', 'none')"
#)
#test_parse_sql(
# "INSERT INTO person VALUES (3, 'Paul', 'none'), (4, 'John', 'none')"
#)
#test_parse_sql(
# "INSERT INTO person (id, name, authority) VALUES (3, 'Paul', 'none'), (4, 'John', 'none')"
#)
#
test_parse_sql(
"DELETE FROM person"
)
test_parse_sql(
"DELETE FROM person WHERE name = 'Joe'"
)
test_parse_sql(
"DELETE FROM person WHERE id = 1 AND name = 'Joe'"
)
test_parse_sql(
"UPDATE person SET name = 'Paul' WHERE id = 1"
)
test_parse_sql(
"UPDATE person SET name = 'Paul' WHERE name = 'Joe'"
)
test_parse_sql(
"UPDATE person SET name = 'Paul' WHERE id = 1 AND name = 'Joe'"
)
test_parse_sql(
"UPDATE person SET name = 'Paul', authority = 'none' WHERE id = 1"
)
test_parse_sql(
"UPDATE person SET name = 'Paul', authority = 'none' WHERE name = 'Joe'"
)
test_parse_sql(
"UPDATE person SET name = 'Paul', authority = 'none' WHERE id = 1 AND name = 'Joe'"
)
| 0
|
solana_public_repos/nautilus-project/nautilus
|
solana_public_repos/nautilus-project/nautilus/js/yarn.lock
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@babel/runtime@^7.12.5", "@babel/runtime@^7.17.2":
version "7.21.0"
resolved "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.0.tgz"
integrity sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw==
dependencies:
regenerator-runtime "^0.13.11"
"@noble/ed25519@^1.7.0":
version "1.7.3"
resolved "https://registry.npmjs.org/@noble/ed25519/-/ed25519-1.7.3.tgz"
integrity sha512-iR8GBkDt0Q3GyaVcIu7mSsVIqnFbkbRzGLWlvhwunacoLwt4J3swfKhfaM6rN6WY+TBGoYT1GtT1mIh2/jGbRQ==
"@noble/hashes@^1.1.2":
version "1.3.0"
resolved "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.0.tgz"
integrity sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg==
"@noble/secp256k1@^1.6.3":
version "1.7.1"
resolved "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.1.tgz"
integrity sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==
"@solana/buffer-layout@^4.0.0":
version "4.0.1"
resolved "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz"
integrity sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==
dependencies:
buffer "~6.0.3"
"@solana/web3.js@^1.73.2":
version "1.74.0"
resolved "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.74.0.tgz"
integrity sha512-RKZyPqizPCxmpMGfpu4fuplNZEWCrhRBjjVstv5QnAJvgln1jgOfgui+rjl1ExnqDnWKg9uaZ5jtGROH/cwabg==
dependencies:
"@babel/runtime" "^7.12.5"
"@noble/ed25519" "^1.7.0"
"@noble/hashes" "^1.1.2"
"@noble/secp256k1" "^1.6.3"
"@solana/buffer-layout" "^4.0.0"
agentkeepalive "^4.2.1"
bigint-buffer "^1.1.5"
bn.js "^5.0.0"
borsh "^0.7.0"
bs58 "^4.0.1"
buffer "6.0.1"
fast-stable-stringify "^1.0.0"
jayson "^3.4.4"
node-fetch "^2.6.7"
rpc-websockets "^7.5.1"
superstruct "^0.14.2"
"@types/chai@^4.3.4":
version "4.3.4"
resolved "https://registry.npmjs.org/@types/chai/-/chai-4.3.4.tgz"
integrity sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==
"@types/connect@^3.4.33":
version "3.4.35"
resolved "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz"
integrity sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==
dependencies:
"@types/node" "*"
"@types/json5@^0.0.29":
version "0.0.29"
resolved "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz"
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==
"@types/mocha@^10.0.1":
version "10.0.1"
resolved "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.1.tgz"
integrity sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==
"@types/node-fetch@^2.6.2":
version "2.6.3"
resolved "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.3.tgz"
integrity sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w==
dependencies:
"@types/node" "*"
form-data "^3.0.0"
"@types/node@*":
version "18.15.11"
resolved "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz"
integrity sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==
"@types/node@^12.12.54":
version "12.20.55"
resolved "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz"
integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==
"@types/ws@^7.4.4":
version "7.4.7"
resolved "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz"
integrity sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==
dependencies:
"@types/node" "*"
agentkeepalive@^4.2.1:
version "4.3.0"
resolved "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.3.0.tgz"
integrity sha512-7Epl1Blf4Sy37j4v9f9FjICCh4+KAQOyXgHEwlyBiAQLbhKdq/i2QQU3amQalS/wPhdPzDXPL5DMR5bkn+YeWg==
dependencies:
debug "^4.1.0"
depd "^2.0.0"
humanize-ms "^1.2.1"
ansi-colors@4.1.1:
version "4.1.1"
resolved "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz"
integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==
ansi-regex@^5.0.1:
version "5.0.1"
resolved "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz"
integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==
ansi-styles@^4.0.0, ansi-styles@^4.1.0:
version "4.3.0"
resolved "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz"
integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==
dependencies:
color-convert "^2.0.1"
anymatch@~3.1.2:
version "3.1.3"
resolved "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz"
integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==
dependencies:
normalize-path "^3.0.0"
picomatch "^2.0.4"
argparse@^2.0.1:
version "2.0.1"
resolved "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz"
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
arrify@^1.0.0:
version "1.0.1"
resolved "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz"
integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==
asynckit@^0.4.0:
version "0.4.0"
resolved "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz"
integrity sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
base-x@^3.0.2:
version "3.0.9"
resolved "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz"
integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==
dependencies:
safe-buffer "^5.0.1"
base64-js@^1.3.1:
version "1.5.1"
resolved "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
big-integer@^1.6.48:
version "1.6.51"
resolved "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz"
integrity sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==
bigint-buffer@^1.1.5:
version "1.1.5"
resolved "https://registry.npmjs.org/bigint-buffer/-/bigint-buffer-1.1.5.tgz"
integrity sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==
dependencies:
bindings "^1.3.0"
binary-extensions@^2.0.0:
version "2.2.0"
resolved "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz"
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==
bindings@^1.3.0:
version "1.5.0"
resolved "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz"
integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==
dependencies:
file-uri-to-path "1.0.0"
bn.js@^5.0.0, bn.js@^5.2.0:
version "5.2.1"
resolved "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz"
integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==
borsh@^0.7.0:
version "0.7.0"
resolved "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz"
integrity sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==
dependencies:
bn.js "^5.2.0"
bs58 "^4.0.0"
text-encoding-utf-8 "^1.0.2"
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
brace-expansion@^2.0.1:
version "2.0.1"
resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz"
integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==
dependencies:
balanced-match "^1.0.0"
braces@~3.0.2:
version "3.0.2"
resolved "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
dependencies:
fill-range "^7.0.1"
browser-stdout@1.3.1:
version "1.3.1"
resolved "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz"
integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==
bs58@^4.0.0, bs58@^4.0.1:
version "4.0.1"
resolved "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz"
integrity sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==
dependencies:
base-x "^3.0.2"
buffer-from@^1.0.0, buffer-from@^1.1.0:
version "1.1.2"
resolved "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz"
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==
buffer@~6.0.3:
version "6.0.3"
resolved "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz"
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.2.1"
buffer@6.0.1:
version "6.0.1"
resolved "https://registry.npmjs.org/buffer/-/buffer-6.0.1.tgz"
integrity sha512-rVAXBwEcEoYtxnHSO5iWyhzV/O1WMtkUYWlfdLS7FjU4PnSJJHEfHXi/uHPI5EwltmOA794gN3bm3/pzuctWjQ==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.2.1"
bufferutil@^4.0.1:
version "4.0.7"
resolved "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz"
integrity sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==
dependencies:
node-gyp-build "^4.3.0"
camelcase@^6.0.0:
version "6.3.0"
resolved "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz"
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
chalk@^4.1.0:
version "4.1.2"
resolved "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"
chokidar@3.5.3:
version "3.5.3"
resolved "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz"
integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==
dependencies:
anymatch "~3.1.2"
braces "~3.0.2"
glob-parent "~5.1.2"
is-binary-path "~2.1.0"
is-glob "~4.0.1"
normalize-path "~3.0.0"
readdirp "~3.6.0"
optionalDependencies:
fsevents "~2.3.2"
cliui@^7.0.2:
version "7.0.4"
resolved "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz"
integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==
dependencies:
string-width "^4.2.0"
strip-ansi "^6.0.0"
wrap-ansi "^7.0.0"
color-convert@^2.0.1:
version "2.0.1"
resolved "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz"
integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==
dependencies:
color-name "~1.1.4"
color-name@~1.1.4:
version "1.1.4"
resolved "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
combined-stream@^1.0.8:
version "1.0.8"
resolved "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz"
integrity sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==
dependencies:
delayed-stream "~1.0.0"
commander@^2.20.3:
version "2.20.3"
resolved "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz"
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
debug@^4.1.0, debug@4.3.4:
version "4.3.4"
resolved "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"
decamelize@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz"
integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==
delay@^5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz"
integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==
delayed-stream@~1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz"
integrity sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==
depd@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz"
integrity sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==
diff@^3.1.0:
version "3.5.0"
resolved "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz"
integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==
diff@5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz"
integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==
emoji-regex@^8.0.0:
version "8.0.0"
resolved "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz"
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
es6-promise@^4.0.3:
version "4.2.8"
resolved "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz"
integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==
es6-promisify@^5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz"
integrity sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==
dependencies:
es6-promise "^4.0.3"
escalade@^3.1.1:
version "3.1.1"
resolved "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz"
integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==
escape-string-regexp@4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
eventemitter3@^4.0.7:
version "4.0.7"
resolved "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz"
integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==
eyes@^0.1.8:
version "0.1.8"
resolved "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz"
integrity sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==
fast-stable-stringify@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz"
integrity sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==
file-uri-to-path@1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz"
integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==
fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
dependencies:
to-regex-range "^5.0.1"
find-up@5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz"
integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==
dependencies:
locate-path "^6.0.0"
path-exists "^4.0.0"
flat@^5.0.2:
version "5.0.2"
resolved "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz"
integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==
form-data@^3.0.0:
version "3.0.1"
resolved "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz"
integrity sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==
dependencies:
asynckit "^0.4.0"
combined-stream "^1.0.8"
mime-types "^2.1.12"
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
fs@^0.0.1-security:
version "0.0.1-security"
resolved "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz"
integrity sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==
fsevents@~2.3.2:
version "2.3.2"
resolved "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
get-caller-file@^2.0.5:
version "2.0.5"
resolved "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz"
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
glob-parent@~5.1.2:
version "5.1.2"
resolved "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz"
integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==
dependencies:
is-glob "^4.0.1"
glob@7.2.0:
version "7.2.0"
resolved "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz"
integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
has-flag@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz"
integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
he@1.2.0:
version "1.2.0"
resolved "https://registry.npmjs.org/he/-/he-1.2.0.tgz"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
humanize-ms@^1.2.1:
version "1.2.1"
resolved "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz"
integrity sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==
dependencies:
ms "^2.0.0"
ieee754@^1.2.1:
version "1.2.1"
resolved "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz"
integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2:
version "2.0.4"
resolved "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
is-binary-path@~2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz"
integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==
dependencies:
binary-extensions "^2.0.0"
is-extglob@^2.1.1:
version "2.1.1"
resolved "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz"
integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==
is-fullwidth-code-point@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz"
integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
is-glob@^4.0.1, is-glob@~4.0.1:
version "4.0.3"
resolved "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz"
integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==
dependencies:
is-extglob "^2.1.1"
is-number@^7.0.0:
version "7.0.0"
resolved "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz"
integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==
is-plain-obj@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz"
integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==
is-unicode-supported@^0.1.0:
version "0.1.0"
resolved "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz"
integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==
isomorphic-ws@^4.0.1:
version "4.0.1"
resolved "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz"
integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==
jayson@^3.4.4:
version "3.7.0"
resolved "https://registry.npmjs.org/jayson/-/jayson-3.7.0.tgz"
integrity sha512-tfy39KJMrrXJ+mFcMpxwBvFDetS8LAID93+rycFglIQM4kl3uNR3W4lBLE/FFhsoUCEox5Dt2adVpDm/XtebbQ==
dependencies:
"@types/connect" "^3.4.33"
"@types/node" "^12.12.54"
"@types/ws" "^7.4.4"
commander "^2.20.3"
delay "^5.0.0"
es6-promisify "^5.0.0"
eyes "^0.1.8"
isomorphic-ws "^4.0.1"
json-stringify-safe "^5.0.1"
JSONStream "^1.3.5"
lodash "^4.17.20"
uuid "^8.3.2"
ws "^7.4.5"
js-yaml@4.1.0:
version "4.1.0"
resolved "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz"
integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
dependencies:
argparse "^2.0.1"
json-stringify-safe@^5.0.1:
version "5.0.1"
resolved "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz"
integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==
json5@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz"
integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==
dependencies:
minimist "^1.2.0"
jsonparse@^1.2.0:
version "1.3.1"
resolved "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz"
integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==
JSONStream@^1.3.5:
version "1.3.5"
resolved "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz"
integrity sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==
dependencies:
jsonparse "^1.2.0"
through ">=2.2.7 <3"
locate-path@^6.0.0:
version "6.0.0"
resolved "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz"
integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==
dependencies:
p-locate "^5.0.0"
lodash@^4.17.20:
version "4.17.21"
resolved "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
log-symbols@4.1.0:
version "4.1.0"
resolved "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz"
integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==
dependencies:
chalk "^4.1.0"
is-unicode-supported "^0.1.0"
make-error@^1.1.1:
version "1.3.6"
resolved "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz"
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
mime-db@1.52.0:
version "1.52.0"
resolved "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz"
integrity sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==
mime-types@^2.1.12:
version "2.1.35"
resolved "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz"
integrity sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==
dependencies:
mime-db "1.52.0"
minimatch@^3.0.4:
version "3.1.2"
resolved "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
dependencies:
brace-expansion "^1.1.7"
minimatch@5.0.1:
version "5.0.1"
resolved "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz"
integrity sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==
dependencies:
brace-expansion "^2.0.1"
minimist@^1.2.0, minimist@^1.2.6:
version "1.2.8"
resolved "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz"
integrity sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==
mkdirp@^0.5.1:
version "0.5.6"
resolved "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz"
integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==
dependencies:
minimist "^1.2.6"
mocha@^10.1.0, "mocha@^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X":
version "10.2.0"
resolved "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz"
integrity sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==
dependencies:
ansi-colors "4.1.1"
browser-stdout "1.3.1"
chokidar "3.5.3"
debug "4.3.4"
diff "5.0.0"
escape-string-regexp "4.0.0"
find-up "5.0.0"
glob "7.2.0"
he "1.2.0"
js-yaml "4.1.0"
log-symbols "4.1.0"
minimatch "5.0.1"
ms "2.1.3"
nanoid "3.3.3"
serialize-javascript "6.0.0"
strip-json-comments "3.1.1"
supports-color "8.1.1"
workerpool "6.2.1"
yargs "16.2.0"
yargs-parser "20.2.4"
yargs-unparser "2.0.0"
ms@^2.0.0, ms@2.1.3:
version "2.1.3"
resolved "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
ms@2.1.2:
version "2.1.2"
resolved "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
nanoid@3.3.3:
version "3.3.3"
resolved "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz"
integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==
node-fetch@^2.6.7:
version "2.6.9"
resolved "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz"
integrity sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==
dependencies:
whatwg-url "^5.0.0"
node-gyp-build@^4.3.0:
version "4.6.0"
resolved "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz"
integrity sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==
node-sql-parser@^4.6.5:
version "4.6.6"
resolved "https://registry.npmjs.org/node-sql-parser/-/node-sql-parser-4.6.6.tgz"
integrity sha512-zpash5xnRY6+0C9HFru32iRJV1LTkwtrVpO90i385tYVF6efyXK/B3Nsq/15Fuv2utxrqHNjKtL55OHb8sl+eQ==
dependencies:
big-integer "^1.6.48"
normalize-path@^3.0.0, normalize-path@~3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz"
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
once@^1.3.0:
version "1.4.0"
resolved "https://registry.npmjs.org/once/-/once-1.4.0.tgz"
integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==
dependencies:
wrappy "1"
p-limit@^3.0.2:
version "3.1.0"
resolved "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz"
integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==
dependencies:
yocto-queue "^0.1.0"
p-locate@^5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz"
integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==
dependencies:
p-limit "^3.0.2"
path-exists@^4.0.0:
version "4.0.0"
resolved "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz"
integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz"
integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==
picomatch@^2.0.4, picomatch@^2.2.1:
version "2.3.1"
resolved "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
randombytes@^2.1.0:
version "2.1.0"
resolved "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz"
integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==
dependencies:
safe-buffer "^5.1.0"
readdirp@~3.6.0:
version "3.6.0"
resolved "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz"
integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==
dependencies:
picomatch "^2.2.1"
regenerator-runtime@^0.13.11:
version "0.13.11"
resolved "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz"
integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==
require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz"
integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==
rpc-websockets@^7.5.1:
version "7.5.1"
resolved "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-7.5.1.tgz"
integrity sha512-kGFkeTsmd37pHPMaHIgN1LVKXMi0JD782v4Ds9ZKtLlwdTKjn+CxM9A9/gLT2LaOuEcEFGL98h1QWQtlOIdW0w==
dependencies:
"@babel/runtime" "^7.17.2"
eventemitter3 "^4.0.7"
uuid "^8.3.2"
ws "^8.5.0"
optionalDependencies:
bufferutil "^4.0.1"
utf-8-validate "^5.0.2"
safe-buffer@^5.0.1, safe-buffer@^5.1.0:
version "5.2.1"
resolved "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz"
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==
serialize-javascript@6.0.0:
version "6.0.0"
resolved "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz"
integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==
dependencies:
randombytes "^2.1.0"
source-map-support@^0.5.6:
version "0.5.21"
resolved "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz"
integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==
dependencies:
buffer-from "^1.0.0"
source-map "^0.6.0"
source-map@^0.6.0:
version "0.6.1"
resolved "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
string-width@^4.1.0, string-width@^4.2.0:
version "4.2.3"
resolved "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"
strip-bom@^3.0.0:
version "3.0.0"
resolved "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz"
integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==
strip-json-comments@3.1.1:
version "3.1.1"
resolved "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz"
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
superstruct@^0.14.2:
version "0.14.2"
resolved "https://registry.npmjs.org/superstruct/-/superstruct-0.14.2.tgz"
integrity sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ==
supports-color@^7.1.0:
version "7.2.0"
resolved "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz"
integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==
dependencies:
has-flag "^4.0.0"
supports-color@8.1.1:
version "8.1.1"
resolved "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz"
integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==
dependencies:
has-flag "^4.0.0"
text-encoding-utf-8@^1.0.2:
version "1.0.2"
resolved "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz"
integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==
"through@>=2.2.7 <3":
version "2.3.8"
resolved "https://registry.npmjs.org/through/-/through-2.3.8.tgz"
integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==
to-regex-range@^5.0.1:
version "5.0.1"
resolved "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz"
integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==
dependencies:
is-number "^7.0.0"
tr46@~0.0.3:
version "0.0.3"
resolved "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz"
integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==
ts-mocha@^10.0.0:
version "10.0.0"
resolved "https://registry.npmjs.org/ts-mocha/-/ts-mocha-10.0.0.tgz"
integrity sha512-VRfgDO+iiuJFlNB18tzOfypJ21xn2xbuZyDvJvqpTbWgkAgD17ONGr8t+Tl8rcBtOBdjXp5e/Rk+d39f7XBHRw==
dependencies:
ts-node "7.0.1"
optionalDependencies:
tsconfig-paths "^3.5.0"
ts-node@7.0.1:
version "7.0.1"
resolved "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz"
integrity sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==
dependencies:
arrify "^1.0.0"
buffer-from "^1.1.0"
diff "^3.1.0"
make-error "^1.1.1"
minimist "^1.2.0"
mkdirp "^0.5.1"
source-map-support "^0.5.6"
yn "^2.0.0"
tsconfig-paths@^3.5.0:
version "3.14.2"
resolved "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz"
integrity sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==
dependencies:
"@types/json5" "^0.0.29"
json5 "^1.0.2"
minimist "^1.2.6"
strip-bom "^3.0.0"
typescript@^4.9.3:
version "4.9.5"
resolved "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz"
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==
utf-8-validate@^5.0.2, utf-8-validate@>=5.0.2:
version "5.0.10"
resolved "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz"
integrity sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==
dependencies:
node-gyp-build "^4.3.0"
uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz"
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==
whatwg-url@^5.0.0:
version "5.0.0"
resolved "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz"
integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==
dependencies:
tr46 "~0.0.3"
webidl-conversions "^3.0.0"
workerpool@6.2.1:
version "6.2.1"
resolved "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz"
integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==
wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"
wrappy@1:
version "1.0.2"
resolved "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz"
integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==
ws@*, ws@^7.4.5:
version "7.5.9"
resolved "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz"
integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==
ws@^8.5.0:
version "8.13.0"
resolved "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz"
integrity sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==
y18n@^5.0.5:
version "5.0.8"
resolved "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz"
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==
yargs-parser@^20.2.2:
version "20.2.9"
resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz"
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==
yargs-parser@20.2.4:
version "20.2.4"
resolved "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz"
integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==
yargs-unparser@2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz"
integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==
dependencies:
camelcase "^6.0.0"
decamelize "^4.0.0"
flat "^5.0.2"
is-plain-obj "^2.1.0"
yargs@16.2.0:
version "16.2.0"
resolved "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz"
integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==
dependencies:
cliui "^7.0.2"
escalade "^3.1.1"
get-caller-file "^2.0.5"
require-directory "^2.1.1"
string-width "^4.2.0"
y18n "^5.0.5"
yargs-parser "^20.2.2"
yn@^2.0.0:
version "2.0.0"
resolved "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz"
integrity sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ==
yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
| 0
|
solana_public_repos/nautilus-project/nautilus
|
solana_public_repos/nautilus-project/nautilus/js/package-lock.json
|
{
"name": "nautilus-js",
"version": "0.0.1",
"lockfileVersion": 3,
"requires": true,
"packages": {
"": {
"name": "nautilus-js",
"version": "0.0.1",
"license": "MIT",
"dependencies": {
"@solana/web3.js": "^1.73.2",
"node-sql-parser": "^4.6.5"
},
"devDependencies": {
"@types/chai": "^4.3.4",
"@types/mocha": "^10.0.1",
"@types/node-fetch": "^2.6.2",
"fs": "^0.0.1-security",
"mocha": "^10.1.0",
"ts-mocha": "^10.0.0",
"typescript": "^4.9.3"
}
},
"node_modules/@babel/runtime": {
"version": "7.21.0",
"resolved": "https://registry.npmjs.org/@babel/runtime/-/runtime-7.21.0.tgz",
"integrity": "sha512-xwII0//EObnq89Ji5AKYQaRYiW/nZ3llSv29d49IuxPhKbtJoLP+9QUUZ4nVragQVtaVGeZrpB+ZtG/Pdy/POw==",
"license": "MIT",
"dependencies": {
"regenerator-runtime": "^0.13.11"
},
"engines": {
"node": ">=6.9.0"
}
},
"node_modules/@noble/ed25519": {
"version": "1.7.3",
"resolved": "https://registry.npmjs.org/@noble/ed25519/-/ed25519-1.7.3.tgz",
"integrity": "sha512-iR8GBkDt0Q3GyaVcIu7mSsVIqnFbkbRzGLWlvhwunacoLwt4J3swfKhfaM6rN6WY+TBGoYT1GtT1mIh2/jGbRQ==",
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
],
"license": "MIT"
},
"node_modules/@noble/hashes": {
"version": "1.3.0",
"resolved": "https://registry.npmjs.org/@noble/hashes/-/hashes-1.3.0.tgz",
"integrity": "sha512-ilHEACi9DwqJB0pw7kv+Apvh50jiiSyR/cQ3y4W7lOR5mhvn/50FLUfsnfJz0BDZtl/RR16kXvptiv6q1msYZg==",
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
],
"license": "MIT"
},
"node_modules/@noble/secp256k1": {
"version": "1.7.1",
"resolved": "https://registry.npmjs.org/@noble/secp256k1/-/secp256k1-1.7.1.tgz",
"integrity": "sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==",
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
],
"license": "MIT"
},
"node_modules/@solana/buffer-layout": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz",
"integrity": "sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==",
"license": "MIT",
"dependencies": {
"buffer": "~6.0.3"
},
"engines": {
"node": ">=5.10"
}
},
"node_modules/@solana/buffer-layout/node_modules/buffer": {
"version": "6.0.3",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.3.tgz",
"integrity": "sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT",
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
},
"node_modules/@solana/web3.js": {
"version": "1.74.0",
"resolved": "https://registry.npmjs.org/@solana/web3.js/-/web3.js-1.74.0.tgz",
"integrity": "sha512-RKZyPqizPCxmpMGfpu4fuplNZEWCrhRBjjVstv5QnAJvgln1jgOfgui+rjl1ExnqDnWKg9uaZ5jtGROH/cwabg==",
"license": "MIT",
"dependencies": {
"@babel/runtime": "^7.12.5",
"@noble/ed25519": "^1.7.0",
"@noble/hashes": "^1.1.2",
"@noble/secp256k1": "^1.6.3",
"@solana/buffer-layout": "^4.0.0",
"agentkeepalive": "^4.2.1",
"bigint-buffer": "^1.1.5",
"bn.js": "^5.0.0",
"borsh": "^0.7.0",
"bs58": "^4.0.1",
"buffer": "6.0.1",
"fast-stable-stringify": "^1.0.0",
"jayson": "^3.4.4",
"node-fetch": "^2.6.7",
"rpc-websockets": "^7.5.1",
"superstruct": "^0.14.2"
}
},
"node_modules/@types/chai": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/@types/chai/-/chai-4.3.4.tgz",
"integrity": "sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/connect": {
"version": "3.4.35",
"resolved": "https://registry.npmjs.org/@types/connect/-/connect-3.4.35.tgz",
"integrity": "sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==",
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/@types/json5": {
"version": "0.0.29",
"resolved": "https://registry.npmjs.org/@types/json5/-/json5-0.0.29.tgz",
"integrity": "sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==",
"dev": true,
"license": "MIT",
"optional": true
},
"node_modules/@types/mocha": {
"version": "10.0.1",
"resolved": "https://registry.npmjs.org/@types/mocha/-/mocha-10.0.1.tgz",
"integrity": "sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==",
"dev": true,
"license": "MIT"
},
"node_modules/@types/node": {
"version": "18.15.11",
"resolved": "https://registry.npmjs.org/@types/node/-/node-18.15.11.tgz",
"integrity": "sha512-E5Kwq2n4SbMzQOn6wnmBjuK9ouqlURrcZDVfbo9ftDDTFt3nk7ZKK4GMOzoYgnpQJKcxwQw+lGaBvvlMo0qN/Q==",
"license": "MIT"
},
"node_modules/@types/node-fetch": {
"version": "2.6.3",
"resolved": "https://registry.npmjs.org/@types/node-fetch/-/node-fetch-2.6.3.tgz",
"integrity": "sha512-ETTL1mOEdq/sxUtgtOhKjyB2Irra4cjxksvcMUR5Zr4n+PxVhsCD9WS46oPbHL3et9Zde7CNRr+WUNlcHvsX+w==",
"dev": true,
"license": "MIT",
"dependencies": {
"@types/node": "*",
"form-data": "^3.0.0"
}
},
"node_modules/@types/ws": {
"version": "7.4.7",
"resolved": "https://registry.npmjs.org/@types/ws/-/ws-7.4.7.tgz",
"integrity": "sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==",
"license": "MIT",
"dependencies": {
"@types/node": "*"
}
},
"node_modules/agentkeepalive": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/agentkeepalive/-/agentkeepalive-4.3.0.tgz",
"integrity": "sha512-7Epl1Blf4Sy37j4v9f9FjICCh4+KAQOyXgHEwlyBiAQLbhKdq/i2QQU3amQalS/wPhdPzDXPL5DMR5bkn+YeWg==",
"license": "MIT",
"dependencies": {
"debug": "^4.1.0",
"depd": "^2.0.0",
"humanize-ms": "^1.2.1"
},
"engines": {
"node": ">= 8.0.0"
}
},
"node_modules/ansi-colors": {
"version": "4.1.1",
"resolved": "https://registry.npmjs.org/ansi-colors/-/ansi-colors-4.1.1.tgz",
"integrity": "sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/ansi-regex": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/ansi-regex/-/ansi-regex-5.0.1.tgz",
"integrity": "sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/ansi-styles": {
"version": "4.3.0",
"resolved": "https://registry.npmjs.org/ansi-styles/-/ansi-styles-4.3.0.tgz",
"integrity": "sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==",
"dev": true,
"license": "MIT",
"dependencies": {
"color-convert": "^2.0.1"
},
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/chalk/ansi-styles?sponsor=1"
}
},
"node_modules/anymatch": {
"version": "3.1.3",
"resolved": "https://registry.npmjs.org/anymatch/-/anymatch-3.1.3.tgz",
"integrity": "sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==",
"dev": true,
"license": "ISC",
"dependencies": {
"normalize-path": "^3.0.0",
"picomatch": "^2.0.4"
},
"engines": {
"node": ">= 8"
}
},
"node_modules/argparse": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/argparse/-/argparse-2.0.1.tgz",
"integrity": "sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==",
"dev": true,
"license": "Python-2.0"
},
"node_modules/arrify": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/arrify/-/arrify-1.0.1.tgz",
"integrity": "sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/asynckit": {
"version": "0.4.0",
"resolved": "https://registry.npmjs.org/asynckit/-/asynckit-0.4.0.tgz",
"integrity": "sha512-Oei9OH4tRh0YqU3GxhX79dM/mwVgvbZJaSNaRk+bshkj0S5cfHcgYakreBjrHwatXKbz+IoIdYLxrKim2MjW0Q==",
"dev": true,
"license": "MIT"
},
"node_modules/balanced-match": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.2.tgz",
"integrity": "sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==",
"dev": true,
"license": "MIT"
},
"node_modules/base-x": {
"version": "3.0.9",
"resolved": "https://registry.npmjs.org/base-x/-/base-x-3.0.9.tgz",
"integrity": "sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==",
"license": "MIT",
"dependencies": {
"safe-buffer": "^5.0.1"
}
},
"node_modules/base64-js": {
"version": "1.5.1",
"resolved": "https://registry.npmjs.org/base64-js/-/base64-js-1.5.1.tgz",
"integrity": "sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/big-integer": {
"version": "1.6.51",
"resolved": "https://registry.npmjs.org/big-integer/-/big-integer-1.6.51.tgz",
"integrity": "sha512-GPEid2Y9QU1Exl1rpO9B2IPJGHPSupF5GnVIP0blYvNOMer2bTvSWs1jGOUg04hTmu67nmLsQ9TBo1puaotBHg==",
"license": "Unlicense",
"engines": {
"node": ">=0.6"
}
},
"node_modules/bigint-buffer": {
"version": "1.1.5",
"resolved": "https://registry.npmjs.org/bigint-buffer/-/bigint-buffer-1.1.5.tgz",
"integrity": "sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==",
"hasInstallScript": true,
"license": "Apache-2.0",
"dependencies": {
"bindings": "^1.3.0"
},
"engines": {
"node": ">= 10.0.0"
}
},
"node_modules/binary-extensions": {
"version": "2.2.0",
"resolved": "https://registry.npmjs.org/binary-extensions/-/binary-extensions-2.2.0.tgz",
"integrity": "sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/bindings": {
"version": "1.5.0",
"resolved": "https://registry.npmjs.org/bindings/-/bindings-1.5.0.tgz",
"integrity": "sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==",
"license": "MIT",
"dependencies": {
"file-uri-to-path": "1.0.0"
}
},
"node_modules/bn.js": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/bn.js/-/bn.js-5.2.1.tgz",
"integrity": "sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==",
"license": "MIT"
},
"node_modules/borsh": {
"version": "0.7.0",
"resolved": "https://registry.npmjs.org/borsh/-/borsh-0.7.0.tgz",
"integrity": "sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==",
"license": "Apache-2.0",
"dependencies": {
"bn.js": "^5.2.0",
"bs58": "^4.0.0",
"text-encoding-utf-8": "^1.0.2"
}
},
"node_modules/brace-expansion": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-2.0.1.tgz",
"integrity": "sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==",
"dev": true,
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0"
}
},
"node_modules/braces": {
"version": "3.0.2",
"resolved": "https://registry.npmjs.org/braces/-/braces-3.0.2.tgz",
"integrity": "sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==",
"dev": true,
"license": "MIT",
"dependencies": {
"fill-range": "^7.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/browser-stdout": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/browser-stdout/-/browser-stdout-1.3.1.tgz",
"integrity": "sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==",
"dev": true,
"license": "ISC"
},
"node_modules/bs58": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/bs58/-/bs58-4.0.1.tgz",
"integrity": "sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==",
"license": "MIT",
"dependencies": {
"base-x": "^3.0.2"
}
},
"node_modules/buffer": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/buffer/-/buffer-6.0.1.tgz",
"integrity": "sha512-rVAXBwEcEoYtxnHSO5iWyhzV/O1WMtkUYWlfdLS7FjU4PnSJJHEfHXi/uHPI5EwltmOA794gN3bm3/pzuctWjQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT",
"dependencies": {
"base64-js": "^1.3.1",
"ieee754": "^1.2.1"
}
},
"node_modules/buffer-from": {
"version": "1.1.2",
"resolved": "https://registry.npmjs.org/buffer-from/-/buffer-from-1.1.2.tgz",
"integrity": "sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==",
"dev": true,
"license": "MIT"
},
"node_modules/bufferutil": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/bufferutil/-/bufferutil-4.0.7.tgz",
"integrity": "sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==",
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"dependencies": {
"node-gyp-build": "^4.3.0"
},
"engines": {
"node": ">=6.14.2"
}
},
"node_modules/camelcase": {
"version": "6.3.0",
"resolved": "https://registry.npmjs.org/camelcase/-/camelcase-6.3.0.tgz",
"integrity": "sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/chalk": {
"version": "4.1.2",
"resolved": "https://registry.npmjs.org/chalk/-/chalk-4.1.2.tgz",
"integrity": "sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.1.0",
"supports-color": "^7.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/chalk?sponsor=1"
}
},
"node_modules/chalk/node_modules/supports-color": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-7.2.0.tgz",
"integrity": "sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==",
"dev": true,
"license": "MIT",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/chokidar": {
"version": "3.5.3",
"resolved": "https://registry.npmjs.org/chokidar/-/chokidar-3.5.3.tgz",
"integrity": "sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==",
"dev": true,
"funding": [
{
"type": "individual",
"url": "https://paulmillr.com/funding/"
}
],
"license": "MIT",
"dependencies": {
"anymatch": "~3.1.2",
"braces": "~3.0.2",
"glob-parent": "~5.1.2",
"is-binary-path": "~2.1.0",
"is-glob": "~4.0.1",
"normalize-path": "~3.0.0",
"readdirp": "~3.6.0"
},
"engines": {
"node": ">= 8.10.0"
},
"optionalDependencies": {
"fsevents": "~2.3.2"
}
},
"node_modules/cliui": {
"version": "7.0.4",
"resolved": "https://registry.npmjs.org/cliui/-/cliui-7.0.4.tgz",
"integrity": "sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==",
"dev": true,
"license": "ISC",
"dependencies": {
"string-width": "^4.2.0",
"strip-ansi": "^6.0.0",
"wrap-ansi": "^7.0.0"
}
},
"node_modules/color-convert": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/color-convert/-/color-convert-2.0.1.tgz",
"integrity": "sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"color-name": "~1.1.4"
},
"engines": {
"node": ">=7.0.0"
}
},
"node_modules/color-name": {
"version": "1.1.4",
"resolved": "https://registry.npmjs.org/color-name/-/color-name-1.1.4.tgz",
"integrity": "sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==",
"dev": true,
"license": "MIT"
},
"node_modules/combined-stream": {
"version": "1.0.8",
"resolved": "https://registry.npmjs.org/combined-stream/-/combined-stream-1.0.8.tgz",
"integrity": "sha512-FQN4MRfuJeHf7cBbBMJFXhKSDq+2kAArBlmRBvcvFE5BB1HZKXtSFASDhdlz9zOYwxh8lDdnvmMOe/+5cdoEdg==",
"dev": true,
"license": "MIT",
"dependencies": {
"delayed-stream": "~1.0.0"
},
"engines": {
"node": ">= 0.8"
}
},
"node_modules/commander": {
"version": "2.20.3",
"resolved": "https://registry.npmjs.org/commander/-/commander-2.20.3.tgz",
"integrity": "sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==",
"license": "MIT"
},
"node_modules/concat-map": {
"version": "0.0.1",
"resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz",
"integrity": "sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==",
"dev": true,
"license": "MIT"
},
"node_modules/debug": {
"version": "4.3.4",
"resolved": "https://registry.npmjs.org/debug/-/debug-4.3.4.tgz",
"integrity": "sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==",
"license": "MIT",
"dependencies": {
"ms": "2.1.2"
},
"engines": {
"node": ">=6.0"
},
"peerDependenciesMeta": {
"supports-color": {
"optional": true
}
}
},
"node_modules/debug/node_modules/ms": {
"version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"license": "MIT"
},
"node_modules/decamelize": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/decamelize/-/decamelize-4.0.0.tgz",
"integrity": "sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/delay": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/delay/-/delay-5.0.0.tgz",
"integrity": "sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==",
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/delayed-stream": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/delayed-stream/-/delayed-stream-1.0.0.tgz",
"integrity": "sha512-ZySD7Nf91aLB0RxL4KGrKHBXl7Eds1DAmEdcoVawXnLD7SDhpNgtuII2aAkg7a7QS41jxPSZ17p4VdGnMHk3MQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.4.0"
}
},
"node_modules/depd": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/depd/-/depd-2.0.0.tgz",
"integrity": "sha512-g7nH6P6dyDioJogAAGprGpCtVImJhpPk/roCzdb3fIh61/s/nPsfR6onyMwkCAR/OlC3yBC0lESvUoQEAssIrw==",
"license": "MIT",
"engines": {
"node": ">= 0.8"
}
},
"node_modules/diff": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-5.0.0.tgz",
"integrity": "sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/emoji-regex": {
"version": "8.0.0",
"resolved": "https://registry.npmjs.org/emoji-regex/-/emoji-regex-8.0.0.tgz",
"integrity": "sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==",
"dev": true,
"license": "MIT"
},
"node_modules/es6-promise": {
"version": "4.2.8",
"resolved": "https://registry.npmjs.org/es6-promise/-/es6-promise-4.2.8.tgz",
"integrity": "sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==",
"license": "MIT"
},
"node_modules/es6-promisify": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/es6-promisify/-/es6-promisify-5.0.0.tgz",
"integrity": "sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==",
"license": "MIT",
"dependencies": {
"es6-promise": "^4.0.3"
}
},
"node_modules/escalade": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/escalade/-/escalade-3.1.1.tgz",
"integrity": "sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=6"
}
},
"node_modules/escape-string-regexp": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz",
"integrity": "sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/eventemitter3": {
"version": "4.0.7",
"resolved": "https://registry.npmjs.org/eventemitter3/-/eventemitter3-4.0.7.tgz",
"integrity": "sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==",
"license": "MIT"
},
"node_modules/eyes": {
"version": "0.1.8",
"resolved": "https://registry.npmjs.org/eyes/-/eyes-0.1.8.tgz",
"integrity": "sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==",
"engines": {
"node": "> 0.1.90"
}
},
"node_modules/fast-stable-stringify": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz",
"integrity": "sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==",
"license": "MIT"
},
"node_modules/file-uri-to-path": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz",
"integrity": "sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==",
"license": "MIT"
},
"node_modules/fill-range": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/fill-range/-/fill-range-7.0.1.tgz",
"integrity": "sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"to-regex-range": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/find-up": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/find-up/-/find-up-5.0.0.tgz",
"integrity": "sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==",
"dev": true,
"license": "MIT",
"dependencies": {
"locate-path": "^6.0.0",
"path-exists": "^4.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/flat": {
"version": "5.0.2",
"resolved": "https://registry.npmjs.org/flat/-/flat-5.0.2.tgz",
"integrity": "sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==",
"dev": true,
"license": "BSD-3-Clause",
"bin": {
"flat": "cli.js"
}
},
"node_modules/form-data": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/form-data/-/form-data-3.0.1.tgz",
"integrity": "sha512-RHkBKtLWUVwd7SqRIvCZMEvAMoGUp0XU+seQiZejj0COz3RI3hWP4sCv3gZWWLjJTd7rGwcsF5eKZGii0r/hbg==",
"dev": true,
"license": "MIT",
"dependencies": {
"asynckit": "^0.4.0",
"combined-stream": "^1.0.8",
"mime-types": "^2.1.12"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/fs": {
"version": "0.0.1-security",
"resolved": "https://registry.npmjs.org/fs/-/fs-0.0.1-security.tgz",
"integrity": "sha512-3XY9e1pP0CVEUCdj5BmfIZxRBTSDycnbqhIOGec9QYtmVH2fbLpj86CFWkrNOkt/Fvty4KZG5lTglL9j/gJ87w==",
"dev": true,
"license": "ISC"
},
"node_modules/fs.realpath": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz",
"integrity": "sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==",
"dev": true,
"license": "ISC"
},
"node_modules/fsevents": {
"version": "2.3.2",
"resolved": "https://registry.npmjs.org/fsevents/-/fsevents-2.3.2.tgz",
"integrity": "sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==",
"dev": true,
"license": "MIT",
"optional": true,
"os": [
"darwin"
],
"engines": {
"node": "^8.16.0 || ^10.6.0 || >=11.0.0"
}
},
"node_modules/get-caller-file": {
"version": "2.0.5",
"resolved": "https://registry.npmjs.org/get-caller-file/-/get-caller-file-2.0.5.tgz",
"integrity": "sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==",
"dev": true,
"license": "ISC",
"engines": {
"node": "6.* || 8.* || >= 10.*"
}
},
"node_modules/glob": {
"version": "7.2.0",
"resolved": "https://registry.npmjs.org/glob/-/glob-7.2.0.tgz",
"integrity": "sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==",
"dev": true,
"license": "ISC",
"dependencies": {
"fs.realpath": "^1.0.0",
"inflight": "^1.0.4",
"inherits": "2",
"minimatch": "^3.0.4",
"once": "^1.3.0",
"path-is-absolute": "^1.0.0"
},
"engines": {
"node": "*"
},
"funding": {
"url": "https://github.com/sponsors/isaacs"
}
},
"node_modules/glob-parent": {
"version": "5.1.2",
"resolved": "https://registry.npmjs.org/glob-parent/-/glob-parent-5.1.2.tgz",
"integrity": "sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==",
"dev": true,
"license": "ISC",
"dependencies": {
"is-glob": "^4.0.1"
},
"engines": {
"node": ">= 6"
}
},
"node_modules/glob/node_modules/brace-expansion": {
"version": "1.1.11",
"resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz",
"integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==",
"dev": true,
"license": "MIT",
"dependencies": {
"balanced-match": "^1.0.0",
"concat-map": "0.0.1"
}
},
"node_modules/glob/node_modules/minimatch": {
"version": "3.1.2",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.1.2.tgz",
"integrity": "sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==",
"dev": true,
"license": "ISC",
"dependencies": {
"brace-expansion": "^1.1.7"
},
"engines": {
"node": "*"
}
},
"node_modules/has-flag": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/has-flag/-/has-flag-4.0.0.tgz",
"integrity": "sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/he": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/he/-/he-1.2.0.tgz",
"integrity": "sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==",
"dev": true,
"license": "MIT",
"bin": {
"he": "bin/he"
}
},
"node_modules/humanize-ms": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/humanize-ms/-/humanize-ms-1.2.1.tgz",
"integrity": "sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==",
"license": "MIT",
"dependencies": {
"ms": "^2.0.0"
}
},
"node_modules/ieee754": {
"version": "1.2.1",
"resolved": "https://registry.npmjs.org/ieee754/-/ieee754-1.2.1.tgz",
"integrity": "sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "BSD-3-Clause"
},
"node_modules/inflight": {
"version": "1.0.6",
"resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz",
"integrity": "sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==",
"dev": true,
"license": "ISC",
"dependencies": {
"once": "^1.3.0",
"wrappy": "1"
}
},
"node_modules/inherits": {
"version": "2.0.4",
"resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz",
"integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==",
"dev": true,
"license": "ISC"
},
"node_modules/is-binary-path": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-binary-path/-/is-binary-path-2.1.0.tgz",
"integrity": "sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==",
"dev": true,
"license": "MIT",
"dependencies": {
"binary-extensions": "^2.0.0"
},
"engines": {
"node": ">=8"
}
},
"node_modules/is-extglob": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/is-extglob/-/is-extglob-2.1.1.tgz",
"integrity": "sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-fullwidth-code-point": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz",
"integrity": "sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/is-glob": {
"version": "4.0.3",
"resolved": "https://registry.npmjs.org/is-glob/-/is-glob-4.0.3.tgz",
"integrity": "sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-extglob": "^2.1.1"
},
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/is-number": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/is-number/-/is-number-7.0.0.tgz",
"integrity": "sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.12.0"
}
},
"node_modules/is-plain-obj": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/is-plain-obj/-/is-plain-obj-2.1.0.tgz",
"integrity": "sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/is-unicode-supported": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz",
"integrity": "sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/isomorphic-ws": {
"version": "4.0.1",
"resolved": "https://registry.npmjs.org/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz",
"integrity": "sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==",
"license": "MIT",
"peerDependencies": {
"ws": "*"
}
},
"node_modules/jayson": {
"version": "3.7.0",
"resolved": "https://registry.npmjs.org/jayson/-/jayson-3.7.0.tgz",
"integrity": "sha512-tfy39KJMrrXJ+mFcMpxwBvFDetS8LAID93+rycFglIQM4kl3uNR3W4lBLE/FFhsoUCEox5Dt2adVpDm/XtebbQ==",
"license": "MIT",
"dependencies": {
"@types/connect": "^3.4.33",
"@types/node": "^12.12.54",
"@types/ws": "^7.4.4",
"commander": "^2.20.3",
"delay": "^5.0.0",
"es6-promisify": "^5.0.0",
"eyes": "^0.1.8",
"isomorphic-ws": "^4.0.1",
"json-stringify-safe": "^5.0.1",
"JSONStream": "^1.3.5",
"lodash": "^4.17.20",
"uuid": "^8.3.2",
"ws": "^7.4.5"
},
"bin": {
"jayson": "bin/jayson.js"
},
"engines": {
"node": ">=8"
}
},
"node_modules/jayson/node_modules/@types/node": {
"version": "12.20.55",
"resolved": "https://registry.npmjs.org/@types/node/-/node-12.20.55.tgz",
"integrity": "sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==",
"license": "MIT"
},
"node_modules/js-yaml": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/js-yaml/-/js-yaml-4.1.0.tgz",
"integrity": "sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==",
"dev": true,
"license": "MIT",
"dependencies": {
"argparse": "^2.0.1"
},
"bin": {
"js-yaml": "bin/js-yaml.js"
}
},
"node_modules/json-stringify-safe": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz",
"integrity": "sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==",
"license": "ISC"
},
"node_modules/json5": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/json5/-/json5-1.0.2.tgz",
"integrity": "sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
"minimist": "^1.2.0"
},
"bin": {
"json5": "lib/cli.js"
}
},
"node_modules/jsonparse": {
"version": "1.3.1",
"resolved": "https://registry.npmjs.org/jsonparse/-/jsonparse-1.3.1.tgz",
"integrity": "sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==",
"engines": [
"node >= 0.2.0"
],
"license": "MIT"
},
"node_modules/JSONStream": {
"version": "1.3.5",
"resolved": "https://registry.npmjs.org/JSONStream/-/JSONStream-1.3.5.tgz",
"integrity": "sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==",
"license": "(MIT OR Apache-2.0)",
"dependencies": {
"jsonparse": "^1.2.0",
"through": ">=2.2.7 <3"
},
"bin": {
"JSONStream": "bin.js"
},
"engines": {
"node": "*"
}
},
"node_modules/locate-path": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/locate-path/-/locate-path-6.0.0.tgz",
"integrity": "sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==",
"dev": true,
"license": "MIT",
"dependencies": {
"p-locate": "^5.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/lodash": {
"version": "4.17.21",
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
"license": "MIT"
},
"node_modules/log-symbols": {
"version": "4.1.0",
"resolved": "https://registry.npmjs.org/log-symbols/-/log-symbols-4.1.0.tgz",
"integrity": "sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==",
"dev": true,
"license": "MIT",
"dependencies": {
"chalk": "^4.1.0",
"is-unicode-supported": "^0.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/make-error": {
"version": "1.3.6",
"resolved": "https://registry.npmjs.org/make-error/-/make-error-1.3.6.tgz",
"integrity": "sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==",
"dev": true,
"license": "ISC"
},
"node_modules/mime-db": {
"version": "1.52.0",
"resolved": "https://registry.npmjs.org/mime-db/-/mime-db-1.52.0.tgz",
"integrity": "sha512-sPU4uV7dYlvtWJxwwxHD0PuihVNiE7TyAbQ5SWxDCB9mUYvOgroQOwYQQOKPJ8CIbE+1ETVlOoK1UC2nU3gYvg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">= 0.6"
}
},
"node_modules/mime-types": {
"version": "2.1.35",
"resolved": "https://registry.npmjs.org/mime-types/-/mime-types-2.1.35.tgz",
"integrity": "sha512-ZDY+bPm5zTTF+YpCrAU9nK0UgICYPT0QtT1NZWFv4s++TNkcgVaT0g6+4R2uI4MjQjzysHB1zxuWL50hzaeXiw==",
"dev": true,
"license": "MIT",
"dependencies": {
"mime-db": "1.52.0"
},
"engines": {
"node": ">= 0.6"
}
},
"node_modules/minimatch": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/minimatch/-/minimatch-5.0.1.tgz",
"integrity": "sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==",
"dev": true,
"license": "ISC",
"dependencies": {
"brace-expansion": "^2.0.1"
},
"engines": {
"node": ">=10"
}
},
"node_modules/minimist": {
"version": "1.2.8",
"resolved": "https://registry.npmjs.org/minimist/-/minimist-1.2.8.tgz",
"integrity": "sha512-2yyAR8qBkN3YuheJanUpWC5U3bb5osDywNB8RzDVlDwDHbocAJveqqj1u8+SVD7jkWT4yvsHCpWqqWqAxb0zCA==",
"dev": true,
"license": "MIT",
"funding": {
"url": "https://github.com/sponsors/ljharb"
}
},
"node_modules/mkdirp": {
"version": "0.5.6",
"resolved": "https://registry.npmjs.org/mkdirp/-/mkdirp-0.5.6.tgz",
"integrity": "sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==",
"dev": true,
"license": "MIT",
"dependencies": {
"minimist": "^1.2.6"
},
"bin": {
"mkdirp": "bin/cmd.js"
}
},
"node_modules/mocha": {
"version": "10.2.0",
"resolved": "https://registry.npmjs.org/mocha/-/mocha-10.2.0.tgz",
"integrity": "sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-colors": "4.1.1",
"browser-stdout": "1.3.1",
"chokidar": "3.5.3",
"debug": "4.3.4",
"diff": "5.0.0",
"escape-string-regexp": "4.0.0",
"find-up": "5.0.0",
"glob": "7.2.0",
"he": "1.2.0",
"js-yaml": "4.1.0",
"log-symbols": "4.1.0",
"minimatch": "5.0.1",
"ms": "2.1.3",
"nanoid": "3.3.3",
"serialize-javascript": "6.0.0",
"strip-json-comments": "3.1.1",
"supports-color": "8.1.1",
"workerpool": "6.2.1",
"yargs": "16.2.0",
"yargs-parser": "20.2.4",
"yargs-unparser": "2.0.0"
},
"bin": {
"_mocha": "bin/_mocha",
"mocha": "bin/mocha.js"
},
"engines": {
"node": ">= 14.0.0"
},
"funding": {
"type": "opencollective",
"url": "https://opencollective.com/mochajs"
}
},
"node_modules/ms": {
"version": "2.1.3",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.3.tgz",
"integrity": "sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==",
"license": "MIT"
},
"node_modules/nanoid": {
"version": "3.3.3",
"resolved": "https://registry.npmjs.org/nanoid/-/nanoid-3.3.3.tgz",
"integrity": "sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==",
"dev": true,
"license": "MIT",
"bin": {
"nanoid": "bin/nanoid.cjs"
},
"engines": {
"node": "^10 || ^12 || ^13.7 || ^14 || >=15.0.1"
}
},
"node_modules/node-fetch": {
"version": "2.6.9",
"resolved": "https://registry.npmjs.org/node-fetch/-/node-fetch-2.6.9.tgz",
"integrity": "sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==",
"license": "MIT",
"dependencies": {
"whatwg-url": "^5.0.0"
},
"engines": {
"node": "4.x || >=6.0.0"
},
"peerDependencies": {
"encoding": "^0.1.0"
},
"peerDependenciesMeta": {
"encoding": {
"optional": true
}
}
},
"node_modules/node-gyp-build": {
"version": "4.6.0",
"resolved": "https://registry.npmjs.org/node-gyp-build/-/node-gyp-build-4.6.0.tgz",
"integrity": "sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==",
"license": "MIT",
"optional": true,
"bin": {
"node-gyp-build": "bin.js",
"node-gyp-build-optional": "optional.js",
"node-gyp-build-test": "build-test.js"
}
},
"node_modules/node-sql-parser": {
"version": "4.6.6",
"resolved": "https://registry.npmjs.org/node-sql-parser/-/node-sql-parser-4.6.6.tgz",
"integrity": "sha512-zpash5xnRY6+0C9HFru32iRJV1LTkwtrVpO90i385tYVF6efyXK/B3Nsq/15Fuv2utxrqHNjKtL55OHb8sl+eQ==",
"license": "GPLv2",
"dependencies": {
"big-integer": "^1.6.48"
},
"engines": {
"node": ">=8"
}
},
"node_modules/normalize-path": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/normalize-path/-/normalize-path-3.0.0.tgz",
"integrity": "sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/once": {
"version": "1.4.0",
"resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz",
"integrity": "sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==",
"dev": true,
"license": "ISC",
"dependencies": {
"wrappy": "1"
}
},
"node_modules/p-limit": {
"version": "3.1.0",
"resolved": "https://registry.npmjs.org/p-limit/-/p-limit-3.1.0.tgz",
"integrity": "sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"yocto-queue": "^0.1.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/p-locate": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/p-locate/-/p-locate-5.0.0.tgz",
"integrity": "sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==",
"dev": true,
"license": "MIT",
"dependencies": {
"p-limit": "^3.0.2"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/path-exists": {
"version": "4.0.0",
"resolved": "https://registry.npmjs.org/path-exists/-/path-exists-4.0.0.tgz",
"integrity": "sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
}
},
"node_modules/path-is-absolute": {
"version": "1.0.1",
"resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz",
"integrity": "sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/picomatch": {
"version": "2.3.1",
"resolved": "https://registry.npmjs.org/picomatch/-/picomatch-2.3.1.tgz",
"integrity": "sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8.6"
},
"funding": {
"url": "https://github.com/sponsors/jonschlinkert"
}
},
"node_modules/randombytes": {
"version": "2.1.0",
"resolved": "https://registry.npmjs.org/randombytes/-/randombytes-2.1.0.tgz",
"integrity": "sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"safe-buffer": "^5.1.0"
}
},
"node_modules/readdirp": {
"version": "3.6.0",
"resolved": "https://registry.npmjs.org/readdirp/-/readdirp-3.6.0.tgz",
"integrity": "sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==",
"dev": true,
"license": "MIT",
"dependencies": {
"picomatch": "^2.2.1"
},
"engines": {
"node": ">=8.10.0"
}
},
"node_modules/regenerator-runtime": {
"version": "0.13.11",
"resolved": "https://registry.npmjs.org/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz",
"integrity": "sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==",
"license": "MIT"
},
"node_modules/require-directory": {
"version": "2.1.1",
"resolved": "https://registry.npmjs.org/require-directory/-/require-directory-2.1.1.tgz",
"integrity": "sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/rpc-websockets": {
"version": "7.5.1",
"resolved": "https://registry.npmjs.org/rpc-websockets/-/rpc-websockets-7.5.1.tgz",
"integrity": "sha512-kGFkeTsmd37pHPMaHIgN1LVKXMi0JD782v4Ds9ZKtLlwdTKjn+CxM9A9/gLT2LaOuEcEFGL98h1QWQtlOIdW0w==",
"license": "LGPL-3.0-only",
"dependencies": {
"@babel/runtime": "^7.17.2",
"eventemitter3": "^4.0.7",
"uuid": "^8.3.2",
"ws": "^8.5.0"
},
"funding": {
"type": "paypal",
"url": "https://paypal.me/kozjak"
},
"optionalDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
}
},
"node_modules/rpc-websockets/node_modules/ws": {
"version": "8.13.0",
"resolved": "https://registry.npmjs.org/ws/-/ws-8.13.0.tgz",
"integrity": "sha512-x9vcZYTrFPC7aSIbj7sRCYo7L/Xb8Iy+pW0ng0wt2vCJv7M9HOMy0UoN3rr+IFC7hb7vXoqS+P9ktyLLLhO+LA==",
"license": "MIT",
"engines": {
"node": ">=10.0.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": ">=5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
},
"node_modules/safe-buffer": {
"version": "5.2.1",
"resolved": "https://registry.npmjs.org/safe-buffer/-/safe-buffer-5.2.1.tgz",
"integrity": "sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==",
"funding": [
{
"type": "github",
"url": "https://github.com/sponsors/feross"
},
{
"type": "patreon",
"url": "https://www.patreon.com/feross"
},
{
"type": "consulting",
"url": "https://feross.org/support"
}
],
"license": "MIT"
},
"node_modules/serialize-javascript": {
"version": "6.0.0",
"resolved": "https://registry.npmjs.org/serialize-javascript/-/serialize-javascript-6.0.0.tgz",
"integrity": "sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==",
"dev": true,
"license": "BSD-3-Clause",
"dependencies": {
"randombytes": "^2.1.0"
}
},
"node_modules/source-map": {
"version": "0.6.1",
"resolved": "https://registry.npmjs.org/source-map/-/source-map-0.6.1.tgz",
"integrity": "sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.10.0"
}
},
"node_modules/source-map-support": {
"version": "0.5.21",
"resolved": "https://registry.npmjs.org/source-map-support/-/source-map-support-0.5.21.tgz",
"integrity": "sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==",
"dev": true,
"license": "MIT",
"dependencies": {
"buffer-from": "^1.0.0",
"source-map": "^0.6.0"
}
},
"node_modules/string-width": {
"version": "4.2.3",
"resolved": "https://registry.npmjs.org/string-width/-/string-width-4.2.3.tgz",
"integrity": "sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==",
"dev": true,
"license": "MIT",
"dependencies": {
"emoji-regex": "^8.0.0",
"is-fullwidth-code-point": "^3.0.0",
"strip-ansi": "^6.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-ansi": {
"version": "6.0.1",
"resolved": "https://registry.npmjs.org/strip-ansi/-/strip-ansi-6.0.1.tgz",
"integrity": "sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-regex": "^5.0.1"
},
"engines": {
"node": ">=8"
}
},
"node_modules/strip-bom": {
"version": "3.0.0",
"resolved": "https://registry.npmjs.org/strip-bom/-/strip-bom-3.0.0.tgz",
"integrity": "sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==",
"dev": true,
"license": "MIT",
"optional": true,
"engines": {
"node": ">=4"
}
},
"node_modules/strip-json-comments": {
"version": "3.1.1",
"resolved": "https://registry.npmjs.org/strip-json-comments/-/strip-json-comments-3.1.1.tgz",
"integrity": "sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=8"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
},
"node_modules/superstruct": {
"version": "0.14.2",
"resolved": "https://registry.npmjs.org/superstruct/-/superstruct-0.14.2.tgz",
"integrity": "sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ==",
"license": "MIT"
},
"node_modules/supports-color": {
"version": "8.1.1",
"resolved": "https://registry.npmjs.org/supports-color/-/supports-color-8.1.1.tgz",
"integrity": "sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"has-flag": "^4.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/supports-color?sponsor=1"
}
},
"node_modules/text-encoding-utf-8": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz",
"integrity": "sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg=="
},
"node_modules/through": {
"version": "2.3.8",
"resolved": "https://registry.npmjs.org/through/-/through-2.3.8.tgz",
"integrity": "sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==",
"license": "MIT"
},
"node_modules/to-regex-range": {
"version": "5.0.1",
"resolved": "https://registry.npmjs.org/to-regex-range/-/to-regex-range-5.0.1.tgz",
"integrity": "sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==",
"dev": true,
"license": "MIT",
"dependencies": {
"is-number": "^7.0.0"
},
"engines": {
"node": ">=8.0"
}
},
"node_modules/tr46": {
"version": "0.0.3",
"resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
"integrity": "sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==",
"license": "MIT"
},
"node_modules/ts-mocha": {
"version": "10.0.0",
"resolved": "https://registry.npmjs.org/ts-mocha/-/ts-mocha-10.0.0.tgz",
"integrity": "sha512-VRfgDO+iiuJFlNB18tzOfypJ21xn2xbuZyDvJvqpTbWgkAgD17ONGr8t+Tl8rcBtOBdjXp5e/Rk+d39f7XBHRw==",
"dev": true,
"license": "MIT",
"dependencies": {
"ts-node": "7.0.1"
},
"bin": {
"ts-mocha": "bin/ts-mocha"
},
"engines": {
"node": ">= 6.X.X"
},
"optionalDependencies": {
"tsconfig-paths": "^3.5.0"
},
"peerDependencies": {
"mocha": "^3.X.X || ^4.X.X || ^5.X.X || ^6.X.X || ^7.X.X || ^8.X.X || ^9.X.X || ^10.X.X"
}
},
"node_modules/ts-node": {
"version": "7.0.1",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-7.0.1.tgz",
"integrity": "sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==",
"dev": true,
"license": "MIT",
"dependencies": {
"arrify": "^1.0.0",
"buffer-from": "^1.1.0",
"diff": "^3.1.0",
"make-error": "^1.1.1",
"minimist": "^1.2.0",
"mkdirp": "^0.5.1",
"source-map-support": "^0.5.6",
"yn": "^2.0.0"
},
"bin": {
"ts-node": "dist/bin.js"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/ts-node/node_modules/diff": {
"version": "3.5.0",
"resolved": "https://registry.npmjs.org/diff/-/diff-3.5.0.tgz",
"integrity": "sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==",
"dev": true,
"license": "BSD-3-Clause",
"engines": {
"node": ">=0.3.1"
}
},
"node_modules/tsconfig-paths": {
"version": "3.14.2",
"resolved": "https://registry.npmjs.org/tsconfig-paths/-/tsconfig-paths-3.14.2.tgz",
"integrity": "sha512-o/9iXgCYc5L/JxCHPe3Hvh8Q/2xm5Z+p18PESBU6Ff33695QnCHBEjcytY2q19ua7Mbl/DavtBOLq+oG0RCL+g==",
"dev": true,
"license": "MIT",
"optional": true,
"dependencies": {
"@types/json5": "^0.0.29",
"json5": "^1.0.2",
"minimist": "^1.2.6",
"strip-bom": "^3.0.0"
}
},
"node_modules/typescript": {
"version": "4.9.5",
"resolved": "https://registry.npmjs.org/typescript/-/typescript-4.9.5.tgz",
"integrity": "sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==",
"dev": true,
"license": "Apache-2.0",
"bin": {
"tsc": "bin/tsc",
"tsserver": "bin/tsserver"
},
"engines": {
"node": ">=4.2.0"
}
},
"node_modules/utf-8-validate": {
"version": "5.0.10",
"resolved": "https://registry.npmjs.org/utf-8-validate/-/utf-8-validate-5.0.10.tgz",
"integrity": "sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==",
"hasInstallScript": true,
"license": "MIT",
"optional": true,
"dependencies": {
"node-gyp-build": "^4.3.0"
},
"engines": {
"node": ">=6.14.2"
}
},
"node_modules/uuid": {
"version": "8.3.2",
"resolved": "https://registry.npmjs.org/uuid/-/uuid-8.3.2.tgz",
"integrity": "sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==",
"license": "MIT",
"bin": {
"uuid": "dist/bin/uuid"
}
},
"node_modules/webidl-conversions": {
"version": "3.0.1",
"resolved": "https://registry.npmjs.org/webidl-conversions/-/webidl-conversions-3.0.1.tgz",
"integrity": "sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==",
"license": "BSD-2-Clause"
},
"node_modules/whatwg-url": {
"version": "5.0.0",
"resolved": "https://registry.npmjs.org/whatwg-url/-/whatwg-url-5.0.0.tgz",
"integrity": "sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==",
"license": "MIT",
"dependencies": {
"tr46": "~0.0.3",
"webidl-conversions": "^3.0.0"
}
},
"node_modules/workerpool": {
"version": "6.2.1",
"resolved": "https://registry.npmjs.org/workerpool/-/workerpool-6.2.1.tgz",
"integrity": "sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==",
"dev": true,
"license": "Apache-2.0"
},
"node_modules/wrap-ansi": {
"version": "7.0.0",
"resolved": "https://registry.npmjs.org/wrap-ansi/-/wrap-ansi-7.0.0.tgz",
"integrity": "sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==",
"dev": true,
"license": "MIT",
"dependencies": {
"ansi-styles": "^4.0.0",
"string-width": "^4.1.0",
"strip-ansi": "^6.0.0"
},
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/chalk/wrap-ansi?sponsor=1"
}
},
"node_modules/wrappy": {
"version": "1.0.2",
"resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz",
"integrity": "sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==",
"dev": true,
"license": "ISC"
},
"node_modules/ws": {
"version": "7.5.9",
"resolved": "https://registry.npmjs.org/ws/-/ws-7.5.9.tgz",
"integrity": "sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==",
"license": "MIT",
"engines": {
"node": ">=8.3.0"
},
"peerDependencies": {
"bufferutil": "^4.0.1",
"utf-8-validate": "^5.0.2"
},
"peerDependenciesMeta": {
"bufferutil": {
"optional": true
},
"utf-8-validate": {
"optional": true
}
}
},
"node_modules/y18n": {
"version": "5.0.8",
"resolved": "https://registry.npmjs.org/y18n/-/y18n-5.0.8.tgz",
"integrity": "sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">=10"
}
},
"node_modules/yargs": {
"version": "16.2.0",
"resolved": "https://registry.npmjs.org/yargs/-/yargs-16.2.0.tgz",
"integrity": "sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==",
"dev": true,
"license": "MIT",
"dependencies": {
"cliui": "^7.0.2",
"escalade": "^3.1.1",
"get-caller-file": "^2.0.5",
"require-directory": "^2.1.1",
"string-width": "^4.2.0",
"y18n": "^5.0.5",
"yargs-parser": "^20.2.2"
},
"engines": {
"node": ">=10"
}
},
"node_modules/yargs-parser": {
"version": "20.2.4",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.4.tgz",
"integrity": "sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">=10"
}
},
"node_modules/yargs-unparser": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/yargs-unparser/-/yargs-unparser-2.0.0.tgz",
"integrity": "sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==",
"dev": true,
"license": "MIT",
"dependencies": {
"camelcase": "^6.0.0",
"decamelize": "^4.0.0",
"flat": "^5.0.2",
"is-plain-obj": "^2.1.0"
},
"engines": {
"node": ">=10"
}
},
"node_modules/yargs/node_modules/yargs-parser": {
"version": "20.2.9",
"resolved": "https://registry.npmjs.org/yargs-parser/-/yargs-parser-20.2.9.tgz",
"integrity": "sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==",
"dev": true,
"license": "ISC",
"engines": {
"node": ">=10"
}
},
"node_modules/yn": {
"version": "2.0.0",
"resolved": "https://registry.npmjs.org/yn/-/yn-2.0.0.tgz",
"integrity": "sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=4"
}
},
"node_modules/yocto-queue": {
"version": "0.1.0",
"resolved": "https://registry.npmjs.org/yocto-queue/-/yocto-queue-0.1.0.tgz",
"integrity": "sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==",
"dev": true,
"license": "MIT",
"engines": {
"node": ">=10"
},
"funding": {
"url": "https://github.com/sponsors/sindresorhus"
}
}
}
}
| 0
|
solana_public_repos/nautilus-project/nautilus
|
solana_public_repos/nautilus-project/nautilus/js/package.json
|
{
"name": "nautilus-js",
"version": "0.0.1",
"description": "SQL server for Solana",
"main": "index.js",
"repository": "https://github.com/realbuffalojoe/nautilus",
"author": "Joe Caulfield",
"license": "MIT",
"private": true,
"dependencies": {
"@solana/web3.js": "^1.73.2",
"node-sql-parser": "^4.6.5"
},
"devDependencies": {
"@types/chai": "^4.3.4",
"@types/mocha": "^10.0.1",
"@types/node-fetch": "^2.6.2",
"fs": "^0.0.1-security",
"mocha": "^10.1.0",
"ts-mocha": "^10.0.0",
"typescript": "^4.9.3"
},
"scripts": {
"test": "yarn run ts-mocha -p ./tests/tsconfig.test.json -t 1000000 ./tests/main.test.ts",
"build": "tsc"
}
}
| 0
|
solana_public_repos/nautilus-project/nautilus
|
solana_public_repos/nautilus-project/nautilus/js/tsconfig.json
|
{
"compilerOptions": {
"target": "es2021",
"module": "commonjs",
"esModuleInterop": true,
"forceConsistentCasingInFileNames": true,
"strict": true,
"outDir": "./dist",
},
"exclude": ["./tests"]
}
| 0
|
solana_public_repos/nautilus-project/nautilus/js
|
solana_public_repos/nautilus-project/nautilus/js/tests/instantiate.test.ts
|
import assert from "assert"
import { describe, it } from "mocha"
import { Nautilus } from "../src"
import { CONNECTION, PROGRAM_ID, PROGRAM_ID_STRING } from "./main.test"
export function tests() {
describe("[Unit Tests]: Instantiating", () => {
function canInstantiate(method: string, nautilus: Nautilus) {
it(` -- Can instantiate: ${method}`, () => assert(nautilus))
}
canInstantiate(
"string | no default program",
new Nautilus(CONNECTION, PROGRAM_ID_STRING),
)
canInstantiate(
"string | with default program",
new Nautilus(CONNECTION, PROGRAM_ID_STRING, PROGRAM_ID),
)
canInstantiate(
"pubkey | no default program",
new Nautilus(CONNECTION, PROGRAM_ID),
)
canInstantiate(
"pubkey | with default program",
new Nautilus(CONNECTION, PROGRAM_ID, PROGRAM_ID),
)
canInstantiate(
"single-list | no default program",
new Nautilus(CONNECTION, [[PROGRAM_ID, "person-program"]]),
)
canInstantiate(
"single-list | with default program | string arg",
new Nautilus(
CONNECTION,
[[PROGRAM_ID, "person-program"]],
"person-program",
),
)
canInstantiate(
"single-list | with default program | PublicKey arg",
new Nautilus(
CONNECTION,
[[PROGRAM_ID, "person-program"]],
PROGRAM_ID,
),
)
canInstantiate(
"multiple-list | no default program",
new Nautilus(
CONNECTION,
[
[PROGRAM_ID, "person-program"],
[PROGRAM_ID, "person-program-2"],
],
),
)
canInstantiate(
"multiple-list | with default program | string arg",
new Nautilus(
CONNECTION,
[
[PROGRAM_ID, "person-program"],
[PROGRAM_ID, "person-program-2"],
],
"person-program",
),
)
canInstantiate(
"multiple-list | with default program | PublicKey arg",
new Nautilus(
CONNECTION,
[
[PROGRAM_ID, "person-program"],
[PROGRAM_ID, "person-program-2"],
],
PROGRAM_ID,
),
)
})
}
| 0
|
solana_public_repos/nautilus-project/nautilus/js
|
solana_public_repos/nautilus-project/nautilus/js/tests/tsconfig.test.json
|
{
"compilerOptions": {
"types": ["mocha", "chai"],
"typeRoots": ["./node_modules/@types"],
"lib": ["es2021"],
"module": "commonjs",
"target": "es6",
"esModuleInterop": true
}
}
| 0
|
solana_public_repos/nautilus-project/nautilus/js
|
solana_public_repos/nautilus-project/nautilus/js/tests/sql-parse.test.ts
|
import assert from "assert"
import { describe, it } from "mocha"
import { Nautilus } from "../src"
import { CONNECTION, PROGRAM_ID } from "./main.test"
export function tests() {
describe("[Unit Tests]: SQL Parsing", () => {
const nautilus = new Nautilus(CONNECTION, PROGRAM_ID);
function testParseSql(input: string) {
it(` -- Can parse: ${input}`, () => assert(input = nautilus.sql(input).dumpSql()))
}
testParseSql(
"SELECT * FROM person"
)
testParseSql(
"SELECT id, name FROM person"
)
testParseSql(
"SELECT * FROM person WHERE name = 'Joe'"
)
testParseSql(
"SELECT (id, name) FROM person WHERE name = 'Joe'"
)
testParseSql(
"SELECT * FROM person WHERE id = 1 AND name = 'Joe'"
)
testParseSql(
"SELECT (id, name) FROM person WHERE id = 1 AND name = 'Joe'"
)
testParseSql(
"SELECT * FROM person WHERE id = 1 AND name = 'Joe' AND authority = 'Joe'"
)
testParseSql(
"SELECT (id, name) FROM person WHERE id = 1 AND name = 'Joe' AND authority = 'Joe'"
)
testParseSql(
"SELECT * FROM person ORDER BY name ASC"
)
testParseSql(
"SELECT (id, name) FROM person ORDER BY name ASC"
)
testParseSql(
"SELECT * FROM person WHERE name = 'Joe' ORDER BY name ASC"
)
testParseSql(
"SELECT (id, name) FROM person WHERE name = 'Joe' ORDER BY name ASC"
)
testParseSql(
"SELECT * FROM person WHERE id = 1 AND name = 'Joe' ORDER BY name ASC"
)
testParseSql(
"SELECT (id, name) FROM person WHERE id = 1 AND name = 'Joe' ORDER BY name ASC"
)
testParseSql(
"SELECT * FROM person ORDER BY id DESC, name ASC"
)
testParseSql(
"SELECT (id, name) FROM person ORDER BY id DESC, name ASC"
)
testParseSql(
"SELECT * FROM person WHERE name = 'Joe' ORDER BY id DESC, name ASC"
)
testParseSql(
"SELECT (id, name) FROM person WHERE name = 'Joe' ORDER BY id DESC, name ASC"
)
testParseSql(
"SELECT * FROM person WHERE id = 1 AND name = 'Joe' ORDER BY id DESC, name ASC"
)
testParseSql(
"SELECT (id, name) FROM person WHERE id = 1 AND name = 'Joe' ORDER BY id DESC, name ASC"
)
testParseSql(
"SELECT id, name FROM person; SELECT id, name from heroes"
)
testParseSql(
"INSERT INTO person VALUES ('Paul', 'none')"
)
testParseSql(
"INSERT INTO person (name, authority) VALUES ('Paul', 'none')"
)
testParseSql(
"INSERT INTO person VALUES ('Paul', 'none'), ('John', 'none')"
)
testParseSql(
"INSERT INTO person (name, authority) VALUES ('Paul', 'none'), ('John', 'none')"
)
// Can un-comment when autoincrement config comes from IDL
//
// testParseSql(
// "INSERT INTO person VALUES (3, 'Paul', 'none')"
// )
// testParseSql(
// "INSERT INTO person (id, name, authority) VALUES (3, 'Paul', 'none')"
// )
// testParseSql(
// "INSERT INTO person VALUES (3, 'Paul', 'none'), (4, 'John', 'none')"
// )
// testParseSql(
// "INSERT INTO person (id, name, authority) VALUES (3, 'Paul', 'none'), (4, 'John', 'none')"
// )
//
testParseSql(
"DELETE FROM person"
)
testParseSql(
"DELETE FROM person WHERE name = 'Joe'"
)
testParseSql(
"DELETE FROM person WHERE id = 1 AND name = 'Joe'"
)
testParseSql(
"UPDATE person SET name = 'Paul' WHERE id = 1"
)
testParseSql(
"UPDATE person SET name = 'Paul' WHERE name = 'Joe'"
)
testParseSql(
"UPDATE person SET name = 'Paul' WHERE id = 1 AND name = 'Joe'"
)
testParseSql(
"UPDATE person SET name = 'Paul', authority = 'none' WHERE id = 1"
)
testParseSql(
"UPDATE person SET name = 'Paul', authority = 'none' WHERE name = 'Joe'"
)
testParseSql(
"UPDATE person SET name = 'Paul', authority = 'none' WHERE id = 1 AND name = 'Joe'"
)
})
}
| 0
|
solana_public_repos/nautilus-project/nautilus/js
|
solana_public_repos/nautilus-project/nautilus/js/tests/main.test.ts
|
import { Connection, PublicKey } from "@solana/web3.js"
//
// Deploy test program before executing
//
export const CONNECTION = new Connection("http://localhost:8899", "confirmed")
export const PROGRAM_ID_STRING = "9kYnTzxTSTtKJjBBScH2m3SLBq8grogLhwMLZdcD2wG4"
export const PROGRAM_ID = new PublicKey("9kYnTzxTSTtKJjBBScH2m3SLBq8grogLhwMLZdcD2wG4")
function test(file: string) {
require(file).tests()
}
//
// Test Suite
//
test("./instantiate.test.ts")
test("./sql-parse.test.ts")
| 0
|
solana_public_repos/nautilus-project/nautilus/js
|
solana_public_repos/nautilus-project/nautilus/js/src/index.ts
|
//
//
// ----------------------------------------------------------------
// Nautilus
// ----------------------------------------------------------------
//
//
import {
Connection,
Keypair,
PublicKey,
} from '@solana/web3.js';
import {
NautilusQuery,
NautilusTable,
} from './sql';
import { NautilusUtils } from './util';
export class Nautilus {
connection: Connection;
programs: [PublicKey, string][];
defaultProgram: PublicKey | undefined;
payer: Keypair | undefined;
util: NautilusUtils = new NautilusUtils();
constructor(
connection: Connection,
programs: string | PublicKey | [PublicKey, string][],
defaultProgram?: string | PublicKey,
payer?: Keypair,
) {
this.connection = connection;
[this.programs, this.defaultProgram] = parseNautilusArgs(programs, defaultProgram)
this.payer = payer ?? undefined;
}
table(tableName: string): NautilusTable {
return new NautilusTable(
this,
tableName,
);
}
sql(query: string): NautilusQuery {
return new NautilusQuery(
this,
query,
)
}
}
function parseNautilusArgs(
argPrograms: string | PublicKey | [PublicKey, string][],
argDefaultProgram: string | PublicKey | undefined,
): [[PublicKey, string][], PublicKey | undefined] {
const checkForDefaultProgram = (found: boolean) => {
if (!found) throw Error(
"Instance error: Provided default program was not found in the provided programs list"
)
}
let programs: [PublicKey, string][]
let defaultProgram: PublicKey | undefined = undefined
if (typeof argPrograms == "string") {
programs = [[new PublicKey(argPrograms), "default"]]
if (!argDefaultProgram) defaultProgram = new PublicKey(argPrograms)
} else if (argPrograms instanceof PublicKey) {
programs = [[argPrograms, "default"]]
if (!argDefaultProgram) defaultProgram = argPrograms
} else {
programs = argPrograms
if (argDefaultProgram) {
if (argDefaultProgram instanceof PublicKey) {
checkForDefaultProgram(
argPrograms.filter(([publicKey, _]) =>
publicKey === argDefaultProgram).length != 0
)
} else {
checkForDefaultProgram(
argPrograms.filter(([publicKey, name]) =>
publicKey.toBase58() == argDefaultProgram || name === argDefaultProgram).length != 0
)
}
} else {
if (argPrograms.length === 1) defaultProgram = argPrograms[0][0]
}
}
return [programs, defaultProgram]
}
| 0
|
solana_public_repos/nautilus-project/nautilus/js/src
|
solana_public_repos/nautilus-project/nautilus/js/src/util/index.ts
|
import {
AccountInfo,
Connection,
GetProgramAccountsConfig,
GetProgramAccountsFilter,
PublicKey,
SendOptions,
Signer,
TransactionInstruction,
TransactionMessage,
VersionedTransaction,
} from '@solana/web3.js';
export class NautilusUtils {
// Get Program Accounts
static async getProgramAccounts(
connection: Connection,
programId: PublicKey,
config: GetProgramAccountsConfig,
returnFields?: string[]
): Promise<{
pubkey: PublicKey,
account: AccountInfo<any>
}[]> {
return connection.getProgramAccounts(
programId,
config,
)
}
// Nautilus Instruction Utils
// TODO: Create these filters based on the IDL and the passed tableName
static evaluateWhereFilter(
field: string,
operator: string,
matches: string,
): GetProgramAccountsFilter {
return {
memcmp: {
offset: 0,
bytes: 'string',
}
}
}
// TODO: Create these instructions based on the IDL and the passed tableName
static createCreateInstruction(programId: PublicKey, tableName: string, data: any): TransactionInstruction {
return {
programId,
keys: [{
pubkey: PublicKey.unique(), isSigner: true, isWritable: true
}],
data: Buffer.alloc(0),
}
}
// TODO: Create these instructions based on the IDL and the passed tableName
static createDeleteInstruction(programId: PublicKey, tableName: string, account: any): TransactionInstruction {
return {
programId,
keys: [{
pubkey: PublicKey.unique(), isSigner: true, isWritable: true
}],
data: Buffer.alloc(0),
}
}
// TODO: Create these instructions based on the IDL and the passed tableName
static createUpdateInstruction(programId: PublicKey, tableName: string, data: any): TransactionInstruction {
return {
programId,
keys: [{
pubkey: PublicKey.unique(), isSigner: true, isWritable: true
}],
data: Buffer.alloc(0),
}
}
// Solana Transaction Utils
static async buildTransaction(
connection: Connection,
instructionsList: TransactionInstruction[],
signers: Signer[],
payerKey: PublicKey,
): Promise<VersionedTransaction> {
const tx = new VersionedTransaction(
new TransactionMessage({
payerKey,
recentBlockhash: (
await connection
.getLatestBlockhash()
.then((res) => res.blockhash)
),
instructions: instructionsList,
}).compileToV0Message()
);
tx.sign(signers)
return tx
}
static async sendTransactionWithSigner(
connection: Connection,
instructions: TransactionInstruction[],
signers: Signer[],
feePayer: PublicKey,
sendOptions?: SendOptions,
): Promise<string> {
return connection.sendTransaction(
(await NautilusUtils.buildTransaction(
connection,
instructions,
signers,
feePayer,
)),
sendOptions,
)
}
}
| 0
|
solana_public_repos/nautilus-project/nautilus/js/src
|
solana_public_repos/nautilus-project/nautilus/js/src/sql/table.ts
|
import {
AccountInfo,
GetProgramAccountsConfig,
PublicKey,
SendOptions,
Signer,
TransactionInstruction,
} from '@solana/web3.js';
import { Nautilus } from '../';
import { NautilusUtils } from '../util';
enum FetchFirst {
Delete,
Update,
}
export class NautilusTable {
nautilus: Nautilus
programId: PublicKey | undefined
tableName: string
// Reads
getProgramAccountsConfig: GetProgramAccountsConfig
returnFields: string[] | undefined
orderByFunction: any | undefined
// Writes
fetchFirst: FetchFirst | undefined
updateData: any
instructions: TransactionInstruction[]
signersList: Signer[]
constructor(
nautilus: Nautilus,
tableName: string,
) {
this.nautilus = nautilus
if (nautilus.defaultProgram) this.programId = nautilus.defaultProgram
this.tableName = tableName
this.getProgramAccountsConfig = {
filters: [],
}
this.returnFields = undefined;
this.orderByFunction = undefined;
this.fetchFirst = undefined;
this.updateData = undefined;
this.instructions = []
this.signersList = []
}
// Reads
fields(returnFields: string[]) {
this.returnFields = returnFields
return this
}
orderBy(field: string, order: string | number) {
if (order === "ASC" || order === 1) {
this.orderByFunction = (list: any[]) => list.sort((a, b) => (a[field] > b[field]) ? 1 : -1)
} else if (order === "DESC" || order === -1) {
this.orderByFunction = (list: any[]) => list.sort((a, b) => (a[field] > b[field]) ? -1 : 1)
} else {
throw Error("Not a valid ordering statement. Can only use \"ASC\" and \"DESC\", or 1 and -1")
}
return this
}
// TODO: We can optimize this if the only "where" filter is the primary key
where(
field: string,
operator: string,
matches: string,
) {
this.getProgramAccountsConfig.filters?.push(
NautilusUtils.evaluateWhereFilter(field, operator, matches)
);
return this
}
async get(): Promise<{
pubkey: PublicKey,
account: AccountInfo<any>
}[]> {
if (!this.programId) return noProgramIdError()
return NautilusUtils.getProgramAccounts(
this.nautilus.connection,
this.programId,
this.getProgramAccountsConfig,
this.returnFields,
)
}
// Writes
create(data: any | any[]) {
if (this.programId) {
const programId = this.programId
if (Array.isArray(data)) {
data.forEach((d) => this.instructions.push(
NautilusUtils.createCreateInstruction(programId, this.tableName, d)
))
} else {
this.instructions.push(NautilusUtils.createCreateInstruction(programId, this.tableName, data))
}
} else {
return noProgramIdError()
}
return this
}
delete() {
this.fetchFirst = FetchFirst.Delete
return this
}
update(data: any) {
this.fetchFirst = FetchFirst.Update
this.updateData = data
return this
}
signers(signers: Signer[]) {
signers.forEach((s) => this.signersList.push(s))
return this
}
// TODO: Transaction size overflow
async execute(sendOptions?: SendOptions): Promise<string> {
if (this.programId) {
const programId = this.programId
const instructions = this.instructions
if (this.fetchFirst) {
(await this.get()).forEach((account) => this.fetchFirst == FetchFirst.Delete ?
instructions.push(NautilusUtils.createDeleteInstruction(programId, this.tableName, account))
:
instructions.push(NautilusUtils.createUpdateInstruction(programId, this.tableName, this.updateData))
)
}
return NautilusUtils.sendTransactionWithSigner(
this.nautilus.connection,
instructions,
this.signersList,
this.signersList[0].publicKey,
sendOptions,
)
} else {
return noProgramIdError()
}
}
}
const noProgramIdError = () => {
throw Error("A program ID was not provided in your Nautilus object")
}
| 0
|
solana_public_repos/nautilus-project/nautilus/js/src
|
solana_public_repos/nautilus-project/nautilus/js/src/sql/index.ts
|
export * from './query';
export * from './table';
| 0
|
solana_public_repos/nautilus-project/nautilus/js/src
|
solana_public_repos/nautilus-project/nautilus/js/src/sql/query.ts
|
import NodeSQLParser, { From } from 'node-sql-parser';
import {
AST,
Delete,
Dual,
Insert_Replace,
Select,
Update,
} from 'node-sql-parser';
import { Nautilus } from '..';
import { NautilusTable } from './table';
const SUPPORTED_ACTIONS = [
"select",
"insert",
"delete",
"update",
]
export class NautilusQuery {
nautilus: Nautilus;
nautilusTables: NautilusTable[] = [];
ast: AST | AST[];
constructor(
nautilus: Nautilus,
query: string,
) {
this.nautilus = nautilus
const parser = new NodeSQLParser.Parser()
const ast = parser.astify(query)
this.ast = ast
const addTable =(astObj: AST) => {
if (
astObj.type &&
SUPPORTED_ACTIONS.includes(astObj.type)
) {
if (astObj.type === "delete") this.nautilusTables.push(
buildDeleteOperation(nautilus, astObj)
)
if (astObj.type === "insert") this.nautilusTables.push(
buildInsertOperation(nautilus, astObj)
)
if (astObj.type === "select") this.nautilusTables.push(
buildSelectOperation(nautilus, astObj)
)
if (astObj.type === "update") this.nautilusTables.push(
buildUpdateOperation(nautilus, astObj)
)
} else {
unsupportedSqlError()
}
}
if (Array.isArray(ast)) {
ast.forEach((astObj) => addTable(astObj))
} else {
addTable(ast)
}
}
dumpSql(): string {
return new NodeSQLParser.Parser().sqlify(this.ast)
}
}
interface TableIdlConfig {
primaryKey: string,
autoincrement: boolean,
fields: string[],
fieldsWithoutPrimaryKey: string[],
}
// TODO: Get this information from the IDL
function getIdlConfigsForTable(tableName: string): TableIdlConfig {
const primaryKey = "id"
const autoincrement = true
const fields = ["id", "name", "authority"]
const fieldsWithoutPrimaryKey = fields.filter((f) => f != primaryKey)
return {
primaryKey,
autoincrement,
fields,
fieldsWithoutPrimaryKey,
}
}
function buildData(tableName: string, columns: string[] | null, values: any[][]): any[] {
const tableConfig = getIdlConfigsForTable(tableName)
const data: any[] = []
if (tableConfig.autoincrement && columns && columns.includes(tableConfig.primaryKey)) autoincrementBreachError()
for (const val of values) {
if (tableConfig.fields.length == val.length) autoincrementBreachError()
const entries: any[][] = []
val.forEach((v, i) => entries.push([tableConfig.fieldsWithoutPrimaryKey[i], v]))
data.push(Object.fromEntries(entries))
}
return data
}
// TODO: Does not support "OR" yet
function parseWhere(statement: any): [string, string, string][] {
const where: [string, string, string][] = []
if (statement.operator === "AND") {
where.concat(parseWhere(statement.left))
where.concat(parseWhere(statement.right))
}
else {
where.push([statement.left.column, statement.operator, statement.right.value])
}
return where
}
function buildDeleteOperation(nautilus: Nautilus, ast: Delete): NautilusTable {
if (ast.table && Array.isArray(ast.table)) {
const tableName = ast.table[0].table
const table = new NautilusTable(nautilus, tableName)
if (ast.where) parseWhere(ast.where).forEach((w) => table.where(w[0], w[1], w[2]))
return table.delete()
} else {
return sqlMissingError("source table")
}
}
function buildInsertOperation(nautilus: Nautilus, ast: Insert_Replace): NautilusTable {
if (ast.table && Array.isArray(ast.table)) {
const tableName = ast.table[0].table
const columns = ast.columns
const values: any[][] = ast.values.map((valueObj) => valueObj.value.map((v) => v.value))
const data = buildData(tableName, columns, values)
return new NautilusTable(nautilus, tableName).create(data)
} else {
return sqlMissingError("source table")
}
}
function buildSelectOperation(nautilus: Nautilus, ast: Select): NautilusTable {
if (ast.from && Array.isArray(ast.from)) {
const tableName = ast.from[0].table
const returnFields = ast.columns == "*" ?
undefined
:
ast.columns.map((c) => c.expr.column)
const table = new NautilusTable(nautilus, tableName)
if (returnFields) table.fields(returnFields)
if (ast.where) parseWhere(ast.where).forEach((w) => table.where(w[0], w[1], w[2]))
if (ast.orderby) ast.orderby.forEach((o) => table.orderBy(o.expr.column, o.type))
return table
} else {
return sqlMissingError("source table")
}
}
function buildUpdateOperation(nautilus: Nautilus, ast: Update): NautilusTable {
if (ast.table && Array.isArray(ast.table)) {
if (!(ast.table[0] as From)) unsupportedSqlError()
const tableName = (ast.table[0] as From).table
const table = new NautilusTable(nautilus, tableName)
if (ast.where) parseWhere(ast.where).forEach((w) => table.where(w[0], w[1], w[2]))
const tableConfig = getIdlConfigsForTable(tableName)
const data = Object.fromEntries(ast.set.map((s) => {
if (s.column == tableConfig.primaryKey) immutablePrimaryKeyError()
return [s.column, s.value.value]
}))
return table.update(data)
} else {
return sqlMissingError("source table")
}
}
const unsupportedSqlError = () => {
throw Error("SQL operation error: Operation not supported")
}
const sqlMissingError = (missing: string) => {
throw Error(`SQL operation error: SQL missing the following information: ${missing}`)
}
const autoincrementBreachError = () => {
throw Error("You cannot provide a value for the primary key if autoincrement is enabled")
}
const immutablePrimaryKeyError = () => {
throw Error("You cannot change a primary key with an UPDATE operation")
}
| 0
|
solana_public_repos/nautilus-project/nautilus
|
solana_public_repos/nautilus-project/nautilus/tests/yarn.lock
|
# THIS IS AN AUTOGENERATED FILE. DO NOT EDIT THIS FILE DIRECTLY.
# yarn lockfile v1
"@babel/runtime@^7.12.5", "@babel/runtime@^7.17.2":
version "7.20.13"
resolved "https://registry.yarnpkg.com/@babel/runtime/-/runtime-7.20.13.tgz#7055ab8a7cff2b8f6058bf6ae45ff84ad2aded4b"
integrity sha512-gt3PKXs0DBoL9xCvOIIZ2NEqAGZqHjAnmVbfQtB620V0uReIQutpel14KcneZuer7UioY8ALKZ7iocavvzTNFA==
dependencies:
regenerator-runtime "^0.13.11"
"@metaplex-foundation/beet-solana@^0.3.1":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet-solana/-/beet-solana-0.3.1.tgz#4b37cda5c7f32ffd2bdd8b3164edc05c6463ab35"
integrity sha512-tgyEl6dvtLln8XX81JyBvWjIiEcjTkUwZbrM5dIobTmoqMuGewSyk9CClno8qsMsFdB5T3jC91Rjeqmu/6xk2g==
dependencies:
"@metaplex-foundation/beet" ">=0.1.0"
"@solana/web3.js" "^1.56.2"
bs58 "^5.0.0"
debug "^4.3.4"
"@metaplex-foundation/beet-solana@^0.4.0":
version "0.4.0"
resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet-solana/-/beet-solana-0.4.0.tgz#52891e78674aaa54e0031f1bca5bfbc40de12e8d"
integrity sha512-B1L94N3ZGMo53b0uOSoznbuM5GBNJ8LwSeznxBxJ+OThvfHQ4B5oMUqb+0zdLRfkKGS7Q6tpHK9P+QK0j3w2cQ==
dependencies:
"@metaplex-foundation/beet" ">=0.1.0"
"@solana/web3.js" "^1.56.2"
bs58 "^5.0.0"
debug "^4.3.4"
"@metaplex-foundation/beet@>=0.1.0", "@metaplex-foundation/beet@^0.7.1":
version "0.7.1"
resolved "https://registry.yarnpkg.com/@metaplex-foundation/beet/-/beet-0.7.1.tgz#0975314211643f87b5f6f3e584fa31abcf4c612c"
integrity sha512-hNCEnS2WyCiYyko82rwuISsBY3KYpe828ubsd2ckeqZr7tl0WVLivGkoyA/qdiaaHEBGdGl71OpfWa2rqL3DiA==
dependencies:
ansicolors "^0.3.2"
bn.js "^5.2.0"
debug "^4.3.3"
"@metaplex-foundation/cusper@^0.0.2":
version "0.0.2"
resolved "https://registry.yarnpkg.com/@metaplex-foundation/cusper/-/cusper-0.0.2.tgz#dc2032a452d6c269e25f016aa4dd63600e2af975"
integrity sha512-S9RulC2fFCFOQraz61bij+5YCHhSO9llJegK8c8Y6731fSi6snUSQJdCUqYS8AIgR0TKbQvdvgSyIIdbDFZbBA==
"@metaplex-foundation/mpl-token-metadata@^2.9.1":
version "2.9.1"
resolved "https://registry.yarnpkg.com/@metaplex-foundation/mpl-token-metadata/-/mpl-token-metadata-2.9.1.tgz#79b548b60ac4065b438b78e28b0139751f16b186"
integrity sha512-QmeWBG7y2Uu9FyD1JiclPmJtkYA1sd/Vh9US9H9zTGNWnyogM60hqZ9yVcibvkO+aSsWd0ZJIsMXZlewXIx0IQ==
dependencies:
"@metaplex-foundation/beet" "^0.7.1"
"@metaplex-foundation/beet-solana" "^0.4.0"
"@metaplex-foundation/cusper" "^0.0.2"
"@solana/spl-token" "^0.3.6"
"@solana/web3.js" "^1.66.2"
bn.js "^5.2.0"
debug "^4.3.4"
"@metaplex-foundation/rustbin@^0.3.0":
version "0.3.1"
resolved "https://registry.yarnpkg.com/@metaplex-foundation/rustbin/-/rustbin-0.3.1.tgz#bbcd61e8699b73c0b062728c6f5e8d52e8145042"
integrity sha512-hWd2JPrnt2/nJzkBpZD3Y6ZfCUlJujv2K7qUfsxdS0jSwLrSrOvYwmNWFw6mc3lbULj6VP4WDyuy9W5/CHU/lQ==
dependencies:
debug "^4.3.3"
semver "^7.3.7"
text-table "^0.2.0"
toml "^3.0.0"
"@metaplex-foundation/solita@^0.19.4":
version "0.19.4"
resolved "https://registry.yarnpkg.com/@metaplex-foundation/solita/-/solita-0.19.4.tgz#d73fc3eea0424927c8cab2117177704bd8818681"
integrity sha512-5j7F2qKDc7Po6ye7fm/JsUcYMxPK5QkkGBJJfgY7dGhF5YQw8YPwqw95F7rSavuDrXOK9mhq/L8s+3ilvEk6CA==
dependencies:
"@metaplex-foundation/beet" "^0.7.1"
"@metaplex-foundation/beet-solana" "^0.3.1"
"@metaplex-foundation/rustbin" "^0.3.0"
"@solana/web3.js" "^1.56.2"
ansi-colors "^4.1.3"
camelcase "^6.2.1"
debug "^4.3.3"
js-sha256 "^0.9.0"
prettier "^2.5.1"
snake-case "^3.0.4"
spok "^1.4.3"
"@noble/ed25519@^1.7.0":
version "1.7.3"
resolved "https://registry.yarnpkg.com/@noble/ed25519/-/ed25519-1.7.3.tgz#57e1677bf6885354b466c38e2b620c62f45a7123"
integrity sha512-iR8GBkDt0Q3GyaVcIu7mSsVIqnFbkbRzGLWlvhwunacoLwt4J3swfKhfaM6rN6WY+TBGoYT1GtT1mIh2/jGbRQ==
"@noble/hashes@^1.1.2":
version "1.2.0"
resolved "https://registry.yarnpkg.com/@noble/hashes/-/hashes-1.2.0.tgz#a3150eeb09cc7ab207ebf6d7b9ad311a9bdbed12"
integrity sha512-FZfhjEDbT5GRswV3C6uvLPHMiVD6lQBmpoX5+eSiPaMTXte/IKqI5dykDxzZB/WBeK/CDuQRBWarPdi3FNY2zQ==
"@noble/secp256k1@^1.6.3":
version "1.7.1"
resolved "https://registry.yarnpkg.com/@noble/secp256k1/-/secp256k1-1.7.1.tgz#b251c70f824ce3ca7f8dc3df08d58f005cc0507c"
integrity sha512-hOUk6AyBFmqVrv7k5WAw/LpszxVbj9gGN4JRkIX52fdFAj1UA61KXmZDvqVEm+pOyec3+fIeZB02LYa/pWOArw==
"@solana/buffer-layout-utils@^0.2.0":
version "0.2.0"
resolved "https://registry.yarnpkg.com/@solana/buffer-layout-utils/-/buffer-layout-utils-0.2.0.tgz#b45a6cab3293a2eb7597cceb474f229889d875ca"
integrity sha512-szG4sxgJGktbuZYDg2FfNmkMi0DYQoVjN2h7ta1W1hPrwzarcFLBq9UpX1UjNXsNpT9dn+chgprtWGioUAr4/g==
dependencies:
"@solana/buffer-layout" "^4.0.0"
"@solana/web3.js" "^1.32.0"
bigint-buffer "^1.1.5"
bignumber.js "^9.0.1"
"@solana/buffer-layout@^4.0.0":
version "4.0.1"
resolved "https://registry.yarnpkg.com/@solana/buffer-layout/-/buffer-layout-4.0.1.tgz#b996235eaec15b1e0b5092a8ed6028df77fa6c15"
integrity sha512-E1ImOIAD1tBZFRdjeM4/pzTiTApC0AOBGwyAMS4fwIodCWArzJ3DWdoh8cKxeFM2fElkxBh2Aqts1BPC373rHA==
dependencies:
buffer "~6.0.3"
"@solana/spl-token@^0.3.6", "@solana/spl-token@^0.3.7":
version "0.3.7"
resolved "https://registry.yarnpkg.com/@solana/spl-token/-/spl-token-0.3.7.tgz#6f027f9ad8e841f792c32e50920d9d2e714fc8da"
integrity sha512-bKGxWTtIw6VDdCBngjtsGlKGLSmiu/8ghSt/IOYJV24BsymRbgq7r12GToeetpxmPaZYLddKwAz7+EwprLfkfg==
dependencies:
"@solana/buffer-layout" "^4.0.0"
"@solana/buffer-layout-utils" "^0.2.0"
buffer "^6.0.3"
"@solana/web3.js@^1.32.0", "@solana/web3.js@^1.66.2":
version "1.74.0"
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.74.0.tgz#dbcbeabb830dd7cbbcf5e31404ca79c9785cbf2d"
integrity sha512-RKZyPqizPCxmpMGfpu4fuplNZEWCrhRBjjVstv5QnAJvgln1jgOfgui+rjl1ExnqDnWKg9uaZ5jtGROH/cwabg==
dependencies:
"@babel/runtime" "^7.12.5"
"@noble/ed25519" "^1.7.0"
"@noble/hashes" "^1.1.2"
"@noble/secp256k1" "^1.6.3"
"@solana/buffer-layout" "^4.0.0"
agentkeepalive "^4.2.1"
bigint-buffer "^1.1.5"
bn.js "^5.0.0"
borsh "^0.7.0"
bs58 "^4.0.1"
buffer "6.0.1"
fast-stable-stringify "^1.0.0"
jayson "^3.4.4"
node-fetch "^2.6.7"
rpc-websockets "^7.5.1"
superstruct "^0.14.2"
"@solana/web3.js@^1.56.2", "@solana/web3.js@^1.73.2":
version "1.73.3"
resolved "https://registry.yarnpkg.com/@solana/web3.js/-/web3.js-1.73.3.tgz#60e6bd68f6f364d4be360b1e0a03a0a68468a029"
integrity sha512-vHRMo589XEIpoujpE2sZZ1aMZvfA1ImKfNxobzEFyMb+H5j6mRRUXfdgWD0qJ0sm11e5BcBC7HPeRXJB+7f3Lg==
dependencies:
"@babel/runtime" "^7.12.5"
"@noble/ed25519" "^1.7.0"
"@noble/hashes" "^1.1.2"
"@noble/secp256k1" "^1.6.3"
"@solana/buffer-layout" "^4.0.0"
agentkeepalive "^4.2.1"
bigint-buffer "^1.1.5"
bn.js "^5.0.0"
borsh "^0.7.0"
bs58 "^4.0.1"
buffer "6.0.1"
fast-stable-stringify "^1.0.0"
jayson "^3.4.4"
node-fetch "^2.6.7"
rpc-websockets "^7.5.1"
superstruct "^0.14.2"
"@types/chai@^4.3.4":
version "4.3.4"
resolved "https://registry.yarnpkg.com/@types/chai/-/chai-4.3.4.tgz#e913e8175db8307d78b4e8fa690408ba6b65dee4"
integrity sha512-KnRanxnpfpjUTqTCXslZSEdLfXExwgNxYPdiO2WGUj8+HDjFi8R3k5RVKPeSCzLjCcshCAtVO2QBbVuAV4kTnw==
"@types/connect@^3.4.33":
version "3.4.35"
resolved "https://registry.yarnpkg.com/@types/connect/-/connect-3.4.35.tgz#5fcf6ae445e4021d1fc2219a4873cc73a3bb2ad1"
integrity sha512-cdeYyv4KWoEgpBISTxWvqYsVy444DOqehiF3fM3ne10AmJ62RSyNkUnxMJXHQWRQQX2eR94m5y1IZyDwBjV9FQ==
dependencies:
"@types/node" "*"
"@types/json5@^0.0.29":
version "0.0.29"
resolved "https://registry.yarnpkg.com/@types/json5/-/json5-0.0.29.tgz#ee28707ae94e11d2b827bcbe5270bcea7f3e71ee"
integrity sha512-dRLjCWHYg4oaA77cxO64oO+7JwCwnIzkZPdrrC71jQmQtlhM556pwKo5bUzqvZndkVbeFLIIi+9TC40JNF5hNQ==
"@types/mocha@^10.0.1":
version "10.0.1"
resolved "https://registry.yarnpkg.com/@types/mocha/-/mocha-10.0.1.tgz#2f4f65bb08bc368ac39c96da7b2f09140b26851b"
integrity sha512-/fvYntiO1GeICvqbQ3doGDIP97vWmvFt83GKguJ6prmQM2iXZfFcq6YE8KteFyRtX2/h5Hf91BYvPodJKFYv5Q==
"@types/node@*":
version "18.13.0"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.13.0.tgz#0400d1e6ce87e9d3032c19eb6c58205b0d3f7850"
integrity sha512-gC3TazRzGoOnoKAhUx+Q0t8S9Tzs74z7m0ipwGpSqQrleP14hKxP4/JUeEQcD3W1/aIpnWl8pHowI7WokuZpXg==
"@types/node@^12.12.54":
version "12.20.55"
resolved "https://registry.yarnpkg.com/@types/node/-/node-12.20.55.tgz#c329cbd434c42164f846b909bd6f85b5537f6240"
integrity sha512-J8xLz7q2OFulZ2cyGTLE1TbbZcjpno7FaN6zdJNrgAdrJ+DZzh/uFR6YrTb4C+nXakvud8Q4+rbhoIWlYQbUFQ==
"@types/node@^18.14.2":
version "18.14.2"
resolved "https://registry.yarnpkg.com/@types/node/-/node-18.14.2.tgz#c076ed1d7b6095078ad3cf21dfeea951842778b1"
integrity sha512-1uEQxww3DaghA0RxqHx0O0ppVlo43pJhepY51OxuQIKHpjbnYLA7vcdwioNPzIqmC2u3I/dmylcqjlh0e7AyUA==
"@types/ws@^7.4.4":
version "7.4.7"
resolved "https://registry.yarnpkg.com/@types/ws/-/ws-7.4.7.tgz#f7c390a36f7a0679aa69de2d501319f4f8d9b702"
integrity sha512-JQbbmxZTZehdc2iszGKs5oC3NFnjeay7mtAWrdt7qNtAVK0g19muApzAy4bm9byz79xa2ZnO/BOBC2R8RC5Lww==
dependencies:
"@types/node" "*"
JSONStream@^1.3.5:
version "1.3.5"
resolved "https://registry.yarnpkg.com/JSONStream/-/JSONStream-1.3.5.tgz#3208c1f08d3a4d99261ab64f92302bc15e111ca0"
integrity sha512-E+iruNOY8VV9s4JEbe1aNEm6MiszPRr/UfcHMz0TQh1BXSxHK+ASV1R6W4HpjBhSeS+54PIsAMCBmwD06LLsqQ==
dependencies:
jsonparse "^1.2.0"
through ">=2.2.7 <3"
agentkeepalive@^4.2.1:
version "4.2.1"
resolved "https://registry.yarnpkg.com/agentkeepalive/-/agentkeepalive-4.2.1.tgz#a7975cbb9f83b367f06c90cc51ff28fe7d499717"
integrity sha512-Zn4cw2NEqd+9fiSVWMscnjyQ1a8Yfoc5oBajLeo5w+YBHgDUcEBY2hS4YpTz6iN5f/2zQiktcuM6tS8x1p9dpA==
dependencies:
debug "^4.1.0"
depd "^1.1.2"
humanize-ms "^1.2.1"
ansi-colors@4.1.1:
version "4.1.1"
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.1.tgz#cbb9ae256bf750af1eab344f229aa27fe94ba348"
integrity sha512-JoX0apGbHaUJBNl6yF+p6JAFYZ666/hhCGKN5t9QFjbJQKUU/g8MNbFDbvfrgKXvI1QpZplPOnwIo99lX/AAmA==
ansi-colors@^4.1.3:
version "4.1.3"
resolved "https://registry.yarnpkg.com/ansi-colors/-/ansi-colors-4.1.3.tgz#37611340eb2243e70cc604cad35d63270d48781b"
integrity sha512-/6w/C21Pm1A7aZitlI5Ni/2J6FFQN8i1Cvz3kHABAAbw93v/NlvKdVOqz7CCWz/3iv/JplRSEEZ83XION15ovw==
ansi-regex@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/ansi-regex/-/ansi-regex-5.0.1.tgz#082cb2c89c9fe8659a311a53bd6a4dc5301db304"
integrity sha512-quJQXlTSUGL2LH9SUXo8VwsY4soanhgo6LNSm84E1LBcE8s3O0wpdiRzyR9z/ZZJMlMWv37qOOb9pdJlMUEKFQ==
ansi-styles@^4.0.0, ansi-styles@^4.1.0:
version "4.3.0"
resolved "https://registry.yarnpkg.com/ansi-styles/-/ansi-styles-4.3.0.tgz#edd803628ae71c04c85ae7a0906edad34b648937"
integrity sha512-zbB9rCJAT1rbjiVDb2hqKFHNYLxgtk8NURxZ3IZwD3F6NtxbXZQCnnSi1Lkx+IDohdPlFp222wVALIheZJQSEg==
dependencies:
color-convert "^2.0.1"
ansicolors@^0.3.2, ansicolors@~0.3.2:
version "0.3.2"
resolved "https://registry.yarnpkg.com/ansicolors/-/ansicolors-0.3.2.tgz#665597de86a9ffe3aa9bfbe6cae5c6ea426b4979"
integrity sha512-QXu7BPrP29VllRxH8GwB7x5iX5qWKAAMLqKQGWTeLWVlNHNOpVMJ91dsxQAIWXpjuW5wqvxu3Jd/nRjrJ+0pqg==
anymatch@~3.1.2:
version "3.1.3"
resolved "https://registry.yarnpkg.com/anymatch/-/anymatch-3.1.3.tgz#790c58b19ba1720a84205b57c618d5ad8524973e"
integrity sha512-KMReFUr0B4t+D+OBkjR3KYqvocp2XaSzO55UcB6mgQMd3KbcE+mWTyvVV7D/zsdEbNnV6acZUutkiHQXvTr1Rw==
dependencies:
normalize-path "^3.0.0"
picomatch "^2.0.4"
argparse@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/argparse/-/argparse-2.0.1.tgz#246f50f3ca78a3240f6c997e8a9bd1eac49e4b38"
integrity sha512-8+9WqebbFzpX9OR+Wa6O29asIogeRMzcGtAINdpMHHyAg10f05aSFVBbcEqGf/PXw1EjAZ+q2/bEBg3DvurK3Q==
arrify@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/arrify/-/arrify-1.0.1.tgz#898508da2226f380df904728456849c1501a4b0d"
integrity sha512-3CYzex9M9FGQjCGMGyi6/31c8GJbgb0qGyrx5HWxPd0aCwh4cB2YjMb2Xf9UuoogrMrlO9cTqnB5rI5GHZTcUA==
assertion-error@^1.1.0:
version "1.1.0"
resolved "https://registry.yarnpkg.com/assertion-error/-/assertion-error-1.1.0.tgz#e60b6b0e8f301bd97e5375215bda406c85118c0b"
integrity sha512-jgsaNduz+ndvGyFt3uSuWqvy4lCnIJiovtouQN5JZHOKCS2QuhEdbcQHFhVksz2N2U9hXJo8odG7ETyWlEeuDw==
balanced-match@^1.0.0:
version "1.0.2"
resolved "https://registry.yarnpkg.com/balanced-match/-/balanced-match-1.0.2.tgz#e83e3a7e3f300b34cb9d87f615fa0cbf357690ee"
integrity sha512-3oSeUO0TMV67hN1AmbXsK4yaqU7tjiHlbxRDZOpH0KW9+CeX4bRAaX0Anxt0tx2MrpRpWwQaPwIlISEJhYU5Pw==
base-x@^3.0.2:
version "3.0.9"
resolved "https://registry.yarnpkg.com/base-x/-/base-x-3.0.9.tgz#6349aaabb58526332de9f60995e548a53fe21320"
integrity sha512-H7JU6iBHTal1gp56aKoaa//YUxEaAOUiydvrV/pILqIHXTtqxSkATOnDA2u+jZ/61sD+L/412+7kzXRtWukhpQ==
dependencies:
safe-buffer "^5.0.1"
base-x@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/base-x/-/base-x-4.0.0.tgz#d0e3b7753450c73f8ad2389b5c018a4af7b2224a"
integrity sha512-FuwxlW4H5kh37X/oW59pwTzzTKRzfrrQwhmyspRM7swOEZcHtDZSCt45U6oKgtuFE+WYPblePMVIPR4RZrh/hw==
base64-js@^1.3.1:
version "1.5.1"
resolved "https://registry.yarnpkg.com/base64-js/-/base64-js-1.5.1.tgz#1b1b440160a5bf7ad40b650f095963481903930a"
integrity sha512-AKpaYlHn8t4SVbOHCy+b5+KKgvR4vrsD8vbvrbiQJps7fKDTkjkDry6ji0rUJjC0kzbNePLwzxq8iypo41qeWA==
bigint-buffer@^1.1.5:
version "1.1.5"
resolved "https://registry.yarnpkg.com/bigint-buffer/-/bigint-buffer-1.1.5.tgz#d038f31c8e4534c1f8d0015209bf34b4fa6dd442"
integrity sha512-trfYco6AoZ+rKhKnxA0hgX0HAbVP/s808/EuDSe2JDzUnCp/xAsli35Orvk67UrTEcwuxZqYZDmfA2RXJgxVvA==
dependencies:
bindings "^1.3.0"
bignumber.js@^9.0.1:
version "9.1.1"
resolved "https://registry.yarnpkg.com/bignumber.js/-/bignumber.js-9.1.1.tgz#c4df7dc496bd849d4c9464344c1aa74228b4dac6"
integrity sha512-pHm4LsMJ6lzgNGVfZHjMoO8sdoRhOzOH4MLmY65Jg70bpxCKu5iOHNJyfF6OyvYw7t8Fpf35RuzUyqnQsj8Vig==
binary-extensions@^2.0.0:
version "2.2.0"
resolved "https://registry.yarnpkg.com/binary-extensions/-/binary-extensions-2.2.0.tgz#75f502eeaf9ffde42fc98829645be4ea76bd9e2d"
integrity sha512-jDctJ/IVQbZoJykoeHbhXpOlNBqGNcwXJKJog42E5HDPUwQTSdjCHdihjj0DlnheQ7blbT6dHOafNAiS8ooQKA==
bindings@^1.3.0:
version "1.5.0"
resolved "https://registry.yarnpkg.com/bindings/-/bindings-1.5.0.tgz#10353c9e945334bc0511a6d90b38fbc7c9c504df"
integrity sha512-p2q/t/mhvuOj/UeLlV6566GD/guowlr0hHxClI0W9m7MWYkL1F0hLo+0Aexs9HSPCtR1SXQ0TD3MMKrXZajbiQ==
dependencies:
file-uri-to-path "1.0.0"
bn.js@^5.0.0, bn.js@^5.2.0:
version "5.2.1"
resolved "https://registry.yarnpkg.com/bn.js/-/bn.js-5.2.1.tgz#0bc527a6a0d18d0aa8d5b0538ce4a77dccfa7b70"
integrity sha512-eXRvHzWyYPBuB4NBy0cmYQjGitUrtqwbvlzP3G6VFnNRbsZQIxQ10PbKKHt8gZ/HW/D/747aDl+QkDqg3KQLMQ==
borsh@^0.7.0:
version "0.7.0"
resolved "https://registry.yarnpkg.com/borsh/-/borsh-0.7.0.tgz#6e9560d719d86d90dc589bca60ffc8a6c51fec2a"
integrity sha512-CLCsZGIBCFnPtkNnieW/a8wmreDmfUtjU2m9yHrzPXIlNbqVs0AQrSatSG6vdNYUqdc83tkQi2eHfF98ubzQLA==
dependencies:
bn.js "^5.2.0"
bs58 "^4.0.0"
text-encoding-utf-8 "^1.0.2"
brace-expansion@^1.1.7:
version "1.1.11"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
integrity sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==
dependencies:
balanced-match "^1.0.0"
concat-map "0.0.1"
brace-expansion@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/brace-expansion/-/brace-expansion-2.0.1.tgz#1edc459e0f0c548486ecf9fc99f2221364b9a0ae"
integrity sha512-XnAIvQ8eM+kC6aULx6wuQiwVsnzsi9d3WxzV3FpWTGA19F621kwdbsAcFKXgKUHZWsy+mY6iL1sHTxWEFCytDA==
dependencies:
balanced-match "^1.0.0"
braces@~3.0.2:
version "3.0.2"
resolved "https://registry.yarnpkg.com/braces/-/braces-3.0.2.tgz#3454e1a462ee8d599e236df336cd9ea4f8afe107"
integrity sha512-b8um+L1RzM3WDSzvhm6gIz1yfTbBt6YTlcEKAvsmqCZZFw46z626lVj9j1yEPW33H5H+lBQpZMP1k8l+78Ha0A==
dependencies:
fill-range "^7.0.1"
browser-stdout@1.3.1:
version "1.3.1"
resolved "https://registry.yarnpkg.com/browser-stdout/-/browser-stdout-1.3.1.tgz#baa559ee14ced73452229bad7326467c61fabd60"
integrity sha512-qhAVI1+Av2X7qelOfAIYwXONood6XlZE/fXaBSmW/T5SzLAmCgzi+eiWE7fUvbHaeNBQH13UftjpXxsfLkMpgw==
bs58@^4.0.0, bs58@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/bs58/-/bs58-4.0.1.tgz#be161e76c354f6f788ae4071f63f34e8c4f0a42a"
integrity sha512-Ok3Wdf5vOIlBrgCvTq96gBkJw+JUEzdBgyaza5HLtPm7yTHkjRy8+JzNyHF7BHa0bNWOQIp3m5YF0nnFcOIKLw==
dependencies:
base-x "^3.0.2"
bs58@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/bs58/-/bs58-5.0.0.tgz#865575b4d13c09ea2a84622df6c8cbeb54ffc279"
integrity sha512-r+ihvQJvahgYT50JD05dyJNKlmmSlMoOGwn1lCcEzanPglg7TxYjioQUYehQ9mAR/+hOSd2jRc/Z2y5UxBymvQ==
dependencies:
base-x "^4.0.0"
buffer-from@^1.0.0, buffer-from@^1.1.0:
version "1.1.2"
resolved "https://registry.yarnpkg.com/buffer-from/-/buffer-from-1.1.2.tgz#2b146a6fd72e80b4f55d255f35ed59a3a9a41bd5"
integrity sha512-E+XQCRwSbaaiChtv6k6Dwgc+bx+Bs6vuKJHHl5kox/BaKbhiXzqQOwK4cO22yElGp2OCmjwVhT3HmxgyPGnJfQ==
buffer@6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.1.tgz#3cbea8c1463e5a0779e30b66d4c88c6ffa182ac2"
integrity sha512-rVAXBwEcEoYtxnHSO5iWyhzV/O1WMtkUYWlfdLS7FjU4PnSJJHEfHXi/uHPI5EwltmOA794gN3bm3/pzuctWjQ==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.2.1"
buffer@^6.0.3, buffer@~6.0.3:
version "6.0.3"
resolved "https://registry.yarnpkg.com/buffer/-/buffer-6.0.3.tgz#2ace578459cc8fbe2a70aaa8f52ee63b6a74c6c6"
integrity sha512-FTiCpNxtwiZZHEZbcbTIcZjERVICn9yq/pDFkTl95/AxzD1naBctN7YO68riM/gLSDY7sdrMby8hofADYuuqOA==
dependencies:
base64-js "^1.3.1"
ieee754 "^1.2.1"
bufferutil@^4.0.1:
version "4.0.7"
resolved "https://registry.yarnpkg.com/bufferutil/-/bufferutil-4.0.7.tgz#60c0d19ba2c992dd8273d3f73772ffc894c153ad"
integrity sha512-kukuqc39WOHtdxtw4UScxF/WVnMFVSQVKhtx3AjZJzhd0RGZZldcrfSEbVsWWe6KNH253574cq5F+wpv0G9pJw==
dependencies:
node-gyp-build "^4.3.0"
camelcase@^6.0.0, camelcase@^6.2.1:
version "6.3.0"
resolved "https://registry.yarnpkg.com/camelcase/-/camelcase-6.3.0.tgz#5685b95eb209ac9c0c177467778c9c84df58ba9a"
integrity sha512-Gmy6FhYlCY7uOElZUSbxo2UCDH8owEk996gkbrpsgGtrJLM3J7jGxl9Ic7Qwwj4ivOE5AWZWRMecDdF7hqGjFA==
chai@^4.3.7:
version "4.3.7"
resolved "https://registry.yarnpkg.com/chai/-/chai-4.3.7.tgz#ec63f6df01829088e8bf55fca839bcd464a8ec51"
integrity sha512-HLnAzZ2iupm25PlN0xFreAlBA5zaBSv3og0DdeGA4Ar6h6rJ3A0rolRUKJhSF2V10GZKDgWF/VmAEsNWjCRB+A==
dependencies:
assertion-error "^1.1.0"
check-error "^1.0.2"
deep-eql "^4.1.2"
get-func-name "^2.0.0"
loupe "^2.3.1"
pathval "^1.1.1"
type-detect "^4.0.5"
chalk@^4.1.0:
version "4.1.2"
resolved "https://registry.yarnpkg.com/chalk/-/chalk-4.1.2.tgz#aac4e2b7734a740867aeb16bf02aad556a1e7a01"
integrity sha512-oKnbhFyRIXpUuez8iBMmyEa4nbj4IOQyuhc/wy9kY7/WVPcwIO9VA668Pu8RkO7+0G76SLROeyw9CpQ061i4mA==
dependencies:
ansi-styles "^4.1.0"
supports-color "^7.1.0"
check-error@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/check-error/-/check-error-1.0.2.tgz#574d312edd88bb5dd8912e9286dd6c0aed4aac82"
integrity sha512-BrgHpW9NURQgzoNyjfq0Wu6VFO6D7IZEmJNdtgNqpzGG8RuNFHt2jQxWlAs4HMe119chBnv+34syEZtc6IhLtA==
chokidar@3.5.3:
version "3.5.3"
resolved "https://registry.yarnpkg.com/chokidar/-/chokidar-3.5.3.tgz#1cf37c8707b932bd1af1ae22c0432e2acd1903bd"
integrity sha512-Dr3sfKRP6oTcjf2JmUmFJfeVMvXBdegxB0iVQ5eb2V10uFJUCAS8OByZdVAyVb8xXNz3GjjTgj9kLWsZTqE6kw==
dependencies:
anymatch "~3.1.2"
braces "~3.0.2"
glob-parent "~5.1.2"
is-binary-path "~2.1.0"
is-glob "~4.0.1"
normalize-path "~3.0.0"
readdirp "~3.6.0"
optionalDependencies:
fsevents "~2.3.2"
cliui@^7.0.2:
version "7.0.4"
resolved "https://registry.yarnpkg.com/cliui/-/cliui-7.0.4.tgz#a0265ee655476fc807aea9df3df8df7783808b4f"
integrity sha512-OcRE68cOsVMXp1Yvonl/fzkQOyjLSu/8bhPDfQt0e0/Eb283TKP20Fs2MqoPsr9SwA595rRCA+QMzYc9nBP+JQ==
dependencies:
string-width "^4.2.0"
strip-ansi "^6.0.0"
wrap-ansi "^7.0.0"
color-convert@^2.0.1:
version "2.0.1"
resolved "https://registry.yarnpkg.com/color-convert/-/color-convert-2.0.1.tgz#72d3a68d598c9bdb3af2ad1e84f21d896abd4de3"
integrity sha512-RRECPsj7iu/xb5oKYcsFHSppFNnsj/52OVTRKb4zP5onXwVF3zVmmToNcOfGC+CRDpfK/U584fMg38ZHCaElKQ==
dependencies:
color-name "~1.1.4"
color-name@~1.1.4:
version "1.1.4"
resolved "https://registry.yarnpkg.com/color-name/-/color-name-1.1.4.tgz#c2a09a87acbde69543de6f63fa3995c826c536a2"
integrity sha512-dOy+3AuW3a2wNbZHIuMZpTcgjGuLU/uBL/ubcZF9OXbDo8ff4O8yVp5Bf0efS8uEoYo5q4Fx7dY9OgQGXgAsQA==
commander@^2.20.3:
version "2.20.3"
resolved "https://registry.yarnpkg.com/commander/-/commander-2.20.3.tgz#fd485e84c03eb4881c20722ba48035e8531aeb33"
integrity sha512-GpVkmM8vF2vQUkj2LvZmD35JxeJOLCwJ9cUkugyk2nuhbv3+mJvpLYYt+0+USMxE+oj+ey/lJEnhZw75x/OMcQ==
concat-map@0.0.1:
version "0.0.1"
resolved "https://registry.yarnpkg.com/concat-map/-/concat-map-0.0.1.tgz#d8a96bd77fd68df7793a73036a3ba0d5405d477b"
integrity sha512-/Srv4dswyQNBfohGpz9o6Yb3Gz3SrUDqBH5rTuhGR7ahtlbYKnVxw2bCFMRljaA7EXHaXZ8wsHdodFvbkhKmqg==
debug@4.3.4, debug@^4.1.0, debug@^4.3.3, debug@^4.3.4:
version "4.3.4"
resolved "https://registry.yarnpkg.com/debug/-/debug-4.3.4.tgz#1319f6579357f2338d3337d2cdd4914bb5dcc865"
integrity sha512-PRWFHuSU3eDtQJPvnNY7Jcket1j0t5OuOsFzPPzsekD52Zl8qUfFIPEiswXqIvHWGVHOgX+7G/vCNNhehwxfkQ==
dependencies:
ms "2.1.2"
decamelize@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/decamelize/-/decamelize-4.0.0.tgz#aa472d7bf660eb15f3494efd531cab7f2a709837"
integrity sha512-9iE1PgSik9HeIIw2JO94IidnE3eBoQrFJ3w7sFuzSX4DpmZ3v5sZpUiV5Swcf6mQEF+Y0ru8Neo+p+nyh2J+hQ==
deep-eql@^4.1.2:
version "4.1.3"
resolved "https://registry.yarnpkg.com/deep-eql/-/deep-eql-4.1.3.tgz#7c7775513092f7df98d8df9996dd085eb668cc6d"
integrity sha512-WaEtAOpRA1MQ0eohqZjpGD8zdI0Ovsm8mmFhaDN8dvDZzyoUMcYDnf5Y6iu7HTXxf8JDS23qWa4a+hKCDyOPzw==
dependencies:
type-detect "^4.0.0"
delay@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/delay/-/delay-5.0.0.tgz#137045ef1b96e5071060dd5be60bf9334436bd1d"
integrity sha512-ReEBKkIfe4ya47wlPYf/gu5ib6yUG0/Aez0JQZQz94kiWtRQvZIQbTiehsnwHvLSWJnQdhVeqYue7Id1dKr0qw==
depd@^1.1.2:
version "1.1.2"
resolved "https://registry.yarnpkg.com/depd/-/depd-1.1.2.tgz#9bcd52e14c097763e749b274c4346ed2e560b5a9"
integrity sha512-7emPTl6Dpo6JRXOXjLRxck+FlLRX5847cLKEn00PLAgc3g2hTZZgr+e4c2v6QpSmLeFP3n5yUo7ft6avBK/5jQ==
diff@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-5.0.0.tgz#7ed6ad76d859d030787ec35855f5b1daf31d852b"
integrity sha512-/VTCrvm5Z0JGty/BWHljh+BAiw3IK+2j87NGMu8Nwc/f48WoDAC395uomO9ZD117ZOBaHmkX1oyLvkVM/aIT3w==
diff@^3.1.0:
version "3.5.0"
resolved "https://registry.yarnpkg.com/diff/-/diff-3.5.0.tgz#800c0dd1e0a8bfbc95835c202ad220fe317e5a12"
integrity sha512-A46qtFgd+g7pDZinpnwiRJtxbC1hpgf0uzP3iG89scHk0AUC7A1TGxf5OiiOUv/JMZR8GOt8hL900hV0bOy5xA==
dot-case@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/dot-case/-/dot-case-3.0.4.tgz#9b2b670d00a431667a8a75ba29cd1b98809ce751"
integrity sha512-Kv5nKlh6yRrdrGvxeJ2e5y2eRUpkUosIW4A2AS38zwSz27zu7ufDwQPi5Jhs3XAlGNetl3bmnGhQsMtkKJnj3w==
dependencies:
no-case "^3.0.4"
tslib "^2.0.3"
emoji-regex@^8.0.0:
version "8.0.0"
resolved "https://registry.yarnpkg.com/emoji-regex/-/emoji-regex-8.0.0.tgz#e818fd69ce5ccfcb404594f842963bf53164cc37"
integrity sha512-MSjYzcWNOA0ewAHpz0MxpYFvwg6yjy1NG3xteoqz644VCo/RPgnr1/GGt+ic3iJTzQ8Eu3TdM14SawnVUmGE6A==
es6-promise@^4.0.3:
version "4.2.8"
resolved "https://registry.yarnpkg.com/es6-promise/-/es6-promise-4.2.8.tgz#4eb21594c972bc40553d276e510539143db53e0a"
integrity sha512-HJDGx5daxeIvxdBxvG2cb9g4tEvwIk3i8+nhX0yGrYmZUzbkdg8QbDevheDB8gd0//uPj4c1EQua8Q+MViT0/w==
es6-promisify@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/es6-promisify/-/es6-promisify-5.0.0.tgz#5109d62f3e56ea967c4b63505aef08291c8a5203"
integrity sha512-C+d6UdsYDk0lMebHNR4S2NybQMMngAOnOwYBQjTOiv0MkoJMP0Myw2mgpDLBcpfCmRLxyFqYhS/CfOENq4SJhQ==
dependencies:
es6-promise "^4.0.3"
escalade@^3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/escalade/-/escalade-3.1.1.tgz#d8cfdc7000965c5a0174b4a82eaa5c0552742e40"
integrity sha512-k0er2gUkLf8O0zKJiAhmkTnJlTvINGv7ygDNPbeIsX/TJjGJZHuh9B2UxbsaEkmlEo9MfhrSzmhIlhRlI2GXnw==
escape-string-regexp@4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/escape-string-regexp/-/escape-string-regexp-4.0.0.tgz#14ba83a5d373e3d311e5afca29cf5bfad965bf34"
integrity sha512-TtpcNJ3XAzx3Gq8sWRzJaVajRs0uVxA2YAkdb1jm2YkPz4G6egUFAyA3n5vtEIZefPk5Wa4UXbKuS5fKkJWdgA==
eventemitter3@^4.0.7:
version "4.0.7"
resolved "https://registry.yarnpkg.com/eventemitter3/-/eventemitter3-4.0.7.tgz#2de9b68f6528d5644ef5c59526a1b4a07306169f"
integrity sha512-8guHBZCwKnFhYdHr2ysuRWErTwhoN2X8XELRlrRwpmfeY2jjuUN4taQMsULKUVo1K4DvZl+0pgfyoysHxvmvEw==
eyes@^0.1.8:
version "0.1.8"
resolved "https://registry.yarnpkg.com/eyes/-/eyes-0.1.8.tgz#62cf120234c683785d902348a800ef3e0cc20bc0"
integrity sha512-GipyPsXO1anza0AOZdy69Im7hGFCNB7Y/NGjDlZGJ3GJJLtwNSb2vrzYrTYJRrRloVx7pl+bhUaTB8yiccPvFQ==
fast-stable-stringify@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fast-stable-stringify/-/fast-stable-stringify-1.0.0.tgz#5c5543462b22aeeefd36d05b34e51c78cb86d313"
integrity sha512-wpYMUmFu5f00Sm0cj2pfivpmawLZ0NKdviQ4w9zJeR8JVtOpOxHmLaJuj0vxvGqMJQWyP/COUkF75/57OKyRag==
file-uri-to-path@1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/file-uri-to-path/-/file-uri-to-path-1.0.0.tgz#553a7b8446ff6f684359c445f1e37a05dacc33dd"
integrity sha512-0Zt+s3L7Vf1biwWZ29aARiVYLx7iMGnEUl9x33fbB/j3jR81u/O2LbqK+Bm1CDSNDKVtJ/YjwY7TUd5SkeLQLw==
fill-range@^7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/fill-range/-/fill-range-7.0.1.tgz#1919a6a7c75fe38b2c7c77e5198535da9acdda40"
integrity sha512-qOo9F+dMUmC2Lcb4BbVvnKJxTPjCm+RRpe4gDuGrzkL7mEVl/djYSu2OdQ2Pa302N4oqkSg9ir6jaLWJ2USVpQ==
dependencies:
to-regex-range "^5.0.1"
find-up@5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/find-up/-/find-up-5.0.0.tgz#4c92819ecb7083561e4f4a240a86be5198f536fc"
integrity sha512-78/PXT1wlLLDgTzDs7sjq9hzz0vXD+zn+7wypEe4fXQxCmdmqfGsEPQxmiCSQI3ajFV91bVSsvNtrJRiW6nGng==
dependencies:
locate-path "^6.0.0"
path-exists "^4.0.0"
flat@^5.0.2:
version "5.0.2"
resolved "https://registry.yarnpkg.com/flat/-/flat-5.0.2.tgz#8ca6fe332069ffa9d324c327198c598259ceb241"
integrity sha512-b6suED+5/3rTpUBdG1gupIl8MPFCAMA0QXwmljLhvCUKcUvdE4gWky9zpuGCcXHOsz4J9wPGNWq6OKpmIzz3hQ==
fs.realpath@^1.0.0:
version "1.0.0"
resolved "https://registry.yarnpkg.com/fs.realpath/-/fs.realpath-1.0.0.tgz#1504ad2523158caa40db4a2787cb01411994ea4f"
integrity sha512-OO0pH2lK6a0hZnAdau5ItzHPI6pUlvI7jMVnxUQRtw4owF2wk8lOSabtGDCTP4Ggrg2MbGnWO9X8K1t4+fGMDw==
fsevents@~2.3.2:
version "2.3.2"
resolved "https://registry.yarnpkg.com/fsevents/-/fsevents-2.3.2.tgz#8a526f78b8fdf4623b709e0b975c52c24c02fd1a"
integrity sha512-xiqMQR4xAeHTuB9uWm+fFRcIOgKBMiOBP+eXiyT7jsgVCq1bkVygt00oASowB7EdtpOHaaPgKt812P9ab+DDKA==
get-caller-file@^2.0.5:
version "2.0.5"
resolved "https://registry.yarnpkg.com/get-caller-file/-/get-caller-file-2.0.5.tgz#4f94412a82db32f36e3b0b9741f8a97feb031f7e"
integrity sha512-DyFP3BM/3YHTQOCUL/w0OZHR0lpKeGrxotcHWcqNEdnltqFwXVfhEBQ94eIo34AfQpo0rGki4cyIiftY06h2Fg==
get-func-name@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/get-func-name/-/get-func-name-2.0.0.tgz#ead774abee72e20409433a066366023dd6887a41"
integrity sha512-Hm0ixYtaSZ/V7C8FJrtZIuBBI+iSgL+1Aq82zSu8VQNB4S3Gk8e7Qs3VwBDJAhmRZcFqkl3tQu36g/Foh5I5ig==
glob-parent@~5.1.2:
version "5.1.2"
resolved "https://registry.yarnpkg.com/glob-parent/-/glob-parent-5.1.2.tgz#869832c58034fe68a4093c17dc15e8340d8401c4"
integrity sha512-AOIgSQCepiJYwP3ARnGx+5VnTu2HBYdzbGP45eLw1vr3zB3vZLeyed1sC9hnbcOc9/SrMyM5RPQrkGz4aS9Zow==
dependencies:
is-glob "^4.0.1"
glob@7.2.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/glob/-/glob-7.2.0.tgz#d15535af7732e02e948f4c41628bd910293f6023"
integrity sha512-lmLf6gtyrPq8tTjSmrO94wBeQbFR3HbLHbuyD69wuyQkImp2hWqMGB47OX65FBkPffO641IP9jWa1z4ivqG26Q==
dependencies:
fs.realpath "^1.0.0"
inflight "^1.0.4"
inherits "2"
minimatch "^3.0.4"
once "^1.3.0"
path-is-absolute "^1.0.0"
has-flag@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/has-flag/-/has-flag-4.0.0.tgz#944771fd9c81c81265c4d6941860da06bb59479b"
integrity sha512-EykJT/Q1KjTWctppgIAgfSO0tKVuZUjhgMr17kqTumMl6Afv3EISleU7qZUzoXDFTAHTDC4NOoG/ZxU3EvlMPQ==
he@1.2.0:
version "1.2.0"
resolved "https://registry.yarnpkg.com/he/-/he-1.2.0.tgz#84ae65fa7eafb165fddb61566ae14baf05664f0f"
integrity sha512-F/1DnUGPopORZi0ni+CvrCgHQ5FyEAHRLSApuYWMmrbSwoN2Mn/7k+Gl38gJnR7yyDZk6WLXwiGod1JOWNDKGw==
humanize-ms@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/humanize-ms/-/humanize-ms-1.2.1.tgz#c46e3159a293f6b896da29316d8b6fe8bb79bbed"
integrity sha512-Fl70vYtsAFb/C06PTS9dZBo7ihau+Tu/DNCk/OyHhea07S+aeMWpFFkUaXRa8fI+ScZbEI8dfSxwY7gxZ9SAVQ==
dependencies:
ms "^2.0.0"
ieee754@^1.2.1:
version "1.2.1"
resolved "https://registry.yarnpkg.com/ieee754/-/ieee754-1.2.1.tgz#8eb7a10a63fff25d15a57b001586d177d1b0d352"
integrity sha512-dcyqhDvX1C46lXZcVqCpK+FtMRQVdIMN6/Df5js2zouUsqG7I6sFxitIC+7KYK29KdXOLHdu9zL4sFnoVQnqaA==
inflight@^1.0.4:
version "1.0.6"
resolved "https://registry.yarnpkg.com/inflight/-/inflight-1.0.6.tgz#49bd6331d7d02d0c09bc910a1075ba8165b56df9"
integrity sha512-k92I/b08q4wvFscXCLvqfsHCrjrF7yiXsQuIVvVE7N82W3+aqpzuUdBbfhWcy/FZR3/4IgflMgKLOsvPDrGCJA==
dependencies:
once "^1.3.0"
wrappy "1"
inherits@2:
version "2.0.4"
resolved "https://registry.yarnpkg.com/inherits/-/inherits-2.0.4.tgz#0fa2c64f932917c3433a0ded55363aae37416b7c"
integrity sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==
is-binary-path@~2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-binary-path/-/is-binary-path-2.1.0.tgz#ea1f7f3b80f064236e83470f86c09c254fb45b09"
integrity sha512-ZMERYes6pDydyuGidse7OsHxtbI7WVeUEozgR/g7rd0xUimYNlvZRE/K2MgZTjWy725IfelLeVcEM97mmtRGXw==
dependencies:
binary-extensions "^2.0.0"
is-extglob@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/is-extglob/-/is-extglob-2.1.1.tgz#a88c02535791f02ed37c76a1b9ea9773c833f8c2"
integrity sha512-SbKbANkN603Vi4jEZv49LeVJMn4yGwsbzZworEoyEiutsN3nJYdbO36zfhGJ6QEDpOZIFkDtnq5JRxmvl3jsoQ==
is-fullwidth-code-point@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/is-fullwidth-code-point/-/is-fullwidth-code-point-3.0.0.tgz#f116f8064fe90b3f7844a38997c0b75051269f1d"
integrity sha512-zymm5+u+sCsSWyD9qNaejV3DFvhCKclKdizYaJUuHA83RLjb7nSuGnddCHGv0hk+KY7BMAlsWeK4Ueg6EV6XQg==
is-glob@^4.0.1, is-glob@~4.0.1:
version "4.0.3"
resolved "https://registry.yarnpkg.com/is-glob/-/is-glob-4.0.3.tgz#64f61e42cbbb2eec2071a9dac0b28ba1e65d5084"
integrity sha512-xelSayHH36ZgE7ZWhli7pW34hNbNl8Ojv5KVmkJD4hBdD3th8Tfk9vYasLM+mXWOZhFkgZfxhLSnrwRr4elSSg==
dependencies:
is-extglob "^2.1.1"
is-number@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/is-number/-/is-number-7.0.0.tgz#7535345b896734d5f80c4d06c50955527a14f12b"
integrity sha512-41Cifkg6e8TylSpdtTpeLVMqvSBEVzTttHvERD741+pnZ8ANv0004MRL43QKPDlK9cGvNp6NZWZUBlbGXYxxng==
is-plain-obj@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/is-plain-obj/-/is-plain-obj-2.1.0.tgz#45e42e37fccf1f40da8e5f76ee21515840c09287"
integrity sha512-YWnfyRwxL/+SsrWYfOpUtz5b3YD+nyfkHvjbcanzk8zgyO4ASD67uVMRt8k5bM4lLMDnXfriRhOpemw+NfT1eA==
is-unicode-supported@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/is-unicode-supported/-/is-unicode-supported-0.1.0.tgz#3f26c76a809593b52bfa2ecb5710ed2779b522a7"
integrity sha512-knxG2q4UC3u8stRGyAVJCOdxFmv5DZiRcdlIaAQXAbSfJya+OhopNotLQrstBhququ4ZpuKbDc/8S6mgXgPFPw==
isomorphic-ws@^4.0.1:
version "4.0.1"
resolved "https://registry.yarnpkg.com/isomorphic-ws/-/isomorphic-ws-4.0.1.tgz#55fd4cd6c5e6491e76dc125938dd863f5cd4f2dc"
integrity sha512-BhBvN2MBpWTaSHdWRb/bwdZJ1WaehQ2L1KngkCkfLUGF0mAWAT1sQUQacEmQ0jXkFw/czDXPNQSL5u2/Krsz1w==
jayson@^3.4.4:
version "3.7.0"
resolved "https://registry.yarnpkg.com/jayson/-/jayson-3.7.0.tgz#b735b12d06d348639ae8230d7a1e2916cb078f25"
integrity sha512-tfy39KJMrrXJ+mFcMpxwBvFDetS8LAID93+rycFglIQM4kl3uNR3W4lBLE/FFhsoUCEox5Dt2adVpDm/XtebbQ==
dependencies:
"@types/connect" "^3.4.33"
"@types/node" "^12.12.54"
"@types/ws" "^7.4.4"
JSONStream "^1.3.5"
commander "^2.20.3"
delay "^5.0.0"
es6-promisify "^5.0.0"
eyes "^0.1.8"
isomorphic-ws "^4.0.1"
json-stringify-safe "^5.0.1"
lodash "^4.17.20"
uuid "^8.3.2"
ws "^7.4.5"
js-sha256@^0.9.0:
version "0.9.0"
resolved "https://registry.yarnpkg.com/js-sha256/-/js-sha256-0.9.0.tgz#0b89ac166583e91ef9123644bd3c5334ce9d0966"
integrity sha512-sga3MHh9sgQN2+pJ9VYZ+1LPwXOxuBJBA5nrR5/ofPfuiJBE2hnjsaN8se8JznOmGLN2p49Pe5U/ttafcs/apA==
js-yaml@4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/js-yaml/-/js-yaml-4.1.0.tgz#c1fb65f8f5017901cdd2c951864ba18458a10602"
integrity sha512-wpxZs9NoxZaJESJGIZTyDEaYpl0FKSA+FB9aJiyemKhMwkxQg63h4T1KJgUGHpTqPDNRcmmYLugrRjJlBtWvRA==
dependencies:
argparse "^2.0.1"
json-stringify-safe@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/json-stringify-safe/-/json-stringify-safe-5.0.1.tgz#1296a2d58fd45f19a0f6ce01d65701e2c735b6eb"
integrity sha512-ZClg6AaYvamvYEE82d3Iyd3vSSIjQ+odgjaTzRuO3s7toCdFKczob2i0zCh7JE8kWn17yvAWhUVxvqGwUalsRA==
json5@^1.0.1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/json5/-/json5-1.0.2.tgz#63d98d60f21b313b77c4d6da18bfa69d80e1d593"
integrity sha512-g1MWMLBiz8FKi1e4w0UyVL3w+iJceWAFBAaBnnGKOpNa5f8TLktkbre1+s6oICydWAm+HRUGTmI+//xv2hvXYA==
dependencies:
minimist "^1.2.0"
jsonparse@^1.2.0:
version "1.3.1"
resolved "https://registry.yarnpkg.com/jsonparse/-/jsonparse-1.3.1.tgz#3f4dae4a91fac315f71062f8521cc239f1366280"
integrity sha512-POQXvpdL69+CluYsillJ7SUhKvytYjW9vG/GKpnf+xP8UWgYEM/RaMzHHofbALDiKbbP1W8UEYmgGl39WkPZsg==
locate-path@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/locate-path/-/locate-path-6.0.0.tgz#55321eb309febbc59c4801d931a72452a681d286"
integrity sha512-iPZK6eYjbxRu3uB4/WZ3EsEIMJFMqAoopl3R+zuq0UjcAm/MO6KCweDgPfP3elTztoKP3KtnVHxTn2NHBSDVUw==
dependencies:
p-locate "^5.0.0"
lodash@^4.17.20:
version "4.17.21"
resolved "https://registry.yarnpkg.com/lodash/-/lodash-4.17.21.tgz#679591c564c3bffaae8454cf0b3df370c3d6911c"
integrity sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==
log-symbols@4.1.0:
version "4.1.0"
resolved "https://registry.yarnpkg.com/log-symbols/-/log-symbols-4.1.0.tgz#3fbdbb95b4683ac9fc785111e792e558d4abd503"
integrity sha512-8XPvpAA8uyhfteu8pIvQxpJZ7SYYdpUivZpGy6sFsBuKRY/7rQGavedeB8aK+Zkyq6upMFVL/9AW6vOYzfRyLg==
dependencies:
chalk "^4.1.0"
is-unicode-supported "^0.1.0"
loupe@^2.3.1:
version "2.3.6"
resolved "https://registry.yarnpkg.com/loupe/-/loupe-2.3.6.tgz#76e4af498103c532d1ecc9be102036a21f787b53"
integrity sha512-RaPMZKiMy8/JruncMU5Bt6na1eftNoo++R4Y+N2FrxkDVTrGvcyzFTsaGif4QTeKESheMGegbhw6iUAq+5A8zA==
dependencies:
get-func-name "^2.0.0"
lower-case@^2.0.2:
version "2.0.2"
resolved "https://registry.yarnpkg.com/lower-case/-/lower-case-2.0.2.tgz#6fa237c63dbdc4a82ca0fd882e4722dc5e634e28"
integrity sha512-7fm3l3NAF9WfN6W3JOmf5drwpVqX78JtoGJ3A6W0a6ZnldM41w2fV5D490psKFTpMds8TJse/eHLFFsNHHjHgg==
dependencies:
tslib "^2.0.3"
lru-cache@^6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/lru-cache/-/lru-cache-6.0.0.tgz#6d6fe6570ebd96aaf90fcad1dafa3b2566db3a94"
integrity sha512-Jo6dJ04CmSjuznwJSS3pUeWmd/H0ffTlkXXgwZi+eq1UCmqQwCh+eLsYOYCwY991i2Fah4h1BEMCx4qThGbsiA==
dependencies:
yallist "^4.0.0"
make-error@^1.1.1:
version "1.3.6"
resolved "https://registry.yarnpkg.com/make-error/-/make-error-1.3.6.tgz#2eb2e37ea9b67c4891f684a1394799af484cf7a2"
integrity sha512-s8UhlNe7vPKomQhC1qFelMokr/Sc3AgNbso3n74mVPA5LTZwkB9NlXf4XPamLxJE8h0gh73rM94xvwRT2CVInw==
minimatch@5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-5.0.1.tgz#fb9022f7528125187c92bd9e9b6366be1cf3415b"
integrity sha512-nLDxIFRyhDblz3qMuq+SoRZED4+miJ/G+tdDrjkkkRnjAsBexeGpgjLEQ0blJy7rHhR2b93rhQY4SvyWu9v03g==
dependencies:
brace-expansion "^2.0.1"
minimatch@^3.0.4:
version "3.1.2"
resolved "https://registry.yarnpkg.com/minimatch/-/minimatch-3.1.2.tgz#19cd194bfd3e428f049a70817c038d89ab4be35b"
integrity sha512-J7p63hRiAjw1NDEww1W7i37+ByIrOWO5XQQAzZ3VOcL0PNybwpfmV/N05zFAzwQ9USyEcX6t3UO+K5aqBQOIHw==
dependencies:
brace-expansion "^1.1.7"
minimist@^1.2.0, minimist@^1.2.6:
version "1.2.7"
resolved "https://registry.yarnpkg.com/minimist/-/minimist-1.2.7.tgz#daa1c4d91f507390437c6a8bc01078e7000c4d18"
integrity sha512-bzfL1YUZsP41gmu/qjrEk0Q6i2ix/cVeAhbCbqH9u3zYutS1cLg00qhrD0M2MVdCcx4Sc0UpP2eBWo9rotpq6g==
mkdirp@^0.5.1:
version "0.5.6"
resolved "https://registry.yarnpkg.com/mkdirp/-/mkdirp-0.5.6.tgz#7def03d2432dcae4ba1d611445c48396062255f6"
integrity sha512-FP+p8RB8OWpF3YZBCrP5gtADmtXApB5AMLn+vdyA+PyxCjrCs00mjyUozssO33cwDeT3wNGdLxJ5M//YqtHAJw==
dependencies:
minimist "^1.2.6"
mocha@^10.2.0:
version "10.2.0"
resolved "https://registry.yarnpkg.com/mocha/-/mocha-10.2.0.tgz#1fd4a7c32ba5ac372e03a17eef435bd00e5c68b8"
integrity sha512-IDY7fl/BecMwFHzoqF2sg/SHHANeBoMMXFlS9r0OXKDssYE1M5O43wUY/9BVPeIvfH2zmEbBfseqN9gBQZzXkg==
dependencies:
ansi-colors "4.1.1"
browser-stdout "1.3.1"
chokidar "3.5.3"
debug "4.3.4"
diff "5.0.0"
escape-string-regexp "4.0.0"
find-up "5.0.0"
glob "7.2.0"
he "1.2.0"
js-yaml "4.1.0"
log-symbols "4.1.0"
minimatch "5.0.1"
ms "2.1.3"
nanoid "3.3.3"
serialize-javascript "6.0.0"
strip-json-comments "3.1.1"
supports-color "8.1.1"
workerpool "6.2.1"
yargs "16.2.0"
yargs-parser "20.2.4"
yargs-unparser "2.0.0"
ms@2.1.2:
version "2.1.2"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.2.tgz#d09d1f357b443f493382a8eb3ccd183872ae6009"
integrity sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==
ms@2.1.3, ms@^2.0.0:
version "2.1.3"
resolved "https://registry.yarnpkg.com/ms/-/ms-2.1.3.tgz#574c8138ce1d2b5861f0b44579dbadd60c6615b2"
integrity sha512-6FlzubTLZG3J2a/NVCAleEhjzq5oxgHyaCU9yYXvcLsvoVaHJq/s5xXI6/XXP6tz7R9xAOtHnSO/tXtF3WRTlA==
nanoid@3.3.3:
version "3.3.3"
resolved "https://registry.yarnpkg.com/nanoid/-/nanoid-3.3.3.tgz#fd8e8b7aa761fe807dba2d1b98fb7241bb724a25"
integrity sha512-p1sjXuopFs0xg+fPASzQ28agW1oHD7xDsd9Xkf3T15H3c/cifrFHVwrh74PdoklAPi+i7MdRsE47vm2r6JoB+w==
no-case@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/no-case/-/no-case-3.0.4.tgz#d361fd5c9800f558551a8369fc0dcd4662b6124d"
integrity sha512-fgAN3jGAh+RoxUGZHTSOLJIqUc2wmoBwGR4tbpNAKmmovFoWq0OdRkb0VkldReO2a2iBT/OEulG9XSUc10r3zg==
dependencies:
lower-case "^2.0.2"
tslib "^2.0.3"
node-fetch@^2.6.7:
version "2.6.9"
resolved "https://registry.yarnpkg.com/node-fetch/-/node-fetch-2.6.9.tgz#7c7f744b5cc6eb5fd404e0c7a9fec630a55657e6"
integrity sha512-DJm/CJkZkRjKKj4Zi4BsKVZh3ValV5IR5s7LVZnW+6YMh0W1BfNA8XSs6DLMGYlId5F3KnA70uu2qepcR08Qqg==
dependencies:
whatwg-url "^5.0.0"
node-gyp-build@^4.3.0:
version "4.6.0"
resolved "https://registry.yarnpkg.com/node-gyp-build/-/node-gyp-build-4.6.0.tgz#0c52e4cbf54bbd28b709820ef7b6a3c2d6209055"
integrity sha512-NTZVKn9IylLwUzaKjkas1e4u2DLNcV4rdYagA4PWdPwW87Bi7z+BznyKSRwS/761tV/lzCGXplWsiaMjLqP2zQ==
normalize-path@^3.0.0, normalize-path@~3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/normalize-path/-/normalize-path-3.0.0.tgz#0dcd69ff23a1c9b11fd0978316644a0388216a65"
integrity sha512-6eZs5Ls3WtCisHWp9S2GUy8dqkpGi4BVSz3GaqiE6ezub0512ESztXUwUB6C6IKbQkY2Pnb/mD4WYojCRwcwLA==
once@^1.3.0:
version "1.4.0"
resolved "https://registry.yarnpkg.com/once/-/once-1.4.0.tgz#583b1aa775961d4b113ac17d9c50baef9dd76bd1"
integrity sha512-lNaJgI+2Q5URQBkccEKHTQOPaXdUxnZZElQTZY0MFUAuaEqe1E+Nyvgdz/aIyNi6Z9MzO5dv1H8n58/GELp3+w==
dependencies:
wrappy "1"
p-limit@^3.0.2:
version "3.1.0"
resolved "https://registry.yarnpkg.com/p-limit/-/p-limit-3.1.0.tgz#e1daccbe78d0d1388ca18c64fea38e3e57e3706b"
integrity sha512-TYOanM3wGwNGsZN2cVTYPArw454xnXj5qmWF1bEoAc4+cU/ol7GVh7odevjp1FNHduHc3KZMcFduxU5Xc6uJRQ==
dependencies:
yocto-queue "^0.1.0"
p-locate@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/p-locate/-/p-locate-5.0.0.tgz#83c8315c6785005e3bd021839411c9e110e6d834"
integrity sha512-LaNjtRWUBY++zB5nE/NwcaoMylSPk+S+ZHNB1TzdbMJMny6dynpAGt7X/tl/QYq3TIeE6nxHppbo2LGymrG5Pw==
dependencies:
p-limit "^3.0.2"
path-exists@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/path-exists/-/path-exists-4.0.0.tgz#513bdbe2d3b95d7762e8c1137efa195c6c61b5b3"
integrity sha512-ak9Qy5Q7jYb2Wwcey5Fpvg2KoAc/ZIhLSLOSBmRmygPsGwkVVt0fZa0qrtMz+m6tJTAHfZQ8FnmB4MG4LWy7/w==
path-is-absolute@^1.0.0:
version "1.0.1"
resolved "https://registry.yarnpkg.com/path-is-absolute/-/path-is-absolute-1.0.1.tgz#174b9268735534ffbc7ace6bf53a5a9e1b5c5f5f"
integrity sha512-AVbw3UJ2e9bq64vSaS9Am0fje1Pa8pbGqTTsmXfaIiMpnr5DlDhfJOuLj9Sf95ZPVDAUerDfEk88MPmPe7UCQg==
pathval@^1.1.1:
version "1.1.1"
resolved "https://registry.yarnpkg.com/pathval/-/pathval-1.1.1.tgz#8534e77a77ce7ac5a2512ea21e0fdb8fcf6c3d8d"
integrity sha512-Dp6zGqpTdETdR63lehJYPeIOqpiNBNtc7BpWSLrOje7UaIsE5aY92r/AunQA7rsXvet3lrJ3JnZX29UPTKXyKQ==
picomatch@^2.0.4, picomatch@^2.2.1:
version "2.3.1"
resolved "https://registry.yarnpkg.com/picomatch/-/picomatch-2.3.1.tgz#3ba3833733646d9d3e4995946c1365a67fb07a42"
integrity sha512-JU3teHTNjmE2VCGFzuY8EXzCDVwEqB2a8fsIvwaStHhAWJEeVd1o1QD80CU6+ZdEXXSLbSsuLwJjkCBWqRQUVA==
prettier@^2.5.1:
version "2.8.4"
resolved "https://registry.yarnpkg.com/prettier/-/prettier-2.8.4.tgz#34dd2595629bfbb79d344ac4a91ff948694463c3"
integrity sha512-vIS4Rlc2FNh0BySk3Wkd6xmwxB0FpOndW5fisM5H8hsZSxU2VWVB5CWIkIjWvrHjIhxk2g3bfMKM87zNTrZddw==
randombytes@^2.1.0:
version "2.1.0"
resolved "https://registry.yarnpkg.com/randombytes/-/randombytes-2.1.0.tgz#df6f84372f0270dc65cdf6291349ab7a473d4f2a"
integrity sha512-vYl3iOX+4CKUWuxGi9Ukhie6fsqXqS9FE2Zaic4tNFD2N2QQaXOMFbuKK4QmDHC0JO6B1Zp41J0LpT0oR68amQ==
dependencies:
safe-buffer "^5.1.0"
readdirp@~3.6.0:
version "3.6.0"
resolved "https://registry.yarnpkg.com/readdirp/-/readdirp-3.6.0.tgz#74a370bd857116e245b29cc97340cd431a02a6c7"
integrity sha512-hOS089on8RduqdbhvQ5Z37A0ESjsqz6qnRcffsMU3495FuTdqSm+7bhJ29JvIOsBDEEnan5DPu9t3To9VRlMzA==
dependencies:
picomatch "^2.2.1"
regenerator-runtime@^0.13.11:
version "0.13.11"
resolved "https://registry.yarnpkg.com/regenerator-runtime/-/regenerator-runtime-0.13.11.tgz#f6dca3e7ceec20590d07ada785636a90cdca17f9"
integrity sha512-kY1AZVr2Ra+t+piVaJ4gxaFaReZVH40AKNo7UCX6W+dEwBo/2oZJzqfuN1qLq1oL45o56cPaTXELwrTh8Fpggg==
require-directory@^2.1.1:
version "2.1.1"
resolved "https://registry.yarnpkg.com/require-directory/-/require-directory-2.1.1.tgz#8c64ad5fd30dab1c976e2344ffe7f792a6a6df42"
integrity sha512-fGxEI7+wsG9xrvdjsrlmL22OMTTiHRwAMroiEeMgq8gzoLC/PQr7RsRDSTLUg/bZAZtF+TVIkHc6/4RIKrui+Q==
rpc-websockets@^7.5.1:
version "7.5.1"
resolved "https://registry.yarnpkg.com/rpc-websockets/-/rpc-websockets-7.5.1.tgz#e0a05d525a97e7efc31a0617f093a13a2e10c401"
integrity sha512-kGFkeTsmd37pHPMaHIgN1LVKXMi0JD782v4Ds9ZKtLlwdTKjn+CxM9A9/gLT2LaOuEcEFGL98h1QWQtlOIdW0w==
dependencies:
"@babel/runtime" "^7.17.2"
eventemitter3 "^4.0.7"
uuid "^8.3.2"
ws "^8.5.0"
optionalDependencies:
bufferutil "^4.0.1"
utf-8-validate "^5.0.2"
safe-buffer@^5.0.1, safe-buffer@^5.1.0:
version "5.2.1"
resolved "https://registry.yarnpkg.com/safe-buffer/-/safe-buffer-5.2.1.tgz#1eaf9fa9bdb1fdd4ec75f58f9cdb4e6b7827eec6"
integrity sha512-rp3So07KcdmmKbGvgaNxQSJr7bGVSVk5S9Eq1F+ppbRo70+YeaDxkw5Dd8NPN+GD6bjnYm2VuPuCXmpuYvmCXQ==
semver@^7.3.7:
version "7.3.8"
resolved "https://registry.yarnpkg.com/semver/-/semver-7.3.8.tgz#07a78feafb3f7b32347d725e33de7e2a2df67798"
integrity sha512-NB1ctGL5rlHrPJtFDVIVzTyQylMLu9N9VICA6HSFJo8MCGVTMW6gfpicwKmmK/dAjTOrqu5l63JJOpDSrAis3A==
dependencies:
lru-cache "^6.0.0"
serialize-javascript@6.0.0:
version "6.0.0"
resolved "https://registry.yarnpkg.com/serialize-javascript/-/serialize-javascript-6.0.0.tgz#efae5d88f45d7924141da8b5c3a7a7e663fefeb8"
integrity sha512-Qr3TosvguFt8ePWqsvRfrKyQXIiW+nGbYpy8XK24NQHE83caxWt+mIymTT19DGFbNWNLfEwsrkSmN64lVWB9ag==
dependencies:
randombytes "^2.1.0"
snake-case@^3.0.4:
version "3.0.4"
resolved "https://registry.yarnpkg.com/snake-case/-/snake-case-3.0.4.tgz#4f2bbd568e9935abdfd593f34c691dadb49c452c"
integrity sha512-LAOh4z89bGQvl9pFfNF8V146i7o7/CqFPbqzYgP+yYzDIDeS9HaNFtXABamRW+AQzEVODcvE79ljJ+8a9YSdMg==
dependencies:
dot-case "^3.0.4"
tslib "^2.0.3"
source-map-support@^0.5.6:
version "0.5.21"
resolved "https://registry.yarnpkg.com/source-map-support/-/source-map-support-0.5.21.tgz#04fe7c7f9e1ed2d662233c28cb2b35b9f63f6e4f"
integrity sha512-uBHU3L3czsIyYXKX88fdrGovxdSCoTGDRZ6SYXtSRxLZUzHg5P/66Ht6uoUlHu9EZod+inXhKo3qQgwXUT/y1w==
dependencies:
buffer-from "^1.0.0"
source-map "^0.6.0"
source-map@^0.6.0:
version "0.6.1"
resolved "https://registry.yarnpkg.com/source-map/-/source-map-0.6.1.tgz#74722af32e9614e9c287a8d0bbde48b5e2f1a263"
integrity sha512-UjgapumWlbMhkBgzT7Ykc5YXUT46F0iKu8SGXq0bcwP5dz/h0Plj6enJqjz1Zbq2l5WaqYnrVbwWOWMyF3F47g==
spok@^1.4.3:
version "1.4.3"
resolved "https://registry.yarnpkg.com/spok/-/spok-1.4.3.tgz#8516234e6bd8caf0e10567bd675e15fd03b5ceb8"
integrity sha512-5wFGctwrk638aDs+44u99kohxFNByUq2wo0uShQ9yqxSmsxqx7zKbMo1Busy4s7stZQXU+PhJ/BlVf2XWFEGIw==
dependencies:
ansicolors "~0.3.2"
string-width@^4.1.0, string-width@^4.2.0:
version "4.2.3"
resolved "https://registry.yarnpkg.com/string-width/-/string-width-4.2.3.tgz#269c7117d27b05ad2e536830a8ec895ef9c6d010"
integrity sha512-wKyQRQpjJ0sIp62ErSZdGsjMJWsap5oRNihHhu6G7JVO/9jIB6UyevL+tXuOqrng8j/cxKTWyWUwvSTriiZz/g==
dependencies:
emoji-regex "^8.0.0"
is-fullwidth-code-point "^3.0.0"
strip-ansi "^6.0.1"
strip-ansi@^6.0.0, strip-ansi@^6.0.1:
version "6.0.1"
resolved "https://registry.yarnpkg.com/strip-ansi/-/strip-ansi-6.0.1.tgz#9e26c63d30f53443e9489495b2105d37b67a85d9"
integrity sha512-Y38VPSHcqkFrCpFnQ9vuSXmquuv5oXOKpGeT6aGrr3o3Gc9AlVa6JBfUSOCnbxGGZF+/0ooI7KrPuUSztUdU5A==
dependencies:
ansi-regex "^5.0.1"
strip-bom@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/strip-bom/-/strip-bom-3.0.0.tgz#2334c18e9c759f7bdd56fdef7e9ae3d588e68ed3"
integrity sha512-vavAMRXOgBVNF6nyEEmL3DBK19iRpDcoIwW+swQ+CbGiu7lju6t+JklA1MHweoWtadgt4ISVUsXLyDq34ddcwA==
strip-json-comments@3.1.1:
version "3.1.1"
resolved "https://registry.yarnpkg.com/strip-json-comments/-/strip-json-comments-3.1.1.tgz#31f1281b3832630434831c310c01cccda8cbe006"
integrity sha512-6fPc+R4ihwqP6N/aIv2f1gMH8lOVtWQHoqC4yK6oSDVVocumAsfCqjkXnqiYMhmMwS/mEHLp7Vehlt3ql6lEig==
superstruct@^0.14.2:
version "0.14.2"
resolved "https://registry.yarnpkg.com/superstruct/-/superstruct-0.14.2.tgz#0dbcdf3d83676588828f1cf5ed35cda02f59025b"
integrity sha512-nPewA6m9mR3d6k7WkZ8N8zpTWfenFH3q9pA2PkuiZxINr9DKB2+40wEQf0ixn8VaGuJ78AB6iWOtStI+/4FKZQ==
supports-color@8.1.1:
version "8.1.1"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-8.1.1.tgz#cd6fc17e28500cff56c1b86c0a7fd4a54a73005c"
integrity sha512-MpUEN2OodtUzxvKQl72cUF7RQ5EiHsGvSsVG0ia9c5RbWGL2CI4C7EpPS8UTBIplnlzZiNuV56w+FuNxy3ty2Q==
dependencies:
has-flag "^4.0.0"
supports-color@^7.1.0:
version "7.2.0"
resolved "https://registry.yarnpkg.com/supports-color/-/supports-color-7.2.0.tgz#1b7dcdcb32b8138801b3e478ba6a51caa89648da"
integrity sha512-qpCAvRl9stuOHveKsn7HncJRvv501qIacKzQlO/+Lwxc9+0q2wLyv4Dfvt80/DPn2pqOBsJdDiogXGR9+OvwRw==
dependencies:
has-flag "^4.0.0"
text-encoding-utf-8@^1.0.2:
version "1.0.2"
resolved "https://registry.yarnpkg.com/text-encoding-utf-8/-/text-encoding-utf-8-1.0.2.tgz#585b62197b0ae437e3c7b5d0af27ac1021e10d13"
integrity sha512-8bw4MY9WjdsD2aMtO0OzOCY3pXGYNx2d2FfHRVUKkiCPDWjKuOlhLVASS+pD7VkLTVjW268LYJHwsnPFlBpbAg==
text-table@^0.2.0:
version "0.2.0"
resolved "https://registry.yarnpkg.com/text-table/-/text-table-0.2.0.tgz#7f5ee823ae805207c00af2df4a84ec3fcfa570b4"
integrity sha512-N+8UisAXDGk8PFXP4HAzVR9nbfmVJ3zYLAWiTIoqC5v5isinhr+r5uaO8+7r3BMfuNIufIsA7RdpVgacC2cSpw==
"through@>=2.2.7 <3":
version "2.3.8"
resolved "https://registry.yarnpkg.com/through/-/through-2.3.8.tgz#0dd4c9ffaabc357960b1b724115d7e0e86a2e1f5"
integrity sha512-w89qg7PI8wAdvX60bMDP+bFoD5Dvhm9oLheFp5O4a2QF0cSBGsBX4qZmadPMvVqlLJBBci+WqGGOAPvcDeNSVg==
to-regex-range@^5.0.1:
version "5.0.1"
resolved "https://registry.yarnpkg.com/to-regex-range/-/to-regex-range-5.0.1.tgz#1648c44aae7c8d988a326018ed72f5b4dd0392e4"
integrity sha512-65P7iz6X5yEr1cwcgvQxbbIw7Uk3gOy5dIdtZ4rDveLqhrdJP+Li/Hx6tyK0NEb+2GCyneCMJiGqrADCSNk8sQ==
dependencies:
is-number "^7.0.0"
toml@^3.0.0:
version "3.0.0"
resolved "https://registry.yarnpkg.com/toml/-/toml-3.0.0.tgz#342160f1af1904ec9d204d03a5d61222d762c5ee"
integrity sha512-y/mWCZinnvxjTKYhJ+pYxwD0mRLVvOtdS2Awbgxln6iEnt4rk0yBxeSBHkGJcPucRiG0e55mwWp+g/05rsrd6w==
tr46@~0.0.3:
version "0.0.3"
resolved "https://registry.yarnpkg.com/tr46/-/tr46-0.0.3.tgz#8184fd347dac9cdc185992f3a6622e14b9d9ab6a"
integrity sha512-N3WMsuqV66lT30CrXNbEjx4GEwlow3v6rr4mCcv6prnfwhS01rkgyFdjPNBYd9br7LpXV1+Emh01fHnq2Gdgrw==
ts-mocha@^10.0.0:
version "10.0.0"
resolved "https://registry.yarnpkg.com/ts-mocha/-/ts-mocha-10.0.0.tgz#41a8d099ac90dbbc64b06976c5025ffaebc53cb9"
integrity sha512-VRfgDO+iiuJFlNB18tzOfypJ21xn2xbuZyDvJvqpTbWgkAgD17ONGr8t+Tl8rcBtOBdjXp5e/Rk+d39f7XBHRw==
dependencies:
ts-node "7.0.1"
optionalDependencies:
tsconfig-paths "^3.5.0"
ts-node@7.0.1:
version "7.0.1"
resolved "https://registry.yarnpkg.com/ts-node/-/ts-node-7.0.1.tgz#9562dc2d1e6d248d24bc55f773e3f614337d9baf"
integrity sha512-BVwVbPJRspzNh2yfslyT1PSbl5uIk03EZlb493RKHN4qej/D06n1cEhjlOJG69oFsE7OT8XjpTUcYf6pKTLMhw==
dependencies:
arrify "^1.0.0"
buffer-from "^1.1.0"
diff "^3.1.0"
make-error "^1.1.1"
minimist "^1.2.0"
mkdirp "^0.5.1"
source-map-support "^0.5.6"
yn "^2.0.0"
tsconfig-paths@^3.5.0:
version "3.14.1"
resolved "https://registry.yarnpkg.com/tsconfig-paths/-/tsconfig-paths-3.14.1.tgz#ba0734599e8ea36c862798e920bcf163277b137a"
integrity sha512-fxDhWnFSLt3VuTwtvJt5fpwxBHg5AdKWMsgcPOOIilyjymcYVZoCQF8fvFRezCNfblEXmi+PcM1eYHeOAgXCOQ==
dependencies:
"@types/json5" "^0.0.29"
json5 "^1.0.1"
minimist "^1.2.6"
strip-bom "^3.0.0"
tslib@^2.0.3:
version "2.5.0"
resolved "https://registry.yarnpkg.com/tslib/-/tslib-2.5.0.tgz#42bfed86f5787aeb41d031866c8f402429e0fddf"
integrity sha512-336iVw3rtn2BUK7ORdIAHTyxHGRIHVReokCR3XjbckJMK7ms8FysBfhLR8IXnAgy7T0PTPNBWKiH514FOW/WSg==
type-detect@^4.0.0, type-detect@^4.0.5:
version "4.0.8"
resolved "https://registry.yarnpkg.com/type-detect/-/type-detect-4.0.8.tgz#7646fb5f18871cfbb7749e69bd39a6388eb7450c"
integrity sha512-0fr/mIH1dlO+x7TlcMy+bIDqKPsw/70tVyeHW787goQjhmqaZe10uwLujubK9q9Lg6Fiho1KUKDYz0Z7k7g5/g==
typescript@^4.9.5:
version "4.9.5"
resolved "https://registry.yarnpkg.com/typescript/-/typescript-4.9.5.tgz#095979f9bcc0d09da324d58d03ce8f8374cbe65a"
integrity sha512-1FXk9E2Hm+QzZQ7z+McJiHL4NW1F2EzMu9Nq9i3zAaGqibafqYwCVU6WyWAuyQRRzOlxou8xZSyXLEN8oKj24g==
utf-8-validate@^5.0.2:
version "5.0.10"
resolved "https://registry.yarnpkg.com/utf-8-validate/-/utf-8-validate-5.0.10.tgz#d7d10ea39318171ca982718b6b96a8d2442571a2"
integrity sha512-Z6czzLq4u8fPOyx7TU6X3dvUZVvoJmxSQ+IcrlmagKhilxlhZgxPK6C5Jqbkw1IDUmFTM+cz9QDnnLTwDz/2gQ==
dependencies:
node-gyp-build "^4.3.0"
uuid@^8.3.2:
version "8.3.2"
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
webidl-conversions@^3.0.0:
version "3.0.1"
resolved "https://registry.yarnpkg.com/webidl-conversions/-/webidl-conversions-3.0.1.tgz#24534275e2a7bc6be7bc86611cc16ae0a5654871"
integrity sha512-2JAn3z8AR6rjK8Sm8orRC0h/bcl/DqL7tRPdGZ4I1CjdF+EaMLmYxBHyXuKL849eucPFhvBoxMsflfOb8kxaeQ==
whatwg-url@^5.0.0:
version "5.0.0"
resolved "https://registry.yarnpkg.com/whatwg-url/-/whatwg-url-5.0.0.tgz#966454e8765462e37644d3626f6742ce8b70965d"
integrity sha512-saE57nupxk6v3HY35+jzBwYa0rKSy0XR8JSxZPwgLr7ys0IBzhGviA1/TUGJLmSVqs8pb9AnvICXEuOHLprYTw==
dependencies:
tr46 "~0.0.3"
webidl-conversions "^3.0.0"
workerpool@6.2.1:
version "6.2.1"
resolved "https://registry.yarnpkg.com/workerpool/-/workerpool-6.2.1.tgz#46fc150c17d826b86a008e5a4508656777e9c343"
integrity sha512-ILEIE97kDZvF9Wb9f6h5aXK4swSlKGUcOEGiIYb2OOu/IrDU9iwj0fD//SsA6E5ibwJxpEvhullJY4Sl4GcpAw==
wrap-ansi@^7.0.0:
version "7.0.0"
resolved "https://registry.yarnpkg.com/wrap-ansi/-/wrap-ansi-7.0.0.tgz#67e145cff510a6a6984bdf1152911d69d2eb9e43"
integrity sha512-YVGIj2kamLSTxw6NsZjoBxfSwsn0ycdesmc4p+Q21c5zPuZ1pl+NfxVdxPtdHvmNVOQ6XSYG4AUtyt/Fi7D16Q==
dependencies:
ansi-styles "^4.0.0"
string-width "^4.1.0"
strip-ansi "^6.0.0"
wrappy@1:
version "1.0.2"
resolved "https://registry.yarnpkg.com/wrappy/-/wrappy-1.0.2.tgz#b5243d8f3ec1aa35f1364605bc0d1036e30ab69f"
integrity sha512-l4Sp/DRseor9wL6EvV2+TuQn63dMkPjZ/sp9XkghTEbV9KlPS1xUsZ3u7/IQO4wxtcFB4bgpQPRcR3QCvezPcQ==
ws@^7.4.5:
version "7.5.9"
resolved "https://registry.yarnpkg.com/ws/-/ws-7.5.9.tgz#54fa7db29f4c7cec68b1ddd3a89de099942bb591"
integrity sha512-F+P9Jil7UiSKSkppIiD94dN07AwvFixvLIj1Og1Rl9GGMuNipJnV9JzjD6XuqmAeiswGvUmNLjr5cFuXwNS77Q==
ws@^8.5.0:
version "8.12.0"
resolved "https://registry.yarnpkg.com/ws/-/ws-8.12.0.tgz#485074cc392689da78e1828a9ff23585e06cddd8"
integrity sha512-kU62emKIdKVeEIOIKVegvqpXMSTAMLJozpHZaJNDYqBjzlSYXQGviYwN1osDLJ9av68qHd4a2oSjd7yD4pacig==
y18n@^5.0.5:
version "5.0.8"
resolved "https://registry.yarnpkg.com/y18n/-/y18n-5.0.8.tgz#7f4934d0f7ca8c56f95314939ddcd2dd91ce1d55"
integrity sha512-0pfFzegeDWJHJIAmTLRP2DwHjdF5s7jo9tuztdQxAhINCdvS+3nGINqPd00AphqJR/0LhANUS6/+7SCb98YOfA==
yallist@^4.0.0:
version "4.0.0"
resolved "https://registry.yarnpkg.com/yallist/-/yallist-4.0.0.tgz#9bb92790d9c0effec63be73519e11a35019a3a72"
integrity sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==
yaml@^2.2.1:
version "2.2.1"
resolved "https://registry.yarnpkg.com/yaml/-/yaml-2.2.1.tgz#3014bf0482dcd15147aa8e56109ce8632cd60ce4"
integrity sha512-e0WHiYql7+9wr4cWMx3TVQrNwejKaEe7/rHNmQmqRjazfOP5W8PB6Jpebb5o6fIapbz9o9+2ipcaTM2ZwDI6lw==
yargs-parser@20.2.4:
version "20.2.4"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.4.tgz#b42890f14566796f85ae8e3a25290d205f154a54"
integrity sha512-WOkpgNhPTlE73h4VFAFsOnomJVaovO8VqLDzy5saChRBFQFBoMYirowyW+Q9HB4HFF4Z7VZTiG3iSzJJA29yRA==
yargs-parser@^20.2.2:
version "20.2.9"
resolved "https://registry.yarnpkg.com/yargs-parser/-/yargs-parser-20.2.9.tgz#2eb7dc3b0289718fc295f362753845c41a0c94ee"
integrity sha512-y11nGElTIV+CT3Zv9t7VKl+Q3hTQoT9a1Qzezhhl6Rp21gJ/IVTW7Z3y9EWXhuUBC2Shnf+DX0antecpAwSP8w==
yargs-unparser@2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/yargs-unparser/-/yargs-unparser-2.0.0.tgz#f131f9226911ae5d9ad38c432fe809366c2325eb"
integrity sha512-7pRTIA9Qc1caZ0bZ6RYRGbHJthJWuakf+WmHK0rVeLkNrrGhfoabBNdue6kdINI6r4if7ocq9aD/n7xwKOdzOA==
dependencies:
camelcase "^6.0.0"
decamelize "^4.0.0"
flat "^5.0.2"
is-plain-obj "^2.1.0"
yargs@16.2.0:
version "16.2.0"
resolved "https://registry.yarnpkg.com/yargs/-/yargs-16.2.0.tgz#1c82bf0f6b6a66eafce7ef30e376f49a12477f66"
integrity sha512-D1mvvtDG0L5ft/jGWkLpG1+m0eQxOfaBvTNELraWj22wSVUMWxZUvYgJYcKh6jGGIkJFhH4IZPQhR4TKpc8mBw==
dependencies:
cliui "^7.0.2"
escalade "^3.1.1"
get-caller-file "^2.0.5"
require-directory "^2.1.1"
string-width "^4.2.0"
y18n "^5.0.5"
yargs-parser "^20.2.2"
yn@^2.0.0:
version "2.0.0"
resolved "https://registry.yarnpkg.com/yn/-/yn-2.0.0.tgz#e5adabc8acf408f6385fc76495684c88e6af689a"
integrity sha512-uTv8J/wiWTgUTg+9vLTi//leUl5vDQS6uii/emeTb2ssY7vl6QWf2fFbIIGjnhjvbdKlU0ed7QPgY1htTC86jQ==
yocto-queue@^0.1.0:
version "0.1.0"
resolved "https://registry.yarnpkg.com/yocto-queue/-/yocto-queue-0.1.0.tgz#0294eb3dee05028d31ee1a5fa2c556a6aaf10a1b"
integrity sha512-rVksvsnNCdJ/ohGc6xgPwyN8eheCxsiLM8mxuE/t/mOVqJewPuO1miLpTHQiRgTKCLexL4MeAFVagts7HmNZ2Q==
| 0
|
solana_public_repos/nautilus-project/nautilus
|
solana_public_repos/nautilus-project/nautilus/tests/package.json
|
{
"name": "program-nautilus",
"version": "1.0.0",
"main": "index.js",
"license": "MIT",
"devDependencies": {
"@metaplex-foundation/solita": "^0.19.4",
"@types/chai": "^4.3.4",
"@types/mocha": "^10.0.1",
"@types/node": "^18.14.2",
"chai": "^4.3.7",
"mocha": "^10.2.0",
"ts-mocha": "^10.0.0",
"typescript": "^4.9.5"
},
"dependencies": {
"@metaplex-foundation/mpl-token-metadata": "^2.9.1",
"@solana/spl-token": "^0.3.7",
"@solana/web3.js": "^1.73.2",
"yaml": "^2.2.1"
},
"scripts": {
"test-wallets": "yarn run ts-mocha -p ./tests/tsconfig.test.json -t 1000000 ./tests/wallets/test.ts",
"test-tokens": "yarn run ts-mocha -p ./tests/tsconfig.test.json -t 1000000 ./tests/tokens/test.ts",
"test-records": "yarn run ts-mocha -p ./tests/tsconfig.test.json -t 1000000 ./tests/records/test.ts",
"test-accounts": "yarn run ts-mocha -p ./tests/tsconfig.test.json -t 1000000 ./tests/accounts/test.ts",
"all": "sh ./tests/all-tests.sh"
}
}
| 0
|
solana_public_repos/nautilus-project/nautilus/tests
|
solana_public_repos/nautilus-project/nautilus/tests/tests/const.ts
|
import { Connection, Keypair, clusterApiUrl } from '@solana/web3.js'
import fs from 'fs'
import os from 'os'
import { parse as yamlParse, stringify as yamlStringify } from 'yaml'
export const PAYER = loadKeypairFromFile(os.homedir() + '/.config/solana/id.json')
export const PROGRAM_WALLETS = loadKeypairFromFile('./programs/wallets/target/deploy/program_nautilus-keypair.json')
export const PROGRAM_TOKENS = loadKeypairFromFile('./programs/tokens/target/deploy/program_nautilus-keypair.json')
export const PROGRAM_RECORDS = loadKeypairFromFile('./programs/records/target/deploy/program_nautilus-keypair.json')
export const PROGRAM_ACCOUNTS = loadKeypairFromFile('./programs/accounts/target/deploy/program_nautilus-keypair.json')
function loadKeypairFromFile(path: string): Keypair {
return Keypair.fromSecretKey(
Buffer.from(JSON.parse(fs.readFileSync(path, "utf-8")))
)
}
const sleepSeconds = async (s: number) => await new Promise(f => setTimeout(f, s * 1000))
type TestConfigs = {
connection: Connection,
sleep: () => Promise<unknown>,
skipMetadata: boolean,
}
function getTestConfigs(): TestConfigs {
const config = yamlParse(
fs.readFileSync(os.homedir() + '/.config/solana/cli/config.yml', "utf-8")
)
const jsonRpcUrl: string = config['json_rpc_url']
const [timeDelay, skipMetadata] = jsonRpcUrl == "http://localhost:8899" ? [0 , true] : [10, false]
return {
connection: new Connection(jsonRpcUrl, "confirmed"),
sleep: () => sleepSeconds(timeDelay),
skipMetadata,
}
}
export const TEST_CONFIGS = getTestConfigs()
| 0
|
solana_public_repos/nautilus-project/nautilus/tests
|
solana_public_repos/nautilus-project/nautilus/tests/tests/tsconfig.test.json
|
{
"compilerOptions": {
"types": ["mocha", "chai"],
"typeRoots": ["./node_modules/@types"],
"lib": ["es2015"],
"module": "commonjs",
"target": "es6",
"esModuleInterop": true
}
}
| 0
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.