@clober/v2-sdk 0.0.1-a → 0.0.1-b
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/.eslintignore +1 -0
- package/.eslintrc.yaml +34 -0
- package/.github/workflows/ci.yaml +88 -0
- package/.github/workflows/deployer.yaml +19 -0
- package/.nvmrc +1 -0
- package/.prettierignore +6 -0
- package/.prettierrc +7 -0
- package/package.json +8 -4
- package/src/.graphclient/index.ts +1695 -0
- package/src/.graphclient/schema.graphql +1116 -0
- package/src/.graphclient/sources/clober-v2/introspectionSchema.ts +14481 -0
- package/src/.graphclient/sources/clober-v2/schema.graphql +1116 -0
- package/src/.graphclient/sources/clober-v2/types.ts +1133 -0
- package/src/.graphclientrc.yml +12 -0
- package/src/abis/core/controller-abi.ts +985 -0
- package/src/abis/core/params-abi.ts +59 -0
- package/src/apis/currency.ts +92 -0
- package/src/apis/graphql/books.graphql +25 -0
- package/src/apis/graphql/open-order.graphql +29 -0
- package/src/apis/graphql/open-orders.graphql +29 -0
- package/src/apis/market.ts +85 -0
- package/src/apis/open-order.ts +145 -0
- package/src/approval.ts +82 -0
- package/src/call.ts +705 -0
- package/src/constants/action.ts +9 -0
- package/src/constants/addresses.ts +17 -0
- package/src/constants/chain.ts +12 -0
- package/src/constants/currency.ts +15 -0
- package/src/constants/fee.ts +4 -0
- package/src/constants/price.ts +3 -0
- package/src/constants/subgraph-url.ts +8 -0
- package/src/index.ts +5 -0
- package/src/model/book.ts +166 -0
- package/src/model/currency.ts +6 -0
- package/src/model/depth.ts +11 -0
- package/src/model/fee-policy.ts +51 -0
- package/src/model/market.ts +320 -0
- package/src/model/open-order.ts +16 -0
- package/src/signature.ts +196 -0
- package/src/type.ts +38 -0
- package/src/utils/approval.ts +48 -0
- package/{dist/esm/utils/book-id.js → src/utils/book-id.ts} +19 -9
- package/src/utils/build-transaction.ts +39 -0
- package/src/utils/decimals.ts +22 -0
- package/src/utils/market.ts +74 -0
- package/src/utils/math.ts +117 -0
- package/src/utils/prices.ts +29 -0
- package/src/utils/tick.ts +104 -0
- package/src/utils/time.ts +6 -0
- package/src/utils/unit.ts +43 -0
- package/src/view.ts +258 -0
- package/test/book-id.test.ts +101 -0
- package/test/fee-policy.test.ts +228 -0
- package/test/get-expected-input.test.ts +206 -0
- package/test/get-expected-output.test.ts +206 -0
- package/test/limit-order.test.ts +279 -0
- package/test/market-order.test.ts +245 -0
- package/test/market.test.ts +68 -0
- package/test/math.test.ts +91 -0
- package/test/open-order.test.ts +112 -0
- package/test/open.test.ts +15 -0
- package/test/tick.test.ts +230 -0
- package/test/tsconfig.json +12 -0
- package/test/utils/chain.ts +12 -0
- package/test/utils/constants.ts +25 -0
- package/test/utils/currency.ts +44 -0
- package/test/utils/depth.ts +148 -0
- package/test/utils/test-chain.ts +26 -0
- package/test/vitest.config.ts +15 -0
- package/tsconfig.base.json +37 -0
- package/tsconfig.build.json +9 -0
- package/tsconfig.json +9 -0
- package/dist/cjs/.graphclient/index.js +0 -243
- package/dist/cjs/.graphclient/index.js.map +0 -1
- package/dist/cjs/.graphclient/sources/clober-v2/introspectionSchema.js +0 -14482
- package/dist/cjs/.graphclient/sources/clober-v2/introspectionSchema.js.map +0 -1
- package/dist/cjs/.graphclient/sources/clober-v2/types.js +0 -4
- package/dist/cjs/.graphclient/sources/clober-v2/types.js.map +0 -1
- package/dist/cjs/abis/core/controller-abi.js +0 -989
- package/dist/cjs/abis/core/controller-abi.js.map +0 -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 -87
- package/dist/cjs/apis/currency.js.map +0 -1
- package/dist/cjs/apis/market.js +0 -63
- package/dist/cjs/apis/market.js.map +0 -1
- package/dist/cjs/apis/open-order.js +0 -90
- package/dist/cjs/apis/open-order.js.map +0 -1
- package/dist/cjs/approval.js +0 -74
- package/dist/cjs/approval.js.map +0 -1
- package/dist/cjs/call.js +0 -545
- package/dist/cjs/call.js.map +0 -1
- package/dist/cjs/constants/action.js +0 -14
- package/dist/cjs/constants/action.js.map +0 -1
- package/dist/cjs/constants/addresses.js +0 -13
- package/dist/cjs/constants/addresses.js.map +0 -1
- package/dist/cjs/constants/chain.js +0 -13
- package/dist/cjs/constants/chain.js.map +0 -1
- package/dist/cjs/constants/currency.js +0 -12
- package/dist/cjs/constants/currency.js.map +0 -1
- package/dist/cjs/constants/fee.js +0 -7
- package/dist/cjs/constants/fee.js.map +0 -1
- package/dist/cjs/constants/price.js +0 -6
- package/dist/cjs/constants/price.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/index.js +0 -22
- package/dist/cjs/index.js.map +0 -1
- package/dist/cjs/model/book.js +0 -130
- package/dist/cjs/model/book.js.map +0 -1
- package/dist/cjs/model/currency.js +0 -3
- package/dist/cjs/model/currency.js.map +0 -1
- package/dist/cjs/model/depth.js +0 -3
- package/dist/cjs/model/depth.js.map +0 -1
- package/dist/cjs/model/fee-policy.js +0 -42
- package/dist/cjs/model/fee-policy.js.map +0 -1
- package/dist/cjs/model/market.js +0 -215
- package/dist/cjs/model/market.js.map +0 -1
- package/dist/cjs/model/open-order.js +0 -3
- package/dist/cjs/model/open-order.js.map +0 -1
- package/dist/cjs/package.json +0 -1
- package/dist/cjs/signature.js +0 -178
- package/dist/cjs/signature.js.map +0 -1
- package/dist/cjs/tsconfig.build.tsbuildinfo +0 -1
- package/dist/cjs/type.js +0 -6
- package/dist/cjs/type.js.map +0 -1
- package/dist/cjs/utils/approval.js +0 -46
- package/dist/cjs/utils/approval.js.map +0 -1
- package/dist/cjs/utils/book-id.js +0 -25
- package/dist/cjs/utils/book-id.js.map +0 -1
- package/dist/cjs/utils/build-transaction.js +0 -31
- package/dist/cjs/utils/build-transaction.js.map +0 -1
- package/dist/cjs/utils/decimals.js +0 -17
- package/dist/cjs/utils/decimals.js.map +0 -1
- package/dist/cjs/utils/market.js +0 -53
- package/dist/cjs/utils/market.js.map +0 -1
- package/dist/cjs/utils/math.js +0 -83
- package/dist/cjs/utils/math.js.map +0 -1
- package/dist/cjs/utils/prices.js +0 -22
- package/dist/cjs/utils/prices.js.map +0 -1
- package/dist/cjs/utils/tick.js +0 -106
- package/dist/cjs/utils/tick.js.map +0 -1
- package/dist/cjs/utils/time.js +0 -9
- package/dist/cjs/utils/time.js.map +0 -1
- package/dist/cjs/utils/unit.js +0 -38
- package/dist/cjs/utils/unit.js.map +0 -1
- package/dist/cjs/view.js +0 -185
- package/dist/cjs/view.js.map +0 -1
- package/dist/esm/.graphclient/index.js +0 -233
- package/dist/esm/.graphclient/index.js.map +0 -1
- package/dist/esm/.graphclient/sources/clober-v2/introspectionSchema.js +0 -14480
- package/dist/esm/.graphclient/sources/clober-v2/introspectionSchema.js.map +0 -1
- package/dist/esm/.graphclient/sources/clober-v2/types.js +0 -3
- package/dist/esm/.graphclient/sources/clober-v2/types.js.map +0 -1
- package/dist/esm/abis/core/controller-abi.js +0 -986
- package/dist/esm/abis/core/controller-abi.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 -83
- package/dist/esm/apis/currency.js.map +0 -1
- package/dist/esm/apis/market.js +0 -59
- package/dist/esm/apis/market.js.map +0 -1
- package/dist/esm/apis/open-order.js +0 -85
- package/dist/esm/apis/open-order.js.map +0 -1
- package/dist/esm/approval.js +0 -70
- package/dist/esm/approval.js.map +0 -1
- package/dist/esm/call.js +0 -535
- package/dist/esm/call.js.map +0 -1
- package/dist/esm/constants/action.js +0 -11
- package/dist/esm/constants/action.js.map +0 -1
- package/dist/esm/constants/addresses.js +0 -10
- package/dist/esm/constants/addresses.js.map +0 -1
- package/dist/esm/constants/chain.js +0 -10
- package/dist/esm/constants/chain.js.map +0 -1
- package/dist/esm/constants/currency.js +0 -9
- package/dist/esm/constants/currency.js.map +0 -1
- package/dist/esm/constants/fee.js +0 -4
- package/dist/esm/constants/fee.js.map +0 -1
- package/dist/esm/constants/price.js +0 -3
- package/dist/esm/constants/price.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/index.js +0 -6
- package/dist/esm/index.js.map +0 -1
- package/dist/esm/model/book.js +0 -126
- package/dist/esm/model/book.js.map +0 -1
- package/dist/esm/model/currency.js +0 -2
- package/dist/esm/model/currency.js.map +0 -1
- package/dist/esm/model/depth.js +0 -2
- package/dist/esm/model/depth.js.map +0 -1
- package/dist/esm/model/fee-policy.js +0 -38
- package/dist/esm/model/fee-policy.js.map +0 -1
- package/dist/esm/model/market.js +0 -211
- package/dist/esm/model/market.js.map +0 -1
- package/dist/esm/model/open-order.js +0 -2
- package/dist/esm/model/open-order.js.map +0 -1
- package/dist/esm/package.json +0 -1
- package/dist/esm/signature.js +0 -174
- package/dist/esm/signature.js.map +0 -1
- package/dist/esm/tsconfig.build.tsbuildinfo +0 -1
- package/dist/esm/type.js +0 -2
- package/dist/esm/type.js.map +0 -1
- package/dist/esm/utils/approval.js +0 -42
- package/dist/esm/utils/approval.js.map +0 -1
- package/dist/esm/utils/book-id.js.map +0 -1
- package/dist/esm/utils/build-transaction.js +0 -27
- package/dist/esm/utils/build-transaction.js.map +0 -1
- package/dist/esm/utils/decimals.js +0 -12
- package/dist/esm/utils/decimals.js.map +0 -1
- package/dist/esm/utils/market.js +0 -49
- package/dist/esm/utils/market.js.map +0 -1
- package/dist/esm/utils/math.js +0 -78
- package/dist/esm/utils/math.js.map +0 -1
- package/dist/esm/utils/prices.js +0 -17
- package/dist/esm/utils/prices.js.map +0 -1
- package/dist/esm/utils/tick.js +0 -100
- package/dist/esm/utils/tick.js.map +0 -1
- package/dist/esm/utils/time.js +0 -5
- package/dist/esm/utils/time.js.map +0 -1
- package/dist/esm/utils/unit.js +0 -34
- package/dist/esm/utils/unit.js.map +0 -1
- package/dist/esm/view.js +0 -177
- package/dist/esm/view.js.map +0 -1
- package/dist/types/.graphclient/index.d.ts +0 -1281
- package/dist/types/.graphclient/index.d.ts.map +0 -1
- package/dist/types/.graphclient/sources/clober-v2/introspectionSchema.d.ts +0 -3
- package/dist/types/.graphclient/sources/clober-v2/introspectionSchema.d.ts.map +0 -1
- package/dist/types/.graphclient/sources/clober-v2/types.d.ts +0 -984
- package/dist/types/.graphclient/sources/clober-v2/types.d.ts.map +0 -1
- package/dist/types/abis/core/controller-abi.d.ts +0 -757
- package/dist/types/abis/core/controller-abi.d.ts.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 +0 -4
- package/dist/types/apis/currency.d.ts.map +0 -1
- package/dist/types/apis/market.d.ts +0 -4
- package/dist/types/apis/market.d.ts.map +0 -1
- package/dist/types/apis/open-order.d.ts +0 -5
- package/dist/types/apis/open-order.d.ts.map +0 -1
- package/dist/types/approval.d.ts +0 -32
- package/dist/types/approval.d.ts.map +0 -1
- package/dist/types/call.d.ts +0 -234
- package/dist/types/call.d.ts.map +0 -1
- package/dist/types/constants/action.d.ts +0 -10
- package/dist/types/constants/action.d.ts.map +0 -1
- package/dist/types/constants/addresses.d.ts +0 -9
- package/dist/types/constants/addresses.d.ts.map +0 -1
- package/dist/types/constants/chain.d.ts +0 -9
- package/dist/types/constants/chain.d.ts.map +0 -1
- package/dist/types/constants/currency.d.ts +0 -8
- package/dist/types/constants/currency.d.ts.map +0 -1
- package/dist/types/constants/fee.d.ts +0 -4
- package/dist/types/constants/fee.d.ts.map +0 -1
- package/dist/types/constants/price.d.ts +0 -3
- package/dist/types/constants/price.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/index.d.ts +0 -6
- package/dist/types/index.d.ts.map +0 -1
- package/dist/types/model/book.d.ts +0 -31
- package/dist/types/model/book.d.ts.map +0 -1
- package/dist/types/model/currency.d.ts +0 -7
- package/dist/types/model/currency.d.ts.map +0 -1
- package/dist/types/model/depth.d.ts +0 -11
- package/dist/types/model/depth.d.ts.map +0 -1
- package/dist/types/model/fee-policy.d.ts +0 -15
- package/dist/types/model/fee-policy.d.ts.map +0 -1
- package/dist/types/model/market.d.ts +0 -44
- package/dist/types/model/market.d.ts.map +0 -1
- package/dist/types/model/open-order.d.ts +0 -28
- package/dist/types/model/open-order.d.ts.map +0 -1
- package/dist/types/signature.d.ts +0 -40
- package/dist/types/signature.d.ts.map +0 -1
- package/dist/types/type.d.ts +0 -34
- package/dist/types/type.d.ts.map +0 -1
- package/dist/types/utils/approval.d.ts +0 -3
- package/dist/types/utils/approval.d.ts.map +0 -1
- package/dist/types/utils/book-id.d.ts +0 -2
- package/dist/types/utils/book-id.d.ts.map +0 -1
- package/dist/types/utils/build-transaction.d.ts +0 -5
- package/dist/types/utils/build-transaction.d.ts.map +0 -1
- package/dist/types/utils/decimals.d.ts +0 -3
- package/dist/types/utils/decimals.d.ts.map +0 -1
- package/dist/types/utils/market.d.ts +0 -7
- package/dist/types/utils/market.d.ts.map +0 -1
- package/dist/types/utils/math.d.ts +0 -3
- package/dist/types/utils/math.d.ts.map +0 -1
- package/dist/types/utils/prices.d.ts +0 -3
- package/dist/types/utils/prices.d.ts.map +0 -1
- package/dist/types/utils/tick.d.ts +0 -4
- package/dist/types/utils/tick.d.ts.map +0 -1
- package/dist/types/utils/time.d.ts +0 -2
- package/dist/types/utils/time.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/types/view.d.ts +0 -129
- package/dist/types/view.d.ts.map +0 -1
package/dist/cjs/view.js
DELETED
|
@@ -1,185 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOpenOrders = exports.getOpenOrder = exports.getExpectedInput = exports.getExpectedOutput = exports.getMarket = void 0;
|
|
4
|
-
const viem_1 = require("viem");
|
|
5
|
-
const market_1 = require("./apis/market");
|
|
6
|
-
const prices_1 = require("./utils/prices");
|
|
7
|
-
const price_1 = require("./constants/price");
|
|
8
|
-
const open_order_1 = require("./apis/open-order");
|
|
9
|
-
/**
|
|
10
|
-
* Get market information by chain id and token addresses
|
|
11
|
-
* @param chainId - chain id from {@link CHAIN_IDS}
|
|
12
|
-
* @param token0 - token0 address
|
|
13
|
-
* @param token1 - token1 address
|
|
14
|
-
* @param options
|
|
15
|
-
* @param options.rpcUrl - RPC URL of the blockchain
|
|
16
|
-
* @returns A market {@link Market}
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* import { getMarket } from '@clober/v2-sdk'
|
|
20
|
-
*
|
|
21
|
-
* const market = await getMarket(
|
|
22
|
-
* 421614,
|
|
23
|
-
* '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
24
|
-
* '0x0000000000000000000000000000000000000000',
|
|
25
|
-
* )
|
|
26
|
-
*/
|
|
27
|
-
const getMarket = async (chainId, token0, token1, options) => {
|
|
28
|
-
if ((0, viem_1.isAddressEqual)(token0, token1)) {
|
|
29
|
-
throw new Error('Token0 and token1 must be different');
|
|
30
|
-
}
|
|
31
|
-
const market = await (0, market_1.fetchMarket)(chainId, [token0, token1], options?.rpcUrl);
|
|
32
|
-
return {
|
|
33
|
-
chainId,
|
|
34
|
-
quote: market.quote,
|
|
35
|
-
base: market.base,
|
|
36
|
-
makerFee: market.makerFee,
|
|
37
|
-
takerFee: market.takerFee,
|
|
38
|
-
bids: market.bids,
|
|
39
|
-
bidBookOpen: market.bidBookOpen,
|
|
40
|
-
asks: market.asks,
|
|
41
|
-
askBookOpen: market.askBookOpen,
|
|
42
|
-
};
|
|
43
|
-
};
|
|
44
|
-
exports.getMarket = getMarket;
|
|
45
|
-
/**
|
|
46
|
-
* Calculates the expected output for a given input amount, based on the provided market data.
|
|
47
|
-
*
|
|
48
|
-
* @param chainId The chain ID of the blockchain.
|
|
49
|
-
* @param inputToken The address of the input token.
|
|
50
|
-
* @param outputToken The address of the output token.
|
|
51
|
-
* @param amountIn The amount of expected input amount. (ex 1.2 ETH -> 1.2)
|
|
52
|
-
* @param options
|
|
53
|
-
* @param options.limitPrice The maximum limit price to spend.
|
|
54
|
-
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
55
|
-
* @returns A Promise resolving to an object containing the taken amount, spend amount and result of the calculation.
|
|
56
|
-
* @example
|
|
57
|
-
* import { getExpectedOutput } from '@clober/v2-sdk'
|
|
58
|
-
*
|
|
59
|
-
* const { takenAmount, spendAmount } = await getExpectedOutput(
|
|
60
|
-
* 421614,
|
|
61
|
-
* '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
62
|
-
* '0x0000000000000000000000000000000000000000',
|
|
63
|
-
* '1000.123', // spend 1000.123 USDC
|
|
64
|
-
* )
|
|
65
|
-
*/
|
|
66
|
-
const getExpectedOutput = async (chainId, inputToken, outputToken, amountIn, options) => {
|
|
67
|
-
const market = await (0, market_1.fetchMarket)(chainId, [inputToken, outputToken], options?.rpcUrl);
|
|
68
|
-
const isBid = (0, viem_1.isAddressEqual)(market.quote.address, inputToken);
|
|
69
|
-
const rawLimitPrice = options && options.limitPrice
|
|
70
|
-
? (0, prices_1.parsePrice)(Number(options.limitPrice), market.quote.decimals, market.base.decimals)
|
|
71
|
-
: isBid
|
|
72
|
-
? price_1.MAX_PRICE
|
|
73
|
-
: 0n;
|
|
74
|
-
const inputCurrency = isBid ? market.quote : market.base;
|
|
75
|
-
const result = market.spend({
|
|
76
|
-
spendBase: !isBid,
|
|
77
|
-
limitPrice: rawLimitPrice,
|
|
78
|
-
amountIn: (0, viem_1.parseUnits)(amountIn, inputCurrency.decimals),
|
|
79
|
-
});
|
|
80
|
-
const { takenAmount, spendAmount } = Object.values(result).reduce((acc, { takenAmount, spendAmount }) => ({
|
|
81
|
-
takenAmount: acc.takenAmount + takenAmount,
|
|
82
|
-
spendAmount: acc.spendAmount + spendAmount,
|
|
83
|
-
}), { takenAmount: 0n, spendAmount: 0n });
|
|
84
|
-
return {
|
|
85
|
-
takenAmount: (0, viem_1.formatUnits)(takenAmount, isBid ? market.base.decimals : market.quote.decimals),
|
|
86
|
-
spendAmount: (0, viem_1.formatUnits)(spendAmount, isBid ? market.quote.decimals : market.base.decimals),
|
|
87
|
-
result: Object.entries(result).map(([bookId, { takenAmount, spendAmount }]) => ({
|
|
88
|
-
bookId: BigInt(bookId),
|
|
89
|
-
takenAmount,
|
|
90
|
-
spendAmount,
|
|
91
|
-
})),
|
|
92
|
-
};
|
|
93
|
-
};
|
|
94
|
-
exports.getExpectedOutput = getExpectedOutput;
|
|
95
|
-
/**
|
|
96
|
-
* Calculates the expected input for a given output amount, based on the provided market data.
|
|
97
|
-
*
|
|
98
|
-
* @param chainId The chain ID of the blockchain.
|
|
99
|
-
* @param inputToken The address of the input token.
|
|
100
|
-
* @param outputToken The address of the output token.
|
|
101
|
-
* @param amountOut The amount of expected output amount. (ex 1.2 ETH -> 1.2)
|
|
102
|
-
* @param options
|
|
103
|
-
* @param options.limitPrice The maximum limit price to take.
|
|
104
|
-
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
105
|
-
* @returns A Promise resolving to an object containing the taken amount, spend amount and result of the calculation.
|
|
106
|
-
* @example
|
|
107
|
-
* import { getExpectedInput } from '@clober/v2-sdk'
|
|
108
|
-
*
|
|
109
|
-
* const { takenAmount, spendAmount } = await getExpectedInput(
|
|
110
|
-
* 421614,
|
|
111
|
-
* '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
112
|
-
* '0x0000000000000000000000000000000000000000',
|
|
113
|
-
* '0.1', // take 0.1 ETH
|
|
114
|
-
* )
|
|
115
|
-
*/
|
|
116
|
-
const getExpectedInput = async (chainId, inputToken, outputToken, amountOut, options) => {
|
|
117
|
-
const market = await (0, market_1.fetchMarket)(chainId, [inputToken, outputToken], options?.rpcUrl);
|
|
118
|
-
const isBid = (0, viem_1.isAddressEqual)(market.quote.address, inputToken);
|
|
119
|
-
const rawLimitPrice = options && options.limitPrice
|
|
120
|
-
? (0, prices_1.parsePrice)(Number(options.limitPrice), market.quote.decimals, market.base.decimals)
|
|
121
|
-
: isBid
|
|
122
|
-
? price_1.MAX_PRICE
|
|
123
|
-
: 0n;
|
|
124
|
-
const outputCurrency = isBid ? market.base : market.quote;
|
|
125
|
-
const result = market.take({
|
|
126
|
-
takeQuote: !isBid,
|
|
127
|
-
limitPrice: rawLimitPrice,
|
|
128
|
-
amountOut: (0, viem_1.parseUnits)(amountOut, outputCurrency.decimals),
|
|
129
|
-
});
|
|
130
|
-
const { takenAmount, spendAmount } = Object.values(result).reduce((acc, { takenAmount, spendAmount }) => ({
|
|
131
|
-
takenAmount: acc.takenAmount + takenAmount,
|
|
132
|
-
spendAmount: acc.spendAmount + spendAmount,
|
|
133
|
-
}), { takenAmount: 0n, spendAmount: 0n });
|
|
134
|
-
return {
|
|
135
|
-
takenAmount: (0, viem_1.formatUnits)(takenAmount, isBid ? market.base.decimals : market.quote.decimals),
|
|
136
|
-
spendAmount: (0, viem_1.formatUnits)(spendAmount, isBid ? market.quote.decimals : market.base.decimals),
|
|
137
|
-
result: Object.entries(result).map(([bookId, { takenAmount, spendAmount }]) => ({
|
|
138
|
-
bookId: BigInt(bookId),
|
|
139
|
-
takenAmount,
|
|
140
|
-
spendAmount,
|
|
141
|
-
})),
|
|
142
|
-
};
|
|
143
|
-
};
|
|
144
|
-
exports.getExpectedInput = getExpectedInput;
|
|
145
|
-
/**
|
|
146
|
-
* Retrieves the open order with the specified ID on the given chain.
|
|
147
|
-
*
|
|
148
|
-
* @param {CHAIN_IDS} chainId The chain ID.
|
|
149
|
-
* @param {string} id The ID of the open order.
|
|
150
|
-
* @param options
|
|
151
|
-
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
152
|
-
* @returns {Promise<OpenOrder>} Promise resolving to the open order object, or undefined if not found.
|
|
153
|
-
* @example
|
|
154
|
-
* import { getOpenOrder } from '@clober/v2-sdk'
|
|
155
|
-
*
|
|
156
|
-
* const openOrder = await getOpenOrder(
|
|
157
|
-
* 421614,
|
|
158
|
-
* '46223845323662364279893361453861711542636620039907198451770258805035840307200'
|
|
159
|
-
* )
|
|
160
|
-
*/
|
|
161
|
-
const getOpenOrder = async (chainId, id, options) => {
|
|
162
|
-
return (0, open_order_1.fetchOpenOrder)(chainId, id, options?.rpcUrl);
|
|
163
|
-
};
|
|
164
|
-
exports.getOpenOrder = getOpenOrder;
|
|
165
|
-
/**
|
|
166
|
-
* Retrieves open orders for the specified user on the given chain.
|
|
167
|
-
*
|
|
168
|
-
* @param {CHAIN_IDS} chainId The chain ID.
|
|
169
|
-
* @param {`0x${string}`} userAddress The Ethereum address of the user.
|
|
170
|
-
* @param options
|
|
171
|
-
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
172
|
-
* @returns {Promise<OpenOrder[]>} Promise resolving to an array of open orders.
|
|
173
|
-
* @example
|
|
174
|
-
* import { getOpenOrders } from '@clober/v2-sdk'
|
|
175
|
-
*
|
|
176
|
-
* const openOrders = await getOpenOrders(
|
|
177
|
-
* 421614,
|
|
178
|
-
* '0x5F79EE8f8fA862E98201120d83c4eC39D9468D49'
|
|
179
|
-
* )
|
|
180
|
-
*/
|
|
181
|
-
const getOpenOrders = async (chainId, userAddress, options) => {
|
|
182
|
-
return (0, open_order_1.fetchOpenOrders)(chainId, userAddress, options?.rpcUrl);
|
|
183
|
-
};
|
|
184
|
-
exports.getOpenOrders = getOpenOrders;
|
|
185
|
-
//# sourceMappingURL=view.js.map
|
package/dist/cjs/view.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"view.js","sourceRoot":"","sources":["../../src/view.ts"],"names":[],"mappings":";;;AAAA,+BAA8D;AAE9D,0CAA2C;AAG3C,2CAA2C;AAC3C,6CAA6C;AAC7C,kDAAmE;AAGnE;;;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kB,EAClB,WAA0B,EAC1B,OAA6B,EACP,EAAE;IACxB,OAAO,IAAA,4BAAe,EAAC,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;AAC/D,CAAC,CAAA;AANY,QAAA,aAAa,iBAMzB"}
|
|
@@ -1,233 +0,0 @@
|
|
|
1
|
-
import { gql } from '@graphql-mesh/utils';
|
|
2
|
-
import { PubSub } from '@graphql-mesh/utils';
|
|
3
|
-
import { DefaultLogger } from '@graphql-mesh/utils';
|
|
4
|
-
import MeshCache from "@graphql-mesh/cache-localforage";
|
|
5
|
-
import { fetch as fetchFn } from '@whatwg-node/fetch';
|
|
6
|
-
import GraphqlHandler from "@graphql-mesh/graphql";
|
|
7
|
-
import BareMerger from "@graphql-mesh/merger-bare";
|
|
8
|
-
import { printWithCache } from '@graphql-mesh/utils';
|
|
9
|
-
import { createMeshHTTPHandler } from '@graphql-mesh/http';
|
|
10
|
-
import { getMesh } from '@graphql-mesh/runtime';
|
|
11
|
-
import { MeshStore, FsStoreStorageAdapter } from '@graphql-mesh/store';
|
|
12
|
-
import { path as pathModule } from '@graphql-mesh/cross-helpers';
|
|
13
|
-
import * as importedModule$0 from "./sources/clober-v2/introspectionSchema";
|
|
14
|
-
const baseDir = pathModule.join(typeof __dirname === 'string' ? __dirname : '/', '..');
|
|
15
|
-
const importFn = (moduleId) => {
|
|
16
|
-
const relativeModuleId = (pathModule.isAbsolute(moduleId) ? pathModule.relative(baseDir, moduleId) : moduleId).split('\\').join('/').replace(baseDir + '/', '');
|
|
17
|
-
switch (relativeModuleId) {
|
|
18
|
-
case ".graphclient/sources/clober-v2/introspectionSchema":
|
|
19
|
-
return Promise.resolve(importedModule$0);
|
|
20
|
-
default:
|
|
21
|
-
return Promise.reject(new Error(`Cannot find module '${relativeModuleId}'.`));
|
|
22
|
-
}
|
|
23
|
-
};
|
|
24
|
-
const rootStore = new MeshStore('.graphclient', new FsStoreStorageAdapter({
|
|
25
|
-
cwd: baseDir,
|
|
26
|
-
importFn,
|
|
27
|
-
fileType: "ts",
|
|
28
|
-
}), {
|
|
29
|
-
readonly: true,
|
|
30
|
-
validate: false
|
|
31
|
-
});
|
|
32
|
-
export const rawServeConfig = undefined;
|
|
33
|
-
export async function getMeshOptions() {
|
|
34
|
-
const pubsub = new PubSub();
|
|
35
|
-
const sourcesStore = rootStore.child('sources');
|
|
36
|
-
const logger = new DefaultLogger("GraphClient");
|
|
37
|
-
const cache = new MeshCache({
|
|
38
|
-
...{},
|
|
39
|
-
importFn,
|
|
40
|
-
store: rootStore.child('cache'),
|
|
41
|
-
pubsub,
|
|
42
|
-
logger,
|
|
43
|
-
});
|
|
44
|
-
const sources = [];
|
|
45
|
-
const transforms = [];
|
|
46
|
-
const additionalEnvelopPlugins = [];
|
|
47
|
-
const cloberV2Transforms = [];
|
|
48
|
-
const additionalTypeDefs = [];
|
|
49
|
-
const cloberV2Handler = new GraphqlHandler({
|
|
50
|
-
name: "clober-v2",
|
|
51
|
-
config: { "endpoint": "{context.url:https://subgraph.satsuma-prod.com/f6a8c4889b7b/clober/v2-core-subgraph/api}" },
|
|
52
|
-
baseDir,
|
|
53
|
-
cache,
|
|
54
|
-
pubsub,
|
|
55
|
-
store: sourcesStore.child("clober-v2"),
|
|
56
|
-
logger: logger.child("clober-v2"),
|
|
57
|
-
importFn,
|
|
58
|
-
});
|
|
59
|
-
sources[0] = {
|
|
60
|
-
name: 'clober-v2',
|
|
61
|
-
handler: cloberV2Handler,
|
|
62
|
-
transforms: cloberV2Transforms
|
|
63
|
-
};
|
|
64
|
-
const additionalResolvers = [];
|
|
65
|
-
const merger = new BareMerger({
|
|
66
|
-
cache,
|
|
67
|
-
pubsub,
|
|
68
|
-
logger: logger.child('bareMerger'),
|
|
69
|
-
store: rootStore.child('bareMerger')
|
|
70
|
-
});
|
|
71
|
-
return {
|
|
72
|
-
sources,
|
|
73
|
-
transforms,
|
|
74
|
-
additionalTypeDefs,
|
|
75
|
-
additionalResolvers,
|
|
76
|
-
cache,
|
|
77
|
-
pubsub,
|
|
78
|
-
merger,
|
|
79
|
-
logger,
|
|
80
|
-
additionalEnvelopPlugins,
|
|
81
|
-
get documents() {
|
|
82
|
-
return [
|
|
83
|
-
{
|
|
84
|
-
document: GetBooksDocument,
|
|
85
|
-
get rawSDL() {
|
|
86
|
-
return printWithCache(GetBooksDocument);
|
|
87
|
-
},
|
|
88
|
-
location: 'GetBooksDocument.graphql'
|
|
89
|
-
}, {
|
|
90
|
-
document: GetOpenOrderDocument,
|
|
91
|
-
get rawSDL() {
|
|
92
|
-
return printWithCache(GetOpenOrderDocument);
|
|
93
|
-
},
|
|
94
|
-
location: 'GetOpenOrderDocument.graphql'
|
|
95
|
-
}, {
|
|
96
|
-
document: GetOpenOrdersDocument,
|
|
97
|
-
get rawSDL() {
|
|
98
|
-
return printWithCache(GetOpenOrdersDocument);
|
|
99
|
-
},
|
|
100
|
-
location: 'GetOpenOrdersDocument.graphql'
|
|
101
|
-
}
|
|
102
|
-
];
|
|
103
|
-
},
|
|
104
|
-
fetchFn,
|
|
105
|
-
};
|
|
106
|
-
}
|
|
107
|
-
export function createBuiltMeshHTTPHandler() {
|
|
108
|
-
return createMeshHTTPHandler({
|
|
109
|
-
baseDir,
|
|
110
|
-
getBuiltMesh: getBuiltGraphClient,
|
|
111
|
-
rawServeConfig: undefined,
|
|
112
|
-
});
|
|
113
|
-
}
|
|
114
|
-
let meshInstance$;
|
|
115
|
-
export function getBuiltGraphClient() {
|
|
116
|
-
if (meshInstance$ == null) {
|
|
117
|
-
meshInstance$ = getMeshOptions().then(meshOptions => getMesh(meshOptions)).then(mesh => {
|
|
118
|
-
const id = mesh.pubsub.subscribe('destroy', () => {
|
|
119
|
-
meshInstance$ = undefined;
|
|
120
|
-
mesh.pubsub.unsubscribe(id);
|
|
121
|
-
});
|
|
122
|
-
return mesh;
|
|
123
|
-
});
|
|
124
|
-
}
|
|
125
|
-
return meshInstance$;
|
|
126
|
-
}
|
|
127
|
-
export const execute = (...args) => getBuiltGraphClient().then(({ execute }) => execute(...args));
|
|
128
|
-
export const subscribe = (...args) => getBuiltGraphClient().then(({ subscribe }) => subscribe(...args));
|
|
129
|
-
export function getBuiltGraphSDK(globalContext) {
|
|
130
|
-
const sdkRequester$ = getBuiltGraphClient().then(({ sdkRequesterFactory }) => sdkRequesterFactory(globalContext));
|
|
131
|
-
return getSdk((...args) => sdkRequester$.then(sdkRequester => sdkRequester(...args)));
|
|
132
|
-
}
|
|
133
|
-
export const getBooksDocument = gql `
|
|
134
|
-
query getBooks($baseTokenAddress: String!, $quoteTokenAddress: String!) {
|
|
135
|
-
books(
|
|
136
|
-
where: {base: $baseTokenAddress, quote: $quoteTokenAddress, makerPolicy: "8888308", takerPolicy: "8889608", hooks: "0x0000000000000000000000000000000000000000"}
|
|
137
|
-
) {
|
|
138
|
-
id
|
|
139
|
-
base {
|
|
140
|
-
id
|
|
141
|
-
name
|
|
142
|
-
symbol
|
|
143
|
-
decimals
|
|
144
|
-
}
|
|
145
|
-
quote {
|
|
146
|
-
id
|
|
147
|
-
name
|
|
148
|
-
symbol
|
|
149
|
-
decimals
|
|
150
|
-
}
|
|
151
|
-
unit
|
|
152
|
-
depths {
|
|
153
|
-
tick
|
|
154
|
-
price
|
|
155
|
-
rawAmount
|
|
156
|
-
}
|
|
157
|
-
}
|
|
158
|
-
}
|
|
159
|
-
`;
|
|
160
|
-
export const getOpenOrderDocument = gql `
|
|
161
|
-
query getOpenOrder($orderId: ID!) {
|
|
162
|
-
openOrder(id: $orderId) {
|
|
163
|
-
id
|
|
164
|
-
book {
|
|
165
|
-
id
|
|
166
|
-
base {
|
|
167
|
-
id
|
|
168
|
-
name
|
|
169
|
-
symbol
|
|
170
|
-
decimals
|
|
171
|
-
}
|
|
172
|
-
quote {
|
|
173
|
-
id
|
|
174
|
-
name
|
|
175
|
-
symbol
|
|
176
|
-
decimals
|
|
177
|
-
}
|
|
178
|
-
unit
|
|
179
|
-
}
|
|
180
|
-
tick
|
|
181
|
-
txHash
|
|
182
|
-
createdAt
|
|
183
|
-
rawAmount
|
|
184
|
-
rawFilledAmount
|
|
185
|
-
rawClaimedAmount
|
|
186
|
-
rawClaimableAmount
|
|
187
|
-
}
|
|
188
|
-
}
|
|
189
|
-
`;
|
|
190
|
-
export const getOpenOrdersDocument = gql `
|
|
191
|
-
query getOpenOrders($userAddress: String!) {
|
|
192
|
-
openOrders(where: {user: $userAddress}) {
|
|
193
|
-
id
|
|
194
|
-
book {
|
|
195
|
-
id
|
|
196
|
-
base {
|
|
197
|
-
id
|
|
198
|
-
name
|
|
199
|
-
symbol
|
|
200
|
-
decimals
|
|
201
|
-
}
|
|
202
|
-
quote {
|
|
203
|
-
id
|
|
204
|
-
name
|
|
205
|
-
symbol
|
|
206
|
-
decimals
|
|
207
|
-
}
|
|
208
|
-
unit
|
|
209
|
-
}
|
|
210
|
-
tick
|
|
211
|
-
txHash
|
|
212
|
-
createdAt
|
|
213
|
-
rawAmount
|
|
214
|
-
rawFilledAmount
|
|
215
|
-
rawClaimedAmount
|
|
216
|
-
rawClaimableAmount
|
|
217
|
-
}
|
|
218
|
-
}
|
|
219
|
-
`;
|
|
220
|
-
export function getSdk(requester) {
|
|
221
|
-
return {
|
|
222
|
-
getBooks(variables, options) {
|
|
223
|
-
return requester(getBooksDocument, variables, options);
|
|
224
|
-
},
|
|
225
|
-
getOpenOrder(variables, options) {
|
|
226
|
-
return requester(getOpenOrderDocument, variables, options);
|
|
227
|
-
},
|
|
228
|
-
getOpenOrders(variables, options) {
|
|
229
|
-
return requester(getOpenOrdersDocument, variables, options);
|
|
230
|
-
}
|
|
231
|
-
};
|
|
232
|
-
}
|
|
233
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/.graphclient/index.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAI1C,OAAO,EAAE,MAAM,EAAE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