///
import { BN, Idl } from "@project-serum/anchor";
import Provider, { SendTxRequest } from "@project-serum/anchor/dist/provider";
import { u64 } from "@solana/spl-token";
import { Cluster, PublicKey, Signer, TransactionInstruction } from "@solana/web3.js";
import { BNIsh } from ".";
import { NonSpecificAction } from "../index";
import { PreferredTokenAccounts } from "../utils/tokens";
export declare const transactionType: readonly ["prepended", "token", "transfer", "construction", "add construction actions", "prepare construction", "action calls", "cleanup", "unknown"];
export declare type TransactionType = typeof transactionType[number];
export declare type TxRequestsTyped = {
txs: SendTxRequest[] | SendTxRequest[][];
type: TransactionType;
};
export declare type ProcessActionNext = {
construction: PublicKey;
actionProgram: PublicKey;
actionAccounts: AccountsArray;
authority: PublicKey;
rent?: PublicKey;
};
export declare type PartialNextActionCtx = {
actionProgram: PublicKey;
actionAccounts: AccountsArray;
};
export declare type MintAndTokenAccount = {
mint: PublicKey;
tokenAccount: PublicKey;
};
export declare type _NextNodeGeneric = {
actionIdx: number;
fraction: T;
nextInputMintIdx: number;
};
export declare type NextNode = _NextNodeGeneric;
export declare type NextNodeNoNextMint = Omit<_NextNodeGeneric, "nextInputMintIdx">;
export declare type ActionType = {
multiFungibleTokens?: {};
normalCpi?: {};
fungibleToken?: {};
};
export declare type ActionTypeStr = keyof ActionType;
export declare type _ActionVertexInfoGeneric = {
nextNodes: _NextNodeGeneric[][];
inputTokenIdxs: number[];
outputTokenIdxs: number[];
inDegree: number;
numberInputMints: number;
actionType: ActionType;
minOuts?: BNIsh[];
};
export declare type ActionVertexInfo = _ActionVertexInfoGeneric;
export declare type ActionVertexInfoIsolated = Omit, "inputTokenIdxs">, "outputTokenIdxs">;
/**
*
* @param addDefaultTokAccounts - If true, add the token account as the first account, then the TOKEN PID, then the authority
* as the first three accounts in the malloc sdk rather than in the return of action accounts
*
* @param instructions - Extra instructions that get called immediately prior to the call
*
* @param tokenCreationOptions - Provides the optionality of fine tuning token control. If {@code skipInTokenCreation} is set to true,
* then the token will not be created/ analyzed by the malloc sdk if there are no other actions using this mint and not skipping it. The same is true for skipOutTokenCreations.
* skipOutTokenCreations is list of indices of token outs to skip
*
* @param tokenCreationOptions.extraTokenMintsUsed - Mints not included in the input or output mints which also need associated
* token accounts created
*
* @param actionType - Assumed to be a fungible token if unspecified
*/
export declare type ActionOptions = {
instructions?: TransactionInstruction[];
additionalSigners?: Signer[];
preActionTxs?: SendTxRequest[];
addDefaultTokAccounts?: boolean;
tokenCreationOptions?: {
extraTokenMintsUsed?: PublicKey[];
skipInTokenCreation?: boolean;
skipOutTokenCreations?: number[];
};
atStartOfPrepareTxs?: SendTxRequest[];
actionType?: ActionType;
checks?: {
skipInTokenChecks?: boolean;
skipOutTokenChecks?: boolean;
};
};
/**
* An action which does not require the action so vertex info can be inserted in the future
*/
export declare type IsolatedAction = {
actionData: Buffer;
actionAccounts: AccountsArray;
actionProgram: PublicKey;
tokenMintOuts: PublicKey[];
opts?: ActionOptions;
};
export interface IsolatedActionWithNonSpecific extends IsolatedAction {
nonSpecificAction: NonSpecificAction;
actionName: string;
}
/**
* The frontend facing Action interface, the library accepts this type as input
*
* @param actionTypeUID - A unique ID for an action type. An example would be "MALLOC_SPL_SWAP"
* or some other unique id associated to the program
*
* @param tokenOuts - The token out accounts. This is optional and will get prepended
* to actionAccounts if it is given
*
* @param tokenAccountIn - an optional parameter which can be left undefined if the action does not interact/ need an input token account
* (Like an action which mints new tokens)
*
*/
export interface Action extends IsolatedActionWithNonSpecific {
actionTypeUID: string;
actionVertexInfo: ActionVertexInfo;
tokenMintsIn: PublicKey[];
tokenAccountOuts: PublicKey[];
inputTokenAccounts: PublicKey[];
nonSpecificAction: NonSpecificAction;
estimateOuts: MintWithAmount[];
estimateIns: MintWithAmount[];
}
/**
* @param actionOrders - the order of actions to hit. The outer array
* corresponds to a series of actions to hit in separate transactions with
* the inner array corresponding to groupings by instructions
*/
export declare type Construction = {
actions: Action[];
initialSplits: number[];
initialActionIndices: number[];
amountIns: BN[];
actionOrders: number[][];
};
export declare type BuildIsolatedActionFnOpts = {
inputOverrides?: Partial;
preferredTokenAccounts?: PreferredTokenAccounts;
};
export declare type BuildIsolateActionConfig = {
cluster: Cluster;
};
export declare type MintWithAmount = {
mint: PK;
amount: T;
};
export declare type EstimateOutFN = ((amountIn: MintWithAmount[]) => MintWithAmount[]) | ((amountIn: MintWithAmount[]) => Promise[]>);
export declare type BuildIsolatedActionParams = {
inp: T;
inputTokens: MintAndTokenAccount[];
actionPID: PublicKey;
provider: Provider;
authority: PublicKey;
config: BuildIsolateActionConfig;
opts?: BuildIsolatedActionFnOpts;
};
/**
* A standard interface which action libraries should implement
*/
export declare type BuildIsolatedActionFn = (buildActionParams: BuildIsolatedActionParams) => Promise<{
isolatedAction: IsolatedAction;
estimateOuts: EstimateOutFN;
extra?: any;
}>;
/**
* A standard interface for action libraries to implement
*
* @param buildIsolatedAction - a function to build an action from the inputs
* @param actionTypeUID - a unique ID for each action type. I.e. swap could be "swap", transfer can be "transfer", etc
*/
export interface ActionLib {
buildIsolatedAction: BuildIsolatedActionFn;
expectedNumberOutMints: number;
actionTypeUID: string;
idl?: Idl;
}
export declare type AccountsArray = {
address: PublicKey;
isSigner?: boolean;
isWriteable?: boolean;
}[];