@pina-rs/amm 0.1.0 → 0.2.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/dist/index.cjs +501 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +451 -11
- package/dist/index.d.ts +451 -11
- package/dist/index.js +445 -16
- package/dist/index.js.map +1 -1
- package/package.json +59 -58
- package/src/generated/accounts/pool.ts +64 -8
- package/src/generated/errors/pinaAmm.ts +4 -2
- package/src/generated/events/configCreated.ts +80 -0
- package/src/generated/events/configUpdated.ts +64 -0
- package/src/generated/events/index.ts +5 -0
- package/src/generated/events/logs.ts +362 -2
- package/src/generated/events/poolCreatorChanged.ts +56 -0
- package/src/generated/events/poolSynced.ts +78 -0
- package/src/generated/events/poolSyncedV0.ts +44 -0
- package/src/generated/instructions/index.ts +1 -0
- package/src/generated/instructions/syncPool.ts +93 -0
- package/src/generated/pdas/ammConfig.ts +1 -1
- package/src/generated/pdas/pool.ts +1 -1
- package/src/generated/pdas/poolLpMint.ts +1 -1
- package/src/generated/pdas/poolVault.ts +1 -1
- package/src/generated/programs/pinaAmm.ts +17 -8
package/package.json
CHANGED
|
@@ -1,59 +1,60 @@
|
|
|
1
1
|
{
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
}
|
|
2
|
+
"name": "@pina-rs/amm",
|
|
3
|
+
"version": "0.2.0",
|
|
4
|
+
"description": "TypeScript client for the Pina AMM: instruction builders, account decoders, PDAs, events, and errors for @solana/kit",
|
|
5
|
+
"keywords": [
|
|
6
|
+
"solana",
|
|
7
|
+
"amm",
|
|
8
|
+
"pina",
|
|
9
|
+
"defi",
|
|
10
|
+
"solana-kit"
|
|
11
|
+
],
|
|
12
|
+
"homepage": "https://github.com/pina-rs/amm/tree/main/clients/typescript/pina_amm",
|
|
13
|
+
"repository": {
|
|
14
|
+
"type": "git",
|
|
15
|
+
"url": "git+https://github.com/pina-rs/amm.git",
|
|
16
|
+
"directory": "clients/typescript/pina_amm"
|
|
17
|
+
},
|
|
18
|
+
"license": "Apache-2.0",
|
|
19
|
+
"type": "module",
|
|
20
|
+
"sideEffects": false,
|
|
21
|
+
"main": "./dist/index.cjs",
|
|
22
|
+
"types": "./dist/index.d.ts",
|
|
23
|
+
"exports": {
|
|
24
|
+
".": {
|
|
25
|
+
"types": "./dist/index.d.ts",
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"require": "./dist/index.cjs"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"files": [
|
|
31
|
+
"dist",
|
|
32
|
+
"src",
|
|
33
|
+
"README.md",
|
|
34
|
+
"LICENSE"
|
|
35
|
+
],
|
|
36
|
+
"dependencies": {
|
|
37
|
+
"@solana/program-client-core": "^8.3.0"
|
|
38
|
+
},
|
|
39
|
+
"peerDependencies": {
|
|
40
|
+
"@solana/kit": "^8.3.0"
|
|
41
|
+
},
|
|
42
|
+
"devDependencies": {
|
|
43
|
+
"@solana/kit": "^8.3.0",
|
|
44
|
+
"@types/node": "^24.6.0",
|
|
45
|
+
"tsup": "^8.5.0",
|
|
46
|
+
"tsx": "^4.20.0",
|
|
47
|
+
"typescript": "^5.9.3"
|
|
48
|
+
},
|
|
49
|
+
"publishConfig": {
|
|
50
|
+
"access": "public",
|
|
51
|
+
"provenance": true
|
|
52
|
+
},
|
|
53
|
+
"module": "./dist/index.js",
|
|
54
|
+
"scripts": {
|
|
55
|
+
"build": "tsup",
|
|
56
|
+
"check": "tsc --noEmit --project tsconfig.json",
|
|
57
|
+
"journey": "tsx journeys/surfpool.journey.ts",
|
|
58
|
+
"test": "pnpm build && node --test test/*.test.mjs"
|
|
59
|
+
}
|
|
60
|
+
}
|
|
@@ -7,14 +7,14 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
import { getPinaPodDiscriminatorDecoder, getPinaPodMigrationVersionDecoder } from "../pinaPodCodecs";
|
|
10
|
-
import { assertAccountExists, assertAccountsExist, combineCodec, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, getAddressDecoder, getAddressEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, transformEncoder, type Account, type Address, type EncodedAccount, type FetchAccountConfig, type FetchAccountsConfig, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array } from '@solana/kit';
|
|
10
|
+
import { assertAccountExists, assertAccountsExist, combineCodec, decodeAccount, fetchEncodedAccount, fetchEncodedAccounts, getAddressDecoder, getAddressEncoder, getStructDecoder, getStructEncoder, getU128Decoder, getU128Encoder, getU32Decoder, getU32Encoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, transformEncoder, type Account, type Address, type EncodedAccount, type FetchAccountConfig, type FetchAccountsConfig, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type MaybeAccount, type MaybeEncodedAccount, type ReadonlyUint8Array } from '@solana/kit';
|
|
11
11
|
import { findPoolPda, type PoolSeeds } from '../pdas';
|
|
12
12
|
|
|
13
13
|
export const POOL_DISCRIMINATOR = 2;
|
|
14
14
|
|
|
15
15
|
export function getPoolDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_DISCRIMINATOR); }
|
|
16
16
|
|
|
17
|
-
export const POOL_DISCRIMINATOR2 =
|
|
17
|
+
export const POOL_DISCRIMINATOR2 = 1;
|
|
18
18
|
|
|
19
19
|
export function getPoolDiscriminator2Bytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_DISCRIMINATOR2); }
|
|
20
20
|
|
|
@@ -65,7 +65,35 @@ creatorFeeRate: number;
|
|
|
65
65
|
/** `CreatorFeeMode` wire value. */
|
|
66
66
|
creatorFeeMode: number;
|
|
67
67
|
/** Canonical bump of this pool's PDA. */
|
|
68
|
-
bump: number;
|
|
68
|
+
bump: number;
|
|
69
|
+
/**
|
|
70
|
+
* Low 128 bits of the Q64.64 price-time integral. Combine with
|
|
71
|
+
* `price_0_cumulative_high_last` as `low + high * 2^128`. Every swap, deposit,
|
|
72
|
+
* withdrawal, and `SyncPool` advances it with `reserve_0_last` and
|
|
73
|
+
* `reserve_1_last` before changing the reserves.
|
|
74
|
+
*/
|
|
75
|
+
price0CumulativeLast: bigint;
|
|
76
|
+
/**
|
|
77
|
+
* High 128 bits of the Q64.64 price-time integral. Together the limbs
|
|
78
|
+
* retain every bit for all supported reserve ratios and timestamp windows.
|
|
79
|
+
*/
|
|
80
|
+
price0CumulativeHighLast: bigint;
|
|
81
|
+
/** Unix second of the last accumulator advance; zero before the first. */
|
|
82
|
+
lastUpdateTimestamp: bigint;
|
|
83
|
+
/**
|
|
84
|
+
* Token 0 reserve at the end of the last instruction that changed or
|
|
85
|
+
* observed the reserves: `CreatePool`, a swap, a deposit, a withdrawal,
|
|
86
|
+
* or `SyncPool`. It prices the accumulator's next interval and nothing
|
|
87
|
+
* else: trades and liquidity always price from the live vault balances.
|
|
88
|
+
*/
|
|
89
|
+
reserve0Last: bigint;
|
|
90
|
+
/**
|
|
91
|
+
* Token 1 reserve at the end of the last instruction that changed or
|
|
92
|
+
* observed the reserves: `CreatePool`, a swap, a deposit, a withdrawal,
|
|
93
|
+
* or `SyncPool`. It prices the accumulator's next interval and nothing
|
|
94
|
+
* else: trades and liquidity always price from the live vault balances.
|
|
95
|
+
*/
|
|
96
|
+
reserve1Last: bigint; };
|
|
69
97
|
|
|
70
98
|
export type PoolArgs = {
|
|
71
99
|
/** Fee tier this pool was created under. */
|
|
@@ -108,16 +136,44 @@ creatorFeeRate: number;
|
|
|
108
136
|
/** `CreatorFeeMode` wire value. */
|
|
109
137
|
creatorFeeMode: number;
|
|
110
138
|
/** Canonical bump of this pool's PDA. */
|
|
111
|
-
bump: number;
|
|
139
|
+
bump: number;
|
|
140
|
+
/**
|
|
141
|
+
* Low 128 bits of the Q64.64 price-time integral. Combine with
|
|
142
|
+
* `price_0_cumulative_high_last` as `low + high * 2^128`. Every swap, deposit,
|
|
143
|
+
* withdrawal, and `SyncPool` advances it with `reserve_0_last` and
|
|
144
|
+
* `reserve_1_last` before changing the reserves.
|
|
145
|
+
*/
|
|
146
|
+
price0CumulativeLast: number | bigint;
|
|
147
|
+
/**
|
|
148
|
+
* High 128 bits of the Q64.64 price-time integral. Together the limbs
|
|
149
|
+
* retain every bit for all supported reserve ratios and timestamp windows.
|
|
150
|
+
*/
|
|
151
|
+
price0CumulativeHighLast: number | bigint;
|
|
152
|
+
/** Unix second of the last accumulator advance; zero before the first. */
|
|
153
|
+
lastUpdateTimestamp: number | bigint;
|
|
154
|
+
/**
|
|
155
|
+
* Token 0 reserve at the end of the last instruction that changed or
|
|
156
|
+
* observed the reserves: `CreatePool`, a swap, a deposit, a withdrawal,
|
|
157
|
+
* or `SyncPool`. It prices the accumulator's next interval and nothing
|
|
158
|
+
* else: trades and liquidity always price from the live vault balances.
|
|
159
|
+
*/
|
|
160
|
+
reserve0Last: number | bigint;
|
|
161
|
+
/**
|
|
162
|
+
* Token 1 reserve at the end of the last instruction that changed or
|
|
163
|
+
* observed the reserves: `CreatePool`, a swap, a deposit, a withdrawal,
|
|
164
|
+
* or `SyncPool`. It prices the accumulator's next interval and nothing
|
|
165
|
+
* else: trades and liquidity always price from the live vault balances.
|
|
166
|
+
*/
|
|
167
|
+
reserve1Last: number | bigint; };
|
|
112
168
|
|
|
113
169
|
/** Gets the encoder for {@link PoolArgs} account data. */
|
|
114
170
|
export function getPoolEncoder(): FixedSizeEncoder<PoolArgs> {
|
|
115
|
-
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['migrationVersion', getU8Encoder()], ['ammConfig', getAddressEncoder()], ['creator', getAddressEncoder()], ['mint0', getAddressEncoder()], ['mint1', getAddressEncoder()], ['vault0', getAddressEncoder()], ['vault1', getAddressEncoder()], ['lpMint', getAddressEncoder()], ['lpSupply', getU64Encoder()], ['protocolFees0', getU64Encoder()], ['protocolFees1', getU64Encoder()], ['creatorFees0', getU64Encoder()], ['creatorFees1', getU64Encoder()], ['tradeFeeRate', getU32Encoder()], ['protocolFeeRate', getU32Encoder()], ['creatorFeeRate', getU32Encoder()], ['creatorFeeMode', getU8Encoder()], ['bump', getU8Encoder()]]), (value) => ({ ...value, discriminator: 2, migrationVersion:
|
|
171
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['migrationVersion', getU8Encoder()], ['ammConfig', getAddressEncoder()], ['creator', getAddressEncoder()], ['mint0', getAddressEncoder()], ['mint1', getAddressEncoder()], ['vault0', getAddressEncoder()], ['vault1', getAddressEncoder()], ['lpMint', getAddressEncoder()], ['lpSupply', getU64Encoder()], ['protocolFees0', getU64Encoder()], ['protocolFees1', getU64Encoder()], ['creatorFees0', getU64Encoder()], ['creatorFees1', getU64Encoder()], ['tradeFeeRate', getU32Encoder()], ['protocolFeeRate', getU32Encoder()], ['creatorFeeRate', getU32Encoder()], ['creatorFeeMode', getU8Encoder()], ['bump', getU8Encoder()], ['price0CumulativeLast', getU128Encoder()], ['price0CumulativeHighLast', getU128Encoder()], ['lastUpdateTimestamp', getU64Encoder()], ['reserve0Last', getU64Encoder()], ['reserve1Last', getU64Encoder()]]), (value) => ({ ...value, discriminator: 2, migrationVersion: 1 }));
|
|
116
172
|
}
|
|
117
173
|
|
|
118
174
|
/** Gets the decoder for {@link Pool} account data. */
|
|
119
175
|
export function getPoolDecoder(): FixedSizeDecoder<Pool> {
|
|
120
|
-
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(POOL_DISCRIMINATOR, getU8Decoder())], ['migrationVersion', getPinaPodMigrationVersionDecoder(
|
|
176
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(POOL_DISCRIMINATOR, getU8Decoder())], ['migrationVersion', getPinaPodMigrationVersionDecoder(1, getU8Decoder())], ['ammConfig', getAddressDecoder()], ['creator', getAddressDecoder()], ['mint0', getAddressDecoder()], ['mint1', getAddressDecoder()], ['vault0', getAddressDecoder()], ['vault1', getAddressDecoder()], ['lpMint', getAddressDecoder()], ['lpSupply', getU64Decoder()], ['protocolFees0', getU64Decoder()], ['protocolFees1', getU64Decoder()], ['creatorFees0', getU64Decoder()], ['creatorFees1', getU64Decoder()], ['tradeFeeRate', getU32Decoder()], ['protocolFeeRate', getU32Decoder()], ['creatorFeeRate', getU32Decoder()], ['creatorFeeMode', getU8Decoder()], ['bump', getU8Decoder()], ['price0CumulativeLast', getU128Decoder()], ['price0CumulativeHighLast', getU128Decoder()], ['lastUpdateTimestamp', getU64Decoder()], ['reserve0Last', getU64Decoder()], ['reserve1Last', getU64Decoder()]]);
|
|
121
177
|
}
|
|
122
178
|
|
|
123
179
|
/** Gets the codec for {@link Pool} account data. */
|
|
@@ -190,7 +246,7 @@ export async function fetchMaybePoolFromSeeds(
|
|
|
190
246
|
}
|
|
191
247
|
|
|
192
248
|
/** The account schema version this client was generated from. */
|
|
193
|
-
export const POOL_MIGRATION_VERSION =
|
|
249
|
+
export const POOL_MIGRATION_VERSION = 1;
|
|
194
250
|
|
|
195
251
|
/**
|
|
196
252
|
* Cheap envelope check for a fetched `Pool` account: `true` only when the
|
|
@@ -214,5 +270,5 @@ export function poolNeedsMigration(data: ReadonlyUint8Array): boolean {
|
|
|
214
270
|
if (data[0] !== 2) {
|
|
215
271
|
return false;
|
|
216
272
|
}
|
|
217
|
-
return data[1]! <
|
|
273
|
+
return data[1]! < 1;
|
|
218
274
|
}
|
|
@@ -39,12 +39,14 @@ export const PINA_AMM_ERROR__INVARIANT_VIOLATION = 0xc; // 12
|
|
|
39
39
|
export const PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH = 0xd; // 13
|
|
40
40
|
/** This fee tier only lets its pool-creator authority create pools. */
|
|
41
41
|
export const PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED = 0xe; // 14
|
|
42
|
+
/** The pool creator may not be the default address, which can never sign or collect. */
|
|
43
|
+
export const PINA_AMM_ERROR__DEFAULT_CREATOR = 0xf; // 15
|
|
42
44
|
|
|
43
|
-
export type PinaAmmError = typeof PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY | typeof PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY | typeof PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE | typeof PINA_AMM_ERROR__INVALID_FEE_RATES | typeof PINA_AMM_ERROR__INVALID_MINT_ORDER | typeof PINA_AMM_ERROR__INVALID_PROGRAM_DATA | typeof PINA_AMM_ERROR__INVARIANT_VIOLATION | typeof PINA_AMM_ERROR__MATH_OVERFLOW | typeof PINA_AMM_ERROR__POOL_ACCOUNT_MISMATCH | typeof PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED | typeof PINA_AMM_ERROR__SLIPPAGE_EXCEEDED | typeof PINA_AMM_ERROR__UNAUTHORIZED | typeof PINA_AMM_ERROR__UNSUPPORTED_MINT | typeof PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH | typeof PINA_AMM_ERROR__ZERO_AMOUNT;
|
|
45
|
+
export type PinaAmmError = typeof PINA_AMM_ERROR__DEFAULT_CREATOR | typeof PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY | typeof PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY | typeof PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE | typeof PINA_AMM_ERROR__INVALID_FEE_RATES | typeof PINA_AMM_ERROR__INVALID_MINT_ORDER | typeof PINA_AMM_ERROR__INVALID_PROGRAM_DATA | typeof PINA_AMM_ERROR__INVARIANT_VIOLATION | typeof PINA_AMM_ERROR__MATH_OVERFLOW | typeof PINA_AMM_ERROR__POOL_ACCOUNT_MISMATCH | typeof PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED | typeof PINA_AMM_ERROR__SLIPPAGE_EXCEEDED | typeof PINA_AMM_ERROR__UNAUTHORIZED | typeof PINA_AMM_ERROR__UNSUPPORTED_MINT | typeof PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH | typeof PINA_AMM_ERROR__ZERO_AMOUNT;
|
|
44
46
|
|
|
45
47
|
let pinaAmmErrorMessages: Record<PinaAmmError, string> | undefined;
|
|
46
48
|
if (process.env['NODE_ENV'] !== 'production') {
|
|
47
|
-
pinaAmmErrorMessages = { [PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY]: `The initial deposit must mint more LP than the permanently locked minimum.`, [PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY]: `The pool cannot pay this amount from its reserves.`, [PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE]: `The creator fee mode must be 0 (input token), 1 (token 0), or 2 (token 1).`, [PINA_AMM_ERROR__INVALID_FEE_RATES]: `Fee rates are out of range: trade plus creator fee above 10% or protocol share above 100%.`, [PINA_AMM_ERROR__INVALID_MINT_ORDER]: `Pool mints must be distinct and passed in ascending byte order.`, [PINA_AMM_ERROR__INVALID_PROGRAM_DATA]: `The program-data account is not this program's, or the program is not upgradeable.`, [PINA_AMM_ERROR__INVARIANT_VIOLATION]: `The trade would decrease the pool's constant product.`, [PINA_AMM_ERROR__MATH_OVERFLOW]: `An intermediate value overflowed or did not fit its type.`, [PINA_AMM_ERROR__POOL_ACCOUNT_MISMATCH]: `A vault, LP mint, or fee tier account does not belong to this pool.`, [PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED]: `This fee tier only lets its pool-creator authority create pools.`, [PINA_AMM_ERROR__SLIPPAGE_EXCEEDED]: `The result is worse than the caller's slippage limit.`, [PINA_AMM_ERROR__UNAUTHORIZED]: `The signer is not the authority this instruction requires.`, [PINA_AMM_ERROR__UNSUPPORTED_MINT]: `The mint's token program or Token-2022 extensions are not supported.`, [PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH]: `A vault holds less than the fees accrued against it.`, [PINA_AMM_ERROR__ZERO_AMOUNT]: `An amount is zero or the trade rounds down to nothing.` };
|
|
49
|
+
pinaAmmErrorMessages = { [PINA_AMM_ERROR__DEFAULT_CREATOR]: `The pool creator may not be the default address, which can never sign or collect.`, [PINA_AMM_ERROR__INSUFFICIENT_INITIAL_LIQUIDITY]: `The initial deposit must mint more LP than the permanently locked minimum.`, [PINA_AMM_ERROR__INSUFFICIENT_LIQUIDITY]: `The pool cannot pay this amount from its reserves.`, [PINA_AMM_ERROR__INVALID_CREATOR_FEE_MODE]: `The creator fee mode must be 0 (input token), 1 (token 0), or 2 (token 1).`, [PINA_AMM_ERROR__INVALID_FEE_RATES]: `Fee rates are out of range: trade plus creator fee above 10% or protocol share above 100%.`, [PINA_AMM_ERROR__INVALID_MINT_ORDER]: `Pool mints must be distinct and passed in ascending byte order.`, [PINA_AMM_ERROR__INVALID_PROGRAM_DATA]: `The program-data account is not this program's, or the program is not upgradeable.`, [PINA_AMM_ERROR__INVARIANT_VIOLATION]: `The trade would decrease the pool's constant product.`, [PINA_AMM_ERROR__MATH_OVERFLOW]: `An intermediate value overflowed or did not fit its type.`, [PINA_AMM_ERROR__POOL_ACCOUNT_MISMATCH]: `A vault, LP mint, or fee tier account does not belong to this pool.`, [PINA_AMM_ERROR__POOL_CREATOR_NOT_AUTHORIZED]: `This fee tier only lets its pool-creator authority create pools.`, [PINA_AMM_ERROR__SLIPPAGE_EXCEEDED]: `The result is worse than the caller's slippage limit.`, [PINA_AMM_ERROR__UNAUTHORIZED]: `The signer is not the authority this instruction requires.`, [PINA_AMM_ERROR__UNSUPPORTED_MINT]: `The mint's token program or Token-2022 extensions are not supported.`, [PINA_AMM_ERROR__VAULT_ACCOUNTING_MISMATCH]: `A vault holds less than the fees accrued against it.`, [PINA_AMM_ERROR__ZERO_AMOUNT]: `An amount is zero or the trade rounds down to nothing.` };
|
|
48
50
|
}
|
|
49
51
|
|
|
50
52
|
export function getPinaAmmErrorMessage(code: PinaAmmError): string {
|
|
@@ -0,0 +1,80 @@
|
|
|
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, getPinaPodMigrationVersionDecoder } from "../pinaPodCodecs";
|
|
10
|
+
import { combineCodec, containsBytes, getAddressDecoder, getAddressEncoder, getStructDecoder, getStructEncoder, getU16Decoder, getU16Encoder, getU32Decoder, getU32Encoder, getU8Decoder, getU8Encoder, transformEncoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type ReadonlyUint8Array } from '@solana/kit';
|
|
11
|
+
|
|
12
|
+
export const CONFIG_CREATED_EVENT_DISCRIMINATOR = 8;
|
|
13
|
+
|
|
14
|
+
export function getConfigCreatedEventDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(CONFIG_CREATED_EVENT_DISCRIMINATOR); }
|
|
15
|
+
|
|
16
|
+
export const CONFIG_CREATED_EVENT_DISCRIMINATOR2 = 0;
|
|
17
|
+
|
|
18
|
+
export function getConfigCreatedEventDiscriminator2Bytes(): ReadonlyUint8Array { return getU8Encoder().encode(CONFIG_CREATED_EVENT_DISCRIMINATOR2); }
|
|
19
|
+
|
|
20
|
+
/** Emitted by `CreateConfig`. */
|
|
21
|
+
export type ConfigCreatedEvent = { discriminator: number; migrationVersion: number;
|
|
22
|
+
/** The new tier. */
|
|
23
|
+
ammConfig: Address;
|
|
24
|
+
/** Signer that may update the tier and collect its protocol fees. */
|
|
25
|
+
authority: Address;
|
|
26
|
+
/**
|
|
27
|
+
* The only signer allowed to create pools under the tier, or the
|
|
28
|
+
* default address when pool creation is open to anyone. Fixed for the
|
|
29
|
+
* life of the tier.
|
|
30
|
+
*/
|
|
31
|
+
poolCreatorAuthority: Address;
|
|
32
|
+
/** Trade fee pools snapshot, in parts per million. */
|
|
33
|
+
tradeFeeRate: number;
|
|
34
|
+
/** Protocol share of the trade fee pools snapshot, in parts per million. */
|
|
35
|
+
protocolFeeRate: number;
|
|
36
|
+
/** Creator fee pools snapshot, in parts per million. */
|
|
37
|
+
creatorFeeRate: number;
|
|
38
|
+
/** Tier index used as the PDA seed. */
|
|
39
|
+
index: number; };
|
|
40
|
+
|
|
41
|
+
export type ConfigCreatedEventArgs = {
|
|
42
|
+
/** The new tier. */
|
|
43
|
+
ammConfig: Address;
|
|
44
|
+
/** Signer that may update the tier and collect its protocol fees. */
|
|
45
|
+
authority: Address;
|
|
46
|
+
/**
|
|
47
|
+
* The only signer allowed to create pools under the tier, or the
|
|
48
|
+
* default address when pool creation is open to anyone. Fixed for the
|
|
49
|
+
* life of the tier.
|
|
50
|
+
*/
|
|
51
|
+
poolCreatorAuthority: Address;
|
|
52
|
+
/** Trade fee pools snapshot, in parts per million. */
|
|
53
|
+
tradeFeeRate: number;
|
|
54
|
+
/** Protocol share of the trade fee pools snapshot, in parts per million. */
|
|
55
|
+
protocolFeeRate: number;
|
|
56
|
+
/** Creator fee pools snapshot, in parts per million. */
|
|
57
|
+
creatorFeeRate: number;
|
|
58
|
+
/** Tier index used as the PDA seed. */
|
|
59
|
+
index: number; };
|
|
60
|
+
|
|
61
|
+
/** Gets the encoder for {@link ConfigCreatedEventArgs} event data. */
|
|
62
|
+
export function getConfigCreatedEventEncoder(): FixedSizeEncoder<ConfigCreatedEventArgs> {
|
|
63
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['migrationVersion', getU8Encoder()], ['ammConfig', getAddressEncoder()], ['authority', getAddressEncoder()], ['poolCreatorAuthority', getAddressEncoder()], ['tradeFeeRate', getU32Encoder()], ['protocolFeeRate', getU32Encoder()], ['creatorFeeRate', getU32Encoder()], ['index', getU16Encoder()]]), (value) => ({ ...value, discriminator: 8, migrationVersion: 0 }));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Gets the decoder for {@link ConfigCreatedEvent} event data. */
|
|
67
|
+
export function getConfigCreatedEventDecoder(): FixedSizeDecoder<ConfigCreatedEvent> {
|
|
68
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(CONFIG_CREATED_EVENT_DISCRIMINATOR, getU8Decoder())], ['migrationVersion', getPinaPodMigrationVersionDecoder(0, getU8Decoder())], ['ammConfig', getAddressDecoder()], ['authority', getAddressDecoder()], ['poolCreatorAuthority', getAddressDecoder()], ['tradeFeeRate', getU32Decoder()], ['protocolFeeRate', getU32Decoder()], ['creatorFeeRate', getU32Decoder()], ['index', getU16Decoder()]]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Gets the codec for {@link ConfigCreatedEvent} event data. */
|
|
72
|
+
export function getConfigCreatedEventCodec(): FixedSizeCodec<ConfigCreatedEventArgs, ConfigCreatedEvent> {
|
|
73
|
+
return combineCodec(getConfigCreatedEventEncoder(), getConfigCreatedEventDecoder());
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Parses the provided bytes into {@link ConfigCreatedEvent} event data. */
|
|
77
|
+
export function parseConfigCreatedEvent(data: ReadonlyUint8Array | Uint8Array): ConfigCreatedEvent {
|
|
78
|
+
if (containsBytes(data, getU8Encoder().encode(CONFIG_CREATED_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(CONFIG_CREATED_EVENT_DISCRIMINATOR2), 1)) { return getConfigCreatedEventDecoder().decode(data); }
|
|
79
|
+
throw new Error('The provided data does not match the "ConfigCreatedEvent" event discriminators.');
|
|
80
|
+
}
|
|
@@ -0,0 +1,64 @@
|
|
|
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, getPinaPodMigrationVersionDecoder } from "../pinaPodCodecs";
|
|
10
|
+
import { combineCodec, containsBytes, getAddressDecoder, getAddressEncoder, getStructDecoder, getStructEncoder, getU32Decoder, getU32Encoder, getU8Decoder, getU8Encoder, transformEncoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type ReadonlyUint8Array } from '@solana/kit';
|
|
11
|
+
|
|
12
|
+
export const CONFIG_UPDATED_EVENT_DISCRIMINATOR = 6;
|
|
13
|
+
|
|
14
|
+
export function getConfigUpdatedEventDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(CONFIG_UPDATED_EVENT_DISCRIMINATOR); }
|
|
15
|
+
|
|
16
|
+
export const CONFIG_UPDATED_EVENT_DISCRIMINATOR2 = 0;
|
|
17
|
+
|
|
18
|
+
export function getConfigUpdatedEventDiscriminator2Bytes(): ReadonlyUint8Array { return getU8Encoder().encode(CONFIG_UPDATED_EVENT_DISCRIMINATOR2); }
|
|
19
|
+
|
|
20
|
+
/** Emitted by `UpdateConfig`. */
|
|
21
|
+
export type ConfigUpdatedEvent = { discriminator: number; migrationVersion: number;
|
|
22
|
+
/** The tier that was updated. */
|
|
23
|
+
ammConfig: Address;
|
|
24
|
+
/** The tier's new authority. */
|
|
25
|
+
newAuthority: Address;
|
|
26
|
+
/** Trade fee future pools snapshot, in parts per million. */
|
|
27
|
+
tradeFeeRate: number;
|
|
28
|
+
/** Protocol share future pools snapshot, in parts per million. */
|
|
29
|
+
protocolFeeRate: number;
|
|
30
|
+
/** Creator fee future pools snapshot, in parts per million. */
|
|
31
|
+
creatorFeeRate: number; };
|
|
32
|
+
|
|
33
|
+
export type ConfigUpdatedEventArgs = {
|
|
34
|
+
/** The tier that was updated. */
|
|
35
|
+
ammConfig: Address;
|
|
36
|
+
/** The tier's new authority. */
|
|
37
|
+
newAuthority: Address;
|
|
38
|
+
/** Trade fee future pools snapshot, in parts per million. */
|
|
39
|
+
tradeFeeRate: number;
|
|
40
|
+
/** Protocol share future pools snapshot, in parts per million. */
|
|
41
|
+
protocolFeeRate: number;
|
|
42
|
+
/** Creator fee future pools snapshot, in parts per million. */
|
|
43
|
+
creatorFeeRate: number; };
|
|
44
|
+
|
|
45
|
+
/** Gets the encoder for {@link ConfigUpdatedEventArgs} event data. */
|
|
46
|
+
export function getConfigUpdatedEventEncoder(): FixedSizeEncoder<ConfigUpdatedEventArgs> {
|
|
47
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['migrationVersion', getU8Encoder()], ['ammConfig', getAddressEncoder()], ['newAuthority', getAddressEncoder()], ['tradeFeeRate', getU32Encoder()], ['protocolFeeRate', getU32Encoder()], ['creatorFeeRate', getU32Encoder()]]), (value) => ({ ...value, discriminator: 6, migrationVersion: 0 }));
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
/** Gets the decoder for {@link ConfigUpdatedEvent} event data. */
|
|
51
|
+
export function getConfigUpdatedEventDecoder(): FixedSizeDecoder<ConfigUpdatedEvent> {
|
|
52
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(CONFIG_UPDATED_EVENT_DISCRIMINATOR, getU8Decoder())], ['migrationVersion', getPinaPodMigrationVersionDecoder(0, getU8Decoder())], ['ammConfig', getAddressDecoder()], ['newAuthority', getAddressDecoder()], ['tradeFeeRate', getU32Decoder()], ['protocolFeeRate', getU32Decoder()], ['creatorFeeRate', getU32Decoder()]]);
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** Gets the codec for {@link ConfigUpdatedEvent} event data. */
|
|
56
|
+
export function getConfigUpdatedEventCodec(): FixedSizeCodec<ConfigUpdatedEventArgs, ConfigUpdatedEvent> {
|
|
57
|
+
return combineCodec(getConfigUpdatedEventEncoder(), getConfigUpdatedEventDecoder());
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Parses the provided bytes into {@link ConfigUpdatedEvent} event data. */
|
|
61
|
+
export function parseConfigUpdatedEvent(data: ReadonlyUint8Array | Uint8Array): ConfigUpdatedEvent {
|
|
62
|
+
if (containsBytes(data, getU8Encoder().encode(CONFIG_UPDATED_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(CONFIG_UPDATED_EVENT_DISCRIMINATOR2), 1)) { return getConfigUpdatedEventDecoder().decode(data); }
|
|
63
|
+
throw new Error('The provided data does not match the "ConfigUpdatedEvent" event discriminators.');
|
|
64
|
+
}
|
|
@@ -7,7 +7,12 @@
|
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
9
|
export * from "./logs";
|
|
10
|
+
export * from './configCreated';
|
|
11
|
+
export * from './configUpdated';
|
|
10
12
|
export * from './feesCollected';
|
|
11
13
|
export * from './liquidityChanged';
|
|
12
14
|
export * from './poolCreated';
|
|
15
|
+
export * from './poolCreatorChanged';
|
|
16
|
+
export * from './poolSynced';
|
|
17
|
+
export * from './poolSyncedV0';
|
|
13
18
|
export * from './swapped';
|