@clober/v2-sdk 0.0.4 → 0.0.5-0.a.dev
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +12 -4
- package/dist/cjs/abis/core/book-manager-abi.js +112 -0
- package/dist/cjs/abis/core/book-manager-abi.js.map +1 -0
- package/dist/cjs/abis/core/book-viewer-abi.js +321 -0
- package/dist/cjs/abis/core/book-viewer-abi.js.map +1 -0
- package/dist/cjs/abis/core/controller-abi.js +29 -24
- package/dist/cjs/abis/core/controller-abi.js.map +1 -1
- package/dist/cjs/apis/chart-logs.js +154 -0
- package/dist/cjs/apis/chart-logs.js.map +1 -0
- package/dist/cjs/apis/market.js +61 -32
- package/dist/cjs/apis/market.js.map +1 -1
- package/dist/cjs/apis/open-order.js +56 -21
- package/dist/cjs/apis/open-order.js.map +1 -1
- package/dist/cjs/approval.js +77 -30
- package/dist/cjs/approval.js.map +1 -1
- package/dist/cjs/call.js +358 -207
- package/dist/cjs/call.js.map +1 -1
- package/dist/cjs/constants/addresses.js +26 -1
- package/dist/cjs/constants/addresses.js.map +1 -1
- package/dist/cjs/constants/chain.js +19 -1
- package/dist/cjs/constants/chain.js.map +1 -1
- package/dist/cjs/constants/client.js +4 -0
- package/dist/cjs/constants/client.js.map +1 -1
- package/dist/cjs/constants/currency.js +28 -2
- package/dist/cjs/constants/currency.js.map +1 -1
- package/dist/cjs/constants/fee.js +17 -2
- package/dist/cjs/constants/fee.js.map +1 -1
- package/dist/cjs/constants/subgraph.js +57 -0
- package/dist/cjs/constants/subgraph.js.map +1 -0
- package/dist/cjs/constants/test-chain.js +27 -0
- package/dist/cjs/constants/test-chain.js.map +1 -0
- package/dist/cjs/index.js +20 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/model/book.js +63 -29
- package/dist/cjs/model/book.js.map +1 -1
- package/dist/cjs/model/chart-log.js +3 -0
- package/dist/cjs/model/chart-log.js.map +1 -0
- package/dist/cjs/model/market.js +45 -182
- package/dist/cjs/model/market.js.map +1 -1
- package/dist/cjs/signature.js +20 -16
- package/dist/cjs/signature.js.map +1 -1
- package/dist/cjs/type.js +16 -1
- package/dist/cjs/type.js.map +1 -1
- package/dist/cjs/utils/allowance.js +40 -0
- package/dist/cjs/utils/allowance.js.map +1 -0
- package/dist/cjs/utils/bigint.js +9 -0
- package/dist/cjs/utils/bigint.js.map +1 -0
- package/dist/cjs/utils/book-id.js +7 -7
- package/dist/cjs/utils/book-id.js.map +1 -1
- package/dist/cjs/utils/build-transaction.js +8 -7
- package/dist/cjs/utils/build-transaction.js.map +1 -1
- package/dist/cjs/utils/currency.js +166 -0
- package/dist/cjs/utils/currency.js.map +1 -0
- package/dist/cjs/utils/decorator.js +3 -1
- package/dist/cjs/utils/decorator.js.map +1 -1
- package/dist/cjs/utils/open.js +36 -0
- package/dist/cjs/utils/open.js.map +1 -0
- package/dist/cjs/utils/order.js +102 -0
- package/dist/cjs/utils/order.js.map +1 -0
- package/dist/cjs/utils/prices.js +28 -3
- package/dist/cjs/utils/prices.js.map +1 -1
- package/dist/cjs/utils/unit-size.js +49 -0
- package/dist/cjs/utils/unit-size.js.map +1 -0
- package/dist/cjs/utils.js +15 -0
- package/dist/cjs/utils.js.map +1 -0
- package/dist/cjs/view.js +141 -40
- package/dist/cjs/view.js.map +1 -1
- package/dist/esm/abis/core/book-manager-abi.js +109 -0
- package/dist/esm/abis/core/book-manager-abi.js.map +1 -0
- package/dist/esm/abis/core/book-viewer-abi.js +318 -0
- package/dist/esm/abis/core/book-viewer-abi.js.map +1 -0
- package/dist/esm/abis/core/controller-abi.js +29 -24
- package/dist/esm/abis/core/controller-abi.js.map +1 -1
- package/dist/esm/apis/chart-logs.js +150 -0
- package/dist/esm/apis/chart-logs.js.map +1 -0
- package/dist/esm/apis/market.js +61 -32
- package/dist/esm/apis/market.js.map +1 -1
- package/dist/esm/apis/open-order.js +57 -21
- package/dist/esm/apis/open-order.js.map +1 -1
- package/dist/esm/approval.js +116 -44
- package/dist/esm/approval.js.map +1 -1
- package/dist/esm/call.js +478 -311
- package/dist/esm/call.js.map +1 -1
- package/dist/esm/constants/addresses.js +26 -1
- package/dist/esm/constants/addresses.js.map +1 -1
- package/dist/esm/constants/chain.js +20 -2
- package/dist/esm/constants/chain.js.map +1 -1
- package/dist/esm/constants/client.js +5 -1
- package/dist/esm/constants/client.js.map +1 -1
- package/dist/esm/constants/currency.js +28 -2
- package/dist/esm/constants/currency.js.map +1 -1
- package/dist/esm/constants/fee.js +17 -2
- package/dist/esm/constants/fee.js.map +1 -1
- package/dist/esm/constants/subgraph.js +53 -0
- package/dist/esm/constants/subgraph.js.map +1 -0
- package/dist/esm/constants/test-chain.js +24 -0
- package/dist/esm/constants/test-chain.js.map +1 -0
- package/dist/esm/index.js +1 -0
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/model/book.js +63 -29
- package/dist/esm/model/book.js.map +1 -1
- package/dist/esm/model/chart-log.js +2 -0
- package/dist/esm/model/chart-log.js.map +1 -0
- package/dist/esm/model/market.js +46 -187
- package/dist/esm/model/market.js.map +1 -1
- package/dist/esm/signature.js +35 -37
- package/dist/esm/signature.js.map +1 -1
- package/dist/esm/type.js +15 -0
- package/dist/esm/type.js.map +1 -1
- package/dist/esm/utils/allowance.js +36 -0
- package/dist/esm/utils/allowance.js.map +1 -0
- package/dist/esm/utils/bigint.js +5 -0
- package/dist/esm/utils/bigint.js.map +1 -0
- package/dist/esm/utils/book-id.js +7 -7
- package/dist/esm/utils/book-id.js.map +1 -1
- package/dist/esm/utils/build-transaction.js +8 -7
- package/dist/esm/utils/build-transaction.js.map +1 -1
- package/dist/esm/utils/currency.js +161 -0
- package/dist/esm/utils/currency.js.map +1 -0
- package/dist/esm/utils/decorator.js +3 -1
- package/dist/esm/utils/decorator.js.map +1 -1
- package/dist/esm/utils/open.js +32 -0
- package/dist/esm/utils/open.js.map +1 -0
- package/dist/esm/utils/order.js +98 -0
- package/dist/esm/utils/order.js.map +1 -0
- package/dist/esm/utils/prices.js +27 -2
- package/dist/esm/utils/prices.js.map +1 -1
- package/dist/esm/utils/unit-size.js +45 -0
- package/dist/esm/utils/unit-size.js.map +1 -0
- package/dist/esm/utils.js +4 -0
- package/dist/esm/utils.js.map +1 -0
- package/dist/esm/view.js +254 -68
- package/dist/esm/view.js.map +1 -1
- package/dist/tsconfig.build.tsbuildinfo +1 -1
- package/dist/types/abis/core/book-manager-abi.d.ts +82 -0
- package/dist/types/abis/core/book-manager-abi.d.ts.map +1 -0
- package/dist/types/abis/core/book-viewer-abi.d.ts +243 -0
- package/dist/types/abis/core/book-viewer-abi.d.ts.map +1 -0
- package/dist/types/abis/core/controller-abi.d.ts +23 -19
- package/dist/types/abis/core/controller-abi.d.ts.map +1 -1
- package/dist/types/apis/chart-logs.d.ts +5 -0
- package/dist/types/apis/chart-logs.d.ts.map +1 -0
- package/dist/types/apis/market.d.ts +1 -1
- package/dist/types/apis/market.d.ts.map +1 -1
- package/dist/types/apis/open-order.d.ts +3 -2
- package/dist/types/apis/open-order.d.ts.map +1 -1
- package/dist/types/approval.d.ts +48 -16
- package/dist/types/approval.d.ts.map +1 -1
- package/dist/types/call.d.ts +181 -109
- package/dist/types/call.d.ts.map +1 -1
- package/dist/types/constants/addresses.d.ts.map +1 -1
- package/dist/types/constants/chain.d.ts +6 -2
- package/dist/types/constants/chain.d.ts.map +1 -1
- package/dist/types/constants/client.d.ts +1 -1
- package/dist/types/constants/client.d.ts.map +1 -1
- package/dist/types/constants/currency.d.ts.map +1 -1
- package/dist/types/constants/fee.d.ts +7 -2
- package/dist/types/constants/fee.d.ts.map +1 -1
- package/dist/types/constants/subgraph.d.ts +10 -0
- package/dist/types/constants/subgraph.d.ts.map +1 -0
- package/dist/types/constants/test-chain.d.ts +3 -0
- package/dist/types/constants/test-chain.d.ts.map +1 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/model/book.d.ts +23 -29
- package/dist/types/model/book.d.ts.map +1 -1
- package/dist/types/model/chart-log.d.ts +9 -0
- package/dist/types/model/chart-log.d.ts.map +1 -0
- package/dist/types/model/depth.d.ts +4 -5
- package/dist/types/model/depth.d.ts.map +1 -1
- package/dist/types/model/market.d.ts +25 -19
- package/dist/types/model/market.d.ts.map +1 -1
- package/dist/types/model/open-order.d.ts +16 -8
- package/dist/types/model/open-order.d.ts.map +1 -1
- package/dist/types/signature.d.ts +18 -24
- package/dist/types/signature.d.ts.map +1 -1
- package/dist/types/type.d.ts +52 -8
- package/dist/types/type.d.ts.map +1 -1
- package/dist/types/utils/allowance.d.ts +3 -0
- package/dist/types/utils/allowance.d.ts.map +1 -0
- package/dist/types/utils/bigint.d.ts +2 -0
- package/dist/types/utils/bigint.d.ts.map +1 -0
- package/dist/types/utils/book-id.d.ts +2 -1
- package/dist/types/utils/book-id.d.ts.map +1 -1
- package/dist/types/utils/build-transaction.d.ts +3 -3
- package/dist/types/utils/build-transaction.d.ts.map +1 -1
- package/dist/types/{apis → utils}/currency.d.ts +3 -0
- package/dist/types/utils/currency.d.ts.map +1 -0
- package/dist/types/utils/decorator.d.ts +1 -1
- package/dist/types/utils/decorator.d.ts.map +1 -1
- package/dist/types/utils/open.d.ts +3 -0
- package/dist/types/utils/open.d.ts.map +1 -0
- package/dist/types/utils/order.d.ts +8 -0
- package/dist/types/utils/order.d.ts.map +1 -0
- package/dist/types/utils/prices.d.ts +12 -2
- package/dist/types/utils/prices.d.ts.map +1 -1
- package/dist/types/utils/unit-size.d.ts +4 -0
- package/dist/types/utils/unit-size.d.ts.map +1 -0
- package/dist/types/utils.d.ts +4 -0
- package/dist/types/utils.d.ts.map +1 -0
- package/dist/types/view.d.ts +196 -39
- package/dist/types/view.d.ts.map +1 -1
- package/package.json +1 -1
- package/dist/cjs/abis/core/params-abi.js +0 -62
- package/dist/cjs/abis/core/params-abi.js.map +0 -1
- package/dist/cjs/apis/currency.js +0 -83
- package/dist/cjs/apis/currency.js.map +0 -1
- package/dist/cjs/apis/subgraph.js +0 -26
- package/dist/cjs/apis/subgraph.js.map +0 -1
- package/dist/cjs/constants/subgraph-url.js +0 -8
- package/dist/cjs/constants/subgraph-url.js.map +0 -1
- package/dist/cjs/utils/unit.js +0 -34
- package/dist/cjs/utils/unit.js.map +0 -1
- package/dist/esm/abis/core/params-abi.js +0 -59
- package/dist/esm/abis/core/params-abi.js.map +0 -1
- package/dist/esm/apis/currency.js +0 -79
- package/dist/esm/apis/currency.js.map +0 -1
- package/dist/esm/apis/subgraph.js +0 -22
- package/dist/esm/apis/subgraph.js.map +0 -1
- package/dist/esm/constants/subgraph-url.js +0 -5
- package/dist/esm/constants/subgraph-url.js.map +0 -1
- package/dist/esm/utils/unit.js +0 -30
- package/dist/esm/utils/unit.js.map +0 -1
- package/dist/types/abis/core/params-abi.d.ts +0 -21
- package/dist/types/abis/core/params-abi.d.ts.map +0 -1
- package/dist/types/apis/currency.d.ts.map +0 -1
- package/dist/types/apis/subgraph.d.ts +0 -3
- package/dist/types/apis/subgraph.d.ts.map +0 -1
- package/dist/types/constants/subgraph-url.d.ts +0 -5
- package/dist/types/constants/subgraph-url.d.ts.map +0 -1
- package/dist/types/utils/unit.d.ts +0 -4
- package/dist/types/utils/unit.d.ts.map +0 -1
package/dist/esm/view.js
CHANGED
|
@@ -1,44 +1,144 @@
|
|
|
1
|
-
import { formatUnits, isAddressEqual, parseUnits } from 'viem';
|
|
1
|
+
import { formatUnits, getAddress, isAddressEqual, parseUnits } from 'viem';
|
|
2
2
|
import { fetchMarket } from './apis/market';
|
|
3
|
-
import { parsePrice } from './utils/prices';
|
|
3
|
+
import { formatPrice, parsePrice } from './utils/prices';
|
|
4
4
|
import { MAX_PRICE } from './constants/price';
|
|
5
|
-
import { fetchOpenOrder,
|
|
5
|
+
import { fetchOpenOrder, fetchOpenOrdersByUserAddress } from './apis/open-order';
|
|
6
6
|
import { decorator } from './utils/decorator';
|
|
7
|
+
import { fetchChartLogs, fetchLatestChartLog } from './apis/chart-logs';
|
|
8
|
+
import { getMarketId } from './utils/market';
|
|
9
|
+
import { CONTRACT_ADDRESSES } from './constants/addresses';
|
|
10
|
+
import { fromPrice, invertPrice, toPrice } from './utils/tick';
|
|
11
|
+
/**
|
|
12
|
+
* Get contract addresses by chain id
|
|
13
|
+
* @param chainId - chain id from {@link CHAIN_IDS}
|
|
14
|
+
* @returns Contract addresses
|
|
15
|
+
*
|
|
16
|
+
* @example
|
|
17
|
+
* import { getContractAddresses } from '@clober/v2-sdk'
|
|
18
|
+
*
|
|
19
|
+
* const addresses = await getContractAddresses({
|
|
20
|
+
* chainId: 421614,
|
|
21
|
+
* })
|
|
22
|
+
*/
|
|
23
|
+
export const getContractAddresses = ({ chainId }) => {
|
|
24
|
+
return CONTRACT_ADDRESSES[chainId];
|
|
25
|
+
};
|
|
7
26
|
/**
|
|
8
27
|
* Get market information by chain id and token addresses
|
|
9
28
|
* @param chainId - chain id from {@link CHAIN_IDS}
|
|
10
29
|
* @param token0 - token0 address
|
|
11
30
|
* @param token1 - token1 address
|
|
12
31
|
* @param options
|
|
32
|
+
* @param options.n - number of depth levels to fetch
|
|
13
33
|
* @param options.rpcUrl - RPC URL of the blockchain
|
|
34
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
14
35
|
* @returns A market {@link Market}
|
|
15
36
|
*
|
|
16
37
|
* @example
|
|
17
38
|
* import { getMarket } from '@clober/v2-sdk'
|
|
18
39
|
*
|
|
19
|
-
* const market = await getMarket(
|
|
20
|
-
* 421614,
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
* )
|
|
40
|
+
* const market = await getMarket({
|
|
41
|
+
* chainId: 421614,
|
|
42
|
+
* token0: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
43
|
+
* token1: '0x0000000000000000000000000000000000000000',
|
|
44
|
+
* })
|
|
24
45
|
*/
|
|
25
|
-
export const getMarket = decorator(async ({ chainId, token0, token1, }) => {
|
|
46
|
+
export const getMarket = decorator(async ({ chainId, token0, token1, options, }) => {
|
|
26
47
|
if (isAddressEqual(token0, token1)) {
|
|
27
48
|
throw new Error('Token0 and token1 must be different');
|
|
28
49
|
}
|
|
29
|
-
const market = await fetchMarket(chainId, [token0, token1]);
|
|
50
|
+
const market = await fetchMarket(chainId, [token0, token1], options?.n);
|
|
30
51
|
return {
|
|
31
52
|
chainId,
|
|
32
53
|
quote: market.quote,
|
|
33
54
|
base: market.base,
|
|
34
55
|
makerFee: market.makerFee,
|
|
35
56
|
takerFee: market.takerFee,
|
|
36
|
-
bids: market.bids,
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
57
|
+
bids: market.bids.map(({ price, tick, baseAmount }) => ({
|
|
58
|
+
price,
|
|
59
|
+
tick: Number(tick),
|
|
60
|
+
baseAmount: formatUnits(baseAmount, market.base.decimals),
|
|
61
|
+
})),
|
|
62
|
+
bidBook: {
|
|
63
|
+
id: market.bidBook.id.toString(),
|
|
64
|
+
base: market.bidBook.base,
|
|
65
|
+
unitSize: market.bidBook.unitSize.toString(),
|
|
66
|
+
quote: market.bidBook.quote,
|
|
67
|
+
isOpened: market.bidBook.isOpened,
|
|
68
|
+
},
|
|
69
|
+
asks: market.asks.map(({ price, tick, baseAmount }) => ({
|
|
70
|
+
price,
|
|
71
|
+
tick: Number(tick),
|
|
72
|
+
baseAmount: formatUnits(baseAmount, market.base.decimals),
|
|
73
|
+
})),
|
|
74
|
+
askBook: {
|
|
75
|
+
id: market.askBook.id.toString(),
|
|
76
|
+
base: market.askBook.base,
|
|
77
|
+
unitSize: market.askBook.unitSize.toString(),
|
|
78
|
+
quote: market.askBook.quote,
|
|
79
|
+
isOpened: market.askBook.isOpened,
|
|
80
|
+
},
|
|
40
81
|
};
|
|
41
82
|
});
|
|
83
|
+
/**
|
|
84
|
+
* Calculates and returns the neighboring price ticks and their corresponding prices for a given input price.
|
|
85
|
+
*
|
|
86
|
+
* @param {CHAIN_IDS} chainId - chain id from {@link CHAIN_IDS}
|
|
87
|
+
* @param {string} price - The input price to calculate the neighborhood for, as a string.
|
|
88
|
+
* @param {Currency} currency0 - token0 currency {@link Currency}.
|
|
89
|
+
* @param {Currency} currency1 - token1 currency {@link Currency}.
|
|
90
|
+
*
|
|
91
|
+
* @returns {Object} An object containing the normal and inverted price neighborhoods. Each neighborhood includes:
|
|
92
|
+
* - up: The tick and price for one tick above the current price.
|
|
93
|
+
* - now: The tick and price for the current price.
|
|
94
|
+
* - down: The tick and price for one tick below the current price.
|
|
95
|
+
*/
|
|
96
|
+
export const getPriceNeighborhood = ({ chainId, price, currency0, currency1, }) => {
|
|
97
|
+
const quoteTokenAddress = getQuoteToken({
|
|
98
|
+
chainId,
|
|
99
|
+
token0: currency0.address,
|
|
100
|
+
token1: currency1.address,
|
|
101
|
+
});
|
|
102
|
+
const quoteCurrency = isAddressEqual(quoteTokenAddress, currency0.address)
|
|
103
|
+
? currency0
|
|
104
|
+
: currency1;
|
|
105
|
+
const baseCurrency = isAddressEqual(quoteTokenAddress, currency0.address)
|
|
106
|
+
? currency1
|
|
107
|
+
: currency0;
|
|
108
|
+
const { roundingDownPrice, roundingUpPrice } = parsePrice(Number(price), quoteCurrency.decimals, baseCurrency.decimals);
|
|
109
|
+
const bidBookTick = fromPrice(roundingDownPrice);
|
|
110
|
+
const askBookTick = fromPrice(invertPrice(roundingUpPrice));
|
|
111
|
+
return {
|
|
112
|
+
normal: {
|
|
113
|
+
up: {
|
|
114
|
+
tick: bidBookTick + 1n,
|
|
115
|
+
price: formatPrice(toPrice(bidBookTick + 1n), quoteCurrency.decimals, baseCurrency.decimals),
|
|
116
|
+
},
|
|
117
|
+
now: {
|
|
118
|
+
tick: bidBookTick,
|
|
119
|
+
price: formatPrice(toPrice(bidBookTick), quoteCurrency.decimals, baseCurrency.decimals),
|
|
120
|
+
},
|
|
121
|
+
down: {
|
|
122
|
+
tick: bidBookTick - 1n,
|
|
123
|
+
price: formatPrice(toPrice(bidBookTick - 1n), quoteCurrency.decimals, baseCurrency.decimals),
|
|
124
|
+
},
|
|
125
|
+
},
|
|
126
|
+
inverted: {
|
|
127
|
+
up: {
|
|
128
|
+
tick: askBookTick + 1n,
|
|
129
|
+
price: formatPrice(toPrice(askBookTick + 1n), baseCurrency.decimals, quoteCurrency.decimals),
|
|
130
|
+
},
|
|
131
|
+
now: {
|
|
132
|
+
tick: askBookTick,
|
|
133
|
+
price: formatPrice(toPrice(askBookTick), baseCurrency.decimals, quoteCurrency.decimals),
|
|
134
|
+
},
|
|
135
|
+
down: {
|
|
136
|
+
tick: askBookTick - 1n,
|
|
137
|
+
price: formatPrice(toPrice(askBookTick - 1n), baseCurrency.decimals, quoteCurrency.decimals),
|
|
138
|
+
},
|
|
139
|
+
},
|
|
140
|
+
};
|
|
141
|
+
};
|
|
42
142
|
/**
|
|
43
143
|
* Calculates the expected output for a given input amount, based on the provided market data.
|
|
44
144
|
*
|
|
@@ -49,42 +149,51 @@ export const getMarket = decorator(async ({ chainId, token0, token1, }) => {
|
|
|
49
149
|
* @param options
|
|
50
150
|
* @param options.limitPrice The maximum limit price to spend.
|
|
51
151
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
152
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
52
153
|
* @returns A Promise resolving to an object containing the taken amount, spend amount and result of the calculation.
|
|
53
154
|
* @example
|
|
54
155
|
* import { getExpectedOutput } from '@clober/v2-sdk'
|
|
55
156
|
*
|
|
56
|
-
* const { takenAmount,
|
|
57
|
-
* 421614,
|
|
58
|
-
*
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
* )
|
|
157
|
+
* const { takenAmount, spentAmount } = await getExpectedOutput({
|
|
158
|
+
* chainId: 421614,
|
|
159
|
+
* inputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
160
|
+
* outputToken: '0x0000000000000000000000000000000000000000',
|
|
161
|
+
* amountIn: '1000.123', // spend 1000.123 USDC
|
|
162
|
+
* })
|
|
62
163
|
*/
|
|
63
164
|
export const getExpectedOutput = decorator(async ({ chainId, inputToken, outputToken, amountIn, options, }) => {
|
|
165
|
+
const [roundingDownTakenBid, roundingUpTakenAsk] = [
|
|
166
|
+
options?.roundingDownTakenBid ? options.roundingDownTakenBid : false,
|
|
167
|
+
options?.roundingUpTakenAsk ? options.roundingUpTakenAsk : false,
|
|
168
|
+
];
|
|
64
169
|
const market = await fetchMarket(chainId, [inputToken, outputToken]);
|
|
65
170
|
const isBid = isAddressEqual(market.quote.address, inputToken);
|
|
66
|
-
const
|
|
171
|
+
const { roundingDownPrice, roundingUpPrice } = options && options.limitPrice
|
|
67
172
|
? parsePrice(Number(options.limitPrice), market.quote.decimals, market.base.decimals)
|
|
68
173
|
: isBid
|
|
69
|
-
? MAX_PRICE
|
|
70
|
-
: 0n;
|
|
174
|
+
? { roundingDownPrice: MAX_PRICE, roundingUpPrice: MAX_PRICE }
|
|
175
|
+
: { roundingDownPrice: 0n, roundingUpPrice: 0n };
|
|
71
176
|
const inputCurrency = isBid ? market.quote : market.base;
|
|
72
|
-
const
|
|
73
|
-
|
|
74
|
-
|
|
177
|
+
const isTakingBidSide = !isBid;
|
|
178
|
+
const { takenQuoteAmount, spentBaseAmount, bookId, events } = market.spend({
|
|
179
|
+
spentBase: isTakingBidSide,
|
|
180
|
+
limitPrice: isTakingBidSide
|
|
181
|
+
? roundingDownTakenBid
|
|
182
|
+
? roundingDownPrice
|
|
183
|
+
: roundingUpPrice
|
|
184
|
+
: roundingUpTakenAsk
|
|
185
|
+
? roundingUpPrice
|
|
186
|
+
: roundingDownPrice,
|
|
75
187
|
amountIn: parseUnits(amountIn, inputCurrency.decimals),
|
|
76
188
|
});
|
|
77
|
-
const { takenAmount, spendAmount } = Object.values(result).reduce((acc, { takenAmount, spendAmount }) => ({
|
|
78
|
-
takenAmount: acc.takenAmount + takenAmount,
|
|
79
|
-
spendAmount: acc.spendAmount + spendAmount,
|
|
80
|
-
}), { takenAmount: 0n, spendAmount: 0n });
|
|
81
189
|
return {
|
|
82
|
-
takenAmount: formatUnits(
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
190
|
+
takenAmount: formatUnits(takenQuoteAmount, isBid ? market.base.decimals : market.quote.decimals),
|
|
191
|
+
spentAmount: formatUnits(spentBaseAmount, isBid ? market.quote.decimals : market.base.decimals),
|
|
192
|
+
bookId,
|
|
193
|
+
events: events.map(({ tick, takenQuoteAmount, spentBaseAmount }) => ({
|
|
194
|
+
price: formatPrice(isBid ? invertPrice(toPrice(BigInt(tick))) : toPrice(BigInt(tick)), market.quote.decimals, market.base.decimals),
|
|
195
|
+
takenAmount: formatUnits(takenQuoteAmount, isBid ? market.base.decimals : market.quote.decimals),
|
|
196
|
+
spentAmount: formatUnits(spentBaseAmount, isBid ? market.quote.decimals : market.base.decimals),
|
|
88
197
|
})),
|
|
89
198
|
};
|
|
90
199
|
});
|
|
@@ -98,42 +207,51 @@ export const getExpectedOutput = decorator(async ({ chainId, inputToken, outputT
|
|
|
98
207
|
* @param options
|
|
99
208
|
* @param options.limitPrice The maximum limit price to take.
|
|
100
209
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
101
|
-
* @
|
|
210
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
211
|
+
* @returns A Promise resolving to an object containing the taken amount, spent amount and result of the calculation.
|
|
102
212
|
* @example
|
|
103
213
|
* import { getExpectedInput } from '@clober/v2-sdk'
|
|
104
214
|
*
|
|
105
|
-
* const { takenAmount,
|
|
106
|
-
* 421614,
|
|
107
|
-
*
|
|
108
|
-
*
|
|
109
|
-
*
|
|
110
|
-
* )
|
|
215
|
+
* const { takenAmount, spentAmount } = await getExpectedInput({
|
|
216
|
+
* chainId: 421614,
|
|
217
|
+
* inputToken: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
218
|
+
* outputToken: '0x0000000000000000000000000000000000000000',
|
|
219
|
+
* amountOut: '0.1', // take 0.1 ETH
|
|
220
|
+
* })
|
|
111
221
|
*/
|
|
112
222
|
export const getExpectedInput = decorator(async ({ chainId, inputToken, outputToken, amountOut, options, }) => {
|
|
223
|
+
const [roundingDownTakenBid, roundingUpTakenAsk] = [
|
|
224
|
+
options?.roundingDownTakenBid ? options.roundingDownTakenBid : false,
|
|
225
|
+
options?.roundingUpTakenAsk ? options.roundingUpTakenAsk : false,
|
|
226
|
+
];
|
|
113
227
|
const market = await fetchMarket(chainId, [inputToken, outputToken]);
|
|
114
228
|
const isBid = isAddressEqual(market.quote.address, inputToken);
|
|
115
|
-
const
|
|
229
|
+
const { roundingDownPrice, roundingUpPrice } = options && options.limitPrice
|
|
116
230
|
? parsePrice(Number(options.limitPrice), market.quote.decimals, market.base.decimals)
|
|
117
231
|
: isBid
|
|
118
|
-
? MAX_PRICE
|
|
119
|
-
: 0n;
|
|
232
|
+
? { roundingDownPrice: MAX_PRICE, roundingUpPrice: MAX_PRICE }
|
|
233
|
+
: { roundingDownPrice: 0n, roundingUpPrice: 0n };
|
|
120
234
|
const outputCurrency = isBid ? market.base : market.quote;
|
|
121
|
-
const
|
|
122
|
-
|
|
123
|
-
|
|
235
|
+
const isTakingBidSide = !isBid;
|
|
236
|
+
const { takenQuoteAmount, spentBaseAmount, bookId, events } = market.take({
|
|
237
|
+
takeQuote: isTakingBidSide,
|
|
238
|
+
limitPrice: isTakingBidSide
|
|
239
|
+
? roundingDownTakenBid
|
|
240
|
+
? roundingDownPrice
|
|
241
|
+
: roundingUpPrice
|
|
242
|
+
: roundingUpTakenAsk
|
|
243
|
+
? roundingUpPrice
|
|
244
|
+
: roundingDownPrice,
|
|
124
245
|
amountOut: parseUnits(amountOut, outputCurrency.decimals),
|
|
125
246
|
});
|
|
126
|
-
const { takenAmount, spendAmount } = Object.values(result).reduce((acc, { takenAmount, spendAmount }) => ({
|
|
127
|
-
takenAmount: acc.takenAmount + takenAmount,
|
|
128
|
-
spendAmount: acc.spendAmount + spendAmount,
|
|
129
|
-
}), { takenAmount: 0n, spendAmount: 0n });
|
|
130
247
|
return {
|
|
131
|
-
takenAmount: formatUnits(
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
248
|
+
takenAmount: formatUnits(takenQuoteAmount, isBid ? market.base.decimals : market.quote.decimals),
|
|
249
|
+
spentAmount: formatUnits(spentBaseAmount, isBid ? market.quote.decimals : market.base.decimals),
|
|
250
|
+
bookId,
|
|
251
|
+
events: events.map(({ tick, takenQuoteAmount, spentBaseAmount }) => ({
|
|
252
|
+
price: formatPrice(isBid ? invertPrice(toPrice(BigInt(tick))) : toPrice(BigInt(tick)), market.quote.decimals, market.base.decimals),
|
|
253
|
+
takenAmount: formatUnits(takenQuoteAmount, isBid ? market.base.decimals : market.quote.decimals),
|
|
254
|
+
spentAmount: formatUnits(spentBaseAmount, isBid ? market.quote.decimals : market.base.decimals),
|
|
137
255
|
})),
|
|
138
256
|
};
|
|
139
257
|
});
|
|
@@ -144,14 +262,15 @@ export const getExpectedInput = decorator(async ({ chainId, inputToken, outputTo
|
|
|
144
262
|
* @param {string} id The ID of the open order.
|
|
145
263
|
* @param options
|
|
146
264
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
265
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
147
266
|
* @returns {Promise<OpenOrder>} Promise resolving to the open order object, or undefined if not found.
|
|
148
267
|
* @example
|
|
149
268
|
* import { getOpenOrder } from '@clober/v2-sdk'
|
|
150
269
|
*
|
|
151
|
-
* const openOrder = await getOpenOrder(
|
|
152
|
-
* 421614,
|
|
153
|
-
*
|
|
154
|
-
* )
|
|
270
|
+
* const openOrder = await getOpenOrder({
|
|
271
|
+
* chainId: 421614,
|
|
272
|
+
* id: '46223845323662364279893361453861711542636620039907198451770258805035840307200'
|
|
273
|
+
* })
|
|
155
274
|
*/
|
|
156
275
|
export const getOpenOrder = decorator(async ({ chainId, id, }) => {
|
|
157
276
|
return fetchOpenOrder(chainId, id);
|
|
@@ -163,16 +282,83 @@ export const getOpenOrder = decorator(async ({ chainId, id, }) => {
|
|
|
163
282
|
* @param {`0x${string}`} userAddress The Ethereum address of the user.
|
|
164
283
|
* @param options
|
|
165
284
|
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
285
|
+
* @param options.useSubgraph Whether to use the subgraph to fetch the market data.
|
|
166
286
|
* @returns {Promise<OpenOrder[]>} Promise resolving to an array of open orders.
|
|
167
287
|
* @example
|
|
168
288
|
* import { getOpenOrders } from '@clober/v2-sdk'
|
|
169
289
|
*
|
|
170
|
-
* const openOrders = await getOpenOrders(
|
|
171
|
-
* 421614,
|
|
172
|
-
*
|
|
173
|
-
* )
|
|
290
|
+
* const openOrders = await getOpenOrders({
|
|
291
|
+
* chainId: 421614,
|
|
292
|
+
* userAddress: '0x5F79EE8f8fA862E98201120d83c4eC39D9468D49'
|
|
293
|
+
* })
|
|
174
294
|
*/
|
|
175
295
|
export const getOpenOrders = decorator(async ({ chainId, userAddress, }) => {
|
|
176
|
-
return
|
|
296
|
+
return fetchOpenOrdersByUserAddress(chainId, userAddress);
|
|
297
|
+
});
|
|
298
|
+
/**
|
|
299
|
+
* Retrieves the latest chart log for a specific market.
|
|
300
|
+
*
|
|
301
|
+
* @param {CHAIN_IDS} params.chainId - The ID of the blockchain.
|
|
302
|
+
* @param {`0x${string}`} params.quote - The address of the quote token.
|
|
303
|
+
* @param {`0x${string}`} params.base - The address of the base token.
|
|
304
|
+
* @returns {Promise<ChartLog>} A promise that resolves with the latest chart log.
|
|
305
|
+
*
|
|
306
|
+
* @example
|
|
307
|
+
* import { getLatestChartLog } from '@clober/v2-sdk'
|
|
308
|
+
*
|
|
309
|
+
* const logs = await getLatestChartLog({
|
|
310
|
+
* chainId: 421614,
|
|
311
|
+
* quote: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
312
|
+
* base: '0x0000000000000000000000000000000000000000',
|
|
313
|
+
* })
|
|
314
|
+
*/
|
|
315
|
+
export const getLatestChartLog = decorator(async ({ chainId, quote, base, }) => {
|
|
316
|
+
return fetchLatestChartLog(chainId, `${base}/${quote}`);
|
|
317
|
+
});
|
|
318
|
+
/**
|
|
319
|
+
* Retrieves chart logs for a specific market within a specified time interval.
|
|
320
|
+
*
|
|
321
|
+
* @param {CHAIN_IDS} params.chainId - The ID of the chain.
|
|
322
|
+
* @param {`0x${string}`} params.quote - The address of the quote token.
|
|
323
|
+
* @param {`0x${string}`} params.base - The address of the base token.
|
|
324
|
+
* @param {CHART_LOG_INTERVALS} params.intervalType - The type of time interval for the chart logs.
|
|
325
|
+
* @param {number} params.from - The start of the time interval (Unix timestamp in seconds).
|
|
326
|
+
* @param {number} params.to - The end of the time interval (Unix timestamp in seconds).
|
|
327
|
+
* @returns {Promise<ChartLog[]>} A promise that resolves with an array of chart logs within the specified interval.
|
|
328
|
+
*
|
|
329
|
+
* @example
|
|
330
|
+
* import { getLatestChartLog, CHART_LOG_INTERVALS } from '@clober/v2-sdk'
|
|
331
|
+
*
|
|
332
|
+
* const logs = await getChartLogs({
|
|
333
|
+
* chainId: 421614,
|
|
334
|
+
* quote: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
335
|
+
* base: '0x0000000000000000000000000000000000000000',
|
|
336
|
+
* intervalType: CHART_LOG_INTERVALS.oneDay,
|
|
337
|
+
* from: 1687305600,
|
|
338
|
+
* to: 1713312000,
|
|
339
|
+
* })
|
|
340
|
+
*/
|
|
341
|
+
export const getChartLogs = decorator(async ({ chainId, quote, base, intervalType, from, to, }) => {
|
|
342
|
+
return fetchChartLogs(chainId, `${base}/${quote}`, intervalType, from, to);
|
|
177
343
|
});
|
|
344
|
+
/**
|
|
345
|
+
* Retrieves the quote token address for a given chain and a pair of tokens.
|
|
346
|
+
*
|
|
347
|
+
* @param chainId - chain id from {@link CHAIN_IDS}
|
|
348
|
+
* @param token0 - token0 address
|
|
349
|
+
* @param token1 - token1 address
|
|
350
|
+
* @returns {string} The address of the quote token.
|
|
351
|
+
*
|
|
352
|
+
* @example
|
|
353
|
+
* import { getQuoteToken } from '@clober/v2-sdk'
|
|
354
|
+
*
|
|
355
|
+
* const quote = await getQuoteToken({
|
|
356
|
+
* chainId: 421614,
|
|
357
|
+
* token0: '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
358
|
+
* token1: '0x0000000000000000000000000000000000000000',
|
|
359
|
+
* })
|
|
360
|
+
*/
|
|
361
|
+
export const getQuoteToken = ({ chainId, token0, token1, }) => {
|
|
362
|
+
return getAddress(getMarketId(chainId, [token0, token1]).quoteTokenAddress);
|
|
363
|
+
};
|
|
178
364
|
//# sourceMappingURL=view.js.map
|
package/dist/esm/view.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../src/view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;
|
|
1
|
+
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../src/view.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,cAAc,EAAE,UAAU,EAAE,MAAM,MAAM,CAAA;AAE1E,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAA;AAI3C,OAAO,EAAE,WAAW,EAAE,UAAU,EAAE,MAAM,gBAAgB,CAAA;AACxD,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,4BAA4B,EAAE,MAAM,mBAAmB,CAAA;AAEhF,OAAO,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAA;AAC7C,OAAO,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAA;AACvE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAA;AAC5C,OAAO,EAAE,kBAAkB,EAAE,MAAM,uBAAuB,CAAA;AAC1D,OAAO,EAAE,SAAS,EAAE,WAAW,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