@clober/v2-sdk 1.0.0-beta.23 → 1.0.0-beta.24

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.
Files changed (42) hide show
  1. package/dist/cjs/constants/abis/core/book-manager-abi.js +31 -0
  2. package/dist/cjs/constants/abis/core/book-manager-abi.js.map +1 -1
  3. package/dist/cjs/types/index.js.map +1 -1
  4. package/dist/cjs/views/index.js +2 -2
  5. package/dist/cjs/views/market/parse.js +1 -0
  6. package/dist/cjs/views/market/parse.js.map +1 -1
  7. package/dist/cjs/views/pool/market-making.js.map +1 -1
  8. package/dist/cjs/views/trade.js +73 -5
  9. package/dist/cjs/views/trade.js.map +1 -1
  10. package/dist/esm/constants/abis/core/book-manager-abi.js +31 -0
  11. package/dist/esm/constants/abis/core/book-manager-abi.js.map +1 -1
  12. package/dist/esm/types/index.js.map +1 -1
  13. package/dist/esm/views/index.js +1 -1
  14. package/dist/esm/views/market/parse.js +1 -0
  15. package/dist/esm/views/market/parse.js.map +1 -1
  16. package/dist/esm/views/pool/market-making.js.map +1 -1
  17. package/dist/esm/views/trade.js +72 -4
  18. package/dist/esm/views/trade.js.map +1 -1
  19. package/dist/tsconfig.build.tsbuildinfo +1 -1
  20. package/dist/types/constants/abis/core/book-manager-abi.d.ts +25 -0
  21. package/dist/types/constants/abis/core/book-manager-abi.d.ts.map +1 -1
  22. package/dist/types/types/index.d.ts +0 -1
  23. package/dist/types/types/index.d.ts.map +1 -1
  24. package/dist/types/views/index.d.ts +1 -1
  25. package/dist/types/views/market/parse.d.ts.map +1 -1
  26. package/dist/types/views/pool/market-making.d.ts +17 -15
  27. package/dist/types/views/pool/market-making.d.ts.map +1 -1
  28. package/dist/types/views/trade.d.ts +17 -5
  29. package/dist/types/views/trade.d.ts.map +1 -1
  30. package/package.json +1 -1
  31. package/dist/cjs/entities/swap/apis/index.js +0 -48
  32. package/dist/cjs/entities/swap/apis/index.js.map +0 -1
  33. package/dist/cjs/entities/swap/types.js +0 -3
  34. package/dist/cjs/entities/swap/types.js.map +0 -1
  35. package/dist/esm/entities/swap/apis/index.js +0 -44
  36. package/dist/esm/entities/swap/apis/index.js.map +0 -1
  37. package/dist/esm/entities/swap/types.js +0 -2
  38. package/dist/esm/entities/swap/types.js.map +0 -1
  39. package/dist/types/entities/swap/apis/index.d.ts +0 -5
  40. package/dist/types/entities/swap/apis/index.d.ts.map +0 -1
  41. package/dist/types/entities/swap/types.d.ts +0 -12
  42. package/dist/types/entities/swap/types.d.ts.map +0 -1
@@ -113,5 +113,30 @@ export declare const BOOK_MANAGER_ABI: readonly [{
113
113
  readonly internalType: "address";
114
114
  }];
115
115
  readonly anonymous: false;
116
+ }, {
117
+ readonly anonymous: false;
118
+ readonly inputs: readonly [{
119
+ readonly indexed: true;
120
+ readonly internalType: "BookId";
121
+ readonly name: "bookId";
122
+ readonly type: "uint192";
123
+ }, {
124
+ readonly indexed: true;
125
+ readonly internalType: "address";
126
+ readonly name: "user";
127
+ readonly type: "address";
128
+ }, {
129
+ readonly indexed: false;
130
+ readonly internalType: "Tick";
131
+ readonly name: "tick";
132
+ readonly type: "int24";
133
+ }, {
134
+ readonly indexed: false;
135
+ readonly internalType: "uint64";
136
+ readonly name: "unit";
137
+ readonly type: "uint64";
138
+ }];
139
+ readonly name: "Take";
140
+ readonly type: "event";
116
141
  }];
117
142
  //# sourceMappingURL=book-manager-abi.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"book-manager-abi.d.ts","sourceRoot":"","sources":["../../../../../src/constants/abis/core/book-manager-abi.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAuInB,CAAA"}
1
+ {"version":3,"file":"book-manager-abi.d.ts","sourceRoot":"","sources":["../../../../../src/constants/abis/core/book-manager-abi.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EAsKnB,CAAA"}
@@ -4,7 +4,6 @@ export type { OpenOrder, OnChainOpenOrder } from '../entities/open-order/types';
4
4
  export type { Book, Depth } from '../entities/book/types';
5
5
  export type { Market, MarketSnapshot, ChartLog } from '../entities/market/types';
6
6
  export type { Pool, PoolSnapshot, LastAmounts, StrategyPosition, UserPoolPosition, } from '../entities/pool/types';
7
- export type { Swap } from '../entities/swap/types';
8
7
  export type { Take } from '../entities/take/types';
9
8
  export type { DefaultReadContractOptions, DefaultWriteContractOptions, } from './default-options';
10
9
  export type { Transaction } from './transaction';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/types/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,kCAAkC,CAAA;AAC5D,YAAY,EACV,QAAQ,EACR,YAAY,EACZ,cAAc,EACd,kBAAkB,EAClB,YAAY,EACZ,gBAAgB,GACjB,MAAM,4BAA4B,CAAA;AACnC,YAAY,EAAE,SAAS,EAAE,gBAAgB,EAAE,MAAM,8BAA8B,CAAA;AAC/E,YAAY,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,wBAAwB,CAAA;AACzD,YAAY,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAA;AAChF,YAAY,EACV,IAAI,EACJ,YAAY,EACZ,WAAW,EACX,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,wBAAwB,CAAA;AAC/B,YAAY,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAClD,YAAY,EAAE,IAAI,EAAE,MAAM,wBAAwB,CAAA;AAClD,Y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AAM,eAAe,CAAA;AAChD,YAAY,EAAE,eAAe,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAA;AACjE,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,kBAAkB,EAClB,gBAAgB,EAChB,OAAO,EACP,gBAAgB,GACjB,MAAM,6BAA6B,CAAA;AAEpC,oBAAY,mBAAmB;IAC7B,SAAS,OAAO;IAChB,YAAY,OAAO;IACnB,WAAW,OAAO;IAClB,UAAU,QAAQ;IAClB,cAAc,QAAQ;IACtB,aAAa,QAAQ;IACrB,OAAO,OAAO;IACd,QAAQ,OAAO;IACf,SAAS,OAAO;IAChB,QAAQ,OAAO;IACf,MAAM,OAAO;IACb,OAAO,OAAO;CACf"}
@@ -1,6 +1,6 @@
1
1
  export { getMarket, getChartLogs, getLatestChartLog, getExpectedOutput, getExpectedInput, getMarketSnapshots, getMarketSnapshot, getQuoteToken, parseMakeOrderIdsFromReceipt, getLatestTakes, } from './market';
2
2
  export { getPool, getPoolSnapshot, getPoolSnapshots, getUserPoolPositions, getStrategyPrice, getLastAmounts, getLpWrappedERC20Address, watchMarketMakingEvents, } from './pool';
3
- export { getLatestTrades } from './trade';
3
+ export { watchTakeEvents } from './trade';
4
4
  export { getPriceNeighborhood } from './tick';
5
5
  export { getOpenOrder, getOpenOrders } from './open-order';
6
6
  export { getSubgraphEndpoint, getFallbackSubgraphEndpoint, getSubgraphBlockNumber, getSubgraphBlock, } from './subgraph';
@@ -1 +1 @@
1
- {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../../src/views/market/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAIzD,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAA;AAEpD,eAAO,MAAM,4BAA4B,oCAGtC;IACD,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,EAAE,kBAAkB,CAAA;CACvC,KAAG;IACF,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,WAAW,EAAE,MAAM,EAAE,CAAA;CAkBtB,CAAA"}
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../../../src/views/market/parse.ts"],"names":[],"mappings":"AAAA,OAAO,EAAkB,kBAAkB,EAAE,MAAM,MAAM,CAAA;AAIzD,OAAO,EAAE,MAAM,EAAE,MAAM,6BAA6B,CAAA;AAEpD,eAAO,MAAM,4BAA4B,oCAGtC;IACD,MAAM,EAAE,MAAM,CAAA;IACd,kBAAkB,EAAE,kBAAkB,CAAA;CACvC,KAAG;IACF,WAAW,EAAE,MAAM,EAAE,CAAA;IACrB,WAAW,EAAE,MAAM,EAAE,CAAA;CAmBtB,CAAA"}
@@ -10,27 +10,29 @@ export declare const getLastAmounts: ({ chainId, poolKey, options, }: {
10
10
  poolKey: `0x${string}`;
11
11
  options?: DefaultReadContractOptions;
12
12
  }) => Promise<LastAmounts>;
13
+ declare const handleRebalanceLog: (log: any, poolSnapshot: PoolSnapshot, onEvent: (args: {
14
+ transactionHash: `0x${string}`;
15
+ timestamp: number;
16
+ blockNumber: number;
17
+ bidOrderList: {
18
+ price: string;
19
+ size: string;
20
+ }[];
21
+ askOrderList: {
22
+ price: string;
23
+ size: string;
24
+ }[];
25
+ quoteReserve: string;
26
+ baseReserve: string;
27
+ }) => void) => void;
13
28
  export declare const watchMarketMakingEvents: ({ chainId, poolSnapshot, options, onEvent, onError, }: {
14
29
  chainId: CHAIN_IDS;
15
30
  poolSnapshot: PoolSnapshot;
16
- onEvent: (args: {
17
- transactionHash: `0x${string}`;
18
- timestamp: number;
19
- blockNumber: number;
20
- bidOrderList: {
21
- price: string;
22
- size: string;
23
- }[];
24
- askOrderList: {
25
- price: string;
26
- size: string;
27
- }[];
28
- quoteReserve: string;
29
- baseReserve: string;
30
- }) => void;
31
+ onEvent: Parameters<typeof handleRebalanceLog>[2];
31
32
  onError?: (error: Error) => void;
32
33
  options?: {
33
34
  backfillBlocks?: bigint;
34
35
  } & DefaultReadContractOptions;
35
36
  }) => Promise<import("viem").WatchContractEventReturnType>;
37
+ export {};
36
38
  //# sourceMappingURL=market-making.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"market-making.d.ts","sourceRoot":"","sources":["../../../../src/views/pool/market-making.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,SAAS,EAAa,MAAM,qCAAqC,CAAA;AAC1E,OAAO,EACL,0BAA0B,EAC1B,WAAW,EACX,YAAY,EACZ,gBAAgB,EACjB,MAAM,aAAa,CAAA;AAUpB,eAAO,MAAM,gBAAgB,mCAI1B;IACD,OAAO,EAAE,SAAS,CAAA;IAClB,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB,OAAO,CAAC,EAAE,0BAA0B,CAAA;CACrC,KAAG,QAAQ,gBAAgB,CAM3B,CAAA;AAED,eAAO,MAAM,cAAc,mCAIxB;IACD,OAAO,EAAE,SAAS,CAAA;IAClB,OAAO,EAAE,KAAK,MAAM,EAAE,CAAA;IACtB,OAAO,CAAC,EAAE,0BAA0B,CAAA;CACrC,KAAG,QAAQ,WAAW,CAMtB,CAAA;AA6FD,eAAO,MAAM,uBAAuB,0DAMjC;IACD,OAAO,EAAE,SAAS,CAAA;IAClB,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,CAAC,IAAI,EAAE;QACd,eAAe,EAAE,KAAK,MAAM,EAAE,CAAA;QAC9B,SAAS,EAAE,MAAM,CAAA;QACjB,WAAW,EAAE,MAAM,CAAA;QACnB,YAAY,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;QAC/C,YAAY,EAAE;YAAE,KAAK,EAAE,MAAM,CAAC;YAAC,IAAI,EAAE,MAAM,CAAA;SAAE,EAAE,CAAA;QAC/C,YAAY,EAAE,MAAM,CAAA;QACpB,WAAW,EAAE,MAAM,CAAA;KACpB,KAAK,IAAI,CAAA;IACV,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,K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SAAS,CAAA;IAClB,YAAY,EAAE,YAAY,CAAA;IAC1B,OAAO,EAAE,WAAW,yBAAyB,CAAC,CAAC,CAAC,CAAC,CAAA;IACjD,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,OAAO,CAAC,EAAE;QACR,cAAc,CAAC,EAAE,MAAM,CAAA;KACxB,GAAG,0BAA0B,CAAA;CAC/B,yDAuCA,CAAA"}
@@ -1,10 +1,22 @@
1
1
  import { CHAIN_IDS } from '../constants/chain-configs/chain';
2
- import { DefaultReadContractOptions, Swap } from '../types';
3
- export declare const getLatestTrades: ({ chainId, n, options, }: {
2
+ import type { DefaultReadContractOptions, Market } from '../types';
3
+ declare const handleTakeLog: (log: any, market: Market, onEvent: (args: {
4
+ transactionHash: `0x${string}`;
5
+ timestamp: number;
6
+ blockNumber: number;
7
+ price: string;
8
+ size: string;
9
+ usdValue: number;
10
+ side: 'buy' | 'sell';
11
+ }) => void) => void;
12
+ export declare const watchTakeEvents: ({ chainId, market, onEvent, onError, options, }: {
4
13
  chainId: CHAIN_IDS;
5
- n: number;
14
+ market: Market;
15
+ onEvent: Parameters<typeof handleTakeLog>[2];
16
+ onError?: (error: Error) => void;
6
17
  options?: {
7
- useSubgraph?: boolean;
18
+ backfillBlocks?: bigint;
8
19
  } & DefaultReadContractOptions;
9
- }) => Promise<Swap[]>;
20
+ }) => Promise<import("viem").WatchContractEventReturnType>;
21
+ export {};
10
22
  //# sourceMappingURL=trade.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"trade.d.ts","sourceRoot":"","sources":["../../../src/views/trade.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAa,MAAM,kCAAkC,CAAA;AACvE,OAAO,EAAE,0BAA0B,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAG3D,eAAO,MAAM,eAAe,6BAIzB;IACD,OAAO,EAAE,SAAS,CAAA;IAClB,CAAC,EAAE,MAAM,CAAA;IACT,OAAO,CAAC,EAAE;QACR,WAAW,CAAC,EAAE,OAAO,CAAA;KACtB,GAAG,0BAA0B,CAAA;CAC/B,KAAG,QAAQ,IAAI,EAAE,CAWjB,CAAA"}
1
+ {"version":3,"file":"trade.d.ts","sourceRoot":"","sources":["../../../src/views/trade.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,SAAS,EAAa,MAAM,kCAAkC,CAAA;AACvE,OAAO,KAAK,EAAE,0BAA0B,EAAE,MAAM,EAAE,MAAM,UAAU,CAAA;AAMlE,QAAA,MAAM,aAAa,QACZ,GAAG,UACA,MAAM,WACL,CAAC,IAAI,EAAE;IACd,eAAe,EAAE,KAAK,MAAM,EAAE,CAAA;IAC9B,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,EAAE,MAAM,CAAA;IAChB,IAAI,EAAE,KAAK,GAAG,MAAM,CAAA;CACrB,KAAK,IAAI,SAkCX,CAAA;AAuCD,eAAO,MAAM,eAAe,oDAMzB;IACD,OAAO,EAAE,SAAS,CAAA;IAClB,MAAM,EAAE,MAAM,CAAA;IACd,OAAO,EAAE,WAAW,oBAAoB,CAAC,CAAC,CAAC,CAAC,CAAA;IAC5C,OAAO,CAAC,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,CAAA;IAChC,OAAO,CAAC,EAAE;QACR,cAAc,CAAC,EAAE,MAAM,CAAA;KACxB,GAAG,0BAA0B,CAAA;CAC/B,yDAsCA,CAAA"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@clober/v2-sdk",
3
- "version": "1.0.0-beta.23",
3
+ "version": "1.0.0-beta.24",
4
4
  "description": "🛠 An SDK for building applications on top of Clober V2",
5
5
  "files": [
6
6
  "dist"
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.fetchLatestTrades = void 0;
4
- const viem_1 = require("viem");
5
- const subgraph_1 = require("../../../constants/chain-configs/subgraph");
6
- const apis_1 = require("../../currency/apis");
7
- const fetchLatestTrades = async (publicClient, chainId, n, useSubgraph) => {
8
- const { data: { swaps }, } = await subgraph_1.Subgraph.get(chainId, 'getLatestTrades', 'query getLatestTrades($first: Int!) { swaps(first: $first, orderBy: timestamp, orderDirection: desc) { transaction { id gasUsed gasPrice value to from } timestamp inputToken outputToken inputAmount outputAmount amountUSD router } }', {
9
- first: n,
10
- });
11
- const uniqueTokens = [
12
- ...new Set(swaps.flatMap((swap) => [swap.inputToken, swap.outputToken])),
13
- ].map((address) => (0, viem_1.getAddress)(address));
14
- const currencyMap = await (0, apis_1.fetchCurrencyMap)(publicClient, chainId, uniqueTokens, useSubgraph);
15
- return swaps
16
- .map((swap) => {
17
- return currencyMap[(0, viem_1.getAddress)(swap.inputToken)] &&
18
- currencyMap[(0, viem_1.getAddress)(swap.outputToken)]
19
- ? {
20
- transaction: {
21
- data: '',
22
- id: swap.transaction.id,
23
- gas: BigInt(swap.transaction.gasUsed),
24
- gasPrice: BigInt(swap.transaction.gasPrice),
25
- value: BigInt(swap.transaction.value),
26
- to: (0, viem_1.getAddress)(swap.transaction.to),
27
- from: (0, viem_1.getAddress)(swap.transaction.from),
28
- },
29
- timestamp: Number(swap.timestamp),
30
- currencyIn: {
31
- currency: currencyMap[(0, viem_1.getAddress)(swap.inputToken)],
32
- amount: (0, viem_1.formatUnits)(BigInt(swap.inputAmount), currencyMap[(0, viem_1.getAddress)(swap.inputToken)].decimals),
33
- direction: 'in',
34
- },
35
- currencyOut: {
36
- currency: currencyMap[(0, viem_1.getAddress)(swap.outputToken)],
37
- amount: (0, viem_1.formatUnits)(BigInt(swap.outputAmount), currencyMap[(0, viem_1.getAddress)(swap.outputToken)].decimals),
38
- direction: 'out',
39
- },
40
- amountUSD: Number(swap.amountUSD),
41
- router: (0, viem_1.getAddress)(swap.router),
42
- }
43
- : null;
44
- })
45
- .filter((swap) => swap !== null);
46
- };
47
- exports.fetchLatestTrades = fetchLatestTrades;
48
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/entities/swap/apis/index.ts"],"names":[],"mappings":";;;AAAA,+BAA4D;AAG5D,wEAAoE;AAEpE,8CAAsD;AAoB/C,MAAM,iBAAiB,GAAG,KAAK,EACpC,YAA0B,EAC1B,OAAkB,EAClB,CAAS,EACT,WAAoB,EACH,EAAE;IACnB,MAAM,EACJ,IAAI,EAAE,EAAE,KAAK,EAAE,GAChB,GAAG,MAAM,mBAAQ,CAAC,GAAG,CAKpB,OAAO,EACP,iBAAiB,EACjB,yOAAyO,EACzO;QACE,KAAK,EAAE,CAAC;KACT,CACF,CAAA;IACD,MAAM,YAAY,GAAG;QACnB,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;KACzE,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,IAAA,iBAAU,EAAC,OAAO,CAAC,CAAC,CAAA;IACvC,MAAM,WAAW,GAAG,MAAM,IAAA,uBAAgB,EACxC,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,WAAW,CACZ,CAAA;IAED,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,OAAO,WAAW,CAAC,IAAA,iBAAU,EAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC7C,WAAW,CAAC,IAAA,iBAAU,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACzC,CAAC,CAAC;gBACE,WAAW,EAAE;oBACX,IAAI,EAAE,EAAmB;oBACzB,EAAE,EAAE,IAAI,CAAC,WAAW,CAAC,EAAmB;oBACxC,GAAG,EAAE,MAAM,CAAC,IAAI,CAAC,WAA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BAAiB,qBAmE7B"}
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/entities/swap/types.ts"],"names":[],"mappings":""}
@@ -1,44 +0,0 @@
1
- import { formatUnits, getAddress } from 'viem';
2
- import { Subgraph } from '../../../constants/chain-configs/subgraph';
3
- import { fetchCurrencyMap } from '../../currency/apis';
4
- export const fetchLatestTrades = async (publicClient, chainId, n, useSubgraph) => {
5
- const { data: { swaps }, } = await Subgraph.get(chainId, 'getLatestTrades', 'query getLatestTrades($first: Int!) { swaps(first: $first, orderBy: timestamp, orderDirection: desc) { transaction { id gasUsed gasPrice value to from } timestamp inputToken outputToken inputAmount outputAmount amountUSD router } }', {
6
- first: n,
7
- });
8
- const uniqueTokens = [
9
- ...new Set(swaps.flatMap((swap) => [swap.inputToken, swap.outputToken])),
10
- ].map((address) => getAddress(address));
11
- const currencyMap = await fetchCurrencyMap(publicClient, chainId, uniqueTokens, useSubgraph);
12
- return swaps
13
- .map((swap) => {
14
- return currencyMap[getAddress(swap.inputToken)] &&
15
- currencyMap[getAddress(swap.outputToken)]
16
- ? {
17
- transaction: {
18
- data: '',
19
- id: swap.transaction.id,
20
- gas: BigInt(swap.transaction.gasUsed),
21
- gasPrice: BigInt(swap.transaction.gasPrice),
22
- value: BigInt(swap.transaction.value),
23
- to: getAddress(swap.transaction.to),
24
- from: getAddress(swap.transaction.from),
25
- },
26
- timestamp: Number(swap.timestamp),
27
- currencyIn: {
28
- currency: currencyMap[getAddress(swap.inputToken)],
29
- amount: formatUnits(BigInt(swap.inputAmount), currencyMap[getAddress(swap.inputToken)].decimals),
30
- direction: 'in',
31
- },
32
- currencyOut: {
33
- currency: currencyMap[getAddress(swap.outputToken)],
34
- amount: formatUnits(BigInt(swap.outputAmount), currencyMap[getAddress(swap.outputToken)].decimals),
35
- direction: 'out',
36
- },
37
- amountUSD: Number(swap.amountUSD),
38
- router: getAddress(swap.router),
39
- }
40
- : null;
41
- })
42
- .filter((swap) => swap !== null);
43
- };
44
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/entities/swap/apis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAgB,MAAM,MAAM,CAAA;AAG5D,OAAO,EAAE,QAAQ,EAAE,MAAM,2CAA2C,CAAA;AAEpE,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAA;AAoBtD,MAAM,CAAC,MAAM,iBAAiB,GAAG,KAAK,EACpC,YAA0B,EAC1B,OAAkB,EAClB,CAAS,EACT,WAAoB,EACH,EAAE;IACnB,MAAM,EACJ,IAAI,EAAE,EAAE,KAAK,EAAE,GAChB,GAAG,MAAM,QAAQ,CAAC,GAAG,CAKpB,OAAO,EACP,iBAAiB,EACjB,yOAAyO,EACzO;QACE,KAAK,EAAE,CAAC;KACT,CACF,CAAA;IACD,MAAM,YAAY,GAAG;QACnB,GAAG,IAAI,GAAG,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,IAAI,CAAC,UAAU,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC,CAAC;KACzE,CAAC,GAAG,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,CAAC,CAAC,CAAA;IACvC,MAAM,WAAW,GAAG,MAAM,gBAAgB,CACxC,YAAY,EACZ,OAAO,EACP,YAAY,EACZ,WAAW,CACZ,CAAA;IAED,OAAO,KAAK;SACT,GAAG,CAAC,CAAC,IAAI,EAAE,EAAE;QACZ,OAAO,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,UAAU,CAAC,CAAC;YAC7C,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;YACzC,CAAC,CAAC;gBACE,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CAAC,IAAI,KAAK,IAAI,CAAW,CAAA;AAC3D,CAAC,CAAA"}
@@ -1,2 +0,0 @@
1
- export {};
2
- //# sourceMappingURL=types.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.js","sourceRoot":"","sources":["../../../../src/entities/swap/types.ts"],"names":[],"mappings":""}
@@ -1,5 +0,0 @@
1
- import { PublicClient } from 'viem';
2
- import { Swap } from '../types';
3
- import { CHAIN_IDS } from '../../../constants/chain-configs/chain';
4
- export declare const fetchLatestTrades: (publicClient: PublicClient, chainId: CHAIN_IDS, n: number, useSubgraph: boolean) => Promise<Swap[]>;
5
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/entities/swap/apis/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAA2B,YAAY,EAAE,MAAM,MAAM,CAAA;AAE5D,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAA;AAE/B,OAAO,EAAE,SAAS,EAAE,MAAM,wCAAwC,CAAA;AAqBlE,eAAO,MAAM,iBAAiB,iBACd,YAAY,WACjB,SAAS,KACf,MAAM,eACI,OAAO,KACnB,QAAQ,IAAI,EAAE,CA8DhB,CAAA"}
@@ -1,12 +0,0 @@
1
- import { CurrencyFlow, Transaction } from '../../types';
2
- export type Swap = {
3
- transaction: Transaction & {
4
- id: `0x${string}`;
5
- };
6
- timestamp: number;
7
- currencyIn: CurrencyFlow;
8
- currencyOut: CurrencyFlow;
9
- amountUSD: number;
10
- router: `0x${string}`;
11
- };
12
- //# sourceMappingURL=types.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../src/entities/swap/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAA;AAEvD,MAAM,MAAM,IAAI,GAAG;IACjB,WAAW,EAAE,WAAW,GAAG;QACzB,EAAE,EAAE,KAAK,MAAM,EAAE,CAAA;KAClB,CAAA;IACD,SAAS,EAAE,MAAM,CAAA;IACjB,UAAU,EAAE,YAAY,CAAA;IACxB,WAAW,EAAE,YAAY,CAAA;IACzB,SAAS,EAAE,MAAM,CAAA;IACjB,MAAM,EAAE,KAAK,MAAM,EAAE,CAAA;CACtB,CAAA"}