@picon-finance/dlmm-sdk 1.18.3 → 2.0.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 +18 -8
- package/dist/entities/admin_config.d.ts +2 -2
- package/dist/entities/admin_config.d.ts.map +1 -1
- package/dist/entities/admin_config.js +2 -2
- package/dist/entities/bin_array.d.ts +2 -2
- package/dist/entities/bin_array.d.ts.map +1 -1
- package/dist/entities/bin_array.js +5 -5
- package/dist/entities/dlmm_program.d.ts +3 -3
- package/dist/entities/dlmm_program.d.ts.map +1 -1
- package/dist/entities/dlmm_program.js +5 -5
- package/dist/entities/index.d.ts +6 -6
- package/dist/entities/index.d.ts.map +1 -1
- package/dist/entities/index.js +6 -6
- package/dist/entities/pool.d.ts +6 -6
- package/dist/entities/pool.d.ts.map +1 -1
- package/dist/entities/pool.js +11 -11
- package/dist/entities/position.d.ts +5 -5
- package/dist/entities/position.d.ts.map +1 -1
- package/dist/entities/position.js +11 -11
- package/dist/entities/position_pool.js +2 -2
- package/dist/events.d.ts +8 -67
- package/dist/events.d.ts.map +1 -1
- package/dist/events.js +35 -109
- package/dist/generated/accounts/binArray.d.ts +1 -1
- package/dist/generated/accounts/binArray.d.ts.map +1 -1
- package/dist/generated/accounts/binArray.js +1 -1
- package/dist/generated/accounts/index.d.ts +4 -4
- package/dist/generated/accounts/index.d.ts.map +1 -1
- package/dist/generated/accounts/index.js +4 -4
- package/dist/generated/accounts/pool.d.ts +1 -1
- package/dist/generated/accounts/pool.d.ts.map +1 -1
- package/dist/generated/accounts/pool.js +1 -1
- package/dist/generated/accounts/position.d.ts +1 -1
- package/dist/generated/accounts/position.d.ts.map +1 -1
- package/dist/generated/accounts/position.js +1 -1
- package/dist/generated/constants/index.d.ts +9 -0
- package/dist/generated/constants/index.d.ts.map +1 -0
- package/dist/generated/constants/index.js +8 -0
- package/dist/generated/constants/piconDlmm.d.ts +17 -0
- package/dist/generated/constants/piconDlmm.d.ts.map +1 -0
- package/dist/generated/constants/piconDlmm.js +16 -0
- package/dist/generated/errors/index.d.ts +1 -1
- package/dist/generated/errors/index.d.ts.map +1 -1
- package/dist/generated/errors/index.js +1 -1
- package/dist/generated/errors/piconDlmm.js +1 -1
- package/dist/generated/events/claimFeeEvent.d.ts +41 -0
- package/dist/generated/events/claimFeeEvent.d.ts.map +1 -0
- package/dist/generated/events/claimFeeEvent.js +51 -0
- package/dist/generated/events/closePositionEvent.d.ts +27 -0
- package/dist/generated/events/closePositionEvent.d.ts.map +1 -0
- package/dist/generated/events/closePositionEvent.js +43 -0
- package/dist/generated/events/createPoolEvent.d.ts +27 -0
- package/dist/generated/events/createPoolEvent.d.ts.map +1 -0
- package/dist/generated/events/createPoolEvent.js +43 -0
- package/dist/generated/events/depositEvent.d.ts +41 -0
- package/dist/generated/events/depositEvent.d.ts.map +1 -0
- package/dist/generated/events/depositEvent.js +51 -0
- package/dist/generated/events/index.d.ts +15 -0
- package/dist/generated/events/index.d.ts.map +1 -0
- package/dist/generated/events/index.js +14 -0
- package/dist/generated/events/openPositionEvent.d.ts +27 -0
- package/dist/generated/events/openPositionEvent.d.ts.map +1 -0
- package/dist/generated/events/openPositionEvent.js +43 -0
- package/dist/generated/events/swapEvent.d.ts +43 -0
- package/dist/generated/events/swapEvent.d.ts.map +1 -0
- package/dist/generated/events/swapEvent.js +53 -0
- package/dist/generated/events/withdrawEvent.d.ts +43 -0
- package/dist/generated/events/withdrawEvent.d.ts.map +1 -0
- package/dist/generated/events/withdrawEvent.js +53 -0
- package/dist/generated/index.d.ts +8 -6
- package/dist/generated/index.d.ts.map +1 -1
- package/dist/generated/index.js +8 -6
- package/dist/generated/instructions/acceptAdminAuthority.d.ts +1 -1
- package/dist/generated/instructions/acceptAdminAuthority.d.ts.map +1 -1
- package/dist/generated/instructions/acceptAdminAuthority.js +3 -3
- package/dist/generated/instructions/claimFee.d.ts +2 -2
- package/dist/generated/instructions/claimFee.d.ts.map +1 -1
- package/dist/generated/instructions/claimFee.js +2 -2
- package/dist/generated/instructions/claimProtocolFee.d.ts +2 -2
- package/dist/generated/instructions/claimProtocolFee.d.ts.map +1 -1
- package/dist/generated/instructions/claimProtocolFee.js +4 -4
- package/dist/generated/instructions/closePosition.d.ts +1 -1
- package/dist/generated/instructions/closePosition.d.ts.map +1 -1
- package/dist/generated/instructions/closePosition.js +3 -3
- package/dist/generated/instructions/createAdminConfig.d.ts +1 -1
- package/dist/generated/instructions/createAdminConfig.d.ts.map +1 -1
- package/dist/generated/instructions/createAdminConfig.js +3 -3
- package/dist/generated/instructions/createBinArray.d.ts +1 -1
- package/dist/generated/instructions/createBinArray.d.ts.map +1 -1
- package/dist/generated/instructions/createBinArray.js +3 -3
- package/dist/generated/instructions/createPool.d.ts +1 -1
- package/dist/generated/instructions/createPool.d.ts.map +1 -1
- package/dist/generated/instructions/createPool.js +4 -4
- package/dist/generated/instructions/deleteBinArray.d.ts +1 -1
- package/dist/generated/instructions/deleteBinArray.d.ts.map +1 -1
- package/dist/generated/instructions/deleteBinArray.js +4 -4
- package/dist/generated/instructions/depositByWeight.d.ts +2 -2
- package/dist/generated/instructions/depositByWeight.d.ts.map +1 -1
- package/dist/generated/instructions/depositByWeight.js +2 -2
- package/dist/generated/instructions/index.d.ts +19 -19
- package/dist/generated/instructions/index.d.ts.map +1 -1
- package/dist/generated/instructions/index.js +19 -19
- package/dist/generated/instructions/openPosition.d.ts +1 -1
- package/dist/generated/instructions/openPosition.d.ts.map +1 -1
- package/dist/generated/instructions/openPosition.js +4 -4
- package/dist/generated/instructions/resetAdminAuthority.d.ts +1 -1
- package/dist/generated/instructions/resetAdminAuthority.d.ts.map +1 -1
- package/dist/generated/instructions/resetAdminAuthority.js +3 -3
- package/dist/generated/instructions/setMetadataUpdateAuthority.d.ts +1 -1
- package/dist/generated/instructions/setMetadataUpdateAuthority.d.ts.map +1 -1
- package/dist/generated/instructions/setMetadataUpdateAuthority.js +3 -3
- package/dist/generated/instructions/setPoolDynamicFeeConfig.d.ts +2 -2
- package/dist/generated/instructions/setPoolDynamicFeeConfig.d.ts.map +1 -1
- package/dist/generated/instructions/setPoolDynamicFeeConfig.js +4 -4
- package/dist/generated/instructions/setPoolProtocolShare.d.ts +1 -1
- package/dist/generated/instructions/setPoolProtocolShare.d.ts.map +1 -1
- package/dist/generated/instructions/setPoolProtocolShare.js +3 -3
- package/dist/generated/instructions/swapExactIn.d.ts +2 -2
- package/dist/generated/instructions/swapExactIn.d.ts.map +1 -1
- package/dist/generated/instructions/swapExactIn.js +2 -2
- package/dist/generated/instructions/swapExactOut.d.ts +2 -2
- package/dist/generated/instructions/swapExactOut.d.ts.map +1 -1
- package/dist/generated/instructions/swapExactOut.js +2 -2
- package/dist/generated/instructions/syncPool.d.ts +2 -2
- package/dist/generated/instructions/syncPool.d.ts.map +1 -1
- package/dist/generated/instructions/syncPool.js +2 -2
- package/dist/generated/instructions/transferAdminAuthority.d.ts +1 -1
- package/dist/generated/instructions/transferAdminAuthority.d.ts.map +1 -1
- package/dist/generated/instructions/transferAdminAuthority.js +3 -3
- package/dist/generated/instructions/withdraw.d.ts +2 -2
- package/dist/generated/instructions/withdraw.d.ts.map +1 -1
- package/dist/generated/instructions/withdraw.js +2 -2
- package/dist/generated/pdas/index.d.ts +4 -4
- package/dist/generated/pdas/index.d.ts.map +1 -1
- package/dist/generated/pdas/index.js +4 -4
- package/dist/generated/programs/index.d.ts +1 -1
- package/dist/generated/programs/index.d.ts.map +1 -1
- package/dist/generated/programs/index.js +1 -1
- package/dist/generated/programs/piconDlmm.d.ts +15 -3
- package/dist/generated/programs/piconDlmm.d.ts.map +1 -1
- package/dist/generated/programs/piconDlmm.js +38 -3
- package/dist/generated/types/accountGroup.d.ts +1 -1
- package/dist/generated/types/accountGroup.d.ts.map +1 -1
- package/dist/generated/types/accountGroup.js +1 -1
- package/dist/generated/types/dynamicFeeState.d.ts +1 -1
- package/dist/generated/types/dynamicFeeState.d.ts.map +1 -1
- package/dist/generated/types/dynamicFeeState.js +1 -1
- package/dist/generated/types/index.d.ts +8 -8
- package/dist/generated/types/index.d.ts.map +1 -1
- package/dist/generated/types/index.js +8 -8
- package/dist/generated/types/remainingAccountsScheme.d.ts +1 -1
- package/dist/generated/types/remainingAccountsScheme.d.ts.map +1 -1
- package/dist/generated/types/remainingAccountsScheme.js +1 -1
- package/dist/index.d.ts +9 -9
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +8 -8
- package/dist/program_addresses.d.ts +1 -1
- package/dist/program_addresses.d.ts.map +1 -1
- package/dist/program_addresses.js +1 -1
- package/dist/utils/assert.d.ts +1 -1
- package/dist/utils/assert.d.ts.map +1 -1
- package/dist/utils/bin_location.js +1 -1
- package/dist/utils/constants.d.ts +1 -9
- package/dist/utils/constants.d.ts.map +1 -1
- package/dist/utils/constants.js +1 -34
- package/dist/utils/price.js +3 -3
- package/dist/utils/transfer_fee.d.ts +1 -1
- package/dist/utils/transfer_fee.d.ts.map +1 -1
- package/dist/utils/transfer_hook.d.ts +1 -1
- package/dist/utils/transfer_hook.d.ts.map +1 -1
- package/dist/utils/transfer_hook.js +1 -1
- package/package.json +10 -10
- package/src/entities/admin_config.ts +3 -3
- package/src/entities/bin_array.ts +6 -6
- package/src/entities/dlmm_program.ts +7 -7
- package/src/entities/index.ts +6 -6
- package/src/entities/pool.ts +12 -12
- package/src/entities/position.ts +13 -13
- package/src/entities/position_pool.ts +2 -2
- package/src/events.ts +66 -199
- package/src/generated/accounts/binArray.ts +6 -1
- package/src/generated/accounts/index.ts +4 -4
- package/src/generated/accounts/pool.ts +1 -1
- package/src/generated/accounts/position.ts +1 -1
- package/src/generated/constants/index.ts +9 -0
- package/src/generated/constants/piconDlmm.ts +25 -0
- package/src/generated/errors/index.ts +1 -1
- package/src/generated/errors/piconDlmm.ts +1 -1
- package/src/generated/events/claimFeeEvent.ts +123 -0
- package/src/generated/events/closePositionEvent.ts +99 -0
- package/src/generated/events/createPoolEvent.ts +101 -0
- package/src/generated/events/depositEvent.ts +123 -0
- package/src/generated/events/index.ts +15 -0
- package/src/generated/events/openPositionEvent.ts +99 -0
- package/src/generated/events/swapEvent.ts +126 -0
- package/src/generated/events/withdrawEvent.ts +129 -0
- package/src/generated/index.ts +8 -6
- package/src/generated/instructions/acceptAdminAuthority.ts +3 -3
- package/src/generated/instructions/claimFee.ts +2 -2
- package/src/generated/instructions/claimProtocolFee.ts +4 -4
- package/src/generated/instructions/closePosition.ts +11 -8
- package/src/generated/instructions/createAdminConfig.ts +3 -3
- package/src/generated/instructions/createBinArray.ts +12 -9
- package/src/generated/instructions/createPool.ts +18 -15
- package/src/generated/instructions/deleteBinArray.ts +10 -7
- package/src/generated/instructions/depositByWeight.ts +2 -2
- package/src/generated/instructions/index.ts +19 -19
- package/src/generated/instructions/openPosition.ts +12 -9
- package/src/generated/instructions/resetAdminAuthority.ts +3 -3
- package/src/generated/instructions/setMetadataUpdateAuthority.ts +3 -3
- package/src/generated/instructions/setPoolDynamicFeeConfig.ts +4 -4
- package/src/generated/instructions/setPoolProtocolShare.ts +3 -3
- package/src/generated/instructions/swapExactIn.ts +2 -2
- package/src/generated/instructions/swapExactOut.ts +2 -2
- package/src/generated/instructions/syncPool.ts +2 -2
- package/src/generated/instructions/transferAdminAuthority.ts +3 -3
- package/src/generated/instructions/withdraw.ts +2 -2
- package/src/generated/pdas/index.ts +4 -4
- package/src/generated/programs/index.ts +1 -1
- package/src/generated/programs/piconDlmm.ts +99 -3
- package/src/generated/types/accountGroup.ts +1 -1
- package/src/generated/types/dynamicFeeState.ts +1 -1
- package/src/generated/types/index.ts +8 -8
- package/src/generated/types/remainingAccountsScheme.ts +1 -1
- package/src/index.ts +9 -9
- package/src/program_addresses.ts +1 -1
- package/src/utils/assert.ts +1 -1
- package/src/utils/bin_location.ts +1 -1
- package/src/utils/constants.ts +11 -39
- package/src/utils/price.ts +3 -3
- package/src/utils/transfer_fee.ts +1 -1
- package/src/utils/transfer_hook.ts +1 -1
- package/dist/picon_dlmm.json +0 -2639
package/src/events.ts
CHANGED
|
@@ -1,199 +1,54 @@
|
|
|
1
|
-
//
|
|
2
|
-
//
|
|
3
|
-
//
|
|
4
|
-
//
|
|
5
|
-
//
|
|
6
|
-
//
|
|
1
|
+
// Event shapes/codecs/discriminators are generated (src/generated/events/*, via Codama's
|
|
2
|
+
// event-rendering support added in @codama/renderers-js 2.4.0 + @codama/nodes-from-anchor's
|
|
3
|
+
// eventNodeFromAnchorV01). What stays hand-written here — and always will — is the log-parsing
|
|
4
|
+
// and subscription layer: none of it is IDL-derivable. The IDL says nothing about Anchor's
|
|
5
|
+
// `emit!` writing events as `Program data: <base64>` log lines, about how to scope those lines
|
|
6
|
+
// to this program specifically when a transaction's logs interleave multiple programs' output
|
|
7
|
+
// via CPI, or about how to actually subscribe to get logs over the wire in the first place —
|
|
8
|
+
// those are runtime/RPC-client facts, not data-shape facts, and no IDL revision could add them.
|
|
9
|
+
//
|
|
10
|
+
// Re-exported here under the IDL's own single-"Event" names (SwapEvent, not the generated
|
|
11
|
+
// module's SwapEventEvent — Codama appends its own "Event" suffix on top of names that already
|
|
12
|
+
// end in one) so nothing downstream needs to change on this migration.
|
|
7
13
|
import {
|
|
8
14
|
type Address,
|
|
9
15
|
type Commitment,
|
|
10
16
|
type createSolanaRpcSubscriptions,
|
|
11
|
-
getAddressDecoder,
|
|
12
17
|
getBase64Encoder,
|
|
13
|
-
getBooleanDecoder,
|
|
14
|
-
getI32Decoder,
|
|
15
|
-
getStructDecoder,
|
|
16
|
-
getU16Decoder,
|
|
17
|
-
getU32Decoder,
|
|
18
|
-
getU64Decoder,
|
|
19
|
-
type FixedSizeDecoder,
|
|
20
18
|
type ReadonlyUint8Array,
|
|
21
19
|
} from "@solana/kit";
|
|
22
|
-
import { PICON_DLMM_PROGRAM_ADDRESS } from "./generated";
|
|
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
|
-
export type
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
amountX: bigint;
|
|
55
|
-
amountY: bigint;
|
|
56
|
-
transferFeeX: bigint;
|
|
57
|
-
transferFeeY: bigint;
|
|
58
|
-
};
|
|
59
|
-
|
|
60
|
-
export type WithdrawEvent = {
|
|
61
|
-
pool: Address;
|
|
62
|
-
position: Address;
|
|
63
|
-
owner: Address;
|
|
64
|
-
lowerBinId: number;
|
|
65
|
-
upperBinId: number;
|
|
66
|
-
bpsRemoved: number;
|
|
67
|
-
amountX: bigint;
|
|
68
|
-
amountY: bigint;
|
|
69
|
-
transferFeeX: bigint;
|
|
70
|
-
transferFeeY: bigint;
|
|
71
|
-
};
|
|
72
|
-
|
|
73
|
-
export type ClaimFeeEvent = {
|
|
74
|
-
pool: Address;
|
|
75
|
-
position: Address;
|
|
76
|
-
owner: Address;
|
|
77
|
-
lowerBinId: number;
|
|
78
|
-
upperBinId: number;
|
|
79
|
-
amountX: bigint;
|
|
80
|
-
amountY: bigint;
|
|
81
|
-
transferFeeX: bigint;
|
|
82
|
-
transferFeeY: bigint;
|
|
83
|
-
};
|
|
84
|
-
|
|
85
|
-
export type SwapEvent = {
|
|
86
|
-
pool: Address;
|
|
87
|
-
xToY: boolean;
|
|
88
|
-
preBinId: number;
|
|
89
|
-
postBinId: number;
|
|
90
|
-
amountIn: bigint;
|
|
91
|
-
amountOut: bigint;
|
|
92
|
-
inputTransferFee: bigint;
|
|
93
|
-
outputTransferFee: bigint;
|
|
94
|
-
lpFee: bigint;
|
|
95
|
-
protocolFee: bigint;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
function getCreatePoolEventDecoder(): FixedSizeDecoder<CreatePoolEvent> {
|
|
99
|
-
return getStructDecoder([
|
|
100
|
-
["pool", getAddressDecoder()],
|
|
101
|
-
["binStep", getU16Decoder()],
|
|
102
|
-
["feeRate", getU32Decoder()],
|
|
103
|
-
["tokenMintX", getAddressDecoder()],
|
|
104
|
-
["tokenMintY", getAddressDecoder()],
|
|
105
|
-
]);
|
|
106
|
-
}
|
|
107
|
-
|
|
108
|
-
function getOpenPositionEventDecoder(): FixedSizeDecoder<OpenPositionEvent> {
|
|
109
|
-
return getStructDecoder([
|
|
110
|
-
["pool", getAddressDecoder()],
|
|
111
|
-
["position", getAddressDecoder()],
|
|
112
|
-
["owner", getAddressDecoder()],
|
|
113
|
-
["lowerBinId", getI32Decoder()],
|
|
114
|
-
["upperBinId", getI32Decoder()],
|
|
115
|
-
]);
|
|
116
|
-
}
|
|
117
|
-
|
|
118
|
-
function getClosePositionEventDecoder(): FixedSizeDecoder<ClosePositionEvent> {
|
|
119
|
-
return getStructDecoder([
|
|
120
|
-
["pool", getAddressDecoder()],
|
|
121
|
-
["position", getAddressDecoder()],
|
|
122
|
-
["owner", getAddressDecoder()],
|
|
123
|
-
["lowerBinId", getI32Decoder()],
|
|
124
|
-
["upperBinId", getI32Decoder()],
|
|
125
|
-
]);
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
function getDepositEventDecoder(): FixedSizeDecoder<DepositEvent> {
|
|
129
|
-
return getStructDecoder([
|
|
130
|
-
["pool", getAddressDecoder()],
|
|
131
|
-
["position", getAddressDecoder()],
|
|
132
|
-
["owner", getAddressDecoder()],
|
|
133
|
-
["lowerBinId", getI32Decoder()],
|
|
134
|
-
["upperBinId", getI32Decoder()],
|
|
135
|
-
["amountX", getU64Decoder()],
|
|
136
|
-
["amountY", getU64Decoder()],
|
|
137
|
-
["transferFeeX", getU64Decoder()],
|
|
138
|
-
["transferFeeY", getU64Decoder()],
|
|
139
|
-
]);
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
function getWithdrawEventDecoder(): FixedSizeDecoder<WithdrawEvent> {
|
|
143
|
-
return getStructDecoder([
|
|
144
|
-
["pool", getAddressDecoder()],
|
|
145
|
-
["position", getAddressDecoder()],
|
|
146
|
-
["owner", getAddressDecoder()],
|
|
147
|
-
["lowerBinId", getI32Decoder()],
|
|
148
|
-
["upperBinId", getI32Decoder()],
|
|
149
|
-
["bpsRemoved", getU16Decoder()],
|
|
150
|
-
["amountX", getU64Decoder()],
|
|
151
|
-
["amountY", getU64Decoder()],
|
|
152
|
-
["transferFeeX", getU64Decoder()],
|
|
153
|
-
["transferFeeY", getU64Decoder()],
|
|
154
|
-
]);
|
|
155
|
-
}
|
|
156
|
-
|
|
157
|
-
function getClaimFeeEventDecoder(): FixedSizeDecoder<ClaimFeeEvent> {
|
|
158
|
-
return getStructDecoder([
|
|
159
|
-
["pool", getAddressDecoder()],
|
|
160
|
-
["position", getAddressDecoder()],
|
|
161
|
-
["owner", getAddressDecoder()],
|
|
162
|
-
["lowerBinId", getI32Decoder()],
|
|
163
|
-
["upperBinId", getI32Decoder()],
|
|
164
|
-
["amountX", getU64Decoder()],
|
|
165
|
-
["amountY", getU64Decoder()],
|
|
166
|
-
["transferFeeX", getU64Decoder()],
|
|
167
|
-
["transferFeeY", getU64Decoder()],
|
|
168
|
-
]);
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
function getSwapEventDecoder(): FixedSizeDecoder<SwapEvent> {
|
|
172
|
-
return getStructDecoder([
|
|
173
|
-
["pool", getAddressDecoder()],
|
|
174
|
-
["xToY", getBooleanDecoder()],
|
|
175
|
-
["preBinId", getI32Decoder()],
|
|
176
|
-
["postBinId", getI32Decoder()],
|
|
177
|
-
["amountIn", getU64Decoder()],
|
|
178
|
-
["amountOut", getU64Decoder()],
|
|
179
|
-
["inputTransferFee", getU64Decoder()],
|
|
180
|
-
["outputTransferFee", getU64Decoder()],
|
|
181
|
-
["lpFee", getU64Decoder()],
|
|
182
|
-
["protocolFee", getU64Decoder()],
|
|
183
|
-
]);
|
|
184
|
-
}
|
|
185
|
-
|
|
186
|
-
// Discriminators are the first 8 bytes of sha256("event:<EventName>") — copied from the IDL's
|
|
187
|
-
// `events` array (`ts-sdk/src/picon_dlmm.json`), same derivation Anchor uses for accounts.
|
|
188
|
-
const DISCRIMINATORS = {
|
|
189
|
-
CreatePoolEvent: [177, 49, 12, 210, 160, 118, 167, 116],
|
|
190
|
-
OpenPositionEvent: [83, 43, 164, 147, 169, 87, 81, 172],
|
|
191
|
-
ClosePositionEvent: [198, 217, 115, 95, 191, 120, 142, 137],
|
|
192
|
-
DepositEvent: [120, 248, 61, 83, 31, 142, 107, 144],
|
|
193
|
-
WithdrawEvent: [22, 9, 133, 26, 160, 44, 71, 192],
|
|
194
|
-
ClaimFeeEvent: [173, 80, 235, 15, 116, 19, 144, 33],
|
|
195
|
-
SwapEvent: [64, 198, 205, 232, 38, 8, 113, 226],
|
|
196
|
-
} as const satisfies Record<string, number[]>;
|
|
20
|
+
import { PICON_DLMM_PROGRAM_ADDRESS } from "./generated/index.js";
|
|
21
|
+
import {
|
|
22
|
+
type ClaimFeeEventEvent,
|
|
23
|
+
type ClosePositionEventEvent,
|
|
24
|
+
type CreatePoolEventEvent,
|
|
25
|
+
type DepositEventEvent,
|
|
26
|
+
type OpenPositionEventEvent,
|
|
27
|
+
type SwapEventEvent,
|
|
28
|
+
type WithdrawEventEvent,
|
|
29
|
+
getClaimFeeEventEventDecoder,
|
|
30
|
+
getClosePositionEventEventDecoder,
|
|
31
|
+
getCreatePoolEventEventDecoder,
|
|
32
|
+
getDepositEventEventDecoder,
|
|
33
|
+
getOpenPositionEventEventDecoder,
|
|
34
|
+
getSwapEventEventDecoder,
|
|
35
|
+
getWithdrawEventEventDecoder,
|
|
36
|
+
CLAIM_FEE_EVENT_EVENT_DISCRIMINATOR,
|
|
37
|
+
CLOSE_POSITION_EVENT_EVENT_DISCRIMINATOR,
|
|
38
|
+
CREATE_POOL_EVENT_EVENT_DISCRIMINATOR,
|
|
39
|
+
DEPOSIT_EVENT_EVENT_DISCRIMINATOR,
|
|
40
|
+
OPEN_POSITION_EVENT_EVENT_DISCRIMINATOR,
|
|
41
|
+
SWAP_EVENT_EVENT_DISCRIMINATOR,
|
|
42
|
+
WITHDRAW_EVENT_EVENT_DISCRIMINATOR,
|
|
43
|
+
} from "./generated/events/index.js";
|
|
44
|
+
|
|
45
|
+
export type CreatePoolEvent = CreatePoolEventEvent;
|
|
46
|
+
export type OpenPositionEvent = OpenPositionEventEvent;
|
|
47
|
+
export type ClosePositionEvent = ClosePositionEventEvent;
|
|
48
|
+
export type DepositEvent = DepositEventEvent;
|
|
49
|
+
export type WithdrawEvent = WithdrawEventEvent;
|
|
50
|
+
export type ClaimFeeEvent = ClaimFeeEventEvent;
|
|
51
|
+
export type SwapEvent = SwapEventEvent;
|
|
197
52
|
|
|
198
53
|
export type DlmmEvent =
|
|
199
54
|
| { name: "CreatePoolEvent", data: CreatePoolEvent }
|
|
@@ -204,14 +59,27 @@ export type DlmmEvent =
|
|
|
204
59
|
| { name: "ClaimFeeEvent", data: ClaimFeeEvent }
|
|
205
60
|
| { name: "SwapEvent", data: SwapEvent };
|
|
206
61
|
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
62
|
+
// Each generated decoder is a getHiddenPrefixDecoder wrapping its struct decoder — it expects
|
|
63
|
+
// the discriminator bytes still present at the front and verifies+strips them itself, so
|
|
64
|
+
// decodeEventBytes below feeds it the full byte range, not a pre-sliced body.
|
|
65
|
+
const DECODERS = {
|
|
66
|
+
CreatePoolEvent: getCreatePoolEventEventDecoder(),
|
|
67
|
+
OpenPositionEvent: getOpenPositionEventEventDecoder(),
|
|
68
|
+
ClosePositionEvent: getClosePositionEventEventDecoder(),
|
|
69
|
+
DepositEvent: getDepositEventEventDecoder(),
|
|
70
|
+
WithdrawEvent: getWithdrawEventEventDecoder(),
|
|
71
|
+
ClaimFeeEvent: getClaimFeeEventEventDecoder(),
|
|
72
|
+
SwapEvent: getSwapEventEventDecoder(),
|
|
73
|
+
} satisfies { [K in DlmmEvent["name"]]: { decode(bytes: ReadonlyUint8Array): Extract<DlmmEvent, { name: K }>["data"] } };
|
|
74
|
+
|
|
75
|
+
const DISCRIMINATORS: Record<DlmmEvent["name"], ReadonlyUint8Array> = {
|
|
76
|
+
CreatePoolEvent: CREATE_POOL_EVENT_EVENT_DISCRIMINATOR,
|
|
77
|
+
OpenPositionEvent: OPEN_POSITION_EVENT_EVENT_DISCRIMINATOR,
|
|
78
|
+
ClosePositionEvent: CLOSE_POSITION_EVENT_EVENT_DISCRIMINATOR,
|
|
79
|
+
DepositEvent: DEPOSIT_EVENT_EVENT_DISCRIMINATOR,
|
|
80
|
+
WithdrawEvent: WITHDRAW_EVENT_EVENT_DISCRIMINATOR,
|
|
81
|
+
ClaimFeeEvent: CLAIM_FEE_EVENT_EVENT_DISCRIMINATOR,
|
|
82
|
+
SwapEvent: SWAP_EVENT_EVENT_DISCRIMINATOR,
|
|
215
83
|
};
|
|
216
84
|
|
|
217
85
|
const PROGRAM_DATA_PREFIX = "Program data: ";
|
|
@@ -220,12 +88,11 @@ const PROGRAM_DATA_PREFIX = "Program data: ";
|
|
|
220
88
|
// base64 payload is [8-byte discriminator][borsh-encoded fields], same layout as an account.
|
|
221
89
|
function decodeEventBytes(bytes: ReadonlyUint8Array): DlmmEvent | undefined {
|
|
222
90
|
const discriminator = bytes.subarray(0, 8);
|
|
223
|
-
const body = bytes.subarray(8);
|
|
224
91
|
|
|
225
92
|
for (const name of Object.keys(DISCRIMINATORS) as DlmmEvent["name"][]) {
|
|
226
93
|
const expected = DISCRIMINATORS[name];
|
|
227
94
|
if (expected.every((byte, i) => byte === discriminator[i])) {
|
|
228
|
-
return { name, data: DECODERS[name].decode(
|
|
95
|
+
return { name, data: DECODERS[name].decode(bytes) } as DlmmEvent;
|
|
229
96
|
}
|
|
230
97
|
}
|
|
231
98
|
|
|
@@ -38,7 +38,12 @@ import {
|
|
|
38
38
|
type MaybeEncodedAccount,
|
|
39
39
|
type ReadonlyUint8Array,
|
|
40
40
|
} from "@solana/kit";
|
|
41
|
-
import {
|
|
41
|
+
import {
|
|
42
|
+
getBinDecoder,
|
|
43
|
+
getBinEncoder,
|
|
44
|
+
type Bin,
|
|
45
|
+
type BinArgs,
|
|
46
|
+
} from "../types/index.js";
|
|
42
47
|
|
|
43
48
|
export const BIN_ARRAY_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
|
44
49
|
92, 142, 92, 220, 5, 148, 70, 181,
|
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
* @see https://github.com/codama-idl/codama
|
|
7
7
|
*/
|
|
8
8
|
|
|
9
|
-
export * from "./adminConfig";
|
|
10
|
-
export * from "./binArray";
|
|
11
|
-
export * from "./pool";
|
|
12
|
-
export * from "./position";
|
|
9
|
+
export * from "./adminConfig.js";
|
|
10
|
+
export * from "./binArray.js";
|
|
11
|
+
export * from "./pool.js";
|
|
12
|
+
export * from "./position.js";
|
|
@@ -47,7 +47,7 @@ import {
|
|
|
47
47
|
getDynamicFeeStateEncoder,
|
|
48
48
|
type DynamicFeeState,
|
|
49
49
|
type DynamicFeeStateArgs,
|
|
50
|
-
} from "../types";
|
|
50
|
+
} from "../types/index.js";
|
|
51
51
|
|
|
52
52
|
export const POOL_DISCRIMINATOR: ReadonlyUint8Array = new Uint8Array([
|
|
53
53
|
241, 154, 109, 4, 17, 177, 109, 188,
|
|
@@ -0,0 +1,25 @@
|
|
|
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 const BINS_PER_BIN_ARRAY: number = 100;
|
|
10
|
+
|
|
11
|
+
export const DYNAMIC_FEE_DIVISOR: bigint = 100000000000n;
|
|
12
|
+
|
|
13
|
+
export const FEE_PRECISION: bigint = 1000000000n;
|
|
14
|
+
|
|
15
|
+
export const MAX_BASIS_POINTS: number = 10000;
|
|
16
|
+
|
|
17
|
+
export const MAX_BIN_ARRAYS_PER_POSITION: number = 2;
|
|
18
|
+
|
|
19
|
+
export const MAX_BIN_ARRAYS_PER_TRAVERSAL: number = 6;
|
|
20
|
+
|
|
21
|
+
export const MAX_FEE_RATE: bigint = 100000000n;
|
|
22
|
+
|
|
23
|
+
export const MAX_PROTOCOL_SHARE: number = 2500;
|
|
24
|
+
|
|
25
|
+
export const ONE_BPS_FEE_RATE: number = 100000;
|
|
@@ -12,7 +12,7 @@ import {
|
|
|
12
12
|
type SOLANA_ERROR__INSTRUCTION_ERROR__CUSTOM,
|
|
13
13
|
type SolanaError,
|
|
14
14
|
} from "@solana/kit";
|
|
15
|
-
import { PICON_DLMM_PROGRAM_ADDRESS } from "../programs";
|
|
15
|
+
import { PICON_DLMM_PROGRAM_ADDRESS } from "../programs/index.js";
|
|
16
16
|
|
|
17
17
|
/** LiquidityError: Liquidity error */
|
|
18
18
|
export const PICON_DLMM_ERROR__LIQUIDITY_ERROR = 0x1770; // 6000
|
|
@@ -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 {
|
|
10
|
+
combineCodec,
|
|
11
|
+
containsBytes,
|
|
12
|
+
fixEncoderSize,
|
|
13
|
+
getAddressDecoder,
|
|
14
|
+
getAddressEncoder,
|
|
15
|
+
getBytesEncoder,
|
|
16
|
+
getConstantDecoder,
|
|
17
|
+
getConstantEncoder,
|
|
18
|
+
getHiddenPrefixDecoder,
|
|
19
|
+
getHiddenPrefixEncoder,
|
|
20
|
+
getI32Decoder,
|
|
21
|
+
getI32Encoder,
|
|
22
|
+
getStructDecoder,
|
|
23
|
+
getStructEncoder,
|
|
24
|
+
getU64Decoder,
|
|
25
|
+
getU64Encoder,
|
|
26
|
+
type Address,
|
|
27
|
+
type FixedSizeCodec,
|
|
28
|
+
type FixedSizeDecoder,
|
|
29
|
+
type FixedSizeEncoder,
|
|
30
|
+
type ReadonlyUint8Array,
|
|
31
|
+
} from "@solana/kit";
|
|
32
|
+
|
|
33
|
+
export const CLAIM_FEE_EVENT_EVENT_DISCRIMINATOR: ReadonlyUint8Array =
|
|
34
|
+
new Uint8Array([173, 80, 235, 15, 116, 19, 144, 33]);
|
|
35
|
+
|
|
36
|
+
export function getClaimFeeEventEventDiscriminatorBytes(): ReadonlyUint8Array {
|
|
37
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
38
|
+
CLAIM_FEE_EVENT_EVENT_DISCRIMINATOR,
|
|
39
|
+
);
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export type ClaimFeeEventEvent = {
|
|
43
|
+
pool: Address;
|
|
44
|
+
position: Address;
|
|
45
|
+
owner: Address;
|
|
46
|
+
lowerBinId: number;
|
|
47
|
+
upperBinId: number;
|
|
48
|
+
amountX: bigint;
|
|
49
|
+
amountY: bigint;
|
|
50
|
+
transferFeeX: bigint;
|
|
51
|
+
transferFeeY: bigint;
|
|
52
|
+
};
|
|
53
|
+
|
|
54
|
+
export type ClaimFeeEventEventArgs = {
|
|
55
|
+
pool: Address;
|
|
56
|
+
position: Address;
|
|
57
|
+
owner: Address;
|
|
58
|
+
lowerBinId: number;
|
|
59
|
+
upperBinId: number;
|
|
60
|
+
amountX: number | bigint;
|
|
61
|
+
amountY: number | bigint;
|
|
62
|
+
transferFeeX: number | bigint;
|
|
63
|
+
transferFeeY: number | bigint;
|
|
64
|
+
};
|
|
65
|
+
|
|
66
|
+
/** Gets the encoder for {@link ClaimFeeEventEventArgs} event data. */
|
|
67
|
+
export function getClaimFeeEventEventEncoder(): FixedSizeEncoder<ClaimFeeEventEventArgs> {
|
|
68
|
+
return getHiddenPrefixEncoder(
|
|
69
|
+
getStructEncoder([
|
|
70
|
+
["pool", getAddressEncoder()],
|
|
71
|
+
["position", getAddressEncoder()],
|
|
72
|
+
["owner", getAddressEncoder()],
|
|
73
|
+
["lowerBinId", getI32Encoder()],
|
|
74
|
+
["upperBinId", getI32Encoder()],
|
|
75
|
+
["amountX", getU64Encoder()],
|
|
76
|
+
["amountY", getU64Encoder()],
|
|
77
|
+
["transferFeeX", getU64Encoder()],
|
|
78
|
+
["transferFeeY", getU64Encoder()],
|
|
79
|
+
]),
|
|
80
|
+
[getConstantEncoder(CLAIM_FEE_EVENT_EVENT_DISCRIMINATOR)],
|
|
81
|
+
);
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/** Gets the decoder for {@link ClaimFeeEventEvent} event data. */
|
|
85
|
+
export function getClaimFeeEventEventDecoder(): FixedSizeDecoder<ClaimFeeEventEvent> {
|
|
86
|
+
return getHiddenPrefixDecoder(
|
|
87
|
+
getStructDecoder([
|
|
88
|
+
["pool", getAddressDecoder()],
|
|
89
|
+
["position", getAddressDecoder()],
|
|
90
|
+
["owner", getAddressDecoder()],
|
|
91
|
+
["lowerBinId", getI32Decoder()],
|
|
92
|
+
["upperBinId", getI32Decoder()],
|
|
93
|
+
["amountX", getU64Decoder()],
|
|
94
|
+
["amountY", getU64Decoder()],
|
|
95
|
+
["transferFeeX", getU64Decoder()],
|
|
96
|
+
["transferFeeY", getU64Decoder()],
|
|
97
|
+
]),
|
|
98
|
+
[getConstantDecoder(CLAIM_FEE_EVENT_EVENT_DISCRIMINATOR)],
|
|
99
|
+
);
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
/** Gets the codec for {@link ClaimFeeEventEvent} event data. */
|
|
103
|
+
export function getClaimFeeEventEventCodec(): FixedSizeCodec<
|
|
104
|
+
ClaimFeeEventEventArgs,
|
|
105
|
+
ClaimFeeEventEvent
|
|
106
|
+
> {
|
|
107
|
+
return combineCodec(
|
|
108
|
+
getClaimFeeEventEventEncoder(),
|
|
109
|
+
getClaimFeeEventEventDecoder(),
|
|
110
|
+
);
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
/** Parses the provided bytes into {@link ClaimFeeEventEvent} event data. */
|
|
114
|
+
export function parseClaimFeeEventEvent(
|
|
115
|
+
data: ReadonlyUint8Array | Uint8Array,
|
|
116
|
+
): ClaimFeeEventEvent {
|
|
117
|
+
if (containsBytes(data, CLAIM_FEE_EVENT_EVENT_DISCRIMINATOR, 0)) {
|
|
118
|
+
return getClaimFeeEventEventDecoder().decode(data);
|
|
119
|
+
}
|
|
120
|
+
throw new Error(
|
|
121
|
+
'The provided data does not match the "ClaimFeeEventEvent" event discriminators.',
|
|
122
|
+
);
|
|
123
|
+
}
|
|
@@ -0,0 +1,99 @@
|
|
|
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 {
|
|
10
|
+
combineCodec,
|
|
11
|
+
containsBytes,
|
|
12
|
+
fixEncoderSize,
|
|
13
|
+
getAddressDecoder,
|
|
14
|
+
getAddressEncoder,
|
|
15
|
+
getBytesEncoder,
|
|
16
|
+
getConstantDecoder,
|
|
17
|
+
getConstantEncoder,
|
|
18
|
+
getHiddenPrefixDecoder,
|
|
19
|
+
getHiddenPrefixEncoder,
|
|
20
|
+
getI32Decoder,
|
|
21
|
+
getI32Encoder,
|
|
22
|
+
getStructDecoder,
|
|
23
|
+
getStructEncoder,
|
|
24
|
+
type Address,
|
|
25
|
+
type FixedSizeCodec,
|
|
26
|
+
type FixedSizeDecoder,
|
|
27
|
+
type FixedSizeEncoder,
|
|
28
|
+
type ReadonlyUint8Array,
|
|
29
|
+
} from "@solana/kit";
|
|
30
|
+
|
|
31
|
+
export const CLOSE_POSITION_EVENT_EVENT_DISCRIMINATOR: ReadonlyUint8Array =
|
|
32
|
+
new Uint8Array([198, 217, 115, 95, 191, 120, 142, 137]);
|
|
33
|
+
|
|
34
|
+
export function getClosePositionEventEventDiscriminatorBytes(): ReadonlyUint8Array {
|
|
35
|
+
return fixEncoderSize(getBytesEncoder(), 8).encode(
|
|
36
|
+
CLOSE_POSITION_EVENT_EVENT_DISCRIMINATOR,
|
|
37
|
+
);
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export type ClosePositionEventEvent = {
|
|
41
|
+
pool: Address;
|
|
42
|
+
position: Address;
|
|
43
|
+
owner: Address;
|
|
44
|
+
lowerBinId: number;
|
|
45
|
+
upperBinId: number;
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
export type ClosePositionEventEventArgs = ClosePositionEventEvent;
|
|
49
|
+
|
|
50
|
+
/** Gets the encoder for {@link ClosePositionEventEventArgs} event data. */
|
|
51
|
+
export function getClosePositionEventEventEncoder(): FixedSizeEncoder<ClosePositionEventEventArgs> {
|
|
52
|
+
return getHiddenPrefixEncoder(
|
|
53
|
+
getStructEncoder([
|
|
54
|
+
["pool", getAddressEncoder()],
|
|
55
|
+
["position", getAddressEncoder()],
|
|
56
|
+
["owner", getAddressEncoder()],
|
|
57
|
+
["lowerBinId", getI32Encoder()],
|
|
58
|
+
["upperBinId", getI32Encoder()],
|
|
59
|
+
]),
|
|
60
|
+
[getConstantEncoder(CLOSE_POSITION_EVENT_EVENT_DISCRIMINATOR)],
|
|
61
|
+
);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** Gets the decoder for {@link ClosePositionEventEvent} event data. */
|
|
65
|
+
export function getClosePositionEventEventDecoder(): FixedSizeDecoder<ClosePositionEventEvent> {
|
|
66
|
+
return getHiddenPrefixDecoder(
|
|
67
|
+
getStructDecoder([
|
|
68
|
+
["pool", getAddressDecoder()],
|
|
69
|
+
["position", getAddressDecoder()],
|
|
70
|
+
["owner", getAddressDecoder()],
|
|
71
|
+
["lowerBinId", getI32Decoder()],
|
|
72
|
+
["upperBinId", getI32Decoder()],
|
|
73
|
+
]),
|
|
74
|
+
[getConstantDecoder(CLOSE_POSITION_EVENT_EVENT_DISCRIMINATOR)],
|
|
75
|
+
);
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** Gets the codec for {@link ClosePositionEventEvent} event data. */
|
|
79
|
+
export function getClosePositionEventEventCodec(): FixedSizeCodec<
|
|
80
|
+
ClosePositionEventEventArgs,
|
|
81
|
+
ClosePositionEventEvent
|
|
82
|
+
> {
|
|
83
|
+
return combineCodec(
|
|
84
|
+
getClosePositionEventEventEncoder(),
|
|
85
|
+
getClosePositionEventEventDecoder(),
|
|
86
|
+
);
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
/** Parses the provided bytes into {@link ClosePositionEventEvent} event data. */
|
|
90
|
+
export function parseClosePositionEventEvent(
|
|
91
|
+
data: ReadonlyUint8Array | Uint8Array,
|
|
92
|
+
): ClosePositionEventEvent {
|
|
93
|
+
if (containsBytes(data, CLOSE_POSITION_EVENT_EVENT_DISCRIMINATOR, 0)) {
|
|
94
|
+
return getClosePositionEventEventDecoder().decode(data);
|
|
95
|
+
}
|
|
96
|
+
throw new Error(
|
|
97
|
+
'The provided data does not match the "ClosePositionEventEvent" event discriminators.',
|
|
98
|
+
);
|
|
99
|
+
}
|