@alphafi/alphafi-sdk 0.0.32 → 0.0.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cjs/common/constants.d.ts.map +1 -1
- package/dist/cjs/common/constants.js +74 -1
- package/dist/cjs/common/constants.js.map +1 -1
- package/dist/cjs/common/maps.d.ts.map +1 -1
- package/dist/cjs/common/maps.js +152 -41
- package/dist/cjs/common/maps.js.map +1 -1
- package/dist/cjs/common/types.d.ts.map +1 -1
- package/dist/cjs/common/types.js.map +1 -1
- package/dist/cjs/graphql/getMultiReceipts.d.ts.map +1 -1
- package/dist/cjs/graphql/getMultiReceipts.js +1 -2
- package/dist/cjs/graphql/getMultiReceipts.js.map +1 -1
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +12 -3
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchAfterTransactionEvents.d.ts.map +1 -0
- package/dist/cjs/sui-sdk/events/fetchAfterTransactionEvents.js +127 -0
- package/dist/cjs/sui-sdk/events/fetchAfterTransactionEvents.js.map +1 -0
- package/dist/cjs/sui-sdk/events/fetchEvents.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchEvents.js +64 -2
- package/dist/cjs/sui-sdk/events/fetchEvents.js.map +1 -1
- package/dist/cjs/sui-sdk/events/fetchWithdrawV2Events.js +1 -1
- package/dist/cjs/sui-sdk/events/fetchWithdrawV2Events.js.map +1 -1
- package/dist/cjs/sui-sdk/events/types.d.ts.map +1 -1
- package/dist/cjs/sui-sdk/events/types.js.map +1 -1
- package/dist/esm/common/constants.d.ts.map +1 -1
- package/dist/esm/common/constants.js +72 -0
- package/dist/esm/common/constants.js.map +1 -1
- package/dist/esm/common/maps.d.ts.map +1 -1
- package/dist/esm/common/maps.js +150 -40
- package/dist/esm/common/maps.js.map +1 -1
- package/dist/esm/common/types.d.ts.map +1 -1
- package/dist/esm/common/types.js.map +1 -1
- package/dist/esm/graphql/getMultiReceipts.d.ts.map +1 -1
- package/dist/esm/graphql/getMultiReceipts.js +1 -2
- package/dist/esm/graphql/getMultiReceipts.js.map +1 -1
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +4 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/sui-sdk/events/fetchAfterTransactionEvents.d.ts.map +1 -0
- package/dist/esm/sui-sdk/events/fetchAfterTransactionEvents.js +124 -0
- package/dist/esm/sui-sdk/events/fetchAfterTransactionEvents.js.map +1 -0
- package/dist/esm/sui-sdk/events/fetchEvents.d.ts.map +1 -1
- package/dist/esm/sui-sdk/events/fetchEvents.js +64 -2
- package/dist/esm/sui-sdk/events/fetchEvents.js.map +1 -1
- package/dist/esm/sui-sdk/events/fetchWithdrawV2Events.js +1 -1
- package/dist/esm/sui-sdk/events/fetchWithdrawV2Events.js.map +1 -1
- package/dist/esm/sui-sdk/events/types.d.ts.map +1 -1
- package/dist/esm/sui-sdk/events/types.js.map +1 -1
- package/package.json +2 -2
package/dist/esm/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,aAAa,EACb,YAAY,EACZ,aAAa,EACb,YAAY,GACb,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,SAAS,EACT,oBAAoB,EACpB,oBAAoB,GACrB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,eAAe,EACf,oBAAoB,EACpB,0BAA0B,EAC1B,0BAA0B,EAC1B,6BAA6B,EAC7B,mCAAmC,GACpC,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,YAAY,EACZ,uBAAuB,EACvB,uBAAuB,GACxB,MAAM,mBAAmB,CAAC;AAE3B,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EACL,gBAAgB,EAChB,gBAAgB,EAChB,oBAAoB,GACrB,MAAM,qBA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"./sui-sdk/client.js\";\n\nexport {\n getVaults,\n getSingleAssetVaults,\n getDoubleAssetVaults,\n} from \"./getVaults.js\";\n\nexport {\n getVaultBalance,\n getAlphaVaultBalance,\n getSingleAssetVaultBalance,\n getDoubleAssetVaultBalance,\n getVaultBalanceForActiveUsers,\n getXTokenVaultBalanceForActiveUsers,\n} from \"./getVaultBalances.js\";\n\nexport {\n getAllVaults,\n getAllDoubleAssetVaults,\n getAllSingleAssetVaults,\n} from \"./getAllVaults.js\";\n\nexport { getAirdropShare } from \"./getAirdropShare.js\";\n\nexport {\n alphaLpBreakdown,\n cetusLpBreakdown,\n lastAutocompoundTime,\n} from \"./vaultFunctions.js\";\n\nexport { getApr, getAprs, getApy, getApys } from \"./getAprs.js\";\n\nexport {\n getRebalanceHistory,\n getRebalanceHistories,\n} from \"./getRebalanceHistory.js\";\n\nexport {\n getHoldersFromTransactions,\n getUserTokensFromTransactions,\n getUserTokensInUsdFromTransactions,\n} from \"./getHoldersFromTransactions.js\";\n\nexport { getLastAutoCompoundTime } from \"./getLastAutoCompoundTime.js\";\n\nexport * from \"./common/types.js\";\n\n// src/index.ts\nexport * from \"./graphql/fetchData.js\";\nexport * from \"./graphql/parseData.js\";\nexport * from \"./graphql/executeMutations.js\";\nexport * from \"./graphql/getMultiReceipts.js\";\n\nexport { getReceipts, getPool } from \"./sui-sdk/functions/getReceipts.js\";\n\nexport { liquidityToTokens, multiTokensToUsd } from \"./utils/userHoldings.js\";\n\nexport {\n poolInfo,\n getCetusSqrtPriceMap,\n getCetusInvestorTicksMap,\n getInvestorPoolMap,\n getPoolExchangeRateMap,\n poolCoinMap,\n poolCoinPairMap,\n defunctPoolsSet,\n poolIdPoolNameMap,\n coinsInPool,\n stableCoins,\n} from \"./common/maps.js\";\n\nexport { getConf } from \"./common/constants.js\";\n\nexport { coins } from \"./common/coins.js\";\n\nexport { getAlphaUnlocks } from \"./getAlphaUnlocks.js\";\n\nexport { fetchLiquidityChangeEvents } from \"./sui-sdk/events/fetchLiquidityChangeEvents.js\";\nexport { fetchAutoCompoundingEvents } from \"./sui-sdk/events/fetchAutoCompoundingEvents.js\";\nexport { fetchWithdrawV2Events } from \"./sui-sdk/events/fetchWithdrawV2Events.js\";\nexport { fetchAfterTransactionEvents } from \"./sui-sdk/events/fetchAfterTransactionEvents.js\";\n\nexport {\n LiquidityChangeEventNode,\n AutoCompoundingEventNode,\n WithdrawV2EventNode,\n AfterTransactionEventNode,\n} from \"./sui-sdk/events/types.js\";\n\nexport { ReceiptGQL } from \"./graphql/types.js\";\n\nexport * from \"./types.js\";\n"]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchAfterTransactionEvents.d.ts","sourceRoot":"","sources":["../../../../src/sui-sdk/events/fetchAfterTransactionEvents.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,QAAQ,EAET,MAAM,uBAAuB,CAAC;AAE/B,OAAO,EACL,yBAAyB,EAK1B,MAAM,YAAY,CAAC;AAKpB,wBAAsB,2BAA2B,CAAC,MAAM,EAAE;IACxD,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,QAAQ,EAAE,CAAC;CACxB,wCA+IA"}
|
|
@@ -0,0 +1,124 @@
|
|
|
1
|
+
import { parentPoolMap, poolCoinMap, poolInfo } from "../../common/maps.js";
|
|
2
|
+
import { fetchEvents } from "./fetchEvents.js";
|
|
3
|
+
import { getSuiClient } from "../client.js";
|
|
4
|
+
import { conf, CONF_ENV } from "../../common/constants.js";
|
|
5
|
+
import { coins } from "../../common/coins.js";
|
|
6
|
+
export async function fetchAfterTransactionEvents(params) {
|
|
7
|
+
const eventTypesSet = new Set();
|
|
8
|
+
if (params.poolNames) {
|
|
9
|
+
params.poolNames.forEach((poolName) => {
|
|
10
|
+
const eventType = poolInfo[poolName].afterTransactionEventType;
|
|
11
|
+
if (eventType !== undefined && eventType !== null && eventType !== "") {
|
|
12
|
+
eventTypesSet.add(eventType);
|
|
13
|
+
}
|
|
14
|
+
});
|
|
15
|
+
}
|
|
16
|
+
else {
|
|
17
|
+
// Iterate over all the values in poolInfo and add each autoCompoundingEventType to the Set
|
|
18
|
+
Object.values(poolInfo).forEach((info) => {
|
|
19
|
+
const eventType = info.afterTransactionEventType;
|
|
20
|
+
if (eventType !== undefined && eventType !== null && eventType !== "") {
|
|
21
|
+
eventTypesSet.add(eventType);
|
|
22
|
+
}
|
|
23
|
+
});
|
|
24
|
+
}
|
|
25
|
+
const eventTypes = Array.from(eventTypesSet);
|
|
26
|
+
const eventsPromises = eventTypes.map(async (eventType) => {
|
|
27
|
+
const events = await fetchEvents({
|
|
28
|
+
startTime: params.startTime,
|
|
29
|
+
endTime: params.endTime,
|
|
30
|
+
eventTypes: [eventType],
|
|
31
|
+
});
|
|
32
|
+
return events;
|
|
33
|
+
});
|
|
34
|
+
const events = (await Promise.all(eventsPromises)).flat();
|
|
35
|
+
const afterTransactionEvents = events.map((e) => {
|
|
36
|
+
return e;
|
|
37
|
+
});
|
|
38
|
+
if (params.poolNames &&
|
|
39
|
+
params.poolNames.length === 1 &&
|
|
40
|
+
params.poolNames[0] === "ALPHA") {
|
|
41
|
+
return afterTransactionEvents;
|
|
42
|
+
}
|
|
43
|
+
const afterTransactionEventsWithPool = await (async () => {
|
|
44
|
+
const txDigests = [];
|
|
45
|
+
for (const event of afterTransactionEvents) {
|
|
46
|
+
if (!event.poolName) {
|
|
47
|
+
txDigests.push(event.id.txDigest);
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
const suiClient = getSuiClient();
|
|
51
|
+
let eventsFromTx = [];
|
|
52
|
+
while (txDigests.length > 0) {
|
|
53
|
+
const batch = txDigests.splice(0, Math.min(50, txDigests.length));
|
|
54
|
+
const eventsFromTxBatch = await suiClient.multiGetTransactionBlocks({
|
|
55
|
+
digests: batch,
|
|
56
|
+
options: { showEvents: true },
|
|
57
|
+
});
|
|
58
|
+
eventsFromTx = eventsFromTx.concat(eventsFromTxBatch);
|
|
59
|
+
}
|
|
60
|
+
return new Map(eventsFromTx.map((txData) => {
|
|
61
|
+
return [txData.digest, txData];
|
|
62
|
+
}));
|
|
63
|
+
})();
|
|
64
|
+
for (let i = 0; i < afterTransactionEvents.length; i++) {
|
|
65
|
+
const event = afterTransactionEvents[i];
|
|
66
|
+
if (event.poolName)
|
|
67
|
+
continue;
|
|
68
|
+
const otherEvents = afterTransactionEventsWithPool.get(event.id.txDigest)?.events;
|
|
69
|
+
if (!otherEvents) {
|
|
70
|
+
throw new Error(`SuiTransactionBlockResponse not found for digest: ${event.id.txDigest}`);
|
|
71
|
+
}
|
|
72
|
+
const thisPoolName = ((otherEvents) => {
|
|
73
|
+
for (let j = 0; j < otherEvents.length; j++) {
|
|
74
|
+
const otherEvent = otherEvents[j];
|
|
75
|
+
if (otherEvent.type === conf[CONF_ENV].CETUS_ADD_LIQUIDITY_EVENT ||
|
|
76
|
+
otherEvent.type === conf[CONF_ENV].CETUS_REMOVE_LIQUIDITY_EVENT) {
|
|
77
|
+
//CETUS
|
|
78
|
+
const eventJson = otherEvent.parsedJson;
|
|
79
|
+
const cetusPoolId = eventJson.pool;
|
|
80
|
+
const poolName = Object.keys(parentPoolMap).find((pool) => parentPoolMap[pool] === cetusPoolId);
|
|
81
|
+
if (!poolName)
|
|
82
|
+
throw new Error(`cetusPoolName not found for event: ${otherEvent}`);
|
|
83
|
+
return poolName;
|
|
84
|
+
}
|
|
85
|
+
else if (otherEvent.type === conf[CONF_ENV].NAVI_POOL_DEPOSIT_EVENT ||
|
|
86
|
+
otherEvent.type === conf[CONF_ENV].NAVI_POOL_WITHDRAW_EVENT) {
|
|
87
|
+
//NAVI
|
|
88
|
+
const eventJson = otherEvent.parsedJson;
|
|
89
|
+
const naviCoinId = eventJson.pool ===
|
|
90
|
+
"0000000000000000000000000000000000000000000000000000000000000002::sui::SUI"
|
|
91
|
+
? "0x2::sui::SUI"
|
|
92
|
+
: `0x${eventJson.pool}`;
|
|
93
|
+
const coinName = Object.keys(coins).find((coin) => coins[coin].type === naviCoinId);
|
|
94
|
+
const poolName = Object.keys(poolCoinMap).find((pool) => poolCoinMap[pool] === coinName);
|
|
95
|
+
if (!poolName) {
|
|
96
|
+
console.log(poolCoinMap, "poolCoinMap"); //debug
|
|
97
|
+
console.error("for event: ", otherEvent);
|
|
98
|
+
throw new Error(`naviPoolName not found`);
|
|
99
|
+
}
|
|
100
|
+
return poolName;
|
|
101
|
+
}
|
|
102
|
+
else {
|
|
103
|
+
if (j === otherEvents.length - 1) {
|
|
104
|
+
console.error("digest", event.id.txDigest);
|
|
105
|
+
throw new Error("deposit/withdraw events not found for either CETUS, or NAVI");
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
})(otherEvents);
|
|
110
|
+
if (!thisPoolName)
|
|
111
|
+
throw new Error(`PoolName not found`);
|
|
112
|
+
const eventWithPool = {
|
|
113
|
+
...event,
|
|
114
|
+
poolName: thisPoolName,
|
|
115
|
+
};
|
|
116
|
+
afterTransactionEvents[i] = eventWithPool;
|
|
117
|
+
}
|
|
118
|
+
if (params.poolNames && params.poolNames.length >= 1) {
|
|
119
|
+
const allowedPoolNames = params.poolNames;
|
|
120
|
+
return afterTransactionEvents.filter((event) => allowedPoolNames.includes(event.poolName));
|
|
121
|
+
}
|
|
122
|
+
return afterTransactionEvents;
|
|
123
|
+
}
|
|
124
|
+
//# sourceMappingURL=fetchAfterTransactionEvents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fetchAfterTransactionEvents.js","sourceRoot":"","sources":["../../../../src/sui-sdk/events/fetchAfterTransactionEvents.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAM5E,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAQ/C,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC5C,OAAO,E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EAAE,CAAC;wBACjC,OAAO,CAAC,KAAK,CAAC,QAAQ,EAAE,KAAK,CAAC,EAAE,CAAC,QAAQ,CAAC,CAAC;wBAC3C,MAAM,IAAI,KAAK,CACb,6DAA6D,CAC9D,CAAC;oBACJ,CAAC;gBACH,CAAC;YACH,CAAC;QACH,CAAC,CAAC,CAAC,WAAW,CAAC,CAAC;QAChB,IAAI,CAAC,YAAY;YAAE,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACzD,MAAM,aAAa,GAA8B;YAC/C,GAAG,KAAK;YACR,QAAQ,EAAE,YAAwB;SACnC,CAAC;QACF,sBAAsB,CAAC,CAAC,CAAC,GAAG,aAAa,CAAC;IAC5C,CAAC;IAED,IAAI,MAAM,CAAC,SAAS,IAAI,MAAM,CAAC,SAAS,CAAC,MAAM,IAAI,CAAC,EAAE,CAAC;QACrD,MAAM,gBAAgB,GAAG,MAAM,CAAC,SAAS,CAAC;QAC1C,OAAO,sBAAsB,CAAC,MAAM,CAAC,CAAC,KAAK,EAAE,EAAE,CAC7C,gBAAgB,CAAC,QAAQ,CAAC,KAAK,CAAC,QAAS,CAAC,CAC3C,CAAC;IACJ,CAAC;IAED,OAAO,sBAAsB,CAAC;AAChC,CAAC","sourcesContent":["import { SuiEvent, SuiTransactionBlockResponse } from \"@mysten/sui/client\";\nimport { parentPoolMap, poolCoinMap, poolInfo } from \"../../common/maps.js\";\nimport {\n CoinName,\n PoolName,\n SingleAssetPoolNames,\n} from \"../../common/types.js\";\nimport { fetchEvents } from \"./fetchEvents.js\";\nimport {\n AfterTransactionEventNode,\n CetusAddLiquidityEvent,\n CetusRemoveLiquidityEvent,\n NaviPoolDepositEvent,\n NaviPoolWithdrawEvent,\n} from \"./types.js\";\nimport { getSuiClient } from \"../client.js\";\nimport { conf, CONF_ENV } from \"../../common/constants.js\";\nimport { coins } from \"../../common/coins.js\";\n\nexport async function fetchAfterTransactionEvents(params: {\n startTime: number;\n endTime: number;\n poolNames?: PoolName[];\n}) {\n const eventTypesSet = new Set<string>();\n if (params.poolNames) {\n params.poolNames.forEach((poolName) => {\n const eventType = poolInfo[poolName].afterTransactionEventType;\n if (eventType !== undefined && eventType !== null && eventType !== \"\") {\n eventTypesSet.add(eventType);\n }\n });\n } else {\n // Iterate over all the values in poolInfo and add each autoCompoundingEventType to the Set\n Object.values(poolInfo).forEach((info) => {\n const eventType = info.afterTransactionEventType;\n if (eventType !== undefined && eventType !== null && eventType !== \"\") {\n eventTypesSet.add(eventType);\n }\n });\n }\n const eventTypes = Array.from(eventTypesSet);\n\n const eventsPromises = eventTypes.map(async (eventType) => {\n const events = await fetchEvents({\n startTime: params.startTime,\n endTime: params.endTime,\n eventTypes: [eventType],\n });\n return events;\n });\n const events = (await Promise.all(eventsPromises)).flat();\n const afterTransactionEvents = events.map((e) => {\n return e as AfterTransactionEventNode;\n });\n\n if (\n params.poolNames &&\n params.poolNames.length === 1 &&\n params.poolNames[0] === \"ALPHA\"\n ) {\n return afterTransactionEvents;\n }\n const afterTransactionEventsWithPool = await (async () => {\n const txDigests: string[] = [];\n for (const event of afterTransactionEvents) {\n if (!event.poolName) {\n txDigests.push(event.id.txDigest);\n }\n }\n const suiClient = getSuiClient();\n let eventsFromTx: SuiTransactionBlockResponse[] = [];\n while (txDigests.length > 0) {\n const batch = txDigests.splice(0, Math.min(50, txDigests.length));\n const eventsFromTxBatch = await suiClient.multiGetTransactionBlocks({\n digests: batch,\n options: { showEvents: true },\n });\n eventsFromTx = eventsFromTx.concat(eventsFromTxBatch);\n }\n return new Map<string, SuiTransactionBlockResponse>(\n eventsFromTx.map((txData) => {\n return [txData.digest, txData];\n }),\n );\n })();\n for (let i = 0; i < afterTransactionEvents.length; i++) {\n const event = afterTransactionEvents[i];\n if (event.poolName) continue;\n const otherEvents = afterTransactionEventsWithPool.get(\n event.id.txDigest,\n )?.events;\n if (!otherEvents) {\n throw new Error(\n `SuiTransactionBlockResponse not found for digest: ${event.id.txDigest}`,\n );\n }\n const thisPoolName = ((otherEvents: SuiEvent[]) => {\n for (let j = 0; j < otherEvents.length; j++) {\n const otherEvent = otherEvents[j];\n if (\n otherEvent.type === conf[CONF_ENV].CETUS_ADD_LIQUIDITY_EVENT ||\n otherEvent.type === conf[CONF_ENV].CETUS_REMOVE_LIQUIDITY_EVENT\n ) {\n //CETUS\n const eventJson = otherEvent.parsedJson as\n | CetusAddLiquidityEvent\n | CetusRemoveLiquidityEvent;\n const cetusPoolId = eventJson.pool;\n const poolName = Object.keys(parentPoolMap).find(\n (pool) => parentPoolMap[pool] === cetusPoolId,\n );\n if (!poolName)\n throw new Error(`cetusPoolName not found for event: ${otherEvent}`);\n return poolName;\n } else if (\n otherEvent.type === conf[CONF_ENV].NAVI_POOL_DEPOSIT_EVENT ||\n otherEvent.type === conf[CONF_ENV].NAVI_POOL_WITHDRAW_EVENT\n ) {\n //NAVI\n const eventJson = otherEvent.parsedJson as\n | NaviPoolDepositEvent\n | NaviPoolWithdrawEvent;\n const naviCoinId =\n eventJson.pool ===\n \"0000000000000000000000000000000000000000000000000000000000000002::sui::SUI\"\n ? \"0x2::sui::SUI\"\n : `0x${eventJson.pool}`;\n const coinName = Object.keys(coins).find(\n (coin) => coins[coin as CoinName].type === naviCoinId,\n );\n const poolName = Object.keys(poolCoinMap).find(\n (pool) => poolCoinMap[pool as SingleAssetPoolNames] === coinName,\n );\n if (!poolName) {\n console.log(poolCoinMap, \"poolCoinMap\"); //debug\n console.error(\"for event: \", otherEvent);\n throw new Error(`naviPoolName not found`);\n }\n return poolName;\n } else {\n if (j === otherEvents.length - 1) {\n console.error(\"digest\", event.id.txDigest);\n throw new Error(\n \"deposit/withdraw events not found for either CETUS, or NAVI\",\n );\n }\n }\n }\n })(otherEvents);\n if (!thisPoolName) throw new Error(`PoolName not found`);\n const eventWithPool: AfterTransactionEventNode = {\n ...event,\n poolName: thisPoolName as PoolName,\n };\n afterTransactionEvents[i] = eventWithPool;\n }\n\n if (params.poolNames && params.poolNames.length >= 1) {\n const allowedPoolNames = params.poolNames;\n return afterTransactionEvents.filter((event) =>\n allowedPoolNames.includes(event.poolName!),\n );\n }\n\n return afterTransactionEvents;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchEvents.d.ts","sourceRoot":"","sources":["../../../../src/sui-sdk/events/fetchEvents.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,SAAS,EACT,iBAAiB,
|
|
1
|
+
{"version":3,"file":"fetchEvents.d.ts","sourceRoot":"","sources":["../../../../src/sui-sdk/events/fetchEvents.ts"],"names":[],"mappings":"AAEA,OAAO,EAKL,SAAS,EACT,iBAAiB,EAUlB,MAAM,YAAY,CAAC;AAIpB,wBAAsB,WAAW,CAC/B,MAAM,EAAE,iBAAiB,GACxB,OAAO,CAAC,SAAS,EAAE,CAAC,CAyRtB"}
|
|
@@ -139,7 +139,8 @@ export async function fetchEvents(params) {
|
|
|
139
139
|
else if (isLiquidityChangeEvent(suiEvent.type) &&
|
|
140
140
|
"amount" in suiEventJson &&
|
|
141
141
|
!("investor_id" in suiEventJson) &&
|
|
142
|
-
!("amount_withdrawn_from_locked" in suiEventJson)
|
|
142
|
+
!("amount_withdrawn_from_locked" in suiEventJson) &&
|
|
143
|
+
!("xtokenSupply" in suiEventJson)) {
|
|
143
144
|
// Handling NaviLiquidityChangeEvent and AlphaLiquidityChangeEvent
|
|
144
145
|
eventNode = {
|
|
145
146
|
type: suiEvent.type,
|
|
@@ -172,7 +173,60 @@ export async function fetchEvents(params) {
|
|
|
172
173
|
x_token_supply: suiEventJson.x_token_supply,
|
|
173
174
|
};
|
|
174
175
|
}
|
|
176
|
+
else if (isAfterTransactionEvent(suiEvent.type) &&
|
|
177
|
+
"tokensInvested" in suiEventJson &&
|
|
178
|
+
!("liquidity" in suiEventJson) &&
|
|
179
|
+
!("amount" in suiEventJson)) {
|
|
180
|
+
//handling alpha after transaction event
|
|
181
|
+
if (suiEvent.id.eventSeq === "0")
|
|
182
|
+
continue;
|
|
183
|
+
eventNode = {
|
|
184
|
+
type: suiEvent.type,
|
|
185
|
+
timestamp: Number(suiEvent.timestampMs),
|
|
186
|
+
poolName: "ALPHA",
|
|
187
|
+
id: {
|
|
188
|
+
eventSeq: Number(suiEvent.id.eventSeq),
|
|
189
|
+
txDigest: suiEvent.id.txDigest,
|
|
190
|
+
},
|
|
191
|
+
tokensInvested: suiEventJson.tokensInvested,
|
|
192
|
+
xTokenSupply: suiEventJson.xTokenSupply,
|
|
193
|
+
};
|
|
194
|
+
}
|
|
195
|
+
else if (isAfterTransactionEvent(suiEvent.type) &&
|
|
196
|
+
"tokensInvested" in suiEventJson &&
|
|
197
|
+
"liquidity" in suiEventJson) {
|
|
198
|
+
//handling cetus after transaction event
|
|
199
|
+
eventNode = {
|
|
200
|
+
type: suiEvent.type,
|
|
201
|
+
timestamp: Number(suiEvent.timestampMs),
|
|
202
|
+
poolName: undefined,
|
|
203
|
+
id: {
|
|
204
|
+
eventSeq: Number(suiEvent.id.eventSeq),
|
|
205
|
+
txDigest: suiEvent.id.txDigest,
|
|
206
|
+
},
|
|
207
|
+
tokensInvested: suiEventJson.tokensInvested,
|
|
208
|
+
xtokenSupply: suiEventJson.xtokenSupply,
|
|
209
|
+
liquidity: suiEventJson.liquidity,
|
|
210
|
+
};
|
|
211
|
+
}
|
|
212
|
+
else if (isAfterTransactionEvent(suiEvent.type) &&
|
|
213
|
+
"amount" in suiEventJson &&
|
|
214
|
+
"tokensInvested" in suiEventJson) {
|
|
215
|
+
eventNode = {
|
|
216
|
+
type: suiEvent.type,
|
|
217
|
+
timestamp: Number(suiEvent.timestampMs),
|
|
218
|
+
poolName: undefined,
|
|
219
|
+
id: {
|
|
220
|
+
eventSeq: Number(suiEvent.id.eventSeq),
|
|
221
|
+
txDigest: suiEvent.id.txDigest,
|
|
222
|
+
},
|
|
223
|
+
tokensInvested: suiEventJson.tokensInvested,
|
|
224
|
+
xtokenSupply: suiEventJson.xtokenSupply,
|
|
225
|
+
amount: suiEventJson.amount,
|
|
226
|
+
};
|
|
227
|
+
}
|
|
175
228
|
else {
|
|
229
|
+
console.error("event: ", suiEvent, "json: ", suiEventJson);
|
|
176
230
|
throw new Error("Unknown event type");
|
|
177
231
|
}
|
|
178
232
|
allEvents.push(eventNode);
|
|
@@ -211,7 +265,15 @@ const isLiquidityChangeEvent = (eventType) => {
|
|
|
211
265
|
const isWithdrawV2Event = (eventType) => {
|
|
212
266
|
const eventTypes = Object.values(poolInfo)
|
|
213
267
|
.map((info) => {
|
|
214
|
-
return info.
|
|
268
|
+
return info.withdrawV2EventType;
|
|
269
|
+
})
|
|
270
|
+
.filter((type) => type !== undefined);
|
|
271
|
+
return eventTypes.includes(eventType);
|
|
272
|
+
};
|
|
273
|
+
const isAfterTransactionEvent = (eventType) => {
|
|
274
|
+
const eventTypes = Object.values(poolInfo)
|
|
275
|
+
.map((info) => {
|
|
276
|
+
return info.afterTransactionEventType;
|
|
215
277
|
})
|
|
216
278
|
.filter((type) => type !== undefined);
|
|
217
279
|
return eventTypes.includes(eventType);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchEvents.js","sourceRoot":"","sources":["../../../../src/sui-sdk/events/fetchEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAkB5C,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,IAAI,EAAE,QAAQ,EAAE,MAAM,2BAA2B,CAAC;AAE3D,MAAM,CAAC,KAAK,UAAU,WAAW,CAC/B,MAAyB;IAEzB,MAAM,SAAS,GAAgB,EAAE,CAAC;IAClC,IAAI,WAAW,GAAG,IAAI,CAAC;IACvB,IAAI,WAAW,GAA+B,IAAI,CAAC;IAEnD,IAAI,MAAM,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACjC,OAAO,CAAC,IAAI,CACV,kFAAkF,CACnF,CAAC;IACJ,CAAC;IAED,IAAI,MAAM,C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AO,IAAI,CAAC,kBAA4B,CAAC;IAC3C,CAAC,CAAC,CAAC;IACL,OAAO,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,sBAAsB,GAAG,CAAC,SAAiB,EAAE,EAAE;IACnD,MAAM,UAAU,GAAa,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAChE,OAAO,IAAI,CAAC,wBAAwB,CAAC;IACvC,CAAC,CAAC,CAAC;IACH,OAAO,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC9C,MAAM,UAAU,GAAa,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;SACjD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,OAAO,IAAI,CAAC,eAAe,CAAC;IAC9B,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IACxC,OAAO,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC,CAAC","sourcesContent":["import { getSuiClient } from \"../client.js\";\nimport { EventId, PaginatedEvents } from \"@mysten/sui/client\";\nimport {\n AlphaLiquidityChangeEvent,\n AlphaAutoCompoundingEvent,\n CetusAutoCompoundingEvent,\n CetusLiquidityChangeEvent,\n EventNode,\n FetchEventsParams,\n LiquidityChangeEventNode,\n NaviAutoCompoundingEvent,\n NaviLoopAutoCompoundingEvent,\n NaviLiquidityChangeEvent,\n RebalanceEvent,\n AutoCompoundingEventNode,\n AlphaWithdrawV2Event,\n WithdrawV2EventNode,\n} from \"./types.js\";\nimport { poolInfo } from \"../../common/maps.js\";\nimport { conf, CONF_ENV } from \"../../common/constants.js\";\n\nexport async function fetchEvents(\n params: FetchEventsParams,\n): Promise<EventNode[]> {\n const allEvents: EventNode[] = [];\n let hasNextPage = true;\n let startCursor: EventId | null | undefined = null;\n\n if (params.eventTypes.length > 1) {\n console.warn(\n \"Multiple eventTypes not supported right now, pass only one element in the array.\",\n );\n }\n\n if (params.eventTypes.length < 1) {\n hasNextPage = false;\n }\n\n const now = Date.now();\n const twentyFourHoursAgo = now - 24 * 60 * 60 * 1000; // timestamp for 24 hours ago\n const startTime = params.startTime ? params.startTime : twentyFourHoursAgo;\n const endTime = params.endTime ? params.endTime : now;\n\n if (startTime >= endTime) {\n throw new Error(\"startTime must be less than endTime\");\n }\n\n const suiClient = getSuiClient();\n //const prevTS = 0;\n\n while (hasNextPage) {\n const result: PaginatedEvents = await suiClient.queryEvents({\n cursor: startCursor,\n order: \"descending\",\n query: {\n MoveEventType: params.eventTypes[0],\n },\n });\n\n const se = result.data;\n for (let i = 0; i < se.length; i++) {\n const suiEvent = se[i];\n\n if (Number(suiEvent.timestampMs) > endTime) {\n continue;\n }\n\n if (Number(suiEvent.timestampMs) < startTime) {\n hasNextPage = false; // Stop further pagination\n break; // Exit the loop\n }\n\n const suiEventJson = suiEvent.parsedJson as\n | CetusAutoCompoundingEvent\n | NaviAutoCompoundingEvent\n | NaviLoopAutoCompoundingEvent\n | RebalanceEvent\n | CetusLiquidityChangeEvent\n | AlphaLiquidityChangeEvent\n | NaviLiquidityChangeEvent\n | AlphaAutoCompoundingEvent\n | AlphaWithdrawV2Event;\n\n let eventNode: EventNode;\n\n if (\n isAutoCompoundingEvent(suiEvent.type) &&\n \"compound_amount_a\" in suiEventJson &&\n \"compound_amount_b\" in suiEventJson\n ) {\n // Handling CetusAutoCompoundingEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n compound_amount_a: BigInt(suiEventJson.compound_amount_a.toString()),\n compound_amount_b: BigInt(suiEventJson.compound_amount_b.toString()),\n current_liquidity: BigInt(suiEventJson.current_liquidity.toString()),\n fee_collected_a: BigInt(suiEventJson.fee_collected_a.toString()),\n fee_collected_b: BigInt(suiEventJson.fee_collected_b.toString()),\n free_balance_a: BigInt(suiEventJson.free_balance_a.toString()),\n free_balance_b: BigInt(suiEventJson.free_balance_b.toString()),\n investor_id: suiEventJson.investor_id,\n total_amount_a: BigInt(suiEventJson.total_amount_a.toString()),\n total_amount_b: BigInt(suiEventJson.total_amount_b.toString()),\n };\n\n // if (\n // eventNode.investor_id ===\n // \"0xd060e81548aee885bd3d37ae0caec181185be792bf45412e0d0acccd1e0174e6\"\n // ) {\n // console.log(\n // eventNode.timestamp,\n // (prevTS - eventNode.timestamp) / (1000 * 60),\n // );\n // prevTS = eventNode.timestamp;\n // }\n } else if (\n isAutoCompoundingEvent(suiEvent.type) &&\n \"compound_amount\" in suiEventJson\n ) {\n // Handling NaviAutoCompoundingEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n compound_amount: BigInt(suiEventJson.compound_amount.toString()),\n fee_collected: BigInt(suiEventJson.fee_collected.toString()),\n investor_id: suiEventJson.investor_id,\n location: suiEventJson.location,\n total_amount: BigInt(suiEventJson.total_amount.toString()),\n };\n if (\n \"cur_total_debt\" in suiEventJson &&\n \"accrued_interest\" in suiEventJson\n ) {\n const loopEvent: AutoCompoundingEventNode = {\n ...eventNode,\n cur_total_debt: BigInt(suiEventJson.cur_total_debt.toString()),\n accrued_interest: BigInt(suiEventJson.accrued_interest.toString()),\n };\n eventNode = loopEvent;\n }\n } else if (\n isAutoCompoundingEvent(suiEvent.type) &&\n \"amount\" in suiEventJson\n ) {\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount: suiEventJson.amount,\n investor_id: conf[CONF_ENV].ALPHA_POOL,\n };\n } else if (\n isRebalanceEvent(suiEvent.type) &&\n \"lower_tick_after\" in suiEventJson\n ) {\n // Handling RebalanceEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n investor_id: suiEventJson.investor_id.toString(),\n lower_tick_after: suiEventJson.lower_tick_after.toString(),\n upper_tick_after: suiEventJson.upper_tick_after.toString(),\n sqrt_price_after: suiEventJson.sqrt_price_after.toString(),\n amount_a_before: suiEventJson.amount_a_before.toString(),\n amount_b_before: suiEventJson.amount_b_before.toString(),\n amount_a_after: suiEventJson.amount_a_after.toString(),\n amount_b_after: suiEventJson.amount_b_after.toString(),\n };\n } else if (\n isLiquidityChangeEvent(suiEvent.type) &&\n \"amount_a\" in suiEventJson\n ) {\n // Handling CetusLiquidityChangeEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount_a: suiEventJson.amount_a,\n amount_b: suiEventJson.amount_b,\n event_type: suiEventJson.event_type,\n fee_collected_a: suiEventJson.fee_collected_a,\n fee_collected_b: suiEventJson.fee_collected_b,\n pool_id: suiEventJson.pool_id,\n sender: suiEventJson.sender,\n tokens_invested: suiEventJson.tokens_invested,\n total_amount_a: suiEventJson.total_amount_a,\n total_amount_b: suiEventJson.total_amount_b,\n user_total_x_token_balance: suiEventJson.user_total_x_token_balance,\n x_token_supply: suiEventJson.x_token_supply,\n } as LiquidityChangeEventNode;\n } else if (\n isLiquidityChangeEvent(suiEvent.type) &&\n \"amount\" in suiEventJson &&\n !(\"investor_id\" in suiEventJson) &&\n !(\"amount_withdrawn_from_locked\" in suiEventJson)\n ) {\n // Handling NaviLiquidityChangeEvent and AlphaLiquidityChangeEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount: suiEventJson.amount,\n event_type: suiEventJson.event_type,\n fee_collected: suiEventJson.fee_collected,\n pool_id: suiEventJson.pool_id,\n sender: suiEventJson.sender,\n tokens_invested: suiEventJson.tokens_invested,\n user_total_x_token_balance: suiEventJson.user_total_x_token_balance,\n x_token_supply: suiEventJson.x_token_supply,\n } as LiquidityChangeEventNode;\n } else if (\n isWithdrawV2Event(suiEvent.type) &&\n \"amount_withdrawn_from_locked\" in suiEventJson\n ) {\n // Handling Alpha WithdrawV2 Events\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount: suiEventJson.amount,\n amount_withdrawn_from_locked:\n suiEventJson.amount_withdrawn_from_locked,\n amount_withdrawn_from_unlocked:\n suiEventJson.amount_withdrawn_from_unlocked,\n fee_collected: suiEventJson.fee_collected,\n instant_withdraw_fee_collected:\n suiEventJson.instant_withdraw_fee_collected,\n pool_id: suiEventJson.pool_id,\n sender: suiEventJson.sender,\n tokens_invested: suiEventJson.tokens_invested,\n user_total_x_token_balance: suiEventJson.user_total_x_token_balance,\n x_token_supply: suiEventJson.x_token_supply,\n } as WithdrawV2EventNode;\n } else {\n throw new Error(\"Unknown event type\");\n }\n\n allEvents.push(eventNode);\n }\n\n // If we set hasPreviousPage to false, exit the outer loop as well\n if (!hasNextPage) {\n break;\n }\n\n hasNextPage = result.hasNextPage;\n startCursor = result.nextCursor;\n }\n\n return allEvents;\n}\n\nconst isAutoCompoundingEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo).map((info) => {\n return info.autoCompoundingEventType;\n });\n return eventTypes.includes(eventType);\n};\n\nconst isRebalanceEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo)\n .filter((info) => {\n return info.rebalanceEventType ? true : false;\n })\n .map((info) => {\n return info.rebalanceEventType as string;\n });\n return eventTypes.includes(eventType);\n};\n\nconst isLiquidityChangeEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo).map((info) => {\n return info.liquidityChangeEventType;\n });\n return eventTypes.includes(eventType);\n};\n\nconst isWithdrawV2Event = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo)\n .map((info) => {\n return info.withdrawV2Event;\n })\n .filter((type) => type !== undefined);\n return eventTypes.includes(eventType);\n};\n"]}
|
|
1
|
+
{"version":3,"file":"fetchEvents.js","sourceRoot":"","sources":["../../../../src/sui-sdk/events/fetchEvents.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cA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EF,MAAM,sBAAsB,GAAG,CAAC,SAAiB,EAAE,EAAE;IACnD,MAAM,UAAU,GAAa,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QAChE,OAAO,IAAI,CAAC,wBAAwB,CAAC;IACvC,CAAC,CAAC,CAAC;IACH,OAAO,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,iBAAiB,GAAG,CAAC,SAAiB,EAAE,EAAE;IAC9C,MAAM,UAAU,GAAa,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;SACjD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,OAAO,IAAI,CAAC,mBAAmB,CAAC;IAClC,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IACxC,OAAO,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC,CAAC;AAEF,MAAM,uBAAuB,GAAG,CAAC,SAAiB,EAAE,EAAE;IACpD,MAAM,UAAU,GAAa,MAAM,CAAC,MAAM,CAAC,QAAQ,CAAC;SACjD,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,OAAO,IAAI,CAAC,yBAAyB,CAAC;IACxC,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,IAAI,KAAK,SAAS,CAAC,CAAC;IACxC,OAAO,UAAU,CAAC,QAAQ,CAAC,SAAS,CAAC,CAAC;AACxC,CAAC,CAAC","sourcesContent":["import { getSuiClient } from \"../client.js\";\nimport { EventId, PaginatedEvents } from \"@mysten/sui/client\";\nimport {\n AlphaLiquidityChangeEvent,\n AlphaAutoCompoundingEvent,\n CetusAutoCompoundingEvent,\n CetusLiquidityChangeEvent,\n EventNode,\n FetchEventsParams,\n LiquidityChangeEventNode,\n NaviAutoCompoundingEvent,\n NaviLoopAutoCompoundingEvent,\n NaviLiquidityChangeEvent,\n RebalanceEvent,\n AutoCompoundingEventNode,\n AlphaWithdrawV2Event,\n WithdrawV2EventNode,\n AfterTransactionEventNode,\n} from \"./types.js\";\nimport { poolInfo } from \"../../common/maps.js\";\nimport { conf, CONF_ENV } from \"../../common/constants.js\";\n\nexport async function fetchEvents(\n params: FetchEventsParams,\n): Promise<EventNode[]> {\n const allEvents: EventNode[] = [];\n let hasNextPage = true;\n let startCursor: EventId | null | undefined = null;\n\n if (params.eventTypes.length > 1) {\n console.warn(\n \"Multiple eventTypes not supported right now, pass only one element in the array.\",\n );\n }\n\n if (params.eventTypes.length < 1) {\n hasNextPage = false;\n }\n\n const now = Date.now();\n const twentyFourHoursAgo = now - 24 * 60 * 60 * 1000; // timestamp for 24 hours ago\n const startTime = params.startTime ? params.startTime : twentyFourHoursAgo;\n const endTime = params.endTime ? params.endTime : now;\n\n if (startTime >= endTime) {\n throw new Error(\"startTime must be less than endTime\");\n }\n\n const suiClient = getSuiClient();\n //const prevTS = 0;\n\n while (hasNextPage) {\n const result: PaginatedEvents = await suiClient.queryEvents({\n cursor: startCursor,\n order: \"descending\",\n query: {\n MoveEventType: params.eventTypes[0],\n },\n });\n\n const se = result.data;\n for (let i = 0; i < se.length; i++) {\n const suiEvent = se[i];\n\n if (Number(suiEvent.timestampMs) > endTime) {\n continue;\n }\n\n if (Number(suiEvent.timestampMs) < startTime) {\n hasNextPage = false; // Stop further pagination\n break; // Exit the loop\n }\n\n const suiEventJson = suiEvent.parsedJson as\n | CetusAutoCompoundingEvent\n | NaviAutoCompoundingEvent\n | NaviLoopAutoCompoundingEvent\n | RebalanceEvent\n | CetusLiquidityChangeEvent\n | AlphaLiquidityChangeEvent\n | NaviLiquidityChangeEvent\n | AlphaAutoCompoundingEvent\n | AlphaWithdrawV2Event\n | AfterTransactionEventNode;\n\n let eventNode: EventNode;\n\n if (\n isAutoCompoundingEvent(suiEvent.type) &&\n \"compound_amount_a\" in suiEventJson &&\n \"compound_amount_b\" in suiEventJson\n ) {\n // Handling CetusAutoCompoundingEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n compound_amount_a: BigInt(suiEventJson.compound_amount_a.toString()),\n compound_amount_b: BigInt(suiEventJson.compound_amount_b.toString()),\n current_liquidity: BigInt(suiEventJson.current_liquidity.toString()),\n fee_collected_a: BigInt(suiEventJson.fee_collected_a.toString()),\n fee_collected_b: BigInt(suiEventJson.fee_collected_b.toString()),\n free_balance_a: BigInt(suiEventJson.free_balance_a.toString()),\n free_balance_b: BigInt(suiEventJson.free_balance_b.toString()),\n investor_id: suiEventJson.investor_id,\n total_amount_a: BigInt(suiEventJson.total_amount_a.toString()),\n total_amount_b: BigInt(suiEventJson.total_amount_b.toString()),\n };\n\n // if (\n // eventNode.investor_id ===\n // \"0xd060e81548aee885bd3d37ae0caec181185be792bf45412e0d0acccd1e0174e6\"\n // ) {\n // console.log(\n // eventNode.timestamp,\n // (prevTS - eventNode.timestamp) / (1000 * 60),\n // );\n // prevTS = eventNode.timestamp;\n // }\n } else if (\n isAutoCompoundingEvent(suiEvent.type) &&\n \"compound_amount\" in suiEventJson\n ) {\n // Handling NaviAutoCompoundingEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n compound_amount: BigInt(suiEventJson.compound_amount.toString()),\n fee_collected: BigInt(suiEventJson.fee_collected.toString()),\n investor_id: suiEventJson.investor_id,\n location: suiEventJson.location,\n total_amount: BigInt(suiEventJson.total_amount.toString()),\n };\n if (\n \"cur_total_debt\" in suiEventJson &&\n \"accrued_interest\" in suiEventJson\n ) {\n const loopEvent: AutoCompoundingEventNode = {\n ...eventNode,\n cur_total_debt: BigInt(suiEventJson.cur_total_debt.toString()),\n accrued_interest: BigInt(suiEventJson.accrued_interest.toString()),\n };\n eventNode = loopEvent;\n }\n } else if (\n isAutoCompoundingEvent(suiEvent.type) &&\n \"amount\" in suiEventJson\n ) {\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount: suiEventJson.amount,\n investor_id: conf[CONF_ENV].ALPHA_POOL,\n };\n } else if (\n isRebalanceEvent(suiEvent.type) &&\n \"lower_tick_after\" in suiEventJson\n ) {\n // Handling RebalanceEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n investor_id: suiEventJson.investor_id.toString(),\n lower_tick_after: suiEventJson.lower_tick_after.toString(),\n upper_tick_after: suiEventJson.upper_tick_after.toString(),\n sqrt_price_after: suiEventJson.sqrt_price_after.toString(),\n amount_a_before: suiEventJson.amount_a_before.toString(),\n amount_b_before: suiEventJson.amount_b_before.toString(),\n amount_a_after: suiEventJson.amount_a_after.toString(),\n amount_b_after: suiEventJson.amount_b_after.toString(),\n };\n } else if (\n isLiquidityChangeEvent(suiEvent.type) &&\n \"amount_a\" in suiEventJson\n ) {\n // Handling CetusLiquidityChangeEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount_a: suiEventJson.amount_a,\n amount_b: suiEventJson.amount_b,\n event_type: suiEventJson.event_type,\n fee_collected_a: suiEventJson.fee_collected_a,\n fee_collected_b: suiEventJson.fee_collected_b,\n pool_id: suiEventJson.pool_id,\n sender: suiEventJson.sender,\n tokens_invested: suiEventJson.tokens_invested,\n total_amount_a: suiEventJson.total_amount_a,\n total_amount_b: suiEventJson.total_amount_b,\n user_total_x_token_balance: suiEventJson.user_total_x_token_balance,\n x_token_supply: suiEventJson.x_token_supply,\n } as LiquidityChangeEventNode;\n } else if (\n isLiquidityChangeEvent(suiEvent.type) &&\n \"amount\" in suiEventJson &&\n !(\"investor_id\" in suiEventJson) &&\n !(\"amount_withdrawn_from_locked\" in suiEventJson) &&\n !(\"xtokenSupply\" in suiEventJson)\n ) {\n // Handling NaviLiquidityChangeEvent and AlphaLiquidityChangeEvent\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount: suiEventJson.amount,\n event_type: suiEventJson.event_type,\n fee_collected: suiEventJson.fee_collected,\n pool_id: suiEventJson.pool_id,\n sender: suiEventJson.sender,\n tokens_invested: suiEventJson.tokens_invested,\n user_total_x_token_balance: suiEventJson.user_total_x_token_balance,\n x_token_supply: suiEventJson.x_token_supply,\n } as LiquidityChangeEventNode;\n } else if (\n isWithdrawV2Event(suiEvent.type) &&\n \"amount_withdrawn_from_locked\" in suiEventJson\n ) {\n // Handling Alpha WithdrawV2 Events\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n amount: suiEventJson.amount,\n amount_withdrawn_from_locked:\n suiEventJson.amount_withdrawn_from_locked,\n amount_withdrawn_from_unlocked:\n suiEventJson.amount_withdrawn_from_unlocked,\n fee_collected: suiEventJson.fee_collected,\n instant_withdraw_fee_collected:\n suiEventJson.instant_withdraw_fee_collected,\n pool_id: suiEventJson.pool_id,\n sender: suiEventJson.sender,\n tokens_invested: suiEventJson.tokens_invested,\n user_total_x_token_balance: suiEventJson.user_total_x_token_balance,\n x_token_supply: suiEventJson.x_token_supply,\n } as WithdrawV2EventNode;\n } else if (\n isAfterTransactionEvent(suiEvent.type) &&\n \"tokensInvested\" in suiEventJson &&\n !(\"liquidity\" in suiEventJson) &&\n !(\"amount\" in suiEventJson)\n ) {\n //handling alpha after transaction event\n if (suiEvent.id.eventSeq === \"0\") continue;\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n poolName: \"ALPHA\",\n id: {\n eventSeq: Number(suiEvent.id.eventSeq),\n txDigest: suiEvent.id.txDigest,\n },\n tokensInvested: suiEventJson.tokensInvested,\n xTokenSupply: suiEventJson.xTokenSupply,\n };\n } else if (\n isAfterTransactionEvent(suiEvent.type) &&\n \"tokensInvested\" in suiEventJson &&\n \"liquidity\" in suiEventJson\n ) {\n //handling cetus after transaction event\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n poolName: undefined,\n id: {\n eventSeq: Number(suiEvent.id.eventSeq),\n txDigest: suiEvent.id.txDigest,\n },\n tokensInvested: suiEventJson.tokensInvested,\n xtokenSupply: suiEventJson.xtokenSupply,\n liquidity: suiEventJson.liquidity,\n };\n } else if (\n isAfterTransactionEvent(suiEvent.type) &&\n \"amount\" in suiEventJson &&\n \"tokensInvested\" in suiEventJson\n ) {\n eventNode = {\n type: suiEvent.type,\n timestamp: Number(suiEvent.timestampMs),\n poolName: undefined,\n id: {\n eventSeq: Number(suiEvent.id.eventSeq),\n txDigest: suiEvent.id.txDigest,\n },\n tokensInvested: suiEventJson.tokensInvested,\n xtokenSupply: suiEventJson.xtokenSupply,\n amount: suiEventJson.amount,\n };\n } else {\n console.error(\"event: \", suiEvent, \"json: \", suiEventJson);\n throw new Error(\"Unknown event type\");\n }\n\n allEvents.push(eventNode);\n }\n\n // If we set hasPreviousPage to false, exit the outer loop as well\n if (!hasNextPage) {\n break;\n }\n\n hasNextPage = result.hasNextPage;\n startCursor = result.nextCursor;\n }\n\n return allEvents;\n}\n\nconst isAutoCompoundingEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo).map((info) => {\n return info.autoCompoundingEventType;\n });\n return eventTypes.includes(eventType);\n};\n\nconst isRebalanceEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo)\n .filter((info) => {\n return info.rebalanceEventType ? true : false;\n })\n .map((info) => {\n return info.rebalanceEventType as string;\n });\n return eventTypes.includes(eventType);\n};\n\nconst isLiquidityChangeEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo).map((info) => {\n return info.liquidityChangeEventType;\n });\n return eventTypes.includes(eventType);\n};\n\nconst isWithdrawV2Event = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo)\n .map((info) => {\n return info.withdrawV2EventType;\n })\n .filter((type) => type !== undefined);\n return eventTypes.includes(eventType);\n};\n\nconst isAfterTransactionEvent = (eventType: string) => {\n const eventTypes: string[] = Object.values(poolInfo)\n .map((info) => {\n return info.afterTransactionEventType;\n })\n .filter((type) => type !== undefined);\n return eventTypes.includes(eventType);\n};\n"]}
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { poolInfo } from "../../common/maps.js";
|
|
2
2
|
import { fetchEvents } from "./fetchEvents.js";
|
|
3
3
|
export async function fetchWithdrawV2Events(params) {
|
|
4
|
-
const eventTypes = [poolInfo["ALPHA"].
|
|
4
|
+
const eventTypes = [poolInfo["ALPHA"].withdrawV2EventType];
|
|
5
5
|
const eventsPromises = eventTypes.map(async (eventType) => {
|
|
6
6
|
if (!eventType) {
|
|
7
7
|
console.error(`Event type not found: ${eventTypes}`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fetchWithdrawV2Events.js","sourceRoot":"","sources":["../../../../src/sui-sdk/events/fetchWithdrawV2Events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAmC;IAEnC,MAAM,UAAU,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"fetchWithdrawV2Events.js","sourceRoot":"","sources":["../../../../src/sui-sdk/events/fetchWithdrawV2Events.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AAG/C,MAAM,CAAC,KAAK,UAAU,qBAAqB,CACzC,MAAmC;IAEnC,MAAM,UAAU,GAAG,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,mBAAmB,CAAC,CAAC;IAC3D,MAAM,cAAc,GAAG,UAAU,CAAC,GAAG,CAAC,KAAK,EAAE,SAAS,EAAE,EAAE;QACxD,IAAI,CAAC,SAAS,EAAE,CAAC;YACf,OAAO,CAAC,KAAK,CAAC,yBAAyB,UAAU,EAAE,CAAC,CAAC;YACrD,MAAM,IAAI,KAAK,CAAC,wBAAwB,CAAC,CAAC;QAC5C,CAAC;QACD,MAAM,MAAM,GAAG,MAAM,WAAW,CAAC;YAC/B,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,OAAO,EAAE,MAAM,CAAC,OAAO;YACvB,UAAU,EAAE,CAAC,SAAS,CAAC;SACxB,CAAC,CAAC;QACH,OAAO,MAAM,CAAC;IAChB,CAAC,CAAC,CAAC;IACH,MAAM,MAAM,GAAG,CAAC,MAAM,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC1D,MAAM,oBAAoB,GAAG,MAAM,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QAC5C,OAAO,CAAwB,CAAC;IAClC,CAAC,CAAC,CAAC;IAEH,OAAO,oBAAoB,CAAC;AAC9B,CAAC","sourcesContent":["import { poolInfo } from \"../../common/maps.js\";\nimport { fetchEvents } from \"./fetchEvents.js\";\nimport { FetchWithdrawV2EventsParams, WithdrawV2EventNode } from \"./types.js\";\n\nexport async function fetchWithdrawV2Events(\n params: FetchWithdrawV2EventsParams,\n): Promise<WithdrawV2EventNode[]> {\n const eventTypes = [poolInfo[\"ALPHA\"].withdrawV2EventType];\n const eventsPromises = eventTypes.map(async (eventType) => {\n if (!eventType) {\n console.error(`Event type not found: ${eventTypes}`);\n throw new Error(\"Incomplete Event Types\");\n }\n const events = await fetchEvents({\n startTime: params.startTime,\n endTime: params.endTime,\n eventTypes: [eventType],\n });\n return events;\n });\n const events = (await Promise.all(eventsPromises)).flat();\n const withdrawV2EventNodes = events.map((e) => {\n return e as WithdrawV2EventNode;\n });\n\n return withdrawV2EventNodes;\n}\n"]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/sui-sdk/events/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAA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appings":"","sourcesContent":["import { PoolName } from \"../../common/types.js\";\n\ninterface CommonEventAttributes {\n type: string;\n timestamp: number;\n}\n\nexport interface CetusAutoCompoundingEvent {\n compound_amount_a: bigint;\n compound_amount_b: bigint;\n current_liquidity: bigint;\n fee_collected_a: bigint;\n fee_collected_b: bigint;\n free_balance_a: bigint;\n free_balance_b: bigint;\n investor_id: string;\n total_amount_a: bigint;\n total_amount_b: bigint;\n}\n\nexport interface NaviAutoCompoundingEvent {\n compound_amount: bigint;\n fee_collected: bigint;\n investor_id: string;\n location: number;\n total_amount: bigint;\n}\n\nexport interface NaviLoopAutoCompoundingEvent extends NaviAutoCompoundingEvent {\n cur_total_debt: bigint;\n accrued_interest: bigint;\n}\n\nexport interface RebalanceEvent {\n investor_id: string;\n lower_tick_after: string;\n upper_tick_after: string;\n sqrt_price_after: string;\n amount_a_before: string;\n amount_b_before: string;\n amount_a_after: string;\n amount_b_after: string;\n}\n\n//verify, this might be wrong, alphapool reward event is defined as alpha autocompounding event\nexport interface AlphaAutoCompoundingEvent {\n amount: string;\n investor_id: string;\n}\n\nexport interface CetusLiquidityChangeEvent {\n amount_a: string;\n amount_b: string;\n event_type: number;\n fee_collected_a: string;\n fee_collected_b: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n total_amount_a: string;\n total_amount_b: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface NaviLiquidityChangeEvent {\n amount: string;\n event_type: number;\n fee_collected: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface AlphaLiquidityChangeEvent {\n amount: string;\n event_type: number;\n fee_collected: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface AlphaWithdrawV2Event {\n amount: string;\n amount_withdrawn_from_locked: string;\n amount_withdrawn_from_unlocked: string;\n fee_collected: string;\n instant_withdraw_fee_collected: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport type AutoCompoundingEventNode =\n | (CetusAutoCompoundingEvent & CommonEventAttributes)\n | (NaviAutoCompoundingEvent & CommonEventAttributes)\n | (NaviLoopAutoCompoundingEvent & CommonEventAttributes)\n | (AlphaAutoCompoundingEvent & CommonEventAttributes);\n\nexport type RebalanceEventNode = RebalanceEvent & CommonEventAttributes;\n\nexport type LiquidityChangeEventNode =\n | (CetusLiquidityChangeEvent & CommonEventAttributes)\n | (NaviLiquidityChangeEvent & CommonEventAttributes)\n | (AlphaLiquidityChangeEvent & CommonEventAttributes);\n\nexport type WithdrawV2EventNode = AlphaWithdrawV2Event & CommonEventAttributes;\n\nexport type EventNode =\n | AutoCompoundingEventNode\n | RebalanceEventNode\n | LiquidityChangeEventNode\n | WithdrawV2EventNode;\n\nexport type FetchAutoCompoundingEventsParams = {\n startTime?: number;\n endTime?: number;\n poolNames?: PoolName[];\n};\n\nexport type FetchRebalanceEventsParams = FetchAutoCompoundingEventsParams;\n\nexport type FetchLiquidityChangeEventsParams = FetchAutoCompoundingEventsParams;\n\nexport type FetchWithdrawV2EventsParams = {\n startTime?: number;\n endTime?: number;\n};\n\nexport type FetchEventsParams = {\n eventTypes: string[];\n startTime?: number;\n endTime?: number;\n};\n"]}
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/sui-sdk/events/types.ts"],"names":[],"mappings":"","sourcesContent":["import { PoolName } from \"../../common/types.js\";\n\ninterface CommonEventAttributes {\n type: string;\n timestamp: number;\n}\n\nexport interface CetusAutoCompoundingEvent {\n compound_amount_a: bigint;\n compound_amount_b: bigint;\n current_liquidity: bigint;\n fee_collected_a: bigint;\n fee_collected_b: bigint;\n free_balance_a: bigint;\n free_balance_b: bigint;\n investor_id: string;\n total_amount_a: bigint;\n total_amount_b: bigint;\n}\n\nexport interface NaviAutoCompoundingEvent {\n compound_amount: bigint;\n fee_collected: bigint;\n investor_id: string;\n location: number;\n total_amount: bigint;\n}\n\nexport interface NaviLoopAutoCompoundingEvent extends NaviAutoCompoundingEvent {\n cur_total_debt: bigint;\n accrued_interest: bigint;\n}\n\nexport interface RebalanceEvent {\n investor_id: string;\n lower_tick_after: string;\n upper_tick_after: string;\n sqrt_price_after: string;\n amount_a_before: string;\n amount_b_before: string;\n amount_a_after: string;\n amount_b_after: string;\n}\n\n//verify, this might be wrong, alphapool reward event is defined as alpha autocompounding event\nexport interface AlphaAutoCompoundingEvent {\n amount: string;\n investor_id: string;\n}\n\nexport interface CetusLiquidityChangeEvent {\n amount_a: string;\n amount_b: string;\n event_type: number;\n fee_collected_a: string;\n fee_collected_b: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n total_amount_a: string;\n total_amount_b: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface NaviLiquidityChangeEvent {\n amount: string;\n event_type: number;\n fee_collected: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface AlphaLiquidityChangeEvent {\n amount: string;\n event_type: number;\n fee_collected: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface AlphaWithdrawV2Event {\n amount: string;\n amount_withdrawn_from_locked: string;\n amount_withdrawn_from_unlocked: string;\n fee_collected: string;\n instant_withdraw_fee_collected: string;\n pool_id: string;\n sender: string;\n tokens_invested: string;\n user_total_x_token_balance: string;\n x_token_supply: string;\n}\n\nexport interface CetusAfterTransactionEvent {\n liquidity: string;\n tokensInvested: string;\n xtokenSupply: string;\n}\nexport interface NaviAfterTransactionEvent {\n amount: string;\n tokensInvested: string;\n xtokenSupply: string;\n}\n\n// only event sequence non zero are after transaction\nexport interface AlphaBeforeAndAfterEvent {\n tokensInvested: string;\n xTokenSupply: string;\n}\n\nexport type CetusAddLiquidityEvent = {\n after_liquidity: string;\n amount_a: string;\n amount_b: string;\n liquidity: string;\n pool: string;\n position: string;\n tick_lower: { bits: number };\n tick_upper: { bits: number };\n};\nexport type CetusRemoveLiquidityEvent = {\n after_liquidity: string;\n amount_a: string;\n amount_b: string;\n liquidity: string;\n pool: string;\n position: string;\n tick_lower: { bits: number };\n tick_upper: { bits: number };\n};\n\nexport type NaviPoolDepositEvent = {\n amount: string;\n pool: string;\n sender: string;\n};\nexport type NaviPoolWithdrawEvent = {\n amount: string;\n pool: string;\n recipient: string;\n sender: string;\n};\n\nexport type AfterTransactionEventNode =\n | (CetusAfterTransactionEvent &\n CommonEventAttributes & {\n poolName: PoolName | undefined;\n id: { eventSeq: number; txDigest: string };\n })\n | (NaviAfterTransactionEvent &\n CommonEventAttributes & {\n poolName: PoolName | undefined;\n id: { eventSeq: number; txDigest: string };\n })\n | (AlphaBeforeAndAfterEvent &\n CommonEventAttributes & {\n poolName: PoolName | undefined;\n id: { eventSeq: number; txDigest: string };\n });\n\nexport type AutoCompoundingEventNode =\n | (CetusAutoCompoundingEvent & CommonEventAttributes)\n | (NaviAutoCompoundingEvent & CommonEventAttributes)\n | (NaviLoopAutoCompoundingEvent & CommonEventAttributes)\n | (AlphaAutoCompoundingEvent & CommonEventAttributes);\n\nexport type RebalanceEventNode = RebalanceEvent & CommonEventAttributes;\n\nexport type LiquidityChangeEventNode =\n | (CetusLiquidityChangeEvent & CommonEventAttributes)\n | (NaviLiquidityChangeEvent & CommonEventAttributes)\n | (AlphaLiquidityChangeEvent & CommonEventAttributes);\n\nexport type WithdrawV2EventNode = AlphaWithdrawV2Event & CommonEventAttributes;\n\nexport type EventNode =\n | AutoCompoundingEventNode\n | RebalanceEventNode\n | LiquidityChangeEventNode\n | WithdrawV2EventNode\n | AfterTransactionEventNode;\n\nexport type FetchAutoCompoundingEventsParams = {\n startTime?: number;\n endTime?: number;\n poolNames?: PoolName[];\n};\n\nexport type FetchRebalanceEventsParams = FetchAutoCompoundingEventsParams;\n\nexport type FetchLiquidityChangeEventsParams = FetchAutoCompoundingEventsParams;\n\nexport type FetchWithdrawV2EventsParams = {\n startTime?: number;\n endTime?: number;\n};\n\nexport type FetchEventsParams = {\n eventTypes: string[];\n startTime?: number;\n endTime?: number;\n};\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@alphafi/alphafi-sdk",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.33",
|
|
4
4
|
"description": "Official AlphaFi SDK to access AlphaFi data",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/cjs/index.js",
|
|
@@ -65,7 +65,7 @@
|
|
|
65
65
|
"@apollo/client": "^3.11.4",
|
|
66
66
|
"@cetusprotocol/cetus-sui-clmm-sdk": "^5.1.6",
|
|
67
67
|
"@hop.ag/sdk": "^3.3.0",
|
|
68
|
-
"@mysten/sui": "1.
|
|
68
|
+
"@mysten/sui": "1.14.2",
|
|
69
69
|
"bignumber.js": "^9.1.2",
|
|
70
70
|
"bn.js": "^5.2.1",
|
|
71
71
|
"decimal.js": "^10.4.3",
|