@pina-rs/amm 0.0.0 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +27 -2
- package/dist/index.cjs +1257 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +1752 -0
- package/dist/index.d.ts +1752 -0
- package/dist/index.js +1078 -0
- package/dist/index.js.map +1 -0
- package/package.json +57 -8
- package/src/generated/accounts/ammConfig.ts +197 -0
- package/src/generated/accounts/index.ts +10 -0
- package/src/generated/accounts/pool.ts +218 -0
- package/src/generated/errors/index.ts +9 -0
- package/src/generated/errors/pinaAmm.ts +64 -0
- package/src/generated/events/feesCollected.ts +64 -0
- package/src/generated/events/index.ts +13 -0
- package/src/generated/events/liquidityChanged.ts +72 -0
- package/src/generated/events/logs.ts +372 -0
- package/src/generated/events/poolCreated.ts +80 -0
- package/src/generated/events/swapped.ts +100 -0
- package/src/generated/index.ts +14 -0
- package/src/generated/instructions/collectCreatorFees.ts +119 -0
- package/src/generated/instructions/collectProtocolFees.ts +123 -0
- package/src/generated/instructions/createConfig.ts +142 -0
- package/src/generated/instructions/createPool.ts +291 -0
- package/src/generated/instructions/deposit.ts +139 -0
- package/src/generated/instructions/index.ts +19 -0
- package/src/generated/instructions/migrate.ts +155 -0
- package/src/generated/instructions/setPoolCreator.ts +90 -0
- package/src/generated/instructions/swapExactIn.ts +119 -0
- package/src/generated/instructions/swapExactOut.ts +119 -0
- package/src/generated/instructions/updateConfig.ts +105 -0
- package/src/generated/instructions/withdraw.ts +139 -0
- package/src/generated/pdas/ammConfig.ts +18 -0
- package/src/generated/pdas/index.ts +12 -0
- package/src/generated/pdas/pool.ts +20 -0
- package/src/generated/pdas/poolLpMint.ts +18 -0
- package/src/generated/pdas/poolVault.ts +19 -0
- package/src/generated/pinaPodCodecs.ts +232 -0
- package/src/generated/programs/index.ts +9 -0
- package/src/generated/programs/pinaAmm.ts +115 -0
- package/src/index.ts +11 -0
- package/CHANGELOG.md +0 -5
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { getPinaPodDiscriminatorDecoder } from "../pinaPodCodecs";
|
|
10
|
+
import { combineCodec, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, type ReadonlyUint8Array, type WritableAccount } from '@solana/kit';
|
|
11
|
+
import { getAccountMetaFactory, type InstructionAccountInput, type InstructionAccountInputAddress, type InstructionSignerInput, type ResolvedInstructionAccount, type ResolvedInstructionAccountMeta } from '@solana/program-client-core';
|
|
12
|
+
import { PINA_AMM_PROGRAM_ADDRESS } from '../programs';
|
|
13
|
+
|
|
14
|
+
export const COLLECT_CREATOR_FEES_DISCRIMINATOR = 8;
|
|
15
|
+
|
|
16
|
+
export function getCollectCreatorFeesDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(COLLECT_CREATOR_FEES_DISCRIMINATOR); }
|
|
17
|
+
|
|
18
|
+
export type CollectCreatorFeesInstruction<TProgram extends string = typeof PINA_AMM_PROGRAM_ADDRESS, TAccountCreator extends string | AccountMeta<string> = string, TAccountPool extends string | AccountMeta<string> = string, TAccountVault0 extends string | AccountMeta<string> = string, TAccountVault1 extends string | AccountMeta<string> = string, TAccountRecipientToken0 extends string | AccountMeta<string> = string, TAccountRecipientToken1 extends string | AccountMeta<string> = string, TAccountTokenProgram0 extends string | AccountMeta<string> = string, TAccountTokenProgram1 extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
|
|
19
|
+
Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountCreator extends string ? ReadonlySignerAccount<TAccountCreator> & AccountSignerMeta<TAccountCreator> : TAccountCreator, TAccountPool extends string ? WritableAccount<TAccountPool> : TAccountPool, TAccountVault0 extends string ? WritableAccount<TAccountVault0> : TAccountVault0, TAccountVault1 extends string ? WritableAccount<TAccountVault1> : TAccountVault1, TAccountRecipientToken0 extends string ? WritableAccount<TAccountRecipientToken0> : TAccountRecipientToken0, TAccountRecipientToken1 extends string ? WritableAccount<TAccountRecipientToken1> : TAccountRecipientToken1, TAccountTokenProgram0 extends string ? ReadonlyAccount<TAccountTokenProgram0> : TAccountTokenProgram0, TAccountTokenProgram1 extends string ? ReadonlyAccount<TAccountTokenProgram1> : TAccountTokenProgram1, ...TRemainingAccounts]>;
|
|
20
|
+
|
|
21
|
+
export type CollectCreatorFeesInstructionData = { discriminator: number;
|
|
22
|
+
/** Most token 0 to collect; `u64::MAX` collects everything accrued. */
|
|
23
|
+
maximumAmount0: bigint;
|
|
24
|
+
/** Most token 1 to collect; `u64::MAX` collects everything accrued. */
|
|
25
|
+
maximumAmount1: bigint; };
|
|
26
|
+
|
|
27
|
+
export type CollectCreatorFeesInstructionDataArgs = {
|
|
28
|
+
/** Most token 0 to collect; `u64::MAX` collects everything accrued. */
|
|
29
|
+
maximumAmount0: number | bigint;
|
|
30
|
+
/** Most token 1 to collect; `u64::MAX` collects everything accrued. */
|
|
31
|
+
maximumAmount1: number | bigint; };
|
|
32
|
+
|
|
33
|
+
export function getCollectCreatorFeesInstructionDataEncoder(): FixedSizeEncoder<CollectCreatorFeesInstructionDataArgs> {
|
|
34
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['maximumAmount0', getU64Encoder()], ['maximumAmount1', getU64Encoder()]]), (value) => ({ ...value, discriminator: 8 }));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function getCollectCreatorFeesInstructionDataDecoder(): FixedSizeDecoder<CollectCreatorFeesInstructionData> {
|
|
38
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(COLLECT_CREATOR_FEES_DISCRIMINATOR, getU8Decoder())], ['maximumAmount0', getU64Decoder()], ['maximumAmount1', getU64Decoder()]]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getCollectCreatorFeesInstructionDataCodec(): FixedSizeCodec<CollectCreatorFeesInstructionDataArgs, CollectCreatorFeesInstructionData> {
|
|
42
|
+
return combineCodec(getCollectCreatorFeesInstructionDataEncoder(), getCollectCreatorFeesInstructionDataDecoder());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type CollectCreatorFeesInput<TAccountCreator extends InstructionSignerInput = InstructionSignerInput, TAccountPool extends InstructionAccountInput = InstructionAccountInput, TAccountVault0 extends InstructionAccountInput = InstructionAccountInput, TAccountVault1 extends InstructionAccountInput = InstructionAccountInput, TAccountRecipientToken0 extends InstructionAccountInput = InstructionAccountInput, TAccountRecipientToken1 extends InstructionAccountInput = InstructionAccountInput, TAccountTokenProgram0 extends InstructionAccountInput = InstructionAccountInput, TAccountTokenProgram1 extends InstructionAccountInput = InstructionAccountInput> = {
|
|
46
|
+
/** The pool's creator. */
|
|
47
|
+
creator: TAccountCreator;
|
|
48
|
+
/** The pool. */
|
|
49
|
+
pool: TAccountPool;
|
|
50
|
+
/** The pool's token 0 vault. */
|
|
51
|
+
vault0: TAccountVault0;
|
|
52
|
+
/** The pool's token 1 vault. */
|
|
53
|
+
vault1: TAccountVault1;
|
|
54
|
+
/** Token 0 account that receives the fees. */
|
|
55
|
+
recipientToken0: TAccountRecipientToken0;
|
|
56
|
+
/** Token 1 account that receives the fees. */
|
|
57
|
+
recipientToken1: TAccountRecipientToken1;
|
|
58
|
+
/** Token program that owns token 0. */
|
|
59
|
+
tokenProgram0: TAccountTokenProgram0;
|
|
60
|
+
/** Token program that owns token 1. */
|
|
61
|
+
tokenProgram1: TAccountTokenProgram1;
|
|
62
|
+
maximumAmount0: CollectCreatorFeesInstructionDataArgs["maximumAmount0"];
|
|
63
|
+
maximumAmount1: CollectCreatorFeesInstructionDataArgs["maximumAmount1"];
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
export function getCollectCreatorFeesInstruction<TAccountCreator extends InstructionSignerInput, TAccountPool extends InstructionAccountInput, TAccountVault0 extends InstructionAccountInput, TAccountVault1 extends InstructionAccountInput, TAccountRecipientToken0 extends InstructionAccountInput, TAccountRecipientToken1 extends InstructionAccountInput, TAccountTokenProgram0 extends InstructionAccountInput, TAccountTokenProgram1 extends InstructionAccountInput, TProgramAddress extends Address = typeof PINA_AMM_PROGRAM_ADDRESS>(input: CollectCreatorFeesInput<TAccountCreator, TAccountPool, TAccountVault0, TAccountVault1, TAccountRecipientToken0, TAccountRecipientToken1, TAccountTokenProgram0, TAccountTokenProgram1>, config?: { programAddress?: TProgramAddress } ): CollectCreatorFeesInstruction<TProgramAddress, ResolvedInstructionAccountMeta<TAccountCreator, InstructionAccountInputAddress<TAccountCreator>>, ResolvedInstructionAccountMeta<TAccountPool, InstructionAccountInputAddress<TAccountPool>>, ResolvedInstructionAccountMeta<TAccountVault0, InstructionAccountInputAddress<TAccountVault0>>, ResolvedInstructionAccountMeta<TAccountVault1, InstructionAccountInputAddress<TAccountVault1>>, ResolvedInstructionAccountMeta<TAccountRecipientToken0, InstructionAccountInputAddress<TAccountRecipientToken0>>, ResolvedInstructionAccountMeta<TAccountRecipientToken1, InstructionAccountInputAddress<TAccountRecipientToken1>>, ResolvedInstructionAccountMeta<TAccountTokenProgram0, InstructionAccountInputAddress<TAccountTokenProgram0>>, ResolvedInstructionAccountMeta<TAccountTokenProgram1, InstructionAccountInputAddress<TAccountTokenProgram1>>> {
|
|
67
|
+
// Program address.
|
|
68
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
69
|
+
|
|
70
|
+
// Account meta helper.
|
|
71
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
72
|
+
|
|
73
|
+
// Original accounts.
|
|
74
|
+
const originalAccounts = { creator: { value: input.creator ?? null, isSigner: true, isWritable: false }, pool: { value: input.pool ?? null, isSigner: false, isWritable: true }, vault0: { value: input.vault0 ?? null, isSigner: false, isWritable: true }, vault1: { value: input.vault1 ?? null, isSigner: false, isWritable: true }, recipientToken0: { value: input.recipientToken0 ?? null, isSigner: false, isWritable: true }, recipientToken1: { value: input.recipientToken1 ?? null, isSigner: false, isWritable: true }, tokenProgram0: { value: input.tokenProgram0 ?? null, isSigner: false, isWritable: false }, tokenProgram1: { value: input.tokenProgram1 ?? null, isSigner: false, isWritable: false } }
|
|
75
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
// Original args.
|
|
79
|
+
const args = { ...input, };
|
|
80
|
+
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
return Object.freeze({ accounts: [getAccountMeta("creator", accounts.creator), getAccountMeta("pool", accounts.pool), getAccountMeta("vault0", accounts.vault0), getAccountMeta("vault1", accounts.vault1), getAccountMeta("recipientToken0", accounts.recipientToken0), getAccountMeta("recipientToken1", accounts.recipientToken1), getAccountMeta("tokenProgram0", accounts.tokenProgram0), getAccountMeta("tokenProgram1", accounts.tokenProgram1)], data: getCollectCreatorFeesInstructionDataEncoder().encode(args as CollectCreatorFeesInstructionDataArgs), programAddress } as CollectCreatorFeesInstruction<TProgramAddress, ResolvedInstructionAccountMeta<TAccountCreator, InstructionAccountInputAddress<TAccountCreator>>, ResolvedInstructionAccountMeta<TAccountPool, InstructionAccountInputAddress<TAccountPool>>, ResolvedInstructionAccountMeta<TAccountVault0, InstructionAccountInputAddress<TAccountVault0>>, ResolvedInstructionAccountMeta<TAccountVault1, InstructionAccountInputAddress<TAccountVault1>>, ResolvedInstructionAccountMeta<TAccountRecipientToken0, InstructionAccountInputAddress<TAccountRecipientToken0>>, ResolvedInstructionAccountMeta<TAccountRecipientToken1, InstructionAccountInputAddress<TAccountRecipientToken1>>, ResolvedInstructionAccountMeta<TAccountTokenProgram0, InstructionAccountInputAddress<TAccountTokenProgram0>>, ResolvedInstructionAccountMeta<TAccountTokenProgram1, InstructionAccountInputAddress<TAccountTokenProgram1>>>);
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
export type ParsedCollectCreatorFeesInstruction<TProgram extends string = typeof PINA_AMM_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
88
|
+
accounts: {
|
|
89
|
+
/** The pool's creator. */
|
|
90
|
+
creator: TAccountMetas[0];
|
|
91
|
+
/** The pool. */
|
|
92
|
+
pool: TAccountMetas[1];
|
|
93
|
+
/** The pool's token 0 vault. */
|
|
94
|
+
vault0: TAccountMetas[2];
|
|
95
|
+
/** The pool's token 1 vault. */
|
|
96
|
+
vault1: TAccountMetas[3];
|
|
97
|
+
/** Token 0 account that receives the fees. */
|
|
98
|
+
recipientToken0: TAccountMetas[4];
|
|
99
|
+
/** Token 1 account that receives the fees. */
|
|
100
|
+
recipientToken1: TAccountMetas[5];
|
|
101
|
+
/** Token program that owns token 0. */
|
|
102
|
+
tokenProgram0: TAccountMetas[6];
|
|
103
|
+
/** Token program that owns token 1. */
|
|
104
|
+
tokenProgram1: TAccountMetas[7];
|
|
105
|
+
};
|
|
106
|
+
data: CollectCreatorFeesInstructionData; };
|
|
107
|
+
|
|
108
|
+
export function parseCollectCreatorFeesInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedCollectCreatorFeesInstruction<TProgram, TAccountMetas> {
|
|
109
|
+
if (instruction.accounts.length < 8) {
|
|
110
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 8 });
|
|
111
|
+
}
|
|
112
|
+
let accountIndex = 0;
|
|
113
|
+
const getNextAccount = () => {
|
|
114
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
115
|
+
accountIndex += 1;
|
|
116
|
+
return accountMeta;
|
|
117
|
+
}
|
|
118
|
+
return { programAddress: instruction.programAddress, accounts: { creator: getNextAccount(), pool: getNextAccount(), vault0: getNextAccount(), vault1: getNextAccount(), recipientToken0: getNextAccount(), recipientToken1: getNextAccount(), tokenProgram0: getNextAccount(), tokenProgram1: getNextAccount() }, data: getCollectCreatorFeesInstructionDataDecoder().decode(instruction.data) };
|
|
119
|
+
}
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { getPinaPodDiscriminatorDecoder } from "../pinaPodCodecs";
|
|
10
|
+
import { combineCodec, getStructDecoder, getStructEncoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, type ReadonlyUint8Array, type WritableAccount } from '@solana/kit';
|
|
11
|
+
import { getAccountMetaFactory, type InstructionAccountInput, type InstructionAccountInputAddress, type InstructionSignerInput, type ResolvedInstructionAccount, type ResolvedInstructionAccountMeta } from '@solana/program-client-core';
|
|
12
|
+
import { PINA_AMM_PROGRAM_ADDRESS } from '../programs';
|
|
13
|
+
|
|
14
|
+
export const COLLECT_PROTOCOL_FEES_DISCRIMINATOR = 7;
|
|
15
|
+
|
|
16
|
+
export function getCollectProtocolFeesDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(COLLECT_PROTOCOL_FEES_DISCRIMINATOR); }
|
|
17
|
+
|
|
18
|
+
export type CollectProtocolFeesInstruction<TProgram extends string = typeof PINA_AMM_PROGRAM_ADDRESS, TAccountAuthority extends string | AccountMeta<string> = string, TAccountAmmConfig extends string | AccountMeta<string> = string, TAccountPool extends string | AccountMeta<string> = string, TAccountVault0 extends string | AccountMeta<string> = string, TAccountVault1 extends string | AccountMeta<string> = string, TAccountRecipientToken0 extends string | AccountMeta<string> = string, TAccountRecipientToken1 extends string | AccountMeta<string> = string, TAccountTokenProgram0 extends string | AccountMeta<string> = string, TAccountTokenProgram1 extends string | AccountMeta<string> = string, TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
|
|
19
|
+
Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountAuthority extends string ? ReadonlySignerAccount<TAccountAuthority> & AccountSignerMeta<TAccountAuthority> : TAccountAuthority, TAccountAmmConfig extends string ? ReadonlyAccount<TAccountAmmConfig> : TAccountAmmConfig, TAccountPool extends string ? WritableAccount<TAccountPool> : TAccountPool, TAccountVault0 extends string ? WritableAccount<TAccountVault0> : TAccountVault0, TAccountVault1 extends string ? WritableAccount<TAccountVault1> : TAccountVault1, TAccountRecipientToken0 extends string ? WritableAccount<TAccountRecipientToken0> : TAccountRecipientToken0, TAccountRecipientToken1 extends string ? WritableAccount<TAccountRecipientToken1> : TAccountRecipientToken1, TAccountTokenProgram0 extends string ? ReadonlyAccount<TAccountTokenProgram0> : TAccountTokenProgram0, TAccountTokenProgram1 extends string ? ReadonlyAccount<TAccountTokenProgram1> : TAccountTokenProgram1, ...TRemainingAccounts]>;
|
|
20
|
+
|
|
21
|
+
export type CollectProtocolFeesInstructionData = { discriminator: number;
|
|
22
|
+
/** Most token 0 to collect; `u64::MAX` collects everything accrued. */
|
|
23
|
+
maximumAmount0: bigint;
|
|
24
|
+
/** Most token 1 to collect; `u64::MAX` collects everything accrued. */
|
|
25
|
+
maximumAmount1: bigint; };
|
|
26
|
+
|
|
27
|
+
export type CollectProtocolFeesInstructionDataArgs = {
|
|
28
|
+
/** Most token 0 to collect; `u64::MAX` collects everything accrued. */
|
|
29
|
+
maximumAmount0: number | bigint;
|
|
30
|
+
/** Most token 1 to collect; `u64::MAX` collects everything accrued. */
|
|
31
|
+
maximumAmount1: number | bigint; };
|
|
32
|
+
|
|
33
|
+
export function getCollectProtocolFeesInstructionDataEncoder(): FixedSizeEncoder<CollectProtocolFeesInstructionDataArgs> {
|
|
34
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['maximumAmount0', getU64Encoder()], ['maximumAmount1', getU64Encoder()]]), (value) => ({ ...value, discriminator: 7 }));
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
export function getCollectProtocolFeesInstructionDataDecoder(): FixedSizeDecoder<CollectProtocolFeesInstructionData> {
|
|
38
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(COLLECT_PROTOCOL_FEES_DISCRIMINATOR, getU8Decoder())], ['maximumAmount0', getU64Decoder()], ['maximumAmount1', getU64Decoder()]]);
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
export function getCollectProtocolFeesInstructionDataCodec(): FixedSizeCodec<CollectProtocolFeesInstructionDataArgs, CollectProtocolFeesInstructionData> {
|
|
42
|
+
return combineCodec(getCollectProtocolFeesInstructionDataEncoder(), getCollectProtocolFeesInstructionDataDecoder());
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
export type CollectProtocolFeesInput<TAccountAuthority extends InstructionSignerInput = InstructionSignerInput, TAccountAmmConfig extends InstructionAccountInput = InstructionAccountInput, TAccountPool extends InstructionAccountInput = InstructionAccountInput, TAccountVault0 extends InstructionAccountInput = InstructionAccountInput, TAccountVault1 extends InstructionAccountInput = InstructionAccountInput, TAccountRecipientToken0 extends InstructionAccountInput = InstructionAccountInput, TAccountRecipientToken1 extends InstructionAccountInput = InstructionAccountInput, TAccountTokenProgram0 extends InstructionAccountInput = InstructionAccountInput, TAccountTokenProgram1 extends InstructionAccountInput = InstructionAccountInput> = {
|
|
46
|
+
/** The pool's fee-tier authority. */
|
|
47
|
+
authority: TAccountAuthority;
|
|
48
|
+
/** The pool's fee tier. */
|
|
49
|
+
ammConfig: TAccountAmmConfig;
|
|
50
|
+
/** The pool. */
|
|
51
|
+
pool: TAccountPool;
|
|
52
|
+
/** The pool's token 0 vault. */
|
|
53
|
+
vault0: TAccountVault0;
|
|
54
|
+
/** The pool's token 1 vault. */
|
|
55
|
+
vault1: TAccountVault1;
|
|
56
|
+
/** Token 0 account that receives the fees. */
|
|
57
|
+
recipientToken0: TAccountRecipientToken0;
|
|
58
|
+
/** Token 1 account that receives the fees. */
|
|
59
|
+
recipientToken1: TAccountRecipientToken1;
|
|
60
|
+
/** Token program that owns token 0. */
|
|
61
|
+
tokenProgram0: TAccountTokenProgram0;
|
|
62
|
+
/** Token program that owns token 1. */
|
|
63
|
+
tokenProgram1: TAccountTokenProgram1;
|
|
64
|
+
maximumAmount0: CollectProtocolFeesInstructionDataArgs["maximumAmount0"];
|
|
65
|
+
maximumAmount1: CollectProtocolFeesInstructionDataArgs["maximumAmount1"];
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
export function getCollectProtocolFeesInstruction<TAccountAuthority extends InstructionSignerInput, TAccountAmmConfig extends InstructionAccountInput, TAccountPool extends InstructionAccountInput, TAccountVault0 extends InstructionAccountInput, TAccountVault1 extends InstructionAccountInput, TAccountRecipientToken0 extends InstructionAccountInput, TAccountRecipientToken1 extends InstructionAccountInput, TAccountTokenProgram0 extends InstructionAccountInput, TAccountTokenProgram1 extends InstructionAccountInput, TProgramAddress extends Address = typeof PINA_AMM_PROGRAM_ADDRESS>(input: CollectProtocolFeesInput<TAccountAuthority, TAccountAmmConfig, TAccountPool, TAccountVault0, TAccountVault1, TAccountRecipientToken0, TAccountRecipientToken1, TAccountTokenProgram0, TAccountTokenProgram1>, config?: { programAddress?: TProgramAddress } ): CollectProtocolFeesInstruction<TProgramAddress, ResolvedInstructionAccountMeta<TAccountAuthority, InstructionAccountInputAddress<TAccountAuthority>>, ResolvedInstructionAccountMeta<TAccountAmmConfig, InstructionAccountInputAddress<TAccountAmmConfig>>, ResolvedInstructionAccountMeta<TAccountPool, InstructionAccountInputAddress<TAccountPool>>, ResolvedInstructionAccountMeta<TAccountVault0, InstructionAccountInputAddress<TAccountVault0>>, ResolvedInstructionAccountMeta<TAccountVault1, InstructionAccountInputAddress<TAccountVault1>>, ResolvedInstructionAccountMeta<TAccountRecipientToken0, InstructionAccountInputAddress<TAccountRecipientToken0>>, ResolvedInstructionAccountMeta<TAccountRecipientToken1, InstructionAccountInputAddress<TAccountRecipientToken1>>, ResolvedInstructionAccountMeta<TAccountTokenProgram0, InstructionAccountInputAddress<TAccountTokenProgram0>>, ResolvedInstructionAccountMeta<TAccountTokenProgram1, InstructionAccountInputAddress<TAccountTokenProgram1>>> {
|
|
69
|
+
// Program address.
|
|
70
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
71
|
+
|
|
72
|
+
// Account meta helper.
|
|
73
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
74
|
+
|
|
75
|
+
// Original accounts.
|
|
76
|
+
const originalAccounts = { authority: { value: input.authority ?? null, isSigner: true, isWritable: false }, ammConfig: { value: input.ammConfig ?? null, isSigner: false, isWritable: false }, pool: { value: input.pool ?? null, isSigner: false, isWritable: true }, vault0: { value: input.vault0 ?? null, isSigner: false, isWritable: true }, vault1: { value: input.vault1 ?? null, isSigner: false, isWritable: true }, recipientToken0: { value: input.recipientToken0 ?? null, isSigner: false, isWritable: true }, recipientToken1: { value: input.recipientToken1 ?? null, isSigner: false, isWritable: true }, tokenProgram0: { value: input.tokenProgram0 ?? null, isSigner: false, isWritable: false }, tokenProgram1: { value: input.tokenProgram1 ?? null, isSigner: false, isWritable: false } }
|
|
77
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
78
|
+
|
|
79
|
+
|
|
80
|
+
// Original args.
|
|
81
|
+
const args = { ...input, };
|
|
82
|
+
|
|
83
|
+
|
|
84
|
+
|
|
85
|
+
|
|
86
|
+
return Object.freeze({ accounts: [getAccountMeta("authority", accounts.authority), getAccountMeta("ammConfig", accounts.ammConfig), getAccountMeta("pool", accounts.pool), getAccountMeta("vault0", accounts.vault0), getAccountMeta("vault1", accounts.vault1), getAccountMeta("recipientToken0", accounts.recipientToken0), getAccountMeta("recipientToken1", accounts.recipientToken1), getAccountMeta("tokenProgram0", accounts.tokenProgram0), getAccountMeta("tokenProgram1", accounts.tokenProgram1)], data: getCollectProtocolFeesInstructionDataEncoder().encode(args as CollectProtocolFeesInstructionDataArgs), programAddress } as CollectProtocolFeesInstruction<TProgramAddress, ResolvedInstructionAccountMeta<TAccountAuthority, InstructionAccountInputAddress<TAccountAuthority>>, ResolvedInstructionAccountMeta<TAccountAmmConfig, InstructionAccountInputAddress<TAccountAmmConfig>>, ResolvedInstructionAccountMeta<TAccountPool, InstructionAccountInputAddress<TAccountPool>>, ResolvedInstructionAccountMeta<TAccountVault0, InstructionAccountInputAddress<TAccountVault0>>, ResolvedInstructionAccountMeta<TAccountVault1, InstructionAccountInputAddress<TAccountVault1>>, ResolvedInstructionAccountMeta<TAccountRecipientToken0, InstructionAccountInputAddress<TAccountRecipientToken0>>, ResolvedInstructionAccountMeta<TAccountRecipientToken1, InstructionAccountInputAddress<TAccountRecipientToken1>>, ResolvedInstructionAccountMeta<TAccountTokenProgram0, InstructionAccountInputAddress<TAccountTokenProgram0>>, ResolvedInstructionAccountMeta<TAccountTokenProgram1, InstructionAccountInputAddress<TAccountTokenProgram1>>>);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export type ParsedCollectProtocolFeesInstruction<TProgram extends string = typeof PINA_AMM_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
90
|
+
accounts: {
|
|
91
|
+
/** The pool's fee-tier authority. */
|
|
92
|
+
authority: TAccountMetas[0];
|
|
93
|
+
/** The pool's fee tier. */
|
|
94
|
+
ammConfig: TAccountMetas[1];
|
|
95
|
+
/** The pool. */
|
|
96
|
+
pool: TAccountMetas[2];
|
|
97
|
+
/** The pool's token 0 vault. */
|
|
98
|
+
vault0: TAccountMetas[3];
|
|
99
|
+
/** The pool's token 1 vault. */
|
|
100
|
+
vault1: TAccountMetas[4];
|
|
101
|
+
/** Token 0 account that receives the fees. */
|
|
102
|
+
recipientToken0: TAccountMetas[5];
|
|
103
|
+
/** Token 1 account that receives the fees. */
|
|
104
|
+
recipientToken1: TAccountMetas[6];
|
|
105
|
+
/** Token program that owns token 0. */
|
|
106
|
+
tokenProgram0: TAccountMetas[7];
|
|
107
|
+
/** Token program that owns token 1. */
|
|
108
|
+
tokenProgram1: TAccountMetas[8];
|
|
109
|
+
};
|
|
110
|
+
data: CollectProtocolFeesInstructionData; };
|
|
111
|
+
|
|
112
|
+
export function parseCollectProtocolFeesInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedCollectProtocolFeesInstruction<TProgram, TAccountMetas> {
|
|
113
|
+
if (instruction.accounts.length < 9) {
|
|
114
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 9 });
|
|
115
|
+
}
|
|
116
|
+
let accountIndex = 0;
|
|
117
|
+
const getNextAccount = () => {
|
|
118
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
119
|
+
accountIndex += 1;
|
|
120
|
+
return accountMeta;
|
|
121
|
+
}
|
|
122
|
+
return { programAddress: instruction.programAddress, accounts: { authority: getNextAccount(), ammConfig: getNextAccount(), pool: getNextAccount(), vault0: getNextAccount(), vault1: getNextAccount(), recipientToken0: getNextAccount(), recipientToken1: getNextAccount(), tokenProgram0: getNextAccount(), tokenProgram1: getNextAccount() }, data: getCollectProtocolFeesInstructionDataDecoder().decode(instruction.data) };
|
|
123
|
+
}
|
|
@@ -0,0 +1,142 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* This code was AUTOGENERATED using the Codama library.
|
|
3
|
+
* Please DO NOT EDIT THIS FILE, instead use visitors
|
|
4
|
+
* to add features, then rerun Codama to update it.
|
|
5
|
+
*
|
|
6
|
+
* @see https://github.com/codama-idl/codama
|
|
7
|
+
*/
|
|
8
|
+
|
|
9
|
+
import { getPinaPodDiscriminatorDecoder } from "../pinaPodCodecs";
|
|
10
|
+
import { combineCodec, getAddressDecoder, getAddressEncoder, getStructDecoder, getStructEncoder, getU16Decoder, getU16Encoder, getU32Decoder, getU32Encoder, getU8Decoder, getU8Encoder, SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, SolanaError, transformEncoder, type AccountMeta, type AccountSignerMeta, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type Instruction, type InstructionWithAccounts, type InstructionWithData, type ReadonlyAccount, type ReadonlySignerAccount, type ReadonlyUint8Array, type WritableAccount, type WritableSignerAccount } from '@solana/kit';
|
|
11
|
+
import { getAccountMetaFactory, type InstructionAccountInput, type InstructionAccountInputAddress, type InstructionSignerInput, type ResolvedInstructionAccount, type ResolvedInstructionAccountMeta } from '@solana/program-client-core';
|
|
12
|
+
import { PINA_AMM_PROGRAM_ADDRESS } from '../programs';
|
|
13
|
+
|
|
14
|
+
export const CREATE_CONFIG_DISCRIMINATOR = 0;
|
|
15
|
+
|
|
16
|
+
export function getCreateConfigDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(CREATE_CONFIG_DISCRIMINATOR); }
|
|
17
|
+
|
|
18
|
+
export type CreateConfigInstruction<TProgram extends string = typeof PINA_AMM_PROGRAM_ADDRESS, TAccountPayer extends string | AccountMeta<string> = string, TAccountUpgradeAuthority extends string | AccountMeta<string> = string, TAccountProgramData extends string | AccountMeta<string> = string, TAccountAmmConfig extends string | AccountMeta<string> = string, TAccountSystemProgram extends string | AccountMeta<string> = "11111111111111111111111111111111", TRemainingAccounts extends readonly AccountMeta<string>[] = []> =
|
|
19
|
+
Instruction<TProgram> & InstructionWithData<ReadonlyUint8Array> & InstructionWithAccounts<[TAccountPayer extends string ? WritableSignerAccount<TAccountPayer> & AccountSignerMeta<TAccountPayer> : TAccountPayer, TAccountUpgradeAuthority extends string ? ReadonlySignerAccount<TAccountUpgradeAuthority> & AccountSignerMeta<TAccountUpgradeAuthority> : TAccountUpgradeAuthority, TAccountProgramData extends string ? ReadonlyAccount<TAccountProgramData> : TAccountProgramData, TAccountAmmConfig extends string ? WritableAccount<TAccountAmmConfig> : TAccountAmmConfig, TAccountSystemProgram extends string ? ReadonlyAccount<TAccountSystemProgram> : TAccountSystemProgram, ...TRemainingAccounts]>;
|
|
20
|
+
|
|
21
|
+
export type CreateConfigInstructionData = { discriminator: number;
|
|
22
|
+
/** Tier index; also the PDA seed. */
|
|
23
|
+
index: number;
|
|
24
|
+
/** Swap fee in parts per million. */
|
|
25
|
+
tradeFeeRate: number;
|
|
26
|
+
/** Protocol share of the trade fee in parts per million. */
|
|
27
|
+
protocolFeeRate: number;
|
|
28
|
+
/** Creator fee in parts per million. */
|
|
29
|
+
creatorFeeRate: number;
|
|
30
|
+
/** Signer that may update the tier and collect its protocol fees. */
|
|
31
|
+
authority: Address;
|
|
32
|
+
/**
|
|
33
|
+
* The only signer allowed to create pools in this tier, or the default
|
|
34
|
+
* address to let anyone create pools.
|
|
35
|
+
*/
|
|
36
|
+
poolCreatorAuthority: Address; };
|
|
37
|
+
|
|
38
|
+
export type CreateConfigInstructionDataArgs = {
|
|
39
|
+
/** Tier index; also the PDA seed. */
|
|
40
|
+
index: number;
|
|
41
|
+
/** Swap fee in parts per million. */
|
|
42
|
+
tradeFeeRate: number;
|
|
43
|
+
/** Protocol share of the trade fee in parts per million. */
|
|
44
|
+
protocolFeeRate: number;
|
|
45
|
+
/** Creator fee in parts per million. */
|
|
46
|
+
creatorFeeRate: number;
|
|
47
|
+
/** Signer that may update the tier and collect its protocol fees. */
|
|
48
|
+
authority: Address;
|
|
49
|
+
/**
|
|
50
|
+
* The only signer allowed to create pools in this tier, or the default
|
|
51
|
+
* address to let anyone create pools.
|
|
52
|
+
*/
|
|
53
|
+
poolCreatorAuthority: Address; };
|
|
54
|
+
|
|
55
|
+
export function getCreateConfigInstructionDataEncoder(): FixedSizeEncoder<CreateConfigInstructionDataArgs> {
|
|
56
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['index', getU16Encoder()], ['tradeFeeRate', getU32Encoder()], ['protocolFeeRate', getU32Encoder()], ['creatorFeeRate', getU32Encoder()], ['authority', getAddressEncoder()], ['poolCreatorAuthority', getAddressEncoder()]]), (value) => ({ ...value, discriminator: 0 }));
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function getCreateConfigInstructionDataDecoder(): FixedSizeDecoder<CreateConfigInstructionData> {
|
|
60
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(CREATE_CONFIG_DISCRIMINATOR, getU8Decoder())], ['index', getU16Decoder()], ['tradeFeeRate', getU32Decoder()], ['protocolFeeRate', getU32Decoder()], ['creatorFeeRate', getU32Decoder()], ['authority', getAddressDecoder()], ['poolCreatorAuthority', getAddressDecoder()]]);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
export function getCreateConfigInstructionDataCodec(): FixedSizeCodec<CreateConfigInstructionDataArgs, CreateConfigInstructionData> {
|
|
64
|
+
return combineCodec(getCreateConfigInstructionDataEncoder(), getCreateConfigInstructionDataDecoder());
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
export type CreateConfigInput<TAccountPayer extends InstructionSignerInput = InstructionSignerInput, TAccountUpgradeAuthority extends InstructionSignerInput = InstructionSignerInput, TAccountProgramData extends InstructionAccountInput = InstructionAccountInput, TAccountAmmConfig extends InstructionAccountInput = InstructionAccountInput, TAccountSystemProgram extends InstructionAccountInput = InstructionAccountInput> = {
|
|
68
|
+
/** Pays the new tier's rent. */
|
|
69
|
+
payer: TAccountPayer;
|
|
70
|
+
/** The program's upgrade authority. */
|
|
71
|
+
upgradeAuthority: TAccountUpgradeAuthority;
|
|
72
|
+
/**
|
|
73
|
+
* The program's program-data account, which records its upgrade
|
|
74
|
+
* authority.
|
|
75
|
+
*/
|
|
76
|
+
programData: TAccountProgramData;
|
|
77
|
+
/** The tier PDA to create: `[b"amm_config", index]`. */
|
|
78
|
+
ammConfig: TAccountAmmConfig;
|
|
79
|
+
/** The system program. */
|
|
80
|
+
systemProgram?: TAccountSystemProgram;
|
|
81
|
+
index: CreateConfigInstructionDataArgs["index"];
|
|
82
|
+
tradeFeeRate: CreateConfigInstructionDataArgs["tradeFeeRate"];
|
|
83
|
+
protocolFeeRate: CreateConfigInstructionDataArgs["protocolFeeRate"];
|
|
84
|
+
creatorFeeRate: CreateConfigInstructionDataArgs["creatorFeeRate"];
|
|
85
|
+
authority: CreateConfigInstructionDataArgs["authority"];
|
|
86
|
+
poolCreatorAuthority: CreateConfigInstructionDataArgs["poolCreatorAuthority"];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
export function getCreateConfigInstruction<TAccountPayer extends InstructionSignerInput, TAccountUpgradeAuthority extends InstructionSignerInput, TAccountProgramData extends InstructionAccountInput, TAccountAmmConfig extends InstructionAccountInput, TAccountSystemProgram extends InstructionAccountInput, TProgramAddress extends Address = typeof PINA_AMM_PROGRAM_ADDRESS>(input: CreateConfigInput<TAccountPayer, TAccountUpgradeAuthority, TAccountProgramData, TAccountAmmConfig, TAccountSystemProgram>, config?: { programAddress?: TProgramAddress } ): CreateConfigInstruction<TProgramAddress, ResolvedInstructionAccountMeta<TAccountPayer, InstructionAccountInputAddress<TAccountPayer>>, ResolvedInstructionAccountMeta<TAccountUpgradeAuthority, InstructionAccountInputAddress<TAccountUpgradeAuthority>>, ResolvedInstructionAccountMeta<TAccountProgramData, InstructionAccountInputAddress<TAccountProgramData>>, ResolvedInstructionAccountMeta<TAccountAmmConfig, InstructionAccountInputAddress<TAccountAmmConfig>>, ResolvedInstructionAccountMeta<TAccountSystemProgram, InstructionAccountInputAddress<TAccountSystemProgram>>> {
|
|
90
|
+
// Program address.
|
|
91
|
+
const programAddress = config?.programAddress ?? PINA_AMM_PROGRAM_ADDRESS;
|
|
92
|
+
|
|
93
|
+
// Account meta helper.
|
|
94
|
+
const getAccountMeta = getAccountMetaFactory(programAddress, 'programId');
|
|
95
|
+
|
|
96
|
+
// Original accounts.
|
|
97
|
+
const originalAccounts = { payer: { value: input.payer ?? null, isSigner: true, isWritable: true }, upgradeAuthority: { value: input.upgradeAuthority ?? null, isSigner: true, isWritable: false }, programData: { value: input.programData ?? null, isSigner: false, isWritable: false }, ammConfig: { value: input.ammConfig ?? null, isSigner: false, isWritable: true }, systemProgram: { value: input.systemProgram ?? null, isSigner: false, isWritable: false } }
|
|
98
|
+
const accounts = originalAccounts as Record<keyof typeof originalAccounts, ResolvedInstructionAccount>;
|
|
99
|
+
|
|
100
|
+
|
|
101
|
+
// Original args.
|
|
102
|
+
const args = { ...input, };
|
|
103
|
+
|
|
104
|
+
|
|
105
|
+
// Resolve default values.
|
|
106
|
+
if (!accounts.systemProgram.value) {
|
|
107
|
+
accounts.systemProgram.value = '11111111111111111111111111111111' as Address<'11111111111111111111111111111111'>;
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
return Object.freeze({ accounts: [getAccountMeta("payer", accounts.payer), getAccountMeta("upgradeAuthority", accounts.upgradeAuthority), getAccountMeta("programData", accounts.programData), getAccountMeta("ammConfig", accounts.ammConfig), getAccountMeta("systemProgram", accounts.systemProgram)], data: getCreateConfigInstructionDataEncoder().encode(args as CreateConfigInstructionDataArgs), programAddress } as CreateConfigInstruction<TProgramAddress, ResolvedInstructionAccountMeta<TAccountPayer, InstructionAccountInputAddress<TAccountPayer>>, ResolvedInstructionAccountMeta<TAccountUpgradeAuthority, InstructionAccountInputAddress<TAccountUpgradeAuthority>>, ResolvedInstructionAccountMeta<TAccountProgramData, InstructionAccountInputAddress<TAccountProgramData>>, ResolvedInstructionAccountMeta<TAccountAmmConfig, InstructionAccountInputAddress<TAccountAmmConfig>>, ResolvedInstructionAccountMeta<TAccountSystemProgram, InstructionAccountInputAddress<TAccountSystemProgram>>>);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
export type ParsedCreateConfigInstruction<TProgram extends string = typeof PINA_AMM_PROGRAM_ADDRESS, TAccountMetas extends readonly AccountMeta[] = readonly AccountMeta[]> = { programAddress: Address<TProgram>;
|
|
114
|
+
accounts: {
|
|
115
|
+
/** Pays the new tier's rent. */
|
|
116
|
+
payer: TAccountMetas[0];
|
|
117
|
+
/** The program's upgrade authority. */
|
|
118
|
+
upgradeAuthority: TAccountMetas[1];
|
|
119
|
+
/**
|
|
120
|
+
* The program's program-data account, which records its upgrade
|
|
121
|
+
* authority.
|
|
122
|
+
*/
|
|
123
|
+
programData: TAccountMetas[2];
|
|
124
|
+
/** The tier PDA to create: `[b"amm_config", index]`. */
|
|
125
|
+
ammConfig: TAccountMetas[3];
|
|
126
|
+
/** The system program. */
|
|
127
|
+
systemProgram: TAccountMetas[4];
|
|
128
|
+
};
|
|
129
|
+
data: CreateConfigInstructionData; };
|
|
130
|
+
|
|
131
|
+
export function parseCreateConfigInstruction<TProgram extends string, TAccountMetas extends readonly AccountMeta[]>(instruction: Instruction<TProgram> & InstructionWithAccounts<TAccountMetas> & InstructionWithData<ReadonlyUint8Array>): ParsedCreateConfigInstruction<TProgram, TAccountMetas> {
|
|
132
|
+
if (instruction.accounts.length < 5) {
|
|
133
|
+
throw new SolanaError(SOLANA_ERROR__PROGRAM_CLIENTS__INSUFFICIENT_ACCOUNT_METAS, { actualAccountMetas: instruction.accounts.length, expectedAccountMetas: 5 });
|
|
134
|
+
}
|
|
135
|
+
let accountIndex = 0;
|
|
136
|
+
const getNextAccount = () => {
|
|
137
|
+
const accountMeta = (instruction.accounts as TAccountMetas)[accountIndex]!;
|
|
138
|
+
accountIndex += 1;
|
|
139
|
+
return accountMeta;
|
|
140
|
+
}
|
|
141
|
+
return { programAddress: instruction.programAddress, accounts: { payer: getNextAccount(), upgradeAuthority: getNextAccount(), programData: getNextAccount(), ammConfig: getNextAccount(), systemProgram: getNextAccount() }, data: getCreateConfigInstructionDataDecoder().decode(instruction.data) };
|
|
142
|
+
}
|