@pina-rs/amm 0.0.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/README.md +27 -2
- package/dist/index.cjs +1744 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +2192 -0
- package/dist/index.d.ts +2192 -0
- package/dist/index.js +1507 -0
- package/dist/index.js.map +1 -0
- package/package.json +55 -5
- package/src/generated/accounts/ammConfig.ts +197 -0
- package/src/generated/accounts/index.ts +10 -0
- package/src/generated/accounts/pool.ts +274 -0
- package/src/generated/errors/index.ts +9 -0
- package/src/generated/errors/pinaAmm.ts +66 -0
- package/src/generated/events/configCreated.ts +80 -0
- package/src/generated/events/configUpdated.ts +64 -0
- package/src/generated/events/feesCollected.ts +64 -0
- package/src/generated/events/index.ts +18 -0
- package/src/generated/events/liquidityChanged.ts +72 -0
- package/src/generated/events/logs.ts +732 -0
- package/src/generated/events/poolCreated.ts +80 -0
- 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/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 +20 -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/syncPool.ts +93 -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 +124 -0
- package/src/index.ts +11 -0
- package/CHANGELOG.md +0 -5
|
@@ -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, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, transformEncoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type ReadonlyUint8Array } from '@solana/kit';
|
|
11
|
+
|
|
12
|
+
export const POOL_CREATED_EVENT_DISCRIMINATOR = 1;
|
|
13
|
+
|
|
14
|
+
export function getPoolCreatedEventDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_CREATED_EVENT_DISCRIMINATOR); }
|
|
15
|
+
|
|
16
|
+
export const POOL_CREATED_EVENT_DISCRIMINATOR2 = 0;
|
|
17
|
+
|
|
18
|
+
export function getPoolCreatedEventDiscriminator2Bytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_CREATED_EVENT_DISCRIMINATOR2); }
|
|
19
|
+
|
|
20
|
+
/** Emitted by `CreatePool`. */
|
|
21
|
+
export type PoolCreatedEvent = { discriminator: number; migrationVersion: number;
|
|
22
|
+
/** The new pool. */
|
|
23
|
+
pool: Address;
|
|
24
|
+
/** Fee tier the pool was created under. */
|
|
25
|
+
ammConfig: Address;
|
|
26
|
+
/** Recipient of the pool's creator fees. */
|
|
27
|
+
creator: Address;
|
|
28
|
+
/** Smaller mint of the pair. */
|
|
29
|
+
mint0: Address;
|
|
30
|
+
/** Larger mint of the pair. */
|
|
31
|
+
mint1: Address;
|
|
32
|
+
/** The pool's LP mint. */
|
|
33
|
+
lpMint: Address;
|
|
34
|
+
/** Initial reserve of token 0. */
|
|
35
|
+
amount0: bigint;
|
|
36
|
+
/** Initial reserve of token 1. */
|
|
37
|
+
amount1: bigint;
|
|
38
|
+
/** Initial economic LP supply, including the locked minimum. */
|
|
39
|
+
lpSupply: bigint; };
|
|
40
|
+
|
|
41
|
+
export type PoolCreatedEventArgs = {
|
|
42
|
+
/** The new pool. */
|
|
43
|
+
pool: Address;
|
|
44
|
+
/** Fee tier the pool was created under. */
|
|
45
|
+
ammConfig: Address;
|
|
46
|
+
/** Recipient of the pool's creator fees. */
|
|
47
|
+
creator: Address;
|
|
48
|
+
/** Smaller mint of the pair. */
|
|
49
|
+
mint0: Address;
|
|
50
|
+
/** Larger mint of the pair. */
|
|
51
|
+
mint1: Address;
|
|
52
|
+
/** The pool's LP mint. */
|
|
53
|
+
lpMint: Address;
|
|
54
|
+
/** Initial reserve of token 0. */
|
|
55
|
+
amount0: number | bigint;
|
|
56
|
+
/** Initial reserve of token 1. */
|
|
57
|
+
amount1: number | bigint;
|
|
58
|
+
/** Initial economic LP supply, including the locked minimum. */
|
|
59
|
+
lpSupply: number | bigint; };
|
|
60
|
+
|
|
61
|
+
/** Gets the encoder for {@link PoolCreatedEventArgs} event data. */
|
|
62
|
+
export function getPoolCreatedEventEncoder(): FixedSizeEncoder<PoolCreatedEventArgs> {
|
|
63
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['migrationVersion', getU8Encoder()], ['pool', getAddressEncoder()], ['ammConfig', getAddressEncoder()], ['creator', getAddressEncoder()], ['mint0', getAddressEncoder()], ['mint1', getAddressEncoder()], ['lpMint', getAddressEncoder()], ['amount0', getU64Encoder()], ['amount1', getU64Encoder()], ['lpSupply', getU64Encoder()]]), (value) => ({ ...value, discriminator: 1, migrationVersion: 0 }));
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Gets the decoder for {@link PoolCreatedEvent} event data. */
|
|
67
|
+
export function getPoolCreatedEventDecoder(): FixedSizeDecoder<PoolCreatedEvent> {
|
|
68
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(POOL_CREATED_EVENT_DISCRIMINATOR, getU8Decoder())], ['migrationVersion', getPinaPodMigrationVersionDecoder(0, getU8Decoder())], ['pool', getAddressDecoder()], ['ammConfig', getAddressDecoder()], ['creator', getAddressDecoder()], ['mint0', getAddressDecoder()], ['mint1', getAddressDecoder()], ['lpMint', getAddressDecoder()], ['amount0', getU64Decoder()], ['amount1', getU64Decoder()], ['lpSupply', getU64Decoder()]]);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Gets the codec for {@link PoolCreatedEvent} event data. */
|
|
72
|
+
export function getPoolCreatedEventCodec(): FixedSizeCodec<PoolCreatedEventArgs, PoolCreatedEvent> {
|
|
73
|
+
return combineCodec(getPoolCreatedEventEncoder(), getPoolCreatedEventDecoder());
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
/** Parses the provided bytes into {@link PoolCreatedEvent} event data. */
|
|
77
|
+
export function parsePoolCreatedEvent(data: ReadonlyUint8Array | Uint8Array): PoolCreatedEvent {
|
|
78
|
+
if (containsBytes(data, getU8Encoder().encode(POOL_CREATED_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(POOL_CREATED_EVENT_DISCRIMINATOR2), 1)) { return getPoolCreatedEventDecoder().decode(data); }
|
|
79
|
+
throw new Error('The provided data does not match the "PoolCreatedEvent" event discriminators.');
|
|
80
|
+
}
|
|
@@ -0,0 +1,56 @@
|
|
|
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, getU8Decoder, getU8Encoder, transformEncoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type ReadonlyUint8Array } from '@solana/kit';
|
|
11
|
+
|
|
12
|
+
export const POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR = 7;
|
|
13
|
+
|
|
14
|
+
export function getPoolCreatorChangedEventDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR); }
|
|
15
|
+
|
|
16
|
+
export const POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2 = 0;
|
|
17
|
+
|
|
18
|
+
export function getPoolCreatorChangedEventDiscriminator2Bytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2); }
|
|
19
|
+
|
|
20
|
+
/** Emitted by `SetPoolCreator`. */
|
|
21
|
+
export type PoolCreatorChangedEvent = { discriminator: number; migrationVersion: number;
|
|
22
|
+
/** The pool whose creator-fee rights moved. */
|
|
23
|
+
pool: Address;
|
|
24
|
+
/** The previous creator. */
|
|
25
|
+
previousCreator: Address;
|
|
26
|
+
/** The new creator. */
|
|
27
|
+
newCreator: Address; };
|
|
28
|
+
|
|
29
|
+
export type PoolCreatorChangedEventArgs = {
|
|
30
|
+
/** The pool whose creator-fee rights moved. */
|
|
31
|
+
pool: Address;
|
|
32
|
+
/** The previous creator. */
|
|
33
|
+
previousCreator: Address;
|
|
34
|
+
/** The new creator. */
|
|
35
|
+
newCreator: Address; };
|
|
36
|
+
|
|
37
|
+
/** Gets the encoder for {@link PoolCreatorChangedEventArgs} event data. */
|
|
38
|
+
export function getPoolCreatorChangedEventEncoder(): FixedSizeEncoder<PoolCreatorChangedEventArgs> {
|
|
39
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['migrationVersion', getU8Encoder()], ['pool', getAddressEncoder()], ['previousCreator', getAddressEncoder()], ['newCreator', getAddressEncoder()]]), (value) => ({ ...value, discriminator: 7, migrationVersion: 0 }));
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** Gets the decoder for {@link PoolCreatorChangedEvent} event data. */
|
|
43
|
+
export function getPoolCreatorChangedEventDecoder(): FixedSizeDecoder<PoolCreatorChangedEvent> {
|
|
44
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR, getU8Decoder())], ['migrationVersion', getPinaPodMigrationVersionDecoder(0, getU8Decoder())], ['pool', getAddressDecoder()], ['previousCreator', getAddressDecoder()], ['newCreator', getAddressDecoder()]]);
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Gets the codec for {@link PoolCreatorChangedEvent} event data. */
|
|
48
|
+
export function getPoolCreatorChangedEventCodec(): FixedSizeCodec<PoolCreatorChangedEventArgs, PoolCreatorChangedEvent> {
|
|
49
|
+
return combineCodec(getPoolCreatorChangedEventEncoder(), getPoolCreatorChangedEventDecoder());
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** Parses the provided bytes into {@link PoolCreatorChangedEvent} event data. */
|
|
53
|
+
export function parsePoolCreatorChangedEvent(data: ReadonlyUint8Array | Uint8Array): PoolCreatorChangedEvent {
|
|
54
|
+
if (containsBytes(data, getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(POOL_CREATOR_CHANGED_EVENT_DISCRIMINATOR2), 1)) { return getPoolCreatorChangedEventDecoder().decode(data); }
|
|
55
|
+
throw new Error('The provided data does not match the "PoolCreatorChangedEvent" event discriminators.');
|
|
56
|
+
}
|
|
@@ -0,0 +1,78 @@
|
|
|
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, getU128Decoder, getU128Encoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, transformEncoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type ReadonlyUint8Array } from '@solana/kit';
|
|
11
|
+
|
|
12
|
+
export const POOL_SYNCED_EVENT_DISCRIMINATOR = 5;
|
|
13
|
+
|
|
14
|
+
export function getPoolSyncedEventDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR); }
|
|
15
|
+
|
|
16
|
+
export const POOL_SYNCED_EVENT_DISCRIMINATOR2 = 1;
|
|
17
|
+
|
|
18
|
+
export function getPoolSyncedEventDiscriminator2Bytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR2); }
|
|
19
|
+
|
|
20
|
+
/**
|
|
21
|
+
* Emitted by `SyncPool`. Swaps, deposits, and withdrawals advance the same
|
|
22
|
+
* accumulator and report their effect through `Swapped` and
|
|
23
|
+
* `LiquidityChanged`.
|
|
24
|
+
*/
|
|
25
|
+
export type PoolSyncedEvent = { discriminator: number; migrationVersion: number;
|
|
26
|
+
/** The pool whose accumulator advanced. */
|
|
27
|
+
pool: Address;
|
|
28
|
+
/** Token 0 reserve recorded at the advance; it prices the next interval. */
|
|
29
|
+
reserve0: bigint;
|
|
30
|
+
/** Token 1 reserve recorded at the advance; it prices the next interval. */
|
|
31
|
+
reserve1: bigint;
|
|
32
|
+
/**
|
|
33
|
+
* Low 128 bits of the Q64.64 price-time integral after the advance.
|
|
34
|
+
* Combine with `price_0_cumulative_high_last` as `low + high * 2^128`.
|
|
35
|
+
*/
|
|
36
|
+
price0CumulativeLast: bigint;
|
|
37
|
+
/** High 128 bits of the Q64.64 price-time integral after the advance. */
|
|
38
|
+
price0CumulativeHighLast: bigint;
|
|
39
|
+
/** Unix second of the advance. */
|
|
40
|
+
lastUpdateTimestamp: bigint; };
|
|
41
|
+
|
|
42
|
+
export type PoolSyncedEventArgs = {
|
|
43
|
+
/** The pool whose accumulator advanced. */
|
|
44
|
+
pool: Address;
|
|
45
|
+
/** Token 0 reserve recorded at the advance; it prices the next interval. */
|
|
46
|
+
reserve0: number | bigint;
|
|
47
|
+
/** Token 1 reserve recorded at the advance; it prices the next interval. */
|
|
48
|
+
reserve1: number | bigint;
|
|
49
|
+
/**
|
|
50
|
+
* Low 128 bits of the Q64.64 price-time integral after the advance.
|
|
51
|
+
* Combine with `price_0_cumulative_high_last` as `low + high * 2^128`.
|
|
52
|
+
*/
|
|
53
|
+
price0CumulativeLast: number | bigint;
|
|
54
|
+
/** High 128 bits of the Q64.64 price-time integral after the advance. */
|
|
55
|
+
price0CumulativeHighLast: number | bigint;
|
|
56
|
+
/** Unix second of the advance. */
|
|
57
|
+
lastUpdateTimestamp: number | bigint; };
|
|
58
|
+
|
|
59
|
+
/** Gets the encoder for {@link PoolSyncedEventArgs} event data. */
|
|
60
|
+
export function getPoolSyncedEventEncoder(): FixedSizeEncoder<PoolSyncedEventArgs> {
|
|
61
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['migrationVersion', getU8Encoder()], ['pool', getAddressEncoder()], ['reserve0', getU64Encoder()], ['reserve1', getU64Encoder()], ['price0CumulativeLast', getU128Encoder()], ['price0CumulativeHighLast', getU128Encoder()], ['lastUpdateTimestamp', getU64Encoder()]]), (value) => ({ ...value, discriminator: 5, migrationVersion: 1 }));
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Gets the decoder for {@link PoolSyncedEvent} event data. */
|
|
65
|
+
export function getPoolSyncedEventDecoder(): FixedSizeDecoder<PoolSyncedEvent> {
|
|
66
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(POOL_SYNCED_EVENT_DISCRIMINATOR, getU8Decoder())], ['migrationVersion', getPinaPodMigrationVersionDecoder(1, getU8Decoder())], ['pool', getAddressDecoder()], ['reserve0', getU64Decoder()], ['reserve1', getU64Decoder()], ['price0CumulativeLast', getU128Decoder()], ['price0CumulativeHighLast', getU128Decoder()], ['lastUpdateTimestamp', getU64Decoder()]]);
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
/** Gets the codec for {@link PoolSyncedEvent} event data. */
|
|
70
|
+
export function getPoolSyncedEventCodec(): FixedSizeCodec<PoolSyncedEventArgs, PoolSyncedEvent> {
|
|
71
|
+
return combineCodec(getPoolSyncedEventEncoder(), getPoolSyncedEventDecoder());
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** Parses the provided bytes into {@link PoolSyncedEvent} event data. */
|
|
75
|
+
export function parsePoolSyncedEvent(data: ReadonlyUint8Array | Uint8Array): PoolSyncedEvent {
|
|
76
|
+
if (containsBytes(data, getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(POOL_SYNCED_EVENT_DISCRIMINATOR2), 1)) { return getPoolSyncedEventDecoder().decode(data); }
|
|
77
|
+
throw new Error('The provided data does not match the "PoolSyncedEvent" event discriminators.');
|
|
78
|
+
}
|
|
@@ -0,0 +1,44 @@
|
|
|
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, getU128Decoder, getU128Encoder, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, transformEncoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type ReadonlyUint8Array } from '@solana/kit';
|
|
11
|
+
|
|
12
|
+
export const POOL_SYNCED_V0_EVENT_DISCRIMINATOR = 5;
|
|
13
|
+
|
|
14
|
+
export function getPoolSyncedV0EventDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR); }
|
|
15
|
+
|
|
16
|
+
export const POOL_SYNCED_V0_EVENT_DISCRIMINATOR2 = 0;
|
|
17
|
+
|
|
18
|
+
export function getPoolSyncedV0EventDiscriminator2Bytes(): ReadonlyUint8Array { return getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR2); }
|
|
19
|
+
|
|
20
|
+
/** Version 0 of `PoolSynced`, as emitted before its current layout. Log records carrying this version decode with this event. */
|
|
21
|
+
export type PoolSyncedV0Event = { discriminator: number; migrationVersion: number; pool: Address; reserve0: bigint; reserve1: bigint; price0CumulativeLast: bigint; lastUpdateTimestamp: bigint; };
|
|
22
|
+
|
|
23
|
+
export type PoolSyncedV0EventArgs = { pool: Address; reserve0: number | bigint; reserve1: number | bigint; price0CumulativeLast: number | bigint; lastUpdateTimestamp: number | bigint; };
|
|
24
|
+
|
|
25
|
+
/** Gets the encoder for {@link PoolSyncedV0EventArgs} event data. */
|
|
26
|
+
export function getPoolSyncedV0EventEncoder(): FixedSizeEncoder<PoolSyncedV0EventArgs> {
|
|
27
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['migrationVersion', getU8Encoder()], ['pool', getAddressEncoder()], ['reserve0', getU64Encoder()], ['reserve1', getU64Encoder()], ['price0CumulativeLast', getU128Encoder()], ['lastUpdateTimestamp', getU64Encoder()]]), (value) => ({ ...value, discriminator: 5, migrationVersion: 0 }));
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Gets the decoder for {@link PoolSyncedV0Event} event data. */
|
|
31
|
+
export function getPoolSyncedV0EventDecoder(): FixedSizeDecoder<PoolSyncedV0Event> {
|
|
32
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(POOL_SYNCED_V0_EVENT_DISCRIMINATOR, getU8Decoder())], ['migrationVersion', getPinaPodMigrationVersionDecoder(0, getU8Decoder())], ['pool', getAddressDecoder()], ['reserve0', getU64Decoder()], ['reserve1', getU64Decoder()], ['price0CumulativeLast', getU128Decoder()], ['lastUpdateTimestamp', getU64Decoder()]]);
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** Gets the codec for {@link PoolSyncedV0Event} event data. */
|
|
36
|
+
export function getPoolSyncedV0EventCodec(): FixedSizeCodec<PoolSyncedV0EventArgs, PoolSyncedV0Event> {
|
|
37
|
+
return combineCodec(getPoolSyncedV0EventEncoder(), getPoolSyncedV0EventDecoder());
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Parses the provided bytes into {@link PoolSyncedV0Event} event data. */
|
|
41
|
+
export function parsePoolSyncedV0Event(data: ReadonlyUint8Array | Uint8Array): PoolSyncedV0Event {
|
|
42
|
+
if (containsBytes(data, getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(POOL_SYNCED_V0_EVENT_DISCRIMINATOR2), 1)) { return getPoolSyncedV0EventDecoder().decode(data); }
|
|
43
|
+
throw new Error('The provided data does not match the "PoolSyncedV0Event" event discriminators.');
|
|
44
|
+
}
|
|
@@ -0,0 +1,100 @@
|
|
|
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, getU64Decoder, getU64Encoder, getU8Decoder, getU8Encoder, transformEncoder, type Address, type FixedSizeCodec, type FixedSizeDecoder, type FixedSizeEncoder, type ReadonlyUint8Array } from '@solana/kit';
|
|
11
|
+
|
|
12
|
+
export const SWAPPED_EVENT_DISCRIMINATOR = 2;
|
|
13
|
+
|
|
14
|
+
export function getSwappedEventDiscriminatorBytes(): ReadonlyUint8Array { return getU8Encoder().encode(SWAPPED_EVENT_DISCRIMINATOR); }
|
|
15
|
+
|
|
16
|
+
export const SWAPPED_EVENT_DISCRIMINATOR2 = 0;
|
|
17
|
+
|
|
18
|
+
export function getSwappedEventDiscriminator2Bytes(): ReadonlyUint8Array { return getU8Encoder().encode(SWAPPED_EVENT_DISCRIMINATOR2); }
|
|
19
|
+
|
|
20
|
+
/** Emitted by `SwapExactIn` and `SwapExactOut`. */
|
|
21
|
+
export type SwappedEvent = { discriminator: number; migrationVersion: number;
|
|
22
|
+
/** The pool traded against. */
|
|
23
|
+
pool: Address;
|
|
24
|
+
/** The trader who signed. */
|
|
25
|
+
trader: Address;
|
|
26
|
+
/** `1` when the trader sold token 0 for token 1, `0` for the reverse. */
|
|
27
|
+
zeroForOne: number;
|
|
28
|
+
/** Tokens the trader paid. */
|
|
29
|
+
amountIn: bigint;
|
|
30
|
+
/** Tokens the trader received. */
|
|
31
|
+
amountOut: bigint;
|
|
32
|
+
/** Trade fee in the input token, including the protocol share. */
|
|
33
|
+
tradeFee: bigint;
|
|
34
|
+
/** Protocol share of the trade fee, in the input token. */
|
|
35
|
+
protocolFee: bigint;
|
|
36
|
+
/**
|
|
37
|
+
* Creator fee. It is in the input token when `creator_fee_on_input` is
|
|
38
|
+
* set and in the output token otherwise.
|
|
39
|
+
*/
|
|
40
|
+
creatorFee: bigint;
|
|
41
|
+
/**
|
|
42
|
+
* `1` when `creator_fee` is denominated in the input token, `0` when it is
|
|
43
|
+
* in the output token.
|
|
44
|
+
*/
|
|
45
|
+
creatorFeeOnInput: number;
|
|
46
|
+
/** Token 0 reserve after the swap. */
|
|
47
|
+
reserve0: bigint;
|
|
48
|
+
/** Token 1 reserve after the swap. */
|
|
49
|
+
reserve1: bigint; };
|
|
50
|
+
|
|
51
|
+
export type SwappedEventArgs = {
|
|
52
|
+
/** The pool traded against. */
|
|
53
|
+
pool: Address;
|
|
54
|
+
/** The trader who signed. */
|
|
55
|
+
trader: Address;
|
|
56
|
+
/** `1` when the trader sold token 0 for token 1, `0` for the reverse. */
|
|
57
|
+
zeroForOne: number;
|
|
58
|
+
/** Tokens the trader paid. */
|
|
59
|
+
amountIn: number | bigint;
|
|
60
|
+
/** Tokens the trader received. */
|
|
61
|
+
amountOut: number | bigint;
|
|
62
|
+
/** Trade fee in the input token, including the protocol share. */
|
|
63
|
+
tradeFee: number | bigint;
|
|
64
|
+
/** Protocol share of the trade fee, in the input token. */
|
|
65
|
+
protocolFee: number | bigint;
|
|
66
|
+
/**
|
|
67
|
+
* Creator fee. It is in the input token when `creator_fee_on_input` is
|
|
68
|
+
* set and in the output token otherwise.
|
|
69
|
+
*/
|
|
70
|
+
creatorFee: number | bigint;
|
|
71
|
+
/**
|
|
72
|
+
* `1` when `creator_fee` is denominated in the input token, `0` when it is
|
|
73
|
+
* in the output token.
|
|
74
|
+
*/
|
|
75
|
+
creatorFeeOnInput: number;
|
|
76
|
+
/** Token 0 reserve after the swap. */
|
|
77
|
+
reserve0: number | bigint;
|
|
78
|
+
/** Token 1 reserve after the swap. */
|
|
79
|
+
reserve1: number | bigint; };
|
|
80
|
+
|
|
81
|
+
/** Gets the encoder for {@link SwappedEventArgs} event data. */
|
|
82
|
+
export function getSwappedEventEncoder(): FixedSizeEncoder<SwappedEventArgs> {
|
|
83
|
+
return transformEncoder(getStructEncoder([['discriminator', getU8Encoder()], ['migrationVersion', getU8Encoder()], ['pool', getAddressEncoder()], ['trader', getAddressEncoder()], ['zeroForOne', getU8Encoder()], ['amountIn', getU64Encoder()], ['amountOut', getU64Encoder()], ['tradeFee', getU64Encoder()], ['protocolFee', getU64Encoder()], ['creatorFee', getU64Encoder()], ['creatorFeeOnInput', getU8Encoder()], ['reserve0', getU64Encoder()], ['reserve1', getU64Encoder()]]), (value) => ({ ...value, discriminator: 2, migrationVersion: 0 }));
|
|
84
|
+
}
|
|
85
|
+
|
|
86
|
+
/** Gets the decoder for {@link SwappedEvent} event data. */
|
|
87
|
+
export function getSwappedEventDecoder(): FixedSizeDecoder<SwappedEvent> {
|
|
88
|
+
return getStructDecoder([['discriminator', getPinaPodDiscriminatorDecoder(SWAPPED_EVENT_DISCRIMINATOR, getU8Decoder())], ['migrationVersion', getPinaPodMigrationVersionDecoder(0, getU8Decoder())], ['pool', getAddressDecoder()], ['trader', getAddressDecoder()], ['zeroForOne', getU8Decoder()], ['amountIn', getU64Decoder()], ['amountOut', getU64Decoder()], ['tradeFee', getU64Decoder()], ['protocolFee', getU64Decoder()], ['creatorFee', getU64Decoder()], ['creatorFeeOnInput', getU8Decoder()], ['reserve0', getU64Decoder()], ['reserve1', getU64Decoder()]]);
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
/** Gets the codec for {@link SwappedEvent} event data. */
|
|
92
|
+
export function getSwappedEventCodec(): FixedSizeCodec<SwappedEventArgs, SwappedEvent> {
|
|
93
|
+
return combineCodec(getSwappedEventEncoder(), getSwappedEventDecoder());
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Parses the provided bytes into {@link SwappedEvent} event data. */
|
|
97
|
+
export function parseSwappedEvent(data: ReadonlyUint8Array | Uint8Array): SwappedEvent {
|
|
98
|
+
if (containsBytes(data, getU8Encoder().encode(SWAPPED_EVENT_DISCRIMINATOR), 0) && containsBytes(data, getU8Encoder().encode(SWAPPED_EVENT_DISCRIMINATOR2), 1)) { return getSwappedEventDecoder().decode(data); }
|
|
99
|
+
throw new Error('The provided data does not match the "SwappedEvent" event discriminators.');
|
|
100
|
+
}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
+
export * from './accounts';
|
|
10
|
+
export * from './errors';
|
|
11
|
+
export * from './events';
|
|
12
|
+
export * from './instructions';
|
|
13
|
+
export * from './pdas';
|
|
14
|
+
export * from './programs';
|
|
@@ -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
|
+
}
|