@clober/v2-sdk 0.0.1-b → 0.0.1-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/dist/cjs/.graphclient/index.js +243 -0
- package/dist/cjs/.graphclient/index.js.map +1 -0
- package/dist/cjs/.graphclient/sources/clober-v2/introspectionSchema.js +14482 -0
- package/dist/cjs/.graphclient/sources/clober-v2/introspectionSchema.js.map +1 -0
- package/dist/cjs/.graphclient/sources/clober-v2/types.js +4 -0
- package/dist/cjs/.graphclient/sources/clober-v2/types.js.map +1 -0
- package/dist/cjs/abis/core/controller-abi.js +989 -0
- package/dist/cjs/abis/core/controller-abi.js.map +1 -0
- package/dist/cjs/abis/core/params-abi.js +62 -0
- package/dist/cjs/abis/core/params-abi.js.map +1 -0
- package/dist/cjs/apis/currency.js +87 -0
- package/dist/cjs/apis/currency.js.map +1 -0
- package/dist/cjs/apis/market.js +63 -0
- package/dist/cjs/apis/market.js.map +1 -0
- package/dist/cjs/apis/open-order.js +90 -0
- package/dist/cjs/apis/open-order.js.map +1 -0
- package/dist/cjs/approval.js +74 -0
- package/dist/cjs/approval.js.map +1 -0
- package/dist/cjs/call.js +545 -0
- package/dist/cjs/call.js.map +1 -0
- package/dist/cjs/constants/action.js +14 -0
- package/dist/cjs/constants/action.js.map +1 -0
- package/dist/cjs/constants/addresses.js +13 -0
- package/dist/cjs/constants/addresses.js.map +1 -0
- package/dist/cjs/constants/chain.js +13 -0
- package/dist/cjs/constants/chain.js.map +1 -0
- package/dist/cjs/constants/currency.js +12 -0
- package/dist/cjs/constants/currency.js.map +1 -0
- package/dist/cjs/constants/fee.js +7 -0
- package/dist/cjs/constants/fee.js.map +1 -0
- package/dist/cjs/constants/price.js +6 -0
- package/dist/cjs/constants/price.js.map +1 -0
- package/dist/cjs/constants/subgraph-url.js +8 -0
- package/dist/cjs/constants/subgraph-url.js.map +1 -0
- package/dist/cjs/index.js +22 -0
- package/dist/cjs/index.js.map +1 -0
- package/dist/cjs/model/book.js +130 -0
- package/dist/cjs/model/book.js.map +1 -0
- package/dist/cjs/model/currency.js +3 -0
- package/dist/cjs/model/currency.js.map +1 -0
- package/dist/cjs/model/depth.js +3 -0
- package/dist/cjs/model/depth.js.map +1 -0
- package/dist/cjs/model/fee-policy.js +42 -0
- package/dist/cjs/model/fee-policy.js.map +1 -0
- package/dist/cjs/model/market.js +215 -0
- package/dist/cjs/model/market.js.map +1 -0
- package/dist/cjs/model/open-order.js +3 -0
- package/dist/cjs/model/open-order.js.map +1 -0
- package/dist/cjs/package.json +1 -0
- package/dist/cjs/signature.js +178 -0
- package/dist/cjs/signature.js.map +1 -0
- package/dist/cjs/tsconfig.build.tsbuildinfo +1 -0
- package/dist/cjs/type.js +6 -0
- package/dist/cjs/type.js.map +1 -0
- package/dist/cjs/utils/approval.js +46 -0
- package/dist/cjs/utils/approval.js.map +1 -0
- package/dist/cjs/utils/book-id.js +25 -0
- package/dist/cjs/utils/book-id.js.map +1 -0
- package/dist/cjs/utils/build-transaction.js +31 -0
- package/dist/cjs/utils/build-transaction.js.map +1 -0
- package/dist/cjs/utils/decimals.js +17 -0
- package/dist/cjs/utils/decimals.js.map +1 -0
- package/dist/cjs/utils/market.js +53 -0
- package/dist/cjs/utils/market.js.map +1 -0
- package/dist/cjs/utils/math.js +83 -0
- package/dist/cjs/utils/math.js.map +1 -0
- package/dist/cjs/utils/prices.js +22 -0
- package/dist/cjs/utils/prices.js.map +1 -0
- package/dist/cjs/utils/tick.js +106 -0
- package/dist/cjs/utils/tick.js.map +1 -0
- package/dist/cjs/utils/time.js +9 -0
- package/dist/cjs/utils/time.js.map +1 -0
- package/dist/cjs/utils/unit.js +38 -0
- package/dist/cjs/utils/unit.js.map +1 -0
- package/dist/cjs/view.js +185 -0
- package/dist/cjs/view.js.map +1 -0
- package/dist/esm/.graphclient/index.js +233 -0
- package/dist/esm/.graphclient/index.js.map +1 -0
- package/dist/esm/.graphclient/sources/clober-v2/introspectionSchema.js +14480 -0
- package/dist/esm/.graphclient/sources/clober-v2/introspectionSchema.js.map +1 -0
- package/dist/esm/.graphclient/sources/clober-v2/types.js +3 -0
- package/dist/esm/.graphclient/sources/clober-v2/types.js.map +1 -0
- package/dist/esm/abis/core/controller-abi.js +986 -0
- package/dist/esm/abis/core/controller-abi.js.map +1 -0
- package/dist/esm/abis/core/params-abi.js +59 -0
- package/dist/esm/abis/core/params-abi.js.map +1 -0
- package/dist/esm/apis/currency.js +83 -0
- package/dist/esm/apis/currency.js.map +1 -0
- package/dist/esm/apis/market.js +59 -0
- package/dist/esm/apis/market.js.map +1 -0
- package/dist/esm/apis/open-order.js +85 -0
- package/dist/esm/apis/open-order.js.map +1 -0
- package/dist/esm/approval.js +70 -0
- package/dist/esm/approval.js.map +1 -0
- package/dist/esm/call.js +535 -0
- package/dist/esm/call.js.map +1 -0
- package/dist/esm/constants/action.js +11 -0
- package/dist/esm/constants/action.js.map +1 -0
- package/dist/esm/constants/addresses.js +10 -0
- package/dist/esm/constants/addresses.js.map +1 -0
- package/dist/esm/constants/chain.js +10 -0
- package/dist/esm/constants/chain.js.map +1 -0
- package/dist/esm/constants/currency.js +9 -0
- package/dist/esm/constants/currency.js.map +1 -0
- package/dist/esm/constants/fee.js +4 -0
- package/dist/esm/constants/fee.js.map +1 -0
- package/dist/esm/constants/price.js +3 -0
- package/dist/esm/constants/price.js.map +1 -0
- package/dist/esm/constants/subgraph-url.js +5 -0
- package/dist/esm/constants/subgraph-url.js.map +1 -0
- package/dist/esm/index.js +6 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/model/book.js +126 -0
- package/dist/esm/model/book.js.map +1 -0
- package/dist/esm/model/currency.js +2 -0
- package/dist/esm/model/currency.js.map +1 -0
- package/dist/esm/model/depth.js +2 -0
- package/dist/esm/model/depth.js.map +1 -0
- package/dist/esm/model/fee-policy.js +38 -0
- package/dist/esm/model/fee-policy.js.map +1 -0
- package/dist/esm/model/market.js +211 -0
- package/dist/esm/model/market.js.map +1 -0
- package/dist/esm/model/open-order.js +2 -0
- package/dist/esm/model/open-order.js.map +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/signature.js +174 -0
- package/dist/esm/signature.js.map +1 -0
- package/dist/esm/tsconfig.build.tsbuildinfo +1 -0
- package/dist/esm/type.js +2 -0
- package/dist/esm/type.js.map +1 -0
- package/dist/esm/utils/approval.js +42 -0
- package/dist/esm/utils/approval.js.map +1 -0
- package/{src/utils/book-id.ts → dist/esm/utils/book-id.js} +9 -19
- package/dist/esm/utils/book-id.js.map +1 -0
- package/dist/esm/utils/build-transaction.js +27 -0
- package/dist/esm/utils/build-transaction.js.map +1 -0
- package/dist/esm/utils/decimals.js +12 -0
- package/dist/esm/utils/decimals.js.map +1 -0
- package/dist/esm/utils/market.js +49 -0
- package/dist/esm/utils/market.js.map +1 -0
- package/dist/esm/utils/math.js +78 -0
- package/dist/esm/utils/math.js.map +1 -0
- package/dist/esm/utils/prices.js +17 -0
- package/dist/esm/utils/prices.js.map +1 -0
- package/dist/esm/utils/tick.js +100 -0
- package/dist/esm/utils/tick.js.map +1 -0
- package/dist/esm/utils/time.js +5 -0
- package/dist/esm/utils/time.js.map +1 -0
- package/dist/esm/utils/unit.js +34 -0
- package/dist/esm/utils/unit.js.map +1 -0
- package/dist/esm/view.js +177 -0
- package/dist/esm/view.js.map +1 -0
- package/dist/types/.graphclient/index.d.ts +1281 -0
- package/dist/types/.graphclient/index.d.ts.map +1 -0
- package/dist/types/.graphclient/sources/clober-v2/introspectionSchema.d.ts +3 -0
- package/dist/types/.graphclient/sources/clober-v2/introspectionSchema.d.ts.map +1 -0
- package/dist/types/.graphclient/sources/clober-v2/types.d.ts +984 -0
- package/dist/types/.graphclient/sources/clober-v2/types.d.ts.map +1 -0
- package/dist/types/abis/core/controller-abi.d.ts +757 -0
- package/dist/types/abis/core/controller-abi.d.ts.map +1 -0
- package/dist/types/abis/core/params-abi.d.ts +21 -0
- package/dist/types/abis/core/params-abi.d.ts.map +1 -0
- package/dist/types/apis/currency.d.ts +4 -0
- package/dist/types/apis/currency.d.ts.map +1 -0
- package/dist/types/apis/market.d.ts +4 -0
- package/dist/types/apis/market.d.ts.map +1 -0
- package/dist/types/apis/open-order.d.ts +5 -0
- package/dist/types/apis/open-order.d.ts.map +1 -0
- package/dist/types/approval.d.ts +32 -0
- package/dist/types/approval.d.ts.map +1 -0
- package/dist/types/call.d.ts +234 -0
- package/dist/types/call.d.ts.map +1 -0
- package/dist/types/constants/action.d.ts +10 -0
- package/dist/types/constants/action.d.ts.map +1 -0
- package/dist/types/constants/addresses.d.ts +9 -0
- package/dist/types/constants/addresses.d.ts.map +1 -0
- package/dist/types/constants/chain.d.ts +9 -0
- package/dist/types/constants/chain.d.ts.map +1 -0
- package/dist/types/constants/currency.d.ts +8 -0
- package/dist/types/constants/currency.d.ts.map +1 -0
- package/dist/types/constants/fee.d.ts +4 -0
- package/dist/types/constants/fee.d.ts.map +1 -0
- package/dist/types/constants/price.d.ts +3 -0
- package/dist/types/constants/price.d.ts.map +1 -0
- package/dist/types/constants/subgraph-url.d.ts +5 -0
- package/dist/types/constants/subgraph-url.d.ts.map +1 -0
- package/dist/types/index.d.ts +6 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/model/book.d.ts +31 -0
- package/dist/types/model/book.d.ts.map +1 -0
- package/dist/types/model/currency.d.ts +7 -0
- package/dist/types/model/currency.d.ts.map +1 -0
- package/dist/types/model/depth.d.ts +11 -0
- package/dist/types/model/depth.d.ts.map +1 -0
- package/dist/types/model/fee-policy.d.ts +15 -0
- package/dist/types/model/fee-policy.d.ts.map +1 -0
- package/dist/types/model/market.d.ts +44 -0
- package/dist/types/model/market.d.ts.map +1 -0
- package/dist/types/model/open-order.d.ts +28 -0
- package/dist/types/model/open-order.d.ts.map +1 -0
- package/dist/types/signature.d.ts +40 -0
- package/dist/types/signature.d.ts.map +1 -0
- package/dist/types/type.d.ts +34 -0
- package/dist/types/type.d.ts.map +1 -0
- package/dist/types/utils/approval.d.ts +3 -0
- package/dist/types/utils/approval.d.ts.map +1 -0
- package/dist/types/utils/book-id.d.ts +2 -0
- package/dist/types/utils/book-id.d.ts.map +1 -0
- package/dist/types/utils/build-transaction.d.ts +5 -0
- package/dist/types/utils/build-transaction.d.ts.map +1 -0
- package/dist/types/utils/decimals.d.ts +3 -0
- package/dist/types/utils/decimals.d.ts.map +1 -0
- package/dist/types/utils/market.d.ts +7 -0
- package/dist/types/utils/market.d.ts.map +1 -0
- package/dist/types/utils/math.d.ts +3 -0
- package/dist/types/utils/math.d.ts.map +1 -0
- package/dist/types/utils/prices.d.ts +3 -0
- package/dist/types/utils/prices.d.ts.map +1 -0
- package/dist/types/utils/tick.d.ts +4 -0
- package/dist/types/utils/tick.d.ts.map +1 -0
- package/dist/types/utils/time.d.ts +2 -0
- package/dist/types/utils/time.d.ts.map +1 -0
- package/dist/types/utils/unit.d.ts +4 -0
- package/dist/types/utils/unit.d.ts.map +1 -0
- package/dist/types/view.d.ts +129 -0
- package/dist/types/view.d.ts.map +1 -0
- package/package.json +14 -6
- package/.eslintignore +0 -1
- package/.eslintrc.yaml +0 -34
- package/.github/workflows/ci.yaml +0 -88
- package/.github/workflows/deployer.yaml +0 -19
- package/.nvmrc +0 -1
- package/.prettierignore +0 -6
- package/.prettierrc +0 -7
- package/src/.graphclient/index.ts +0 -1695
- package/src/.graphclient/schema.graphql +0 -1116
- package/src/.graphclient/sources/clober-v2/introspectionSchema.ts +0 -14481
- package/src/.graphclient/sources/clober-v2/schema.graphql +0 -1116
- package/src/.graphclient/sources/clober-v2/types.ts +0 -1133
- package/src/.graphclientrc.yml +0 -12
- package/src/abis/core/controller-abi.ts +0 -985
- package/src/abis/core/params-abi.ts +0 -59
- package/src/apis/currency.ts +0 -92
- package/src/apis/graphql/books.graphql +0 -25
- package/src/apis/graphql/open-order.graphql +0 -29
- package/src/apis/graphql/open-orders.graphql +0 -29
- package/src/apis/market.ts +0 -85
- package/src/apis/open-order.ts +0 -145
- package/src/approval.ts +0 -82
- package/src/call.ts +0 -705
- package/src/constants/action.ts +0 -9
- package/src/constants/addresses.ts +0 -17
- package/src/constants/chain.ts +0 -12
- package/src/constants/currency.ts +0 -15
- package/src/constants/fee.ts +0 -4
- package/src/constants/price.ts +0 -3
- package/src/constants/subgraph-url.ts +0 -8
- package/src/index.ts +0 -5
- package/src/model/book.ts +0 -166
- package/src/model/currency.ts +0 -6
- package/src/model/depth.ts +0 -11
- package/src/model/fee-policy.ts +0 -51
- package/src/model/market.ts +0 -320
- package/src/model/open-order.ts +0 -16
- package/src/signature.ts +0 -196
- package/src/type.ts +0 -38
- package/src/utils/approval.ts +0 -48
- package/src/utils/build-transaction.ts +0 -39
- package/src/utils/decimals.ts +0 -22
- package/src/utils/market.ts +0 -74
- package/src/utils/math.ts +0 -117
- package/src/utils/prices.ts +0 -29
- package/src/utils/tick.ts +0 -104
- package/src/utils/time.ts +0 -6
- package/src/utils/unit.ts +0 -43
- package/src/view.ts +0 -258
- package/test/book-id.test.ts +0 -101
- package/test/fee-policy.test.ts +0 -228
- package/test/get-expected-input.test.ts +0 -206
- package/test/get-expected-output.test.ts +0 -206
- package/test/limit-order.test.ts +0 -279
- package/test/market-order.test.ts +0 -245
- package/test/market.test.ts +0 -68
- package/test/math.test.ts +0 -91
- package/test/open-order.test.ts +0 -112
- package/test/open.test.ts +0 -15
- package/test/tick.test.ts +0 -230
- package/test/tsconfig.json +0 -12
- package/test/utils/chain.ts +0 -12
- package/test/utils/constants.ts +0 -25
- package/test/utils/currency.ts +0 -44
- package/test/utils/depth.ts +0 -148
- package/test/utils/test-chain.ts +0 -26
- package/test/vitest.config.ts +0 -15
- package/tsconfig.base.json +0 -37
- package/tsconfig.build.json +0 -9
- package/tsconfig.json +0 -9
package/src/utils/unit.ts
DELETED
|
@@ -1,43 +0,0 @@
|
|
|
1
|
-
import { createPublicClient, http, isAddressEqual, zeroAddress } from 'viem'
|
|
2
|
-
|
|
3
|
-
import { Currency } from '../model/currency'
|
|
4
|
-
import { CHAIN_IDS, CHAIN_MAP } from '../constants/chain'
|
|
5
|
-
|
|
6
|
-
const _abi = [
|
|
7
|
-
{
|
|
8
|
-
inputs: [],
|
|
9
|
-
name: 'totalSupply',
|
|
10
|
-
outputs: [
|
|
11
|
-
{
|
|
12
|
-
internalType: 'uint256',
|
|
13
|
-
name: '',
|
|
14
|
-
type: 'uint256',
|
|
15
|
-
},
|
|
16
|
-
],
|
|
17
|
-
stateMutability: 'view',
|
|
18
|
-
type: 'function',
|
|
19
|
-
},
|
|
20
|
-
] as const
|
|
21
|
-
|
|
22
|
-
export const calculateUnit = async (
|
|
23
|
-
chainId: CHAIN_IDS,
|
|
24
|
-
quote: Currency,
|
|
25
|
-
rpcUrl?: string,
|
|
26
|
-
) => {
|
|
27
|
-
if (isAddressEqual(quote.address, zeroAddress)) {
|
|
28
|
-
return 10n ** 12n
|
|
29
|
-
}
|
|
30
|
-
const publicClient = createPublicClient({
|
|
31
|
-
chain: CHAIN_MAP[chainId],
|
|
32
|
-
transport: rpcUrl ? http(rpcUrl) : http(),
|
|
33
|
-
})
|
|
34
|
-
const totalSupply = await publicClient.readContract({
|
|
35
|
-
address: quote.address,
|
|
36
|
-
abi: _abi,
|
|
37
|
-
functionName: 'totalSupply',
|
|
38
|
-
})
|
|
39
|
-
return (
|
|
40
|
-
10n **
|
|
41
|
-
BigInt(totalSupply <= 2n ** 64n ? 0n : Math.max(quote.decimals - 6, 0))
|
|
42
|
-
)
|
|
43
|
-
}
|
package/src/view.ts
DELETED
|
@@ -1,258 +0,0 @@
|
|
|
1
|
-
import { formatUnits, isAddressEqual, parseUnits } from 'viem'
|
|
2
|
-
|
|
3
|
-
import { fetchMarket } from './apis/market'
|
|
4
|
-
import { CHAIN_IDS } from './constants/chain'
|
|
5
|
-
import { Market } from './type'
|
|
6
|
-
import { parsePrice } from './utils/prices'
|
|
7
|
-
import { MAX_PRICE } from './constants/price'
|
|
8
|
-
import { fetchOpenOrder, fetchOpenOrders } from './apis/open-order'
|
|
9
|
-
import { OpenOrder } from './model/open-order'
|
|
10
|
-
|
|
11
|
-
/**
|
|
12
|
-
* Get market information by chain id and token addresses
|
|
13
|
-
* @param chainId - chain id from {@link CHAIN_IDS}
|
|
14
|
-
* @param token0 - token0 address
|
|
15
|
-
* @param token1 - token1 address
|
|
16
|
-
* @param options
|
|
17
|
-
* @param options.rpcUrl - RPC URL of the blockchain
|
|
18
|
-
* @returns A market {@link Market}
|
|
19
|
-
*
|
|
20
|
-
* @example
|
|
21
|
-
* import { getMarket } from '@clober/v2-sdk'
|
|
22
|
-
*
|
|
23
|
-
* const market = await getMarket(
|
|
24
|
-
* 421614,
|
|
25
|
-
* '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
26
|
-
* '0x0000000000000000000000000000000000000000',
|
|
27
|
-
* )
|
|
28
|
-
*/
|
|
29
|
-
export const getMarket = async (
|
|
30
|
-
chainId: CHAIN_IDS,
|
|
31
|
-
token0: `0x${string}`,
|
|
32
|
-
token1: `0x${string}`,
|
|
33
|
-
options?: { rpcUrl?: string },
|
|
34
|
-
): Promise<Market> => {
|
|
35
|
-
if (isAddressEqual(token0, token1)) {
|
|
36
|
-
throw new Error('Token0 and token1 must be different')
|
|
37
|
-
}
|
|
38
|
-
const market = await fetchMarket(chainId, [token0, token1], options?.rpcUrl)
|
|
39
|
-
return {
|
|
40
|
-
chainId,
|
|
41
|
-
quote: market.quote,
|
|
42
|
-
base: market.base,
|
|
43
|
-
makerFee: market.makerFee,
|
|
44
|
-
takerFee: market.takerFee,
|
|
45
|
-
bids: market.bids,
|
|
46
|
-
bidBookOpen: market.bidBookOpen,
|
|
47
|
-
asks: market.asks,
|
|
48
|
-
askBookOpen: market.askBookOpen,
|
|
49
|
-
}
|
|
50
|
-
}
|
|
51
|
-
|
|
52
|
-
/**
|
|
53
|
-
* Calculates the expected output for a given input amount, based on the provided market data.
|
|
54
|
-
*
|
|
55
|
-
* @param chainId The chain ID of the blockchain.
|
|
56
|
-
* @param inputToken The address of the input token.
|
|
57
|
-
* @param outputToken The address of the output token.
|
|
58
|
-
* @param amountIn The amount of expected input amount. (ex 1.2 ETH -> 1.2)
|
|
59
|
-
* @param options
|
|
60
|
-
* @param options.limitPrice The maximum limit price to spend.
|
|
61
|
-
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
62
|
-
* @returns A Promise resolving to an object containing the taken amount, spend amount and result of the calculation.
|
|
63
|
-
* @example
|
|
64
|
-
* import { getExpectedOutput } from '@clober/v2-sdk'
|
|
65
|
-
*
|
|
66
|
-
* const { takenAmount, spendAmount } = await getExpectedOutput(
|
|
67
|
-
* 421614,
|
|
68
|
-
* '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
69
|
-
* '0x0000000000000000000000000000000000000000',
|
|
70
|
-
* '1000.123', // spend 1000.123 USDC
|
|
71
|
-
* )
|
|
72
|
-
*/
|
|
73
|
-
export const getExpectedOutput = async (
|
|
74
|
-
chainId: CHAIN_IDS,
|
|
75
|
-
inputToken: `0x${string}`,
|
|
76
|
-
outputToken: `0x${string}`,
|
|
77
|
-
amountIn: string,
|
|
78
|
-
options?: { limitPrice?: string; rpcUrl?: string },
|
|
79
|
-
): Promise<{
|
|
80
|
-
takenAmount: string
|
|
81
|
-
spendAmount: string
|
|
82
|
-
result: { bookId: bigint; takenAmount: bigint; spendAmount: bigint }[]
|
|
83
|
-
}> => {
|
|
84
|
-
const market = await fetchMarket(
|
|
85
|
-
chainId,
|
|
86
|
-
[inputToken, outputToken],
|
|
87
|
-
options?.rpcUrl,
|
|
88
|
-
)
|
|
89
|
-
const isBid = isAddressEqual(market.quote.address, inputToken)
|
|
90
|
-
const rawLimitPrice =
|
|
91
|
-
options && options.limitPrice
|
|
92
|
-
? parsePrice(
|
|
93
|
-
Number(options.limitPrice),
|
|
94
|
-
market.quote.decimals,
|
|
95
|
-
market.base.decimals,
|
|
96
|
-
)
|
|
97
|
-
: isBid
|
|
98
|
-
? MAX_PRICE
|
|
99
|
-
: 0n
|
|
100
|
-
const inputCurrency = isBid ? market.quote : market.base
|
|
101
|
-
const result = market.spend({
|
|
102
|
-
spendBase: !isBid,
|
|
103
|
-
limitPrice: rawLimitPrice,
|
|
104
|
-
amountIn: parseUnits(amountIn, inputCurrency.decimals),
|
|
105
|
-
})
|
|
106
|
-
const { takenAmount, spendAmount } = Object.values(result).reduce(
|
|
107
|
-
(acc, { takenAmount, spendAmount }) => ({
|
|
108
|
-
takenAmount: acc.takenAmount + takenAmount,
|
|
109
|
-
spendAmount: acc.spendAmount + spendAmount,
|
|
110
|
-
}),
|
|
111
|
-
{ takenAmount: 0n, spendAmount: 0n },
|
|
112
|
-
)
|
|
113
|
-
return {
|
|
114
|
-
takenAmount: formatUnits(
|
|
115
|
-
takenAmount,
|
|
116
|
-
isBid ? market.base.decimals : market.quote.decimals,
|
|
117
|
-
),
|
|
118
|
-
spendAmount: formatUnits(
|
|
119
|
-
spendAmount,
|
|
120
|
-
isBid ? market.quote.decimals : market.base.decimals,
|
|
121
|
-
),
|
|
122
|
-
result: Object.entries(result).map(
|
|
123
|
-
([bookId, { takenAmount, spendAmount }]) => ({
|
|
124
|
-
bookId: BigInt(bookId),
|
|
125
|
-
takenAmount,
|
|
126
|
-
spendAmount,
|
|
127
|
-
}),
|
|
128
|
-
),
|
|
129
|
-
}
|
|
130
|
-
}
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Calculates the expected input for a given output amount, based on the provided market data.
|
|
134
|
-
*
|
|
135
|
-
* @param chainId The chain ID of the blockchain.
|
|
136
|
-
* @param inputToken The address of the input token.
|
|
137
|
-
* @param outputToken The address of the output token.
|
|
138
|
-
* @param amountOut The amount of expected output amount. (ex 1.2 ETH -> 1.2)
|
|
139
|
-
* @param options
|
|
140
|
-
* @param options.limitPrice The maximum limit price to take.
|
|
141
|
-
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
142
|
-
* @returns A Promise resolving to an object containing the taken amount, spend amount and result of the calculation.
|
|
143
|
-
* @example
|
|
144
|
-
* import { getExpectedInput } from '@clober/v2-sdk'
|
|
145
|
-
*
|
|
146
|
-
* const { takenAmount, spendAmount } = await getExpectedInput(
|
|
147
|
-
* 421614,
|
|
148
|
-
* '0x00bfd44e79fb7f6dd5887a9426c8ef85a0cd23e0',
|
|
149
|
-
* '0x0000000000000000000000000000000000000000',
|
|
150
|
-
* '0.1', // take 0.1 ETH
|
|
151
|
-
* )
|
|
152
|
-
*/
|
|
153
|
-
export const getExpectedInput = async (
|
|
154
|
-
chainId: CHAIN_IDS,
|
|
155
|
-
inputToken: `0x${string}`,
|
|
156
|
-
outputToken: `0x${string}`,
|
|
157
|
-
amountOut: string,
|
|
158
|
-
options?: { limitPrice?: string; rpcUrl?: string },
|
|
159
|
-
): Promise<{
|
|
160
|
-
takenAmount: string
|
|
161
|
-
spendAmount: string
|
|
162
|
-
result: { bookId: bigint; takenAmount: bigint; spendAmount: bigint }[]
|
|
163
|
-
}> => {
|
|
164
|
-
const market = await fetchMarket(
|
|
165
|
-
chainId,
|
|
166
|
-
[inputToken, outputToken],
|
|
167
|
-
options?.rpcUrl,
|
|
168
|
-
)
|
|
169
|
-
const isBid = isAddressEqual(market.quote.address, inputToken)
|
|
170
|
-
const rawLimitPrice =
|
|
171
|
-
options && options.limitPrice
|
|
172
|
-
? parsePrice(
|
|
173
|
-
Number(options.limitPrice),
|
|
174
|
-
market.quote.decimals,
|
|
175
|
-
market.base.decimals,
|
|
176
|
-
)
|
|
177
|
-
: isBid
|
|
178
|
-
? MAX_PRICE
|
|
179
|
-
: 0n
|
|
180
|
-
const outputCurrency = isBid ? market.base : market.quote
|
|
181
|
-
const result = market.take({
|
|
182
|
-
takeQuote: !isBid,
|
|
183
|
-
limitPrice: rawLimitPrice,
|
|
184
|
-
amountOut: parseUnits(amountOut, outputCurrency.decimals),
|
|
185
|
-
})
|
|
186
|
-
const { takenAmount, spendAmount } = Object.values(result).reduce(
|
|
187
|
-
(acc, { takenAmount, spendAmount }) => ({
|
|
188
|
-
takenAmount: acc.takenAmount + takenAmount,
|
|
189
|
-
spendAmount: acc.spendAmount + spendAmount,
|
|
190
|
-
}),
|
|
191
|
-
{ takenAmount: 0n, spendAmount: 0n },
|
|
192
|
-
)
|
|
193
|
-
return {
|
|
194
|
-
takenAmount: formatUnits(
|
|
195
|
-
takenAmount,
|
|
196
|
-
isBid ? market.base.decimals : market.quote.decimals,
|
|
197
|
-
),
|
|
198
|
-
spendAmount: formatUnits(
|
|
199
|
-
spendAmount,
|
|
200
|
-
isBid ? market.quote.decimals : market.base.decimals,
|
|
201
|
-
),
|
|
202
|
-
result: Object.entries(result).map(
|
|
203
|
-
([bookId, { takenAmount, spendAmount }]) => ({
|
|
204
|
-
bookId: BigInt(bookId),
|
|
205
|
-
takenAmount,
|
|
206
|
-
spendAmount,
|
|
207
|
-
}),
|
|
208
|
-
),
|
|
209
|
-
}
|
|
210
|
-
}
|
|
211
|
-
|
|
212
|
-
/**
|
|
213
|
-
* Retrieves the open order with the specified ID on the given chain.
|
|
214
|
-
*
|
|
215
|
-
* @param {CHAIN_IDS} chainId The chain ID.
|
|
216
|
-
* @param {string} id The ID of the open order.
|
|
217
|
-
* @param options
|
|
218
|
-
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
219
|
-
* @returns {Promise<OpenOrder>} Promise resolving to the open order object, or undefined if not found.
|
|
220
|
-
* @example
|
|
221
|
-
* import { getOpenOrder } from '@clober/v2-sdk'
|
|
222
|
-
*
|
|
223
|
-
* const openOrder = await getOpenOrder(
|
|
224
|
-
* 421614,
|
|
225
|
-
* '46223845323662364279893361453861711542636620039907198451770258805035840307200'
|
|
226
|
-
* )
|
|
227
|
-
*/
|
|
228
|
-
export const getOpenOrder = async (
|
|
229
|
-
chainId: CHAIN_IDS,
|
|
230
|
-
id: string,
|
|
231
|
-
options?: { rpcUrl?: string },
|
|
232
|
-
): Promise<OpenOrder> => {
|
|
233
|
-
return fetchOpenOrder(chainId, id, options?.rpcUrl)
|
|
234
|
-
}
|
|
235
|
-
|
|
236
|
-
/**
|
|
237
|
-
* Retrieves open orders for the specified user on the given chain.
|
|
238
|
-
*
|
|
239
|
-
* @param {CHAIN_IDS} chainId The chain ID.
|
|
240
|
-
* @param {`0x${string}`} userAddress The Ethereum address of the user.
|
|
241
|
-
* @param options
|
|
242
|
-
* @param options.rpcUrl The RPC URL of the blockchain.
|
|
243
|
-
* @returns {Promise<OpenOrder[]>} Promise resolving to an array of open orders.
|
|
244
|
-
* @example
|
|
245
|
-
* import { getOpenOrders } from '@clober/v2-sdk'
|
|
246
|
-
*
|
|
247
|
-
* const openOrders = await getOpenOrders(
|
|
248
|
-
* 421614,
|
|
249
|
-
* '0x5F79EE8f8fA862E98201120d83c4eC39D9468D49'
|
|
250
|
-
* )
|
|
251
|
-
*/
|
|
252
|
-
export const getOpenOrders = async (
|
|
253
|
-
chainId: CHAIN_IDS,
|
|
254
|
-
userAddress: `0x${string}`,
|
|
255
|
-
options?: { rpcUrl?: string },
|
|
256
|
-
): Promise<OpenOrder[]> => {
|
|
257
|
-
return fetchOpenOrders(chainId, userAddress, options?.rpcUrl)
|
|
258
|
-
}
|
package/test/book-id.test.ts
DELETED
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { expect, test } from 'vitest'
|
|
2
|
-
|
|
3
|
-
import { toBookId } from '../src/utils/book-id'
|
|
4
|
-
import {
|
|
5
|
-
MAKER_DEFAULT_POLICY,
|
|
6
|
-
TAKER_DEFAULT_POLICY,
|
|
7
|
-
} from '../src/constants/fee'
|
|
8
|
-
|
|
9
|
-
import { publicClient } from './utils/constants'
|
|
10
|
-
|
|
11
|
-
const _abi = [
|
|
12
|
-
{
|
|
13
|
-
inputs: [
|
|
14
|
-
{
|
|
15
|
-
components: [
|
|
16
|
-
{
|
|
17
|
-
internalType: 'Currency',
|
|
18
|
-
name: 'base',
|
|
19
|
-
type: 'address',
|
|
20
|
-
},
|
|
21
|
-
{
|
|
22
|
-
internalType: 'uint64',
|
|
23
|
-
name: 'unit',
|
|
24
|
-
type: 'uint64',
|
|
25
|
-
},
|
|
26
|
-
{
|
|
27
|
-
internalType: 'Currency',
|
|
28
|
-
name: 'quote',
|
|
29
|
-
type: 'address',
|
|
30
|
-
},
|
|
31
|
-
{
|
|
32
|
-
internalType: 'FeePolicy',
|
|
33
|
-
name: 'makerPolicy',
|
|
34
|
-
type: 'uint24',
|
|
35
|
-
},
|
|
36
|
-
{
|
|
37
|
-
internalType: 'contract IHooks',
|
|
38
|
-
name: 'hooks',
|
|
39
|
-
type: 'address',
|
|
40
|
-
},
|
|
41
|
-
{
|
|
42
|
-
internalType: 'FeePolicy',
|
|
43
|
-
name: 'takerPolicy',
|
|
44
|
-
type: 'uint24',
|
|
45
|
-
},
|
|
46
|
-
],
|
|
47
|
-
internalType: 'struct IBookManager.BookKey',
|
|
48
|
-
name: 'bookKey',
|
|
49
|
-
type: 'tuple',
|
|
50
|
-
},
|
|
51
|
-
],
|
|
52
|
-
name: 'toId',
|
|
53
|
-
outputs: [
|
|
54
|
-
{
|
|
55
|
-
internalType: 'BookId',
|
|
56
|
-
name: 'id',
|
|
57
|
-
type: 'uint192',
|
|
58
|
-
},
|
|
59
|
-
],
|
|
60
|
-
stateMutability: 'pure',
|
|
61
|
-
type: 'function',
|
|
62
|
-
},
|
|
63
|
-
] as const
|
|
64
|
-
|
|
65
|
-
const BOOK_ID_WRAPPER_ADDRESS = '0xbBa11dC70D31578fA426FB0EaCed79EB844F93A7'
|
|
66
|
-
|
|
67
|
-
test('check toBookId function', async () => {
|
|
68
|
-
const bidBookKey = {
|
|
69
|
-
base: '0x0000000000000000000000000000000000000000' as `0x${string}`,
|
|
70
|
-
unit: 10n ** 12n,
|
|
71
|
-
quote: '0x447ad4a108b5540c220f9f7e83723ac87c0f8fd8' as `0x${string}`,
|
|
72
|
-
makerPolicy: Number(MAKER_DEFAULT_POLICY.value),
|
|
73
|
-
hooks: '0x0000000000000000000000000000000000000000' as `0x${string}`,
|
|
74
|
-
takerPolicy: Number(TAKER_DEFAULT_POLICY.value),
|
|
75
|
-
}
|
|
76
|
-
expect(
|
|
77
|
-
await publicClient.readContract({
|
|
78
|
-
address: BOOK_ID_WRAPPER_ADDRESS,
|
|
79
|
-
abi: _abi,
|
|
80
|
-
functionName: 'toId',
|
|
81
|
-
args: [bidBookKey],
|
|
82
|
-
}),
|
|
83
|
-
).toBe(toBookId(bidBookKey.quote, bidBookKey.base, bidBookKey.unit))
|
|
84
|
-
|
|
85
|
-
const askBookKey = {
|
|
86
|
-
base: '0x447ad4a108b5540c220f9f7e83723ac87c0f8fd8' as `0x${string}`,
|
|
87
|
-
unit: 10n ** 1n,
|
|
88
|
-
quote: '0x0000000000000000000000000000000000000000' as `0x${string}`,
|
|
89
|
-
makerPolicy: Number(MAKER_DEFAULT_POLICY.value),
|
|
90
|
-
hooks: '0x0000000000000000000000000000000000000000' as `0x${string}`,
|
|
91
|
-
takerPolicy: Number(TAKER_DEFAULT_POLICY.value),
|
|
92
|
-
}
|
|
93
|
-
expect(
|
|
94
|
-
await publicClient.readContract({
|
|
95
|
-
address: BOOK_ID_WRAPPER_ADDRESS,
|
|
96
|
-
abi: _abi,
|
|
97
|
-
functionName: 'toId',
|
|
98
|
-
args: [askBookKey],
|
|
99
|
-
}),
|
|
100
|
-
).toBe(toBookId(askBookKey.quote, askBookKey.base, askBookKey.unit))
|
|
101
|
-
})
|
package/test/fee-policy.test.ts
DELETED
|
@@ -1,228 +0,0 @@
|
|
|
1
|
-
import { expect, test } from 'vitest'
|
|
2
|
-
|
|
3
|
-
import { FeePolicy } from '../src/model/fee-policy'
|
|
4
|
-
import {
|
|
5
|
-
MAKER_DEFAULT_POLICY,
|
|
6
|
-
TAKER_DEFAULT_POLICY,
|
|
7
|
-
} from '../src/constants/fee'
|
|
8
|
-
|
|
9
|
-
import { publicClient } from './utils/constants'
|
|
10
|
-
|
|
11
|
-
const _abi = [
|
|
12
|
-
{
|
|
13
|
-
inputs: [],
|
|
14
|
-
name: 'InvalidFeePolicy',
|
|
15
|
-
type: 'error',
|
|
16
|
-
},
|
|
17
|
-
{
|
|
18
|
-
inputs: [
|
|
19
|
-
{
|
|
20
|
-
internalType: 'FeePolicy',
|
|
21
|
-
name: 'self',
|
|
22
|
-
type: 'uint24',
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
internalType: 'uint256',
|
|
26
|
-
name: 'amount',
|
|
27
|
-
type: 'uint256',
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
internalType: 'bool',
|
|
31
|
-
name: 'reverseRounding',
|
|
32
|
-
type: 'bool',
|
|
33
|
-
},
|
|
34
|
-
],
|
|
35
|
-
name: 'calculateFee',
|
|
36
|
-
outputs: [
|
|
37
|
-
{
|
|
38
|
-
internalType: 'int256',
|
|
39
|
-
name: 'fee',
|
|
40
|
-
type: 'int256',
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
stateMutability: 'pure',
|
|
44
|
-
type: 'function',
|
|
45
|
-
},
|
|
46
|
-
{
|
|
47
|
-
inputs: [
|
|
48
|
-
{
|
|
49
|
-
internalType: 'FeePolicy',
|
|
50
|
-
name: 'self',
|
|
51
|
-
type: 'uint24',
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
internalType: 'uint256',
|
|
55
|
-
name: 'amount',
|
|
56
|
-
type: 'uint256',
|
|
57
|
-
},
|
|
58
|
-
{
|
|
59
|
-
internalType: 'bool',
|
|
60
|
-
name: 'reverseFee',
|
|
61
|
-
type: 'bool',
|
|
62
|
-
},
|
|
63
|
-
],
|
|
64
|
-
name: 'calculateOriginalAmount',
|
|
65
|
-
outputs: [
|
|
66
|
-
{
|
|
67
|
-
internalType: 'uint256',
|
|
68
|
-
name: 'originalAmount',
|
|
69
|
-
type: 'uint256',
|
|
70
|
-
},
|
|
71
|
-
],
|
|
72
|
-
stateMutability: 'pure',
|
|
73
|
-
type: 'function',
|
|
74
|
-
},
|
|
75
|
-
{
|
|
76
|
-
inputs: [
|
|
77
|
-
{
|
|
78
|
-
internalType: 'bool',
|
|
79
|
-
name: 'usesQuote_',
|
|
80
|
-
type: 'bool',
|
|
81
|
-
},
|
|
82
|
-
{
|
|
83
|
-
internalType: 'int24',
|
|
84
|
-
name: 'rate_',
|
|
85
|
-
type: 'int24',
|
|
86
|
-
},
|
|
87
|
-
],
|
|
88
|
-
name: 'encode',
|
|
89
|
-
outputs: [
|
|
90
|
-
{
|
|
91
|
-
internalType: 'FeePolicy',
|
|
92
|
-
name: 'feePolicy',
|
|
93
|
-
type: 'uint24',
|
|
94
|
-
},
|
|
95
|
-
],
|
|
96
|
-
stateMutability: 'pure',
|
|
97
|
-
type: 'function',
|
|
98
|
-
},
|
|
99
|
-
{
|
|
100
|
-
inputs: [
|
|
101
|
-
{
|
|
102
|
-
internalType: 'FeePolicy',
|
|
103
|
-
name: 'self',
|
|
104
|
-
type: 'uint24',
|
|
105
|
-
},
|
|
106
|
-
],
|
|
107
|
-
name: 'usesQuote',
|
|
108
|
-
outputs: [
|
|
109
|
-
{
|
|
110
|
-
internalType: 'bool',
|
|
111
|
-
name: 'f',
|
|
112
|
-
type: 'bool',
|
|
113
|
-
},
|
|
114
|
-
],
|
|
115
|
-
stateMutability: 'pure',
|
|
116
|
-
type: 'function',
|
|
117
|
-
},
|
|
118
|
-
] as const
|
|
119
|
-
|
|
120
|
-
const FEE_POLICY_WRAPPER_ADDRESS = '0x226Dad19a0C0E0faEB488601B61B1B67E434db6a'
|
|
121
|
-
|
|
122
|
-
const encode = async (usesQuote: boolean, rate: number) => {
|
|
123
|
-
const mockPolicy = new FeePolicy(usesQuote, BigInt(rate))
|
|
124
|
-
const policy = await publicClient.readContract({
|
|
125
|
-
address: FEE_POLICY_WRAPPER_ADDRESS,
|
|
126
|
-
abi: _abi,
|
|
127
|
-
functionName: 'encode',
|
|
128
|
-
args: [usesQuote, rate],
|
|
129
|
-
})
|
|
130
|
-
expect(policy).toEqual(Number(mockPolicy.value))
|
|
131
|
-
expect(
|
|
132
|
-
await publicClient.readContract({
|
|
133
|
-
address: FEE_POLICY_WRAPPER_ADDRESS,
|
|
134
|
-
abi: _abi,
|
|
135
|
-
functionName: 'usesQuote',
|
|
136
|
-
args: [policy],
|
|
137
|
-
}),
|
|
138
|
-
).toEqual(mockPolicy.usesQuote)
|
|
139
|
-
}
|
|
140
|
-
|
|
141
|
-
const checkCalculateFee = async (
|
|
142
|
-
policy: FeePolicy,
|
|
143
|
-
amount: bigint,
|
|
144
|
-
reverseRounding: boolean,
|
|
145
|
-
) => {
|
|
146
|
-
expect(
|
|
147
|
-
await publicClient.readContract({
|
|
148
|
-
address: FEE_POLICY_WRAPPER_ADDRESS,
|
|
149
|
-
abi: _abi,
|
|
150
|
-
functionName: 'calculateFee',
|
|
151
|
-
args: [Number(policy.value), amount, reverseRounding],
|
|
152
|
-
}),
|
|
153
|
-
).toEqual(policy.calculateFee(amount, reverseRounding))
|
|
154
|
-
}
|
|
155
|
-
|
|
156
|
-
const checkCalculateOriginalAmount = async (
|
|
157
|
-
policy: FeePolicy,
|
|
158
|
-
amount: bigint,
|
|
159
|
-
reverseFee: boolean,
|
|
160
|
-
) => {
|
|
161
|
-
expect(
|
|
162
|
-
await publicClient.readContract({
|
|
163
|
-
address: FEE_POLICY_WRAPPER_ADDRESS,
|
|
164
|
-
abi: _abi,
|
|
165
|
-
functionName: 'calculateOriginalAmount',
|
|
166
|
-
args: [Number(policy.value), amount, reverseFee],
|
|
167
|
-
}),
|
|
168
|
-
).toEqual(policy.calculateOriginalAmount(amount, reverseFee))
|
|
169
|
-
}
|
|
170
|
-
|
|
171
|
-
const checkFrom = async (policy: FeePolicy) => {
|
|
172
|
-
const _feePolicy = FeePolicy.from(policy.value)
|
|
173
|
-
expect(policy.usesQuote).toEqual(_feePolicy.usesQuote)
|
|
174
|
-
expect(policy.value).toEqual(_feePolicy.value)
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
test('check encode function', async () => {
|
|
178
|
-
await encode(true, 0)
|
|
179
|
-
await encode(true, 1)
|
|
180
|
-
await encode(true, Number(MAKER_DEFAULT_POLICY.rate))
|
|
181
|
-
await encode(true, Number(TAKER_DEFAULT_POLICY.rate))
|
|
182
|
-
await encode(true, 500000)
|
|
183
|
-
await encode(true, -500000)
|
|
184
|
-
await encode(false, 0)
|
|
185
|
-
await encode(false, 1)
|
|
186
|
-
await encode(false, 500000)
|
|
187
|
-
await encode(false, -500000)
|
|
188
|
-
await encode(false, Number(MAKER_DEFAULT_POLICY.rate))
|
|
189
|
-
await encode(false, Number(TAKER_DEFAULT_POLICY.rate))
|
|
190
|
-
})
|
|
191
|
-
|
|
192
|
-
test('check calculateFee function', async () => {
|
|
193
|
-
await checkCalculateFee(new FeePolicy(true, 0n), 1000000n, false)
|
|
194
|
-
await checkCalculateFee(new FeePolicy(true, 1n), 1000000n, false)
|
|
195
|
-
await checkCalculateFee(MAKER_DEFAULT_POLICY, 1000000n, false)
|
|
196
|
-
await checkCalculateFee(TAKER_DEFAULT_POLICY, 1000000n, false)
|
|
197
|
-
await checkCalculateFee(new FeePolicy(true, 500000n), 1000000n, false)
|
|
198
|
-
await checkCalculateFee(new FeePolicy(true, -500000n), 1000000n, false)
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
test('check calculateOriginalAmount function', async () => {
|
|
202
|
-
await checkCalculateOriginalAmount(new FeePolicy(true, 0n), 1000000n, false)
|
|
203
|
-
await checkCalculateOriginalAmount(new FeePolicy(true, 1n), 1000000n, false)
|
|
204
|
-
await checkCalculateOriginalAmount(MAKER_DEFAULT_POLICY, 1000000n, false)
|
|
205
|
-
await checkCalculateOriginalAmount(TAKER_DEFAULT_POLICY, 1000000n, false)
|
|
206
|
-
await checkCalculateOriginalAmount(
|
|
207
|
-
new FeePolicy(true, 500000n),
|
|
208
|
-
1000000n,
|
|
209
|
-
false,
|
|
210
|
-
)
|
|
211
|
-
await checkCalculateOriginalAmount(
|
|
212
|
-
new FeePolicy(true, -500000n),
|
|
213
|
-
1000000n,
|
|
214
|
-
false,
|
|
215
|
-
)
|
|
216
|
-
})
|
|
217
|
-
|
|
218
|
-
test('check static object', async () => {
|
|
219
|
-
checkFrom(new FeePolicy(true, 0n))
|
|
220
|
-
checkFrom(new FeePolicy(true, 1n))
|
|
221
|
-
checkFrom(MAKER_DEFAULT_POLICY)
|
|
222
|
-
checkFrom(TAKER_DEFAULT_POLICY)
|
|
223
|
-
|
|
224
|
-
checkFrom(new FeePolicy(false, 0n))
|
|
225
|
-
checkFrom(new FeePolicy(false, 1n))
|
|
226
|
-
checkFrom(MAKER_DEFAULT_POLICY)
|
|
227
|
-
checkFrom(TAKER_DEFAULT_POLICY)
|
|
228
|
-
})
|