@exponent-labs/exponent-sdk 0.1.7 → 0.1.8
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/build/EventDecoderV2.d.ts +31 -0
- package/build/EventDecoderV2.js +76 -0
- package/build/EventDecoderV2.js.map +1 -0
- package/build/addressLookupTableUtil.d.ts +17 -1
- package/build/addressLookupTableUtil.js +35 -1
- package/build/addressLookupTableUtil.js.map +1 -1
- package/build/clmm/events.d.ts +10 -0
- package/build/clmm/events.js +10 -0
- package/build/clmm/events.js.map +1 -0
- package/build/clmm/index.d.ts +1 -0
- package/build/clmm/index.js +18 -0
- package/build/clmm/index.js.map +1 -0
- package/build/events.d.ts +200 -9
- package/build/events.js +73 -24
- package/build/events.js.map +1 -1
- package/build/eventsV2.d.ts +7 -0
- package/build/eventsV2.js +10 -0
- package/build/eventsV2.js.map +1 -0
- package/build/flavors.d.ts +2 -0
- package/build/flavors.js +81 -27
- package/build/flavors.js.map +1 -1
- package/build/index.d.ts +6 -0
- package/build/index.js +14 -4
- package/build/index.js.map +1 -1
- package/build/lpPosition.js +4 -1
- package/build/lpPosition.js.map +1 -1
- package/build/market.d.ts +14 -2
- package/build/market.js +70 -29
- package/build/market.js.map +1 -1
- package/build/marketThree.d.ts +664 -0
- package/build/marketThree.js +1415 -0
- package/build/marketThree.js.map +1 -0
- package/build/marketThree.test.d.ts +1 -0
- package/build/marketThree.test.js +166 -0
- package/build/marketThree.test.js.map +1 -0
- package/build/orderbook/events.d.ts +7 -0
- package/build/orderbook/events.js +10 -0
- package/build/orderbook/events.js.map +1 -0
- package/build/orderbook/index.d.ts +4 -0
- package/build/orderbook/index.js +41 -0
- package/build/orderbook/index.js.map +1 -0
- package/build/orderbook/math.d.ts +26 -0
- package/build/orderbook/math.js +111 -0
- package/build/orderbook/math.js.map +1 -0
- package/build/orderbook/orderbook.d.ts +175 -0
- package/build/orderbook/orderbook.js +756 -0
- package/build/orderbook/orderbook.js.map +1 -0
- package/build/orderbook/types.d.ts +49 -0
- package/build/orderbook/types.js +27 -0
- package/build/orderbook/types.js.map +1 -0
- package/build/orderbook/utils.d.ts +18 -0
- package/build/orderbook/utils.js +74 -0
- package/build/orderbook/utils.js.map +1 -0
- package/build/router.d.ts +92 -0
- package/build/router.js +214 -0
- package/build/router.js.map +1 -0
- package/build/syPosition.js +6 -0
- package/build/syPosition.js.map +1 -1
- package/build/utils/index.d.ts +3 -2
- package/build/utils/index.js +22 -1
- package/build/utils/index.js.map +1 -1
- package/build/vault.d.ts +3 -1
- package/build/vault.js +98 -62
- package/build/vault.js.map +1 -1
- package/build/ytPosition.d.ts +2 -0
- package/build/ytPosition.js +18 -5
- package/build/ytPosition.js.map +1 -1
- package/package.json +28 -23
- package/src/EventDecoderV2.ts +96 -0
- package/src/addressLookupTableUtil.ts +42 -1
- package/src/clmm/events.ts +17 -0
- package/src/clmm/index.ts +1 -0
- package/src/events.ts +280 -27
- package/src/eventsV2.ts +13 -0
- package/src/flavors.ts +97 -27
- package/src/index.ts +6 -0
- package/src/lpPosition.ts +5 -2
- package/src/market.ts +100 -31
- package/src/marketThree.test.ts +208 -0
- package/src/marketThree.ts +2430 -0
- package/src/orderbook/events.ts +13 -0
- package/src/orderbook/index.ts +12 -0
- package/src/orderbook/math.ts +122 -0
- package/src/orderbook/orderbook.ts +1153 -0
- package/src/orderbook/types.ts +45 -0
- package/src/orderbook/utils.ts +74 -0
- package/src/router.ts +360 -0
- package/src/syPosition.ts +4 -0
- package/src/utils/index.ts +27 -2
- package/src/vault.ts +100 -62
- package/src/ytPosition.ts +28 -7
- package/tsconfig.json +4 -1
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { web3 } from "@coral-xyz/anchor"
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
CpiAccountIndex,
|
|
5
|
+
CpiAccountIndexes,
|
|
6
|
+
ExponentCoreCpiIndexes,
|
|
7
|
+
MarketCpiCoreIndexes,
|
|
8
|
+
} from "@exponent-labs/exponent-types"
|
|
4
9
|
|
|
5
10
|
/** Fetch and deserialize the ALT */
|
|
6
11
|
export async function fetchAddressLookupTable(
|
|
@@ -33,3 +38,39 @@ export function makeCpiAccountMetaLists(altAddresses: web3.PublicKey[], cpiIndex
|
|
|
33
38
|
getPositionState: cpiIndexes.getPositionState.map(transform),
|
|
34
39
|
}
|
|
35
40
|
}
|
|
41
|
+
|
|
42
|
+
/** Create the CPI accounts lists from the Address Lookup Table and the on-chain stored CPI account indexes (for Orderbook/full core CPI) */
|
|
43
|
+
export function makeCoreCpiAccountMetaLists(altAddresses: web3.PublicKey[], cpiIndexes: ExponentCoreCpiIndexes) {
|
|
44
|
+
const pluckAddress = (index: number) => altAddresses[index]
|
|
45
|
+
const transform = (a: CpiAccountIndex): web3.AccountMeta => ({
|
|
46
|
+
isSigner: false,
|
|
47
|
+
isWritable: a.isWritable,
|
|
48
|
+
pubkey: pluckAddress(a.altIndex),
|
|
49
|
+
})
|
|
50
|
+
|
|
51
|
+
return {
|
|
52
|
+
depositYt: cpiIndexes.depositYt.map(transform),
|
|
53
|
+
withdrawYt: cpiIndexes.withdrawYt.map(transform),
|
|
54
|
+
stripSy: cpiIndexes.stripSy.map(transform),
|
|
55
|
+
mergeSy: cpiIndexes.mergeSy.map(transform),
|
|
56
|
+
collectInterest: cpiIndexes.collectInterest.map(transform),
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
/** Create the CPI accounts lists from the Address Lookup Table for MarketThree (only stripSy and mergeSy, others empty) */
|
|
61
|
+
export function makeMarketCoreCpiAccountMetaLists(altAddresses: web3.PublicKey[], cpiIndexes: MarketCpiCoreIndexes) {
|
|
62
|
+
const pluckAddress = (index: number) => altAddresses[index]
|
|
63
|
+
const transform = (a: CpiAccountIndex): web3.AccountMeta => ({
|
|
64
|
+
isSigner: false,
|
|
65
|
+
isWritable: a.isWritable,
|
|
66
|
+
pubkey: pluckAddress(a.altIndex),
|
|
67
|
+
})
|
|
68
|
+
|
|
69
|
+
return {
|
|
70
|
+
depositYt: [],
|
|
71
|
+
withdrawYt: [],
|
|
72
|
+
stripSy: cpiIndexes.stripSy.map(transform),
|
|
73
|
+
mergeSy: cpiIndexes.mergeSy.map(transform),
|
|
74
|
+
collectInterest: [],
|
|
75
|
+
}
|
|
76
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { IdlTypes } from "@coral-xyz/anchor"
|
|
2
|
+
|
|
3
|
+
import { ExponentClmm, IDL, PROGRAM_ID } from "@exponent-labs/exponent-clmm-idl"
|
|
4
|
+
|
|
5
|
+
import { EventDecoderV2 } from "../EventDecoderV2"
|
|
6
|
+
import { createAnchorProgram } from "../utils"
|
|
7
|
+
|
|
8
|
+
export const CLMM_PROGRAM_ID = PROGRAM_ID
|
|
9
|
+
const CLMM_PROGRAM = createAnchorProgram(IDL as ExponentClmm)
|
|
10
|
+
export const CLMM_EVENT_DECODER = new EventDecoderV2(CLMM_PROGRAM)
|
|
11
|
+
|
|
12
|
+
export type ClmmEventNames = ExponentClmm["events"][number]["name"]
|
|
13
|
+
export type ClmmEvent<Name extends ClmmEventNames> = IdlTypes<ExponentClmm>[Name]
|
|
14
|
+
|
|
15
|
+
export type PersonalYieldTrackers = IdlTypes<ExponentClmm>["personalYieldTrackers"]
|
|
16
|
+
export type PrincipalShare = IdlTypes<ExponentClmm>["principalShare"]
|
|
17
|
+
export type PrincipalShareTrackers = IdlTypes<ExponentClmm>["principalShareTrackers"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from "./events"
|
package/src/events.ts
CHANGED
|
@@ -9,33 +9,34 @@ const EVENT_IX_TAG = new BN("1d9acb512ea545e4", 16)
|
|
|
9
9
|
export class EventDecoder {
|
|
10
10
|
private coder: BorshCoder
|
|
11
11
|
programId: web3.PublicKey
|
|
12
|
-
private static
|
|
12
|
+
private static eventIxTagBuffer = Buffer.from(EVENT_IX_TAG.toArray("le", 8))
|
|
13
13
|
|
|
14
14
|
constructor(idl: ExponentCore = IDL as ExponentCore) {
|
|
15
15
|
this.programId = new web3.PublicKey(idl.address)
|
|
16
16
|
this.coder = new BorshCoder(idl)
|
|
17
17
|
}
|
|
18
18
|
|
|
19
|
-
parseAsTransactionCpiData(
|
|
19
|
+
private parseAsTransactionCpiData(ixnData: string | Uint8Array, errLogger?: typeof console.error): string | null {
|
|
20
20
|
try {
|
|
21
|
-
const encodedLog = Buffer.from(bs58.decode(
|
|
21
|
+
const encodedLog = typeof ixnData === "string" ? Buffer.from(bs58.decode(ixnData)) : Buffer.from(ixnData)
|
|
22
22
|
const discriminator = encodedLog.subarray(0, 8)
|
|
23
23
|
|
|
24
|
-
const eventIxTagBuffer =
|
|
24
|
+
const eventIxTagBuffer = EventDecoder.eventIxTagBuffer
|
|
25
25
|
|
|
26
26
|
if (discriminator.equals(eventIxTagBuffer)) {
|
|
27
27
|
return Buffer.from(Uint8Array.from(encodedLog.subarray(8))).toString("base64")
|
|
28
28
|
}
|
|
29
29
|
|
|
30
|
-
|
|
30
|
+
// Not an event instruction - just a regular instruction from the same program
|
|
31
|
+
return null
|
|
31
32
|
} catch (error) {
|
|
32
|
-
|
|
33
|
+
errLogger?.("Unable to parse transaction CPI data:", error)
|
|
33
34
|
return null
|
|
34
35
|
}
|
|
35
36
|
}
|
|
36
37
|
|
|
37
|
-
decode(
|
|
38
|
-
const cpiData = this.parseAsTransactionCpiData(
|
|
38
|
+
private decode(ixnData: string | Uint8Array, errLogger?: typeof console.error): GenericEvent | null {
|
|
39
|
+
const cpiData = this.parseAsTransactionCpiData(ixnData)
|
|
39
40
|
if (!cpiData) {
|
|
40
41
|
return null
|
|
41
42
|
}
|
|
@@ -47,12 +48,26 @@ export class EventDecoder {
|
|
|
47
48
|
data: event.data,
|
|
48
49
|
}
|
|
49
50
|
} catch (error) {
|
|
50
|
-
|
|
51
|
+
errLogger?.(`Failed to decode event:`, error)
|
|
51
52
|
return null
|
|
52
53
|
}
|
|
53
54
|
}
|
|
54
55
|
|
|
55
|
-
|
|
56
|
+
parseCpiEvents(instructions: web3.CompiledInstruction[], accountKeys: web3.MessageAccountKeys) {
|
|
57
|
+
const events = instructions
|
|
58
|
+
.map((ixn) => {
|
|
59
|
+
const programPubkey = accountKeys.get(ixn.programIdIndex)
|
|
60
|
+
if (programPubkey === undefined || !programPubkey.equals(new web3.PublicKey(this.programId))) {
|
|
61
|
+
return null
|
|
62
|
+
}
|
|
63
|
+
return this.decode(ixn.data) || null
|
|
64
|
+
})
|
|
65
|
+
.filter((ev) => !!ev)
|
|
66
|
+
|
|
67
|
+
return categorizeEvents(events)
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
async parseTransactionResponseCpiEvents(
|
|
56
71
|
transactionResponse: web3.VersionedTransactionResponse | web3.TransactionResponse,
|
|
57
72
|
connection: web3.Connection,
|
|
58
73
|
): Promise<CategorizedEvents> {
|
|
@@ -67,27 +82,16 @@ export class EventDecoder {
|
|
|
67
82
|
}),
|
|
68
83
|
)
|
|
69
84
|
|
|
70
|
-
const
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
.map((ix) => {
|
|
74
|
-
const accountKeys = transactionResponse?.transaction.message.getAccountKeys({
|
|
75
|
-
addressLookupTableAccounts: lookupTables.map((lookup) => lookup.value),
|
|
76
|
-
})
|
|
77
|
-
const programPubkey = accountKeys.get(ix.programIdIndex)
|
|
78
|
-
if (programPubkey === undefined || !programPubkey.equals(this.programId)) {
|
|
79
|
-
return null
|
|
80
|
-
}
|
|
81
|
-
|
|
82
|
-
const event = this.decode(ix.data)
|
|
85
|
+
const accountKeys = transactionResponse?.transaction.message.getAccountKeys({
|
|
86
|
+
addressLookupTableAccounts: lookupTables.map((lookup) => lookup.value),
|
|
87
|
+
})
|
|
83
88
|
|
|
84
|
-
|
|
85
|
-
})
|
|
86
|
-
.filter((ev) => !!ev)
|
|
89
|
+
const instructions: web3.CompiledInstruction[] = innerInstructions.map(({ instructions }) => instructions).flat()
|
|
87
90
|
|
|
88
|
-
return
|
|
91
|
+
return this.parseCpiEvents(instructions, accountKeys)
|
|
89
92
|
}
|
|
90
93
|
|
|
94
|
+
//? Keep as legacy for indexer v1 on websocket
|
|
91
95
|
parseHeliusWebsocketCpiEvents(
|
|
92
96
|
transactionResponse: web3.VersionedTransactionResponse | web3.TransactionResponse,
|
|
93
97
|
): CategorizedEvents {
|
|
@@ -127,19 +131,28 @@ function categorizeEvents(events: GenericEvent[]): CategorizedEvents {
|
|
|
127
131
|
const stripEvents: StripEvent[] = []
|
|
128
132
|
const mergeEvents: MergeEvent[] = []
|
|
129
133
|
const depositYtEvents: DepositYtEvent[] = []
|
|
134
|
+
const depositYtEventsV2: DepositYtEventV2[] = []
|
|
130
135
|
const withdrawYtEvents: WithdrawYtEvent[] = []
|
|
136
|
+
const withdrawYtEventsV2: WithdrawYtEventV2[] = []
|
|
131
137
|
const collectInterestEvents: CollectInterestEvent[] = []
|
|
138
|
+
const collectInterestEventsV2: CollectInterestEventV2[] = []
|
|
132
139
|
const collectEmissionEvents: CollectEmissionEvent[] = []
|
|
140
|
+
const collectEmissionEventsV2: CollectEmissionEventV2[] = []
|
|
133
141
|
const stageYieldEvents: StageYieldEvent[] = []
|
|
142
|
+
const stageYieldEventsV2: StageYieldEventV2[] = []
|
|
134
143
|
const initializeYieldPositionEvents: InitializeYieldPositionEvent[] = []
|
|
135
144
|
const withdrawLpEvents: WithdrawLpEvent[] = []
|
|
145
|
+
const withdrawLpEventsV2: WithdrawLpEventV2[] = []
|
|
136
146
|
const withdrawLiquidityEvents: WithdrawLiquidityEvent[] = []
|
|
137
147
|
const sellYtEvents: SellYtEvent[] = []
|
|
138
148
|
const marketCollectEmissionEvents: MarketCollectEmissionEvent[] = []
|
|
149
|
+
const marketCollectEmissionEventsV2: MarketCollectEmissionEventV2[] = []
|
|
139
150
|
const initLpPositionEvents: InitLpPositionEvent[] = []
|
|
140
151
|
const depositLpEvents: DepositLpEvent[] = []
|
|
152
|
+
const depositLpEventsV2: DepositLpEventV2[] = []
|
|
141
153
|
const depositLiquidityEvents: DepositLiquidityEvent[] = []
|
|
142
154
|
const claimFarmEmissionsEvents: ClaimFarmEmissionsEvent[] = []
|
|
155
|
+
const claimFarmEmissionsEventsV2: ClaimFarmEmissionsEventV2[] = []
|
|
143
156
|
const buyYtEvents: BuyYtEvent[] = []
|
|
144
157
|
const wrapperBuyYtEvents: WrapperBuyYtEvent[] = []
|
|
145
158
|
const wrapperSellYtEvents: WrapperSellYtEvent[] = []
|
|
@@ -168,24 +181,42 @@ function categorizeEvents(events: GenericEvent[]): CategorizedEvents {
|
|
|
168
181
|
case "DepositYtEvent":
|
|
169
182
|
depositYtEvents.push(ev.data as DepositYtEvent)
|
|
170
183
|
break
|
|
184
|
+
case "DepositYtEventV2":
|
|
185
|
+
depositYtEventsV2.push(ev.data as DepositYtEventV2)
|
|
186
|
+
break
|
|
171
187
|
case "WithdrawYtEvent":
|
|
172
188
|
withdrawYtEvents.push(ev.data as WithdrawYtEvent)
|
|
173
189
|
break
|
|
190
|
+
case "WithdrawYtEventV2":
|
|
191
|
+
withdrawYtEventsV2.push(ev.data as WithdrawYtEventV2)
|
|
192
|
+
break
|
|
174
193
|
case "CollectInterestEvent":
|
|
175
194
|
collectInterestEvents.push(ev.data as CollectInterestEvent)
|
|
176
195
|
break
|
|
196
|
+
case "CollectInterestEventV2":
|
|
197
|
+
collectInterestEventsV2.push(ev.data as CollectInterestEventV2)
|
|
198
|
+
break
|
|
177
199
|
case "CollectEmissionEvent":
|
|
178
200
|
collectEmissionEvents.push(ev.data as CollectEmissionEvent)
|
|
179
201
|
break
|
|
202
|
+
case "CollectEmissionEventV2":
|
|
203
|
+
collectEmissionEventsV2.push(ev.data as CollectEmissionEventV2)
|
|
204
|
+
break
|
|
180
205
|
case "StageYieldEvent":
|
|
181
206
|
stageYieldEvents.push(ev.data as StageYieldEvent)
|
|
182
207
|
break
|
|
208
|
+
case "StageYieldEventV2":
|
|
209
|
+
stageYieldEventsV2.push(ev.data as StageYieldEventV2)
|
|
210
|
+
break
|
|
183
211
|
case "InitializeYieldPositionEvent":
|
|
184
212
|
initializeYieldPositionEvents.push(ev.data as InitializeYieldPositionEvent)
|
|
185
213
|
break
|
|
186
214
|
case "WithdrawLpEvent":
|
|
187
215
|
withdrawLpEvents.push(ev.data as WithdrawLpEvent)
|
|
188
216
|
break
|
|
217
|
+
case "WithdrawLpEventV2":
|
|
218
|
+
withdrawLpEventsV2.push(ev.data as WithdrawLpEventV2)
|
|
219
|
+
break
|
|
189
220
|
case "WithdrawLiquidityEvent":
|
|
190
221
|
withdrawLiquidityEvents.push(ev.data as WithdrawLiquidityEvent)
|
|
191
222
|
break
|
|
@@ -195,18 +226,27 @@ function categorizeEvents(events: GenericEvent[]): CategorizedEvents {
|
|
|
195
226
|
case "MarketCollectEmissionEvent":
|
|
196
227
|
marketCollectEmissionEvents.push(ev.data as MarketCollectEmissionEvent)
|
|
197
228
|
break
|
|
229
|
+
case "MarketCollectEmissionEventV2":
|
|
230
|
+
marketCollectEmissionEventsV2.push(ev.data as MarketCollectEmissionEventV2)
|
|
231
|
+
break
|
|
198
232
|
case "InitLpPositionEvent":
|
|
199
233
|
initLpPositionEvents.push(ev.data as InitLpPositionEvent)
|
|
200
234
|
break
|
|
201
235
|
case "DepositLpEvent":
|
|
202
236
|
depositLpEvents.push(ev.data as DepositLpEvent)
|
|
203
237
|
break
|
|
238
|
+
case "DepositLpEventV2":
|
|
239
|
+
depositLpEventsV2.push(ev.data as DepositLpEventV2)
|
|
240
|
+
break
|
|
204
241
|
case "DepositLiquidityEvent":
|
|
205
242
|
depositLiquidityEvents.push(ev.data as DepositLiquidityEvent)
|
|
206
243
|
break
|
|
207
244
|
case "ClaimFarmEmissionsEvent":
|
|
208
245
|
claimFarmEmissionsEvents.push(ev.data as ClaimFarmEmissionsEvent)
|
|
209
246
|
break
|
|
247
|
+
case "ClaimFarmEmissionsEventV2":
|
|
248
|
+
claimFarmEmissionsEventsV2.push(ev.data as ClaimFarmEmissionsEventV2)
|
|
249
|
+
break
|
|
210
250
|
case "BuyYtEvent":
|
|
211
251
|
buyYtEvents.push(ev.data as BuyYtEvent)
|
|
212
252
|
break
|
|
@@ -254,19 +294,28 @@ function categorizeEvents(events: GenericEvent[]): CategorizedEvents {
|
|
|
254
294
|
stripEvents,
|
|
255
295
|
mergeEvents,
|
|
256
296
|
depositYtEvents,
|
|
297
|
+
depositYtEventsV2,
|
|
257
298
|
withdrawYtEvents,
|
|
299
|
+
withdrawYtEventsV2,
|
|
258
300
|
collectInterestEvents,
|
|
301
|
+
collectInterestEventsV2,
|
|
259
302
|
collectEmissionEvents,
|
|
303
|
+
collectEmissionEventsV2,
|
|
260
304
|
stageYieldEvents,
|
|
305
|
+
stageYieldEventsV2,
|
|
261
306
|
initializeYieldPositionEvents,
|
|
262
307
|
withdrawLpEvents,
|
|
308
|
+
withdrawLpEventsV2,
|
|
263
309
|
withdrawLiquidityEvents,
|
|
264
310
|
sellYtEvents,
|
|
265
311
|
marketCollectEmissionEvents,
|
|
312
|
+
marketCollectEmissionEventsV2,
|
|
266
313
|
initLpPositionEvents,
|
|
267
314
|
depositLpEvents,
|
|
315
|
+
depositLpEventsV2,
|
|
268
316
|
depositLiquidityEvents,
|
|
269
317
|
claimFarmEmissionsEvents,
|
|
318
|
+
claimFarmEmissionsEventsV2,
|
|
270
319
|
buyYtEvents,
|
|
271
320
|
wrapperBuyYtEvents,
|
|
272
321
|
wrapperSellYtEvents,
|
|
@@ -288,19 +337,28 @@ export interface CategorizedEvents {
|
|
|
288
337
|
stripEvents: StripEvent[]
|
|
289
338
|
mergeEvents: MergeEvent[]
|
|
290
339
|
depositYtEvents: DepositYtEvent[]
|
|
340
|
+
depositYtEventsV2: DepositYtEventV2[]
|
|
291
341
|
withdrawYtEvents: WithdrawYtEvent[]
|
|
342
|
+
withdrawYtEventsV2: WithdrawYtEventV2[]
|
|
292
343
|
collectInterestEvents: CollectInterestEvent[]
|
|
344
|
+
collectInterestEventsV2: CollectInterestEventV2[]
|
|
293
345
|
collectEmissionEvents: CollectEmissionEvent[]
|
|
346
|
+
collectEmissionEventsV2: CollectEmissionEventV2[]
|
|
294
347
|
stageYieldEvents: StageYieldEvent[]
|
|
348
|
+
stageYieldEventsV2: StageYieldEventV2[]
|
|
295
349
|
initializeYieldPositionEvents: InitializeYieldPositionEvent[]
|
|
296
350
|
withdrawLpEvents: WithdrawLpEvent[]
|
|
351
|
+
withdrawLpEventsV2: WithdrawLpEventV2[]
|
|
297
352
|
withdrawLiquidityEvents: WithdrawLiquidityEvent[]
|
|
298
353
|
sellYtEvents: SellYtEvent[]
|
|
299
354
|
marketCollectEmissionEvents: MarketCollectEmissionEvent[]
|
|
355
|
+
marketCollectEmissionEventsV2: MarketCollectEmissionEventV2[]
|
|
300
356
|
initLpPositionEvents: InitLpPositionEvent[]
|
|
301
357
|
depositLpEvents: DepositLpEvent[]
|
|
358
|
+
depositLpEventsV2: DepositLpEventV2[]
|
|
302
359
|
depositLiquidityEvents: DepositLiquidityEvent[]
|
|
303
360
|
claimFarmEmissionsEvents: ClaimFarmEmissionsEvent[]
|
|
361
|
+
claimFarmEmissionsEventsV2: ClaimFarmEmissionsEventV2[]
|
|
304
362
|
buyYtEvents: BuyYtEvent[]
|
|
305
363
|
wrapperBuyYtEvents: WrapperBuyYtEvent[]
|
|
306
364
|
wrapperSellYtEvents: WrapperSellYtEvent[]
|
|
@@ -389,6 +447,29 @@ export interface DepositYtEvent {
|
|
|
389
447
|
unix_timestamp: BN
|
|
390
448
|
}
|
|
391
449
|
|
|
450
|
+
export interface DepositYtEventV2 {
|
|
451
|
+
depositor: web3.PublicKey
|
|
452
|
+
vault: web3.PublicKey
|
|
453
|
+
user_yield_position: web3.PublicKey
|
|
454
|
+
vault_yield_position: web3.PublicKey
|
|
455
|
+
yt_src: web3.PublicKey
|
|
456
|
+
escrow_yt: web3.PublicKey
|
|
457
|
+
amount: BN
|
|
458
|
+
sy_exchange_rate: AnchorizedPNum
|
|
459
|
+
user_yt_balance_after: BN
|
|
460
|
+
vault_yt_balance_after: BN
|
|
461
|
+
user_staged_yield: BN
|
|
462
|
+
unix_timestamp: BN
|
|
463
|
+
user_interest: {
|
|
464
|
+
last_seen_index: AnchorizedPNum
|
|
465
|
+
staged: BN
|
|
466
|
+
}
|
|
467
|
+
user_emissions: {
|
|
468
|
+
last_seen_index: AnchorizedPNum
|
|
469
|
+
staged: BN
|
|
470
|
+
}[]
|
|
471
|
+
}
|
|
472
|
+
|
|
392
473
|
export interface WithdrawYtEvent {
|
|
393
474
|
owner: web3.PublicKey
|
|
394
475
|
vault: web3.PublicKey
|
|
@@ -404,6 +485,29 @@ export interface WithdrawYtEvent {
|
|
|
404
485
|
unix_timestamp: BN
|
|
405
486
|
}
|
|
406
487
|
|
|
488
|
+
export interface WithdrawYtEventV2 {
|
|
489
|
+
owner: web3.PublicKey
|
|
490
|
+
vault: web3.PublicKey
|
|
491
|
+
user_yield_position: web3.PublicKey
|
|
492
|
+
vault_yield_position: web3.PublicKey
|
|
493
|
+
yt_dst: web3.PublicKey
|
|
494
|
+
escrow_yt: web3.PublicKey
|
|
495
|
+
amount: BN
|
|
496
|
+
sy_exchange_rate: AnchorizedPNum
|
|
497
|
+
user_yt_balance_after: BN
|
|
498
|
+
vault_yt_balance_after: BN
|
|
499
|
+
user_staged_yield: BN
|
|
500
|
+
unix_timestamp: BN
|
|
501
|
+
user_interest: {
|
|
502
|
+
last_seen_index: AnchorizedPNum
|
|
503
|
+
staged: BN
|
|
504
|
+
}
|
|
505
|
+
user_emissions: {
|
|
506
|
+
last_seen_index: AnchorizedPNum
|
|
507
|
+
staged: BN
|
|
508
|
+
}[]
|
|
509
|
+
}
|
|
510
|
+
|
|
407
511
|
export interface CollectInterestEvent {
|
|
408
512
|
user: web3.PublicKey
|
|
409
513
|
vault: web3.PublicKey
|
|
@@ -413,6 +517,23 @@ export interface CollectInterestEvent {
|
|
|
413
517
|
unix_timestamp: BN
|
|
414
518
|
}
|
|
415
519
|
|
|
520
|
+
export interface CollectInterestEventV2 {
|
|
521
|
+
user: web3.PublicKey
|
|
522
|
+
vault: web3.PublicKey
|
|
523
|
+
user_yield_position: web3.PublicKey
|
|
524
|
+
amount_to_user: BN
|
|
525
|
+
amount_to_treasury: BN
|
|
526
|
+
unix_timestamp: BN
|
|
527
|
+
user_interest: {
|
|
528
|
+
last_seen_index: AnchorizedPNum
|
|
529
|
+
staged: BN
|
|
530
|
+
}
|
|
531
|
+
user_emissions: {
|
|
532
|
+
last_seen_index: AnchorizedPNum
|
|
533
|
+
staged: BN
|
|
534
|
+
}[]
|
|
535
|
+
}
|
|
536
|
+
|
|
416
537
|
export interface CollectEmissionEvent {
|
|
417
538
|
user: web3.PublicKey
|
|
418
539
|
vault: web3.PublicKey
|
|
@@ -423,6 +544,24 @@ export interface CollectEmissionEvent {
|
|
|
423
544
|
unix_timestamp: BN
|
|
424
545
|
}
|
|
425
546
|
|
|
547
|
+
export interface CollectEmissionEventV2 {
|
|
548
|
+
user: web3.PublicKey
|
|
549
|
+
vault: web3.PublicKey
|
|
550
|
+
position: web3.PublicKey
|
|
551
|
+
emission_index: number
|
|
552
|
+
amount_to_user: BN
|
|
553
|
+
amount_to_treasury: BN
|
|
554
|
+
unix_timestamp: BN
|
|
555
|
+
user_interest: {
|
|
556
|
+
last_seen_index: AnchorizedPNum
|
|
557
|
+
staged: BN
|
|
558
|
+
}
|
|
559
|
+
user_emissions: {
|
|
560
|
+
last_seen_index: AnchorizedPNum
|
|
561
|
+
staged: BN
|
|
562
|
+
}[]
|
|
563
|
+
}
|
|
564
|
+
|
|
426
565
|
export interface StageYieldEvent {
|
|
427
566
|
payer: web3.PublicKey
|
|
428
567
|
vault: web3.PublicKey
|
|
@@ -435,6 +574,25 @@ export interface StageYieldEvent {
|
|
|
435
574
|
unix_timestamp: BN
|
|
436
575
|
}
|
|
437
576
|
|
|
577
|
+
export interface StageYieldEventV2 {
|
|
578
|
+
payer: web3.PublicKey
|
|
579
|
+
vault: web3.PublicKey
|
|
580
|
+
user_yield_position: web3.PublicKey
|
|
581
|
+
vault_yield_position: web3.PublicKey
|
|
582
|
+
sy_exchange_rate: AnchorizedPNum
|
|
583
|
+
user_yt_balance: BN
|
|
584
|
+
user_staged_yield: BN
|
|
585
|
+
unix_timestamp: BN
|
|
586
|
+
user_interest: {
|
|
587
|
+
last_seen_index: AnchorizedPNum
|
|
588
|
+
staged: BN
|
|
589
|
+
}
|
|
590
|
+
user_emissions: {
|
|
591
|
+
last_seen_index: AnchorizedPNum
|
|
592
|
+
staged: BN
|
|
593
|
+
}[]
|
|
594
|
+
}
|
|
595
|
+
|
|
438
596
|
export interface InitializeYieldPositionEvent {
|
|
439
597
|
owner: web3.PublicKey
|
|
440
598
|
vault: web3.PublicKey
|
|
@@ -454,6 +612,30 @@ export interface WithdrawLpEvent {
|
|
|
454
612
|
unix_timestamp: BN
|
|
455
613
|
}
|
|
456
614
|
|
|
615
|
+
export interface WithdrawLpEventV2 {
|
|
616
|
+
owner: web3.PublicKey
|
|
617
|
+
market: web3.PublicKey
|
|
618
|
+
lp_position: web3.PublicKey
|
|
619
|
+
mint_lp: web3.PublicKey
|
|
620
|
+
token_lp_dst: web3.PublicKey
|
|
621
|
+
token_lp_escrow: web3.PublicKey
|
|
622
|
+
amount: BN
|
|
623
|
+
new_lp_balance: BN
|
|
624
|
+
unix_timestamp: BN
|
|
625
|
+
emissions: {
|
|
626
|
+
trackers: {
|
|
627
|
+
last_seen_index: AnchorizedPNum
|
|
628
|
+
staged: BN
|
|
629
|
+
}[]
|
|
630
|
+
}
|
|
631
|
+
farms: {
|
|
632
|
+
trackers: {
|
|
633
|
+
last_seen_index: AnchorizedPNum
|
|
634
|
+
staged: BN
|
|
635
|
+
}[]
|
|
636
|
+
}
|
|
637
|
+
}
|
|
638
|
+
|
|
457
639
|
export interface WithdrawLiquidityEvent {
|
|
458
640
|
withdrawer: web3.PublicKey
|
|
459
641
|
market: web3.PublicKey
|
|
@@ -497,6 +679,29 @@ export interface MarketCollectEmissionEvent {
|
|
|
497
679
|
timestamp: BN
|
|
498
680
|
}
|
|
499
681
|
|
|
682
|
+
export interface MarketCollectEmissionEventV2 {
|
|
683
|
+
owner: web3.PublicKey
|
|
684
|
+
market: web3.PublicKey
|
|
685
|
+
lp_position: web3.PublicKey
|
|
686
|
+
token_emission_escrow: web3.PublicKey
|
|
687
|
+
token_emission_dst: web3.PublicKey
|
|
688
|
+
emission_index: number
|
|
689
|
+
amount_collected: BN
|
|
690
|
+
timestamp: BN
|
|
691
|
+
emissions: {
|
|
692
|
+
trackers: {
|
|
693
|
+
last_seen_index: AnchorizedPNum
|
|
694
|
+
staged: BN
|
|
695
|
+
}[]
|
|
696
|
+
}
|
|
697
|
+
farms: {
|
|
698
|
+
trackers: {
|
|
699
|
+
last_seen_index: AnchorizedPNum
|
|
700
|
+
staged: BN
|
|
701
|
+
}[]
|
|
702
|
+
}
|
|
703
|
+
}
|
|
704
|
+
|
|
500
705
|
export interface InitLpPositionEvent {
|
|
501
706
|
fee_payer: web3.PublicKey
|
|
502
707
|
owner: web3.PublicKey
|
|
@@ -519,6 +724,30 @@ export interface DepositLpEvent {
|
|
|
519
724
|
timestamp: BN
|
|
520
725
|
}
|
|
521
726
|
|
|
727
|
+
export interface DepositLpEventV2 {
|
|
728
|
+
owner: web3.PublicKey
|
|
729
|
+
market: web3.PublicKey
|
|
730
|
+
lp_position: web3.PublicKey
|
|
731
|
+
token_lp_src: web3.PublicKey
|
|
732
|
+
token_lp_escrow: web3.PublicKey
|
|
733
|
+
mint_lp: web3.PublicKey
|
|
734
|
+
amount: BN
|
|
735
|
+
new_lp_balance: BN
|
|
736
|
+
timestamp: BN
|
|
737
|
+
emissions: {
|
|
738
|
+
trackers: {
|
|
739
|
+
last_seen_index: AnchorizedPNum
|
|
740
|
+
staged: BN
|
|
741
|
+
}[]
|
|
742
|
+
}
|
|
743
|
+
farms: {
|
|
744
|
+
trackers: {
|
|
745
|
+
last_seen_index: AnchorizedPNum
|
|
746
|
+
staged: BN
|
|
747
|
+
}[]
|
|
748
|
+
}
|
|
749
|
+
}
|
|
750
|
+
|
|
522
751
|
export interface DepositLiquidityEvent {
|
|
523
752
|
depositor: web3.PublicKey
|
|
524
753
|
market: web3.PublicKey
|
|
@@ -549,6 +778,30 @@ export interface ClaimFarmEmissionsEvent {
|
|
|
549
778
|
remaining_staged: BN
|
|
550
779
|
}
|
|
551
780
|
|
|
781
|
+
export interface ClaimFarmEmissionsEventV2 {
|
|
782
|
+
owner: web3.PublicKey
|
|
783
|
+
market: web3.PublicKey
|
|
784
|
+
lp_position: web3.PublicKey
|
|
785
|
+
token_dst: web3.PublicKey
|
|
786
|
+
mint: web3.PublicKey
|
|
787
|
+
token_farm: web3.PublicKey
|
|
788
|
+
farm_index: number
|
|
789
|
+
amount_claimed: BN
|
|
790
|
+
remaining_staged: BN
|
|
791
|
+
emissions: {
|
|
792
|
+
trackers: {
|
|
793
|
+
last_seen_index: AnchorizedPNum
|
|
794
|
+
staged: BN
|
|
795
|
+
}[]
|
|
796
|
+
}
|
|
797
|
+
farms: {
|
|
798
|
+
trackers: {
|
|
799
|
+
last_seen_index: AnchorizedPNum
|
|
800
|
+
staged: BN
|
|
801
|
+
}[]
|
|
802
|
+
}
|
|
803
|
+
}
|
|
804
|
+
|
|
552
805
|
export interface BuyYtEvent {
|
|
553
806
|
trader: web3.PublicKey
|
|
554
807
|
market: web3.PublicKey
|
package/src/eventsV2.ts
ADDED
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import { IdlTypes } from "@coral-xyz/anchor"
|
|
2
|
+
|
|
3
|
+
import { ExponentCore, IDL, PROGRAM_ID } from "@exponent-labs/exponent-idl"
|
|
4
|
+
|
|
5
|
+
import { EventDecoderV2 } from "./EventDecoderV2"
|
|
6
|
+
import { createAnchorProgram } from "./utils"
|
|
7
|
+
|
|
8
|
+
export const EXPONENT_PROGRAM_ID = PROGRAM_ID
|
|
9
|
+
const EXPONENT_PROGRAM = createAnchorProgram(IDL as ExponentCore)
|
|
10
|
+
export const EXPONENT_EVENT_DECODER = new EventDecoderV2(EXPONENT_PROGRAM)
|
|
11
|
+
|
|
12
|
+
export type ExponentCoreEventNames = ExponentCore["events"][number]["name"]
|
|
13
|
+
export type ExponentCoreEvent<Name extends ExponentCoreEventNames> = IdlTypes<ExponentCore>[Name]
|