@kuestcom/clob-client 5.8.1 → 6.0.0
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 +14 -10
- package/dist/client.d.ts +14 -5
- package/dist/client.js +134 -43
- package/dist/client.js.map +1 -1
- package/dist/config.d.ts +1 -1
- package/dist/config.js +11 -11
- package/dist/config.js.map +1 -1
- package/dist/endpoints.d.ts +3 -1
- package/dist/endpoints.js +4 -1
- package/dist/endpoints.js.map +1 -1
- package/dist/order-builder/builder.js +6 -5
- package/dist/order-builder/builder.js.map +1 -1
- package/dist/order-builder/helpers.d.ts +1 -1
- package/dist/order-builder/helpers.js +25 -59
- package/dist/order-builder/helpers.js.map +1 -1
- package/dist/order-utils/exchange.order.builder.d.ts +2 -1
- package/dist/order-utils/exchange.order.builder.js +103 -22
- package/dist/order-utils/exchange.order.builder.js.map +1 -1
- package/dist/order-utils/exchange.order.const.d.ts +2 -1
- package/dist/order-utils/exchange.order.const.js +5 -5
- package/dist/order-utils/exchange.order.const.js.map +1 -1
- package/dist/order-utils/model/eip712.model.d.ts +1 -1
- package/dist/order-utils/model/order.model.d.ts +22 -23
- package/dist/order-utils/model/signature-types.model.d.ts +2 -10
- package/dist/order-utils/model/signature-types.model.js +2 -10
- package/dist/order-utils/model/signature-types.model.js.map +1 -1
- package/dist/rfq-client.js +3 -0
- package/dist/rfq-client.js.map +1 -1
- package/dist/site-config.d.ts +13 -0
- package/dist/site-config.js +18 -0
- package/dist/site-config.js.map +1 -0
- package/dist/types.d.ts +65 -24
- package/dist/types.js.map +1 -1
- package/dist/utilities.d.ts +2 -0
- package/dist/utilities.js +38 -4
- package/dist/utilities.js.map +1 -1
- package/package.json +2 -2
package/dist/config.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
const AMOY_CONTRACTS = {
|
|
2
|
-
exchange: "
|
|
3
|
-
negRiskAdapter: "
|
|
4
|
-
negRiskExchange: "
|
|
5
|
-
collateral: "
|
|
6
|
-
conditionalTokens: "
|
|
2
|
+
exchange: "0x4bB1871fdaE80331ce5fF87547b8ff886D1695a5",
|
|
3
|
+
negRiskAdapter: "0xd9416E904e1ab925ad72F03F6D6ce0Aa80fd2dC5",
|
|
4
|
+
negRiskExchange: "0xdb1E374a05130d7DE3F16677066553F225D2eE53",
|
|
5
|
+
collateral: "0x41E94Eb019C0762f9Bfcf9Fb1E58725BfB0e7582",
|
|
6
|
+
conditionalTokens: "0x4682048725865bf17067bd85fF518527A262A9C7",
|
|
7
7
|
};
|
|
8
8
|
const MATIC_CONTRACTS = {
|
|
9
|
-
exchange: "
|
|
10
|
-
negRiskAdapter: "
|
|
11
|
-
negRiskExchange: "
|
|
12
|
-
collateral: "
|
|
13
|
-
conditionalTokens: "
|
|
9
|
+
exchange: "0x4bB1871fdaE80331ce5fF87547b8ff886D1695a5",
|
|
10
|
+
negRiskAdapter: "0xd9416E904e1ab925ad72F03F6D6ce0Aa80fd2dC5",
|
|
11
|
+
negRiskExchange: "0xdb1E374a05130d7DE3F16677066553F225D2eE53",
|
|
12
|
+
collateral: "0x3c499c542cef5e3811e1192ce70d8cc03d5c3359",
|
|
13
|
+
conditionalTokens: "0x4682048725865bf17067bd85fF518527A262A9C7",
|
|
14
14
|
};
|
|
15
15
|
const COLLATERAL_TOKEN_DECIMALS = 6;
|
|
16
16
|
const CONDITIONAL_TOKEN_DECIMALS = 6;
|
|
@@ -24,5 +24,5 @@ const getContractConfig = (chainID) => {
|
|
|
24
24
|
throw new Error("Invalid network");
|
|
25
25
|
}
|
|
26
26
|
};
|
|
27
|
-
export {
|
|
27
|
+
export { COLLATERAL_TOKEN_DECIMALS, CONDITIONAL_TOKEN_DECIMALS, getContractConfig };
|
|
28
28
|
//# sourceMappingURL=config.js.map
|
package/dist/config.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":"AAQA,MAAM,cAAc,GAA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1D,QAAQ,OAAO,EAAE,CAAC;QACd,KAAK,GAAG;YACJ,OAAO,eAAe,CAAC;QAC3B,KAAK,KAAK;YACN,OAAO,cAAc,CAAC;QAC1B;YACI,MAAM,IAAI,KAAK,CAAC,iBAAiB,CAAC,CAAC;IAC3C,CAAC;AACL,CAAC,CAAC;AAGF,OAAO,EAAE,yBAAyB,EAAE,0BAA0B,EAAE,iBAAiB,EAAE,CAAC"}
|
package/dist/endpoints.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export declare const TIME = "/time";
|
|
2
|
+
export declare const VERSION = "/version";
|
|
2
3
|
export declare const CREATE_API_KEY = "/auth/api-key";
|
|
3
4
|
export declare const GET_API_KEYS = "/auth/api-keys";
|
|
4
5
|
export declare const DELETE_API_KEY = "/auth/api-key";
|
|
@@ -16,6 +17,7 @@ export declare const GET_SAMPLING_MARKETS = "/sampling-markets";
|
|
|
16
17
|
export declare const GET_SIMPLIFIED_MARKETS = "/simplified-markets";
|
|
17
18
|
export declare const GET_MARKETS = "/markets";
|
|
18
19
|
export declare const GET_MARKET = "/markets/";
|
|
20
|
+
export declare const GET_CLOB_MARKET = "/clob-markets/";
|
|
19
21
|
export declare const GET_ORDER_BOOK = "/book";
|
|
20
22
|
export declare const GET_ORDER_BOOKS = "/books";
|
|
21
23
|
export declare const GET_MIDPOINT = "/midpoint";
|
|
@@ -28,7 +30,6 @@ export declare const GET_LAST_TRADE_PRICE = "/last-trade-price";
|
|
|
28
30
|
export declare const GET_LAST_TRADES_PRICES = "/last-trades-prices";
|
|
29
31
|
export declare const GET_TICK_SIZE = "/tick-size";
|
|
30
32
|
export declare const GET_NEG_RISK = "/neg-risk";
|
|
31
|
-
export declare const GET_FEE_RATE = "/fee-rate";
|
|
32
33
|
export declare const POST_ORDER = "/order";
|
|
33
34
|
export declare const POST_ORDERS = "/orders";
|
|
34
35
|
export declare const CANCEL_ORDER = "/order";
|
|
@@ -53,6 +54,7 @@ export declare const GET_REWARDS_MARKETS_CURRENT = "/rewards/markets/current";
|
|
|
53
54
|
export declare const GET_REWARDS_MARKETS = "/rewards/markets/";
|
|
54
55
|
export declare const GET_REWARDS_EARNINGS_PERCENTAGES = "/rewards/user/markets";
|
|
55
56
|
export declare const GET_BUILDER_TRADES = "/builder/trades";
|
|
57
|
+
export declare const GET_BUILDER_FEES = "/fees/builder-fees/";
|
|
56
58
|
export declare const POST_HEARTBEAT = "/v1/heartbeats";
|
|
57
59
|
export declare const CREATE_RFQ_REQUEST = "/rfq/request";
|
|
58
60
|
export declare const CANCEL_RFQ_REQUEST = "/rfq/request";
|
package/dist/endpoints.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
// Server Time
|
|
2
2
|
export const TIME = "/time";
|
|
3
|
+
export const VERSION = "/version";
|
|
3
4
|
// API Key endpoints
|
|
4
5
|
export const CREATE_API_KEY = "/auth/api-key";
|
|
5
6
|
export const GET_API_KEYS = "/auth/api-keys";
|
|
@@ -21,6 +22,7 @@ export const GET_SAMPLING_MARKETS = "/sampling-markets";
|
|
|
21
22
|
export const GET_SIMPLIFIED_MARKETS = "/simplified-markets";
|
|
22
23
|
export const GET_MARKETS = "/markets";
|
|
23
24
|
export const GET_MARKET = "/markets/";
|
|
25
|
+
export const GET_CLOB_MARKET = "/clob-markets/";
|
|
24
26
|
export const GET_ORDER_BOOK = "/book";
|
|
25
27
|
export const GET_ORDER_BOOKS = "/books";
|
|
26
28
|
export const GET_MIDPOINT = "/midpoint";
|
|
@@ -33,7 +35,6 @@ export const GET_LAST_TRADE_PRICE = "/last-trade-price";
|
|
|
33
35
|
export const GET_LAST_TRADES_PRICES = "/last-trades-prices";
|
|
34
36
|
export const GET_TICK_SIZE = "/tick-size";
|
|
35
37
|
export const GET_NEG_RISK = "/neg-risk";
|
|
36
|
-
export const GET_FEE_RATE = "/fee-rate";
|
|
37
38
|
// Order endpoints
|
|
38
39
|
export const POST_ORDER = "/order";
|
|
39
40
|
export const POST_ORDERS = "/orders";
|
|
@@ -65,6 +66,8 @@ export const GET_REWARDS_MARKETS = "/rewards/markets/";
|
|
|
65
66
|
export const GET_REWARDS_EARNINGS_PERCENTAGES = "/rewards/user/markets";
|
|
66
67
|
// Builder endpoints
|
|
67
68
|
export const GET_BUILDER_TRADES = "/builder/trades";
|
|
69
|
+
// Fees
|
|
70
|
+
export const GET_BUILDER_FEES = "/fees/builder-fees/";
|
|
68
71
|
// Heartbeats
|
|
69
72
|
export const POST_HEARTBEAT = "/v1/heartbeats";
|
|
70
73
|
// RFQ
|
package/dist/endpoints.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../src/endpoints.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,MAAM,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC;
|
|
1
|
+
{"version":3,"file":"endpoints.js","sourceRoot":"","sources":["../src/endpoints.ts"],"names":[],"mappings":"AAAA,cAAc;AACd,MAAM,CAAC,MAAM,IAAI,GAAG,OAAO,CAAC;AAC5B,MAAM,CAAC,MAAM,OAAO,GAAG,UAAU,CAAC;AAElC,oBAAoB;AACpB,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAC9C,MAAM,CAAC,MAAM,YAAY,GAAG,gBAAgB,CAAC;AAC7C,MAAM,CAAC,MAAM,cAAc,GAAG,eAAe,CAAC;AAC9C,MAAM,CAAC,MAAM,cAAc,GAAG,sBAAsB,CAAC;AACrD,MAAM,CAAC,MAAM,WAAW,GAAG,8BAA8B,CAAC;AAE1D,6BAA6B;AAC7B,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AAChE,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAC/D,MAAM,CAAC,MAAM,uBAAuB,GAAG,wBAAwB,CAAC;AAChE,MAAM,CAAC,MAAM,yBAAyB,GAAG,iCAAiC,CAAC;AAE3E,4BAA4B;AAC5B,MAAM,CAAC,MAAM,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a;AACb,MAAM,CAAC,MAAM,cAAc,GAAG,gBAAgB,CAAC;AAE/C,MAAM;AACN,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AACjD,MAAM,CAAC,MAAM,kBAAkB,GAAG,cAAc,CAAC;AACjD,MAAM,CAAC,MAAM,gBAAgB,GAAG,oBAAoB,CAAC;AACrD,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAC7C,MAAM,CAAC,MAAM,gBAAgB,GAAG,YAAY,CAAC;AAC7C,MAAM,CAAC,MAAM,mBAAmB,GAAG,qBAAqB,CAAC;AACzD,MAAM,CAAC,MAAM,iBAAiB,GAAG,oBAAoB,CAAC;AACtD,MAAM,CAAC,MAAM,wBAAwB,GAAG,4BAA4B,CAAC;AACrE,MAAM,CAAC,MAAM,qBAAqB,GAAG,yBAAyB,CAAC;AAC/D,MAAM,CAAC,MAAM,kBAAkB,GAAG,sBAAsB,CAAC;AACzD,MAAM,CAAC,MAAM,UAAU,GAAG,aAAa,CAAC"}
|
|
@@ -3,11 +3,9 @@ import { createMarketOrder, createOrder } from "./helpers.js";
|
|
|
3
3
|
export class OrderBuilder {
|
|
4
4
|
signer;
|
|
5
5
|
chainId;
|
|
6
|
-
//
|
|
6
|
+
// Kuest only supports Deposit Wallet order signatures.
|
|
7
7
|
signatureType;
|
|
8
|
-
//
|
|
9
|
-
// Used for Kuest proxy wallets and other smart contract wallets
|
|
10
|
-
// If not provided, funderAddress is the signer address
|
|
8
|
+
// Deposit Wallet address that holds funds and appears as order maker.
|
|
11
9
|
funderAddress;
|
|
12
10
|
/**
|
|
13
11
|
* Optional function to dynamically resolve the signer.
|
|
@@ -20,7 +18,10 @@ export class OrderBuilder {
|
|
|
20
18
|
constructor(signer, chainId, signatureType, funderAddress, getSigner) {
|
|
21
19
|
this.signer = signer;
|
|
22
20
|
this.chainId = chainId;
|
|
23
|
-
this.signatureType = signatureType
|
|
21
|
+
this.signatureType = signatureType ?? SignatureType.DEPOSIT_WALLET;
|
|
22
|
+
if (this.signatureType !== SignatureType.DEPOSIT_WALLET) {
|
|
23
|
+
throw new Error("Kuest order flow supports only Deposit Wallet signature type 3");
|
|
24
|
+
}
|
|
24
25
|
this.funderAddress = funderAddress;
|
|
25
26
|
this.getSigner = getSigner;
|
|
26
27
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/order-builder/builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,OAAO,YAAY;IACZ,MAAM,CAAa;IAEnB,OAAO,CAAQ;IAExB,
|
|
1
|
+
{"version":3,"file":"builder.js","sourceRoot":"","sources":["../../src/order-builder/builder.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAGxD,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE9D,MAAM,OAAO,YAAY;IACZ,MAAM,CAAa;IAEnB,OAAO,CAAQ;IAExB,uDAAuD;IAC9C,aAAa,CAAgB;IAEtC,sEAAsE;IAC7D,aAAa,CAAU;IAEhC;;;;;;OAMG;IACK,SAAS,CAA0C;IAE3D,YACI,MAAkB,EAClB,OAAc,EACd,aAA6B,EAC7B,aAAsB,EACtB,SAAkD;QAElD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,aAAa,GAAG,aAAa,IAAI,aAAa,CAAC,cAAc,CAAC;QACnE,IAAI,IAAI,CAAC,aAAa,KAAK,aAAa,CAAC,cAAc,EAAE,CAAC;YACtD,MAAM,IAAI,KAAK,CAAC,gEAAgE,CAAC,CAAC;QACtF,CAAC;QACD,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;IAC/B,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,UAAU,CACnB,SAAoB,EACpB,OAA2B;QAE3B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAC1C,OAAO,WAAW,CACd,MAAM,EACN,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,aAAa,EAClB,SAAS,EACT,OAAO,CACV,CAAC;IACN,CAAC;IAED;;OAEG;IACI,KAAK,CAAC,gBAAgB,CACzB,eAAgC,EAChC,OAA2B;QAE3B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC;QAC1C,OAAO,iBAAiB,CACpB,MAAM,EACN,IAAI,CAAC,OAAO,EACZ,IAAI,CAAC,aAAa,EAClB,IAAI,CAAC,aAAa,EAClB,eAAe,EACf,OAAO,CACV,CAAC;IACN,CAAC;IAED,oDAAoD;IAC5C,KAAK,CAAC,aAAa;QACvB,IAAI,IAAI,CAAC,SAAS,EAAE,CAAC;YACjB,MAAM,CAAC,GAAG,MAAM,IAAI,CAAC,SAAS,EAAE,CAAC;YACjC,IAAI,CAAC,CAAC;gBAAE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAC;YAC3E,OAAO,CAAC,CAAC;QACb,CAAC;QACD,OAAO,IAAI,CAAC,MAAM,CAAC;IACvB,CAAC;CACJ"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import type { OrderData, SignedOrder } from "../order-utils/index.ts";
|
|
2
|
-
import {
|
|
2
|
+
import { SignatureType, Side as UtilsSide } from "../order-utils/index.ts";
|
|
3
3
|
import type { ClobSigner } from "../signer.ts";
|
|
4
4
|
import type { Chain, CreateOrderOptions, OrderSummary, RoundConfig, TickSize, UserMarketOrder, UserOrder } from "../types.ts";
|
|
5
5
|
import { OrderType, Side } from "../types.ts";
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { parseUnits } from "viem";
|
|
2
2
|
import { COLLATERAL_TOKEN_DECIMALS, getContractConfig } from "../config.js";
|
|
3
|
-
import {
|
|
4
|
-
import {
|
|
3
|
+
import { ZERO_BYTES32 } from "../order-utils/exchange.order.const.js";
|
|
4
|
+
import { ExchangeOrderBuilder, SignatureType, Side as UtilsSide } from "../order-utils/index.js";
|
|
5
5
|
import { OrderType, Side } from "../types.js";
|
|
6
|
-
import { decimalPlaces, roundDown, roundNormal, roundUp } from "../utilities.js";
|
|
6
|
+
import { builderCodeToBytes32, decimalPlaces, roundDown, roundNormal, roundUp, } from "../utilities.js";
|
|
7
7
|
export const ROUNDING_CONFIG = {
|
|
8
8
|
"0.1": {
|
|
9
9
|
price: 1,
|
|
@@ -78,47 +78,30 @@ export const buildOrderCreationArgs = async (signer, maker, signatureType, userO
|
|
|
78
78
|
const { side, rawMakerAmt, rawTakerAmt } = getOrderRawAmounts(userOrder.side, userOrder.size, userOrder.price, roundConfig);
|
|
79
79
|
const makerAmount = parseUnits(rawMakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();
|
|
80
80
|
const takerAmount = parseUnits(rawTakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();
|
|
81
|
-
let taker;
|
|
82
|
-
if (typeof userOrder.taker !== "undefined" && userOrder.taker) {
|
|
83
|
-
taker = userOrder.taker;
|
|
84
|
-
}
|
|
85
|
-
else {
|
|
86
|
-
taker = "0x0000000000000000000000000000000000000000";
|
|
87
|
-
}
|
|
88
|
-
let feeRateBps;
|
|
89
|
-
if (typeof userOrder.feeRateBps !== "undefined" && userOrder.feeRateBps) {
|
|
90
|
-
feeRateBps = userOrder.feeRateBps.toString();
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
feeRateBps = "0";
|
|
94
|
-
}
|
|
95
|
-
let nonce;
|
|
96
|
-
if (typeof userOrder.nonce !== "undefined" && userOrder.nonce) {
|
|
97
|
-
nonce = userOrder.nonce.toString();
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
nonce = "0";
|
|
101
|
-
}
|
|
102
81
|
return {
|
|
103
82
|
maker,
|
|
104
|
-
taker,
|
|
105
83
|
tokenId: userOrder.tokenID,
|
|
106
84
|
makerAmount,
|
|
107
85
|
takerAmount,
|
|
108
86
|
side,
|
|
109
|
-
feeRateBps,
|
|
110
|
-
nonce,
|
|
111
87
|
signer,
|
|
112
88
|
expiration: (userOrder.expiration || 0).toString(),
|
|
89
|
+
timestamp: Date.now().toString(),
|
|
90
|
+
metadata: userOrder.metadata ?? ZERO_BYTES32,
|
|
91
|
+
builder: builderCodeToBytes32(userOrder.builderCode),
|
|
113
92
|
signatureType,
|
|
114
93
|
};
|
|
115
94
|
};
|
|
116
95
|
export const createOrder = async (eoaSigner, chainId, signatureType, funderAddress, userOrder, options) => {
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
96
|
+
if (signatureType !== SignatureType.DEPOSIT_WALLET) {
|
|
97
|
+
throw new Error("Kuest order flow supports only Deposit Wallet signature type 3");
|
|
98
|
+
}
|
|
99
|
+
if (!funderAddress) {
|
|
100
|
+
throw new Error("Deposit Wallet funder address is required for Kuest orders");
|
|
101
|
+
}
|
|
102
|
+
const maker = funderAddress;
|
|
120
103
|
const contractConfig = getContractConfig(chainId);
|
|
121
|
-
const orderData = await buildOrderCreationArgs(
|
|
104
|
+
const orderData = await buildOrderCreationArgs(maker, maker, signatureType, userOrder, ROUNDING_CONFIG[options.tickSize]);
|
|
122
105
|
const exchangeContract = options.negRisk
|
|
123
106
|
? contractConfig.negRiskExchange
|
|
124
107
|
: contractConfig.exchange;
|
|
@@ -163,47 +146,30 @@ export const buildMarketOrderCreationArgs = async (signer, maker, signatureType,
|
|
|
163
146
|
const { side, rawMakerAmt, rawTakerAmt } = getMarketOrderRawAmounts(userMarketOrder.side, userMarketOrder.amount, userMarketOrder.price || 1, roundConfig);
|
|
164
147
|
const makerAmount = parseUnits(rawMakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();
|
|
165
148
|
const takerAmount = parseUnits(rawTakerAmt.toString(), COLLATERAL_TOKEN_DECIMALS).toString();
|
|
166
|
-
let taker;
|
|
167
|
-
if (typeof userMarketOrder.taker !== "undefined" && userMarketOrder.taker) {
|
|
168
|
-
taker = userMarketOrder.taker;
|
|
169
|
-
}
|
|
170
|
-
else {
|
|
171
|
-
taker = "0x0000000000000000000000000000000000000000";
|
|
172
|
-
}
|
|
173
|
-
let feeRateBps;
|
|
174
|
-
if (typeof userMarketOrder.feeRateBps !== "undefined" && userMarketOrder.feeRateBps) {
|
|
175
|
-
feeRateBps = userMarketOrder.feeRateBps.toString();
|
|
176
|
-
}
|
|
177
|
-
else {
|
|
178
|
-
feeRateBps = "0";
|
|
179
|
-
}
|
|
180
|
-
let nonce;
|
|
181
|
-
if (typeof userMarketOrder.nonce !== "undefined" && userMarketOrder.nonce) {
|
|
182
|
-
nonce = userMarketOrder.nonce.toString();
|
|
183
|
-
}
|
|
184
|
-
else {
|
|
185
|
-
nonce = "0";
|
|
186
|
-
}
|
|
187
149
|
return {
|
|
188
150
|
maker,
|
|
189
|
-
taker,
|
|
190
151
|
tokenId: userMarketOrder.tokenID,
|
|
191
152
|
makerAmount,
|
|
192
153
|
takerAmount,
|
|
193
154
|
side,
|
|
194
|
-
feeRateBps,
|
|
195
|
-
nonce,
|
|
196
155
|
signer,
|
|
197
156
|
expiration: "0",
|
|
157
|
+
timestamp: Date.now().toString(),
|
|
158
|
+
metadata: userMarketOrder.metadata ?? ZERO_BYTES32,
|
|
159
|
+
builder: builderCodeToBytes32(userMarketOrder.builderCode),
|
|
198
160
|
signatureType,
|
|
199
161
|
};
|
|
200
162
|
};
|
|
201
163
|
export const createMarketOrder = async (eoaSigner, chainId, signatureType, funderAddress, userMarketOrder, options) => {
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
164
|
+
if (signatureType !== SignatureType.DEPOSIT_WALLET) {
|
|
165
|
+
throw new Error("Kuest order flow supports only Deposit Wallet signature type 3");
|
|
166
|
+
}
|
|
167
|
+
if (!funderAddress) {
|
|
168
|
+
throw new Error("Deposit Wallet funder address is required for Kuest orders");
|
|
169
|
+
}
|
|
170
|
+
const maker = funderAddress;
|
|
205
171
|
const contractConfig = getContractConfig(chainId);
|
|
206
|
-
const orderData = await buildMarketOrderCreationArgs(
|
|
172
|
+
const orderData = await buildMarketOrderCreationArgs(maker, maker, signatureType, userMarketOrder, ROUNDING_CONFIG[options.tickSize]);
|
|
207
173
|
const exchangeContract = options.negRisk
|
|
208
174
|
? contractConfig.negRiskExchange
|
|
209
175
|
: contractConfig.exchange;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/order-builder/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;
|
|
1
|
+
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/order-builder/helpers.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAClC,OAAO,EAAE,yBAAyB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AAC5E,OAAO,EAAE,YAAY,EAAE,MAAM,wCAAwC,CAAC;AAEtE,OAAO,EAAE,oBAAoB,EAAE,aAAa,EAAE,IAAI,IAAI,SAAS,EAAE,MAAM,yBAAyB,CAAC;AAWjG,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,aAAa,CAAC;AAC9C,OAAO,EACH,oBAAoB,EACpB,aAAa,EACb,SAAS,EACT,WAAW,EACX,OAAO,GACV,MAAM,iBAAiB,CAAC;AAEzB,MAAM,CAAC,MAAM,eAAe,GAAkC;IAC1D,KAAK,EAAE;QACH,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,CAAC;KACZ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M,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC,CAAC;AAEF;;;;;GAKG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,CACpC,SAAyB,EACzB,aAAqB,EACrB,SAAoB,EACtB,EAAE;IACA,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IACD,IAAI,GAAG,GAAG,CAAC,CAAC;IACZ;;;;;;;;MAQE;IACF,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE,CAAC;QAC7C,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QACvB,GAAG,IAAI,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACjC,IAAI,GAAG,IAAI,aAAa,EAAE,CAAC;YACvB,OAAO,MAAM,CAAC,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;QACtC,CAAC;IACL,CAAC;IACD,IAAI,SAAS,KAAK,SAAS,CAAC,GAAG,EAAE,CAAC;QAC9B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;IAChC,CAAC;IACD,OAAO,MAAM,CAAC,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AACjD,CAAC,CAAC"}
|
|
@@ -7,6 +7,7 @@ export declare class ExchangeOrderBuilder {
|
|
|
7
7
|
private readonly chainId;
|
|
8
8
|
private readonly signer;
|
|
9
9
|
private readonly generateSalt;
|
|
10
|
+
private readonly appDomainSeparator;
|
|
10
11
|
constructor(contractAddress: string, chainId: number, signer: ClobSigner, generateSalt?: typeof generateOrderSalt);
|
|
11
12
|
/**
|
|
12
13
|
* Build an order object including the signature.
|
|
@@ -15,7 +16,7 @@ export declare class ExchangeOrderBuilder {
|
|
|
15
16
|
/**
|
|
16
17
|
* Creates an Order object from order data.
|
|
17
18
|
*/
|
|
18
|
-
buildOrder({ maker,
|
|
19
|
+
buildOrder({ maker, tokenId, makerAmount, takerAmount, side, signer, expiration, timestamp, metadata, builder, signatureType, }: OrderData): Promise<Order>;
|
|
19
20
|
/**
|
|
20
21
|
* Parses an Order object to EIP712 typed data.
|
|
21
22
|
*/
|
|
@@ -1,18 +1,45 @@
|
|
|
1
|
-
import { hashTypedData } from "viem";
|
|
2
|
-
import {
|
|
3
|
-
import { EIP712_DOMAIN, ORDER_STRUCTURE, PROTOCOL_NAME, PROTOCOL_VERSION, } from "./exchange.order.const.js";
|
|
1
|
+
import { encodeAbiParameters, hashTypedData, keccak256, toHex } from "viem";
|
|
2
|
+
import { signTypedDataWithSigner } from "../signer.js";
|
|
3
|
+
import { EIP712_DOMAIN, ORDER_STRUCTURE, PROTOCOL_NAME, PROTOCOL_VERSION, ZERO_BYTES32, } from "./exchange.order.const.js";
|
|
4
4
|
import { SignatureType } from "./model/signature-types.model.js";
|
|
5
5
|
import { generateOrderSalt } from "./utils.js";
|
|
6
|
+
const ORDER_TYPE_STRING = "Order(uint256 salt,address maker,address signer,uint256 tokenId,uint256 makerAmount,uint256 takerAmount,uint8 side,uint8 signatureType,uint256 timestamp,bytes32 metadata,bytes32 builder)";
|
|
7
|
+
const ORDER_TYPE_HASH = keccak256(toHex(ORDER_TYPE_STRING));
|
|
8
|
+
const DOMAIN_TYPE_HASH = keccak256(toHex("EIP712Domain(string name,string version,uint256 chainId,address verifyingContract)"));
|
|
9
|
+
const TYPED_DATA_SIGN_STRUCT = [
|
|
10
|
+
{ name: "contents", type: "Order" },
|
|
11
|
+
{ name: "name", type: "string" },
|
|
12
|
+
{ name: "version", type: "string" },
|
|
13
|
+
{ name: "chainId", type: "uint256" },
|
|
14
|
+
{ name: "verifyingContract", type: "address" },
|
|
15
|
+
{ name: "salt", type: "bytes32" },
|
|
16
|
+
];
|
|
17
|
+
const PROTOCOL_NAME_HASH = keccak256(toHex(PROTOCOL_NAME));
|
|
18
|
+
const PROTOCOL_VERSION_HASH = keccak256(toHex(PROTOCOL_VERSION));
|
|
6
19
|
export class ExchangeOrderBuilder {
|
|
7
20
|
contractAddress;
|
|
8
21
|
chainId;
|
|
9
22
|
signer;
|
|
10
23
|
generateSalt;
|
|
24
|
+
appDomainSeparator;
|
|
11
25
|
constructor(contractAddress, chainId, signer, generateSalt = generateOrderSalt) {
|
|
12
26
|
this.contractAddress = contractAddress;
|
|
13
27
|
this.chainId = chainId;
|
|
14
28
|
this.signer = signer;
|
|
15
29
|
this.generateSalt = generateSalt;
|
|
30
|
+
this.appDomainSeparator = keccak256(encodeAbiParameters([
|
|
31
|
+
{ type: "bytes32" },
|
|
32
|
+
{ type: "bytes32" },
|
|
33
|
+
{ type: "bytes32" },
|
|
34
|
+
{ type: "uint256" },
|
|
35
|
+
{ type: "address" },
|
|
36
|
+
], [
|
|
37
|
+
DOMAIN_TYPE_HASH,
|
|
38
|
+
PROTOCOL_NAME_HASH,
|
|
39
|
+
PROTOCOL_VERSION_HASH,
|
|
40
|
+
BigInt(chainId),
|
|
41
|
+
contractAddress,
|
|
42
|
+
]));
|
|
16
43
|
}
|
|
17
44
|
/**
|
|
18
45
|
* Build an order object including the signature.
|
|
@@ -29,32 +56,42 @@ export class ExchangeOrderBuilder {
|
|
|
29
56
|
/**
|
|
30
57
|
* Creates an Order object from order data.
|
|
31
58
|
*/
|
|
32
|
-
async buildOrder({ maker,
|
|
59
|
+
async buildOrder({ maker, tokenId, makerAmount, takerAmount, side, signer, expiration, timestamp, metadata, builder, signatureType, }) {
|
|
33
60
|
if (typeof signer === "undefined" || !signer) {
|
|
34
61
|
signer = maker;
|
|
35
62
|
}
|
|
36
|
-
const signerAddress = await getSignerAddress(this.signer);
|
|
37
|
-
if (signer !== signerAddress) {
|
|
38
|
-
throw new Error("signer does not match");
|
|
39
|
-
}
|
|
40
63
|
if (typeof expiration === "undefined" || !expiration) {
|
|
41
64
|
expiration = "0";
|
|
42
65
|
}
|
|
66
|
+
if (typeof timestamp === "undefined" || !timestamp) {
|
|
67
|
+
timestamp = Date.now().toString();
|
|
68
|
+
}
|
|
69
|
+
if (typeof metadata === "undefined" || !metadata) {
|
|
70
|
+
metadata = ZERO_BYTES32;
|
|
71
|
+
}
|
|
72
|
+
if (typeof builder === "undefined" || !builder) {
|
|
73
|
+
builder = ZERO_BYTES32;
|
|
74
|
+
}
|
|
43
75
|
if (typeof signatureType === "undefined" || !signatureType) {
|
|
44
|
-
|
|
45
|
-
|
|
76
|
+
signatureType = SignatureType.DEPOSIT_WALLET;
|
|
77
|
+
}
|
|
78
|
+
if (signatureType !== SignatureType.DEPOSIT_WALLET) {
|
|
79
|
+
throw new Error("Kuest order signing supports only Deposit Wallet signature type 3");
|
|
80
|
+
}
|
|
81
|
+
if (signer !== maker) {
|
|
82
|
+
throw new Error("Deposit Wallet orders must use the Deposit Wallet as maker and signer");
|
|
46
83
|
}
|
|
47
84
|
return {
|
|
48
85
|
salt: this.generateSalt(),
|
|
49
86
|
maker,
|
|
50
87
|
signer,
|
|
51
|
-
taker,
|
|
52
88
|
tokenId,
|
|
53
89
|
makerAmount,
|
|
54
90
|
takerAmount,
|
|
55
91
|
expiration,
|
|
56
|
-
|
|
57
|
-
|
|
92
|
+
timestamp,
|
|
93
|
+
metadata,
|
|
94
|
+
builder,
|
|
58
95
|
side,
|
|
59
96
|
signatureType,
|
|
60
97
|
};
|
|
@@ -79,15 +116,14 @@ export class ExchangeOrderBuilder {
|
|
|
79
116
|
salt: order.salt,
|
|
80
117
|
maker: order.maker,
|
|
81
118
|
signer: order.signer,
|
|
82
|
-
taker: order.taker,
|
|
83
119
|
tokenId: order.tokenId,
|
|
84
120
|
makerAmount: order.makerAmount,
|
|
85
121
|
takerAmount: order.takerAmount,
|
|
86
|
-
expiration: order.expiration,
|
|
87
|
-
nonce: order.nonce,
|
|
88
|
-
feeRateBps: order.feeRateBps,
|
|
89
122
|
side: order.side,
|
|
90
123
|
signatureType: order.signatureType,
|
|
124
|
+
timestamp: order.timestamp,
|
|
125
|
+
metadata: order.metadata,
|
|
126
|
+
builder: order.builder,
|
|
91
127
|
},
|
|
92
128
|
};
|
|
93
129
|
}
|
|
@@ -96,13 +132,58 @@ export class ExchangeOrderBuilder {
|
|
|
96
132
|
*/
|
|
97
133
|
async buildOrderSignature(typedData) {
|
|
98
134
|
const { EIP712Domain: _, ...orderTypes } = typedData.types;
|
|
99
|
-
|
|
135
|
+
const innerSignature = await signTypedDataWithSigner({
|
|
100
136
|
signer: this.signer,
|
|
101
|
-
domain:
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
137
|
+
domain: {
|
|
138
|
+
name: PROTOCOL_NAME,
|
|
139
|
+
version: PROTOCOL_VERSION,
|
|
140
|
+
chainId: this.chainId,
|
|
141
|
+
verifyingContract: this.contractAddress,
|
|
142
|
+
},
|
|
143
|
+
types: {
|
|
144
|
+
TypedDataSign: TYPED_DATA_SIGN_STRUCT,
|
|
145
|
+
Order: orderTypes.Order,
|
|
146
|
+
},
|
|
147
|
+
value: {
|
|
148
|
+
contents: typedData.message,
|
|
149
|
+
name: "DepositWallet",
|
|
150
|
+
version: "1",
|
|
151
|
+
chainId: this.chainId,
|
|
152
|
+
verifyingContract: typedData.message.signer,
|
|
153
|
+
salt: ZERO_BYTES32,
|
|
154
|
+
},
|
|
155
|
+
primaryType: "TypedDataSign",
|
|
105
156
|
});
|
|
157
|
+
const message = typedData.message;
|
|
158
|
+
const contentsHash = keccak256(encodeAbiParameters([
|
|
159
|
+
{ type: "bytes32" },
|
|
160
|
+
{ type: "uint256" },
|
|
161
|
+
{ type: "address" },
|
|
162
|
+
{ type: "address" },
|
|
163
|
+
{ type: "uint256" },
|
|
164
|
+
{ type: "uint256" },
|
|
165
|
+
{ type: "uint256" },
|
|
166
|
+
{ type: "uint8" },
|
|
167
|
+
{ type: "uint8" },
|
|
168
|
+
{ type: "uint256" },
|
|
169
|
+
{ type: "bytes32" },
|
|
170
|
+
{ type: "bytes32" },
|
|
171
|
+
], [
|
|
172
|
+
ORDER_TYPE_HASH,
|
|
173
|
+
BigInt(message.salt),
|
|
174
|
+
message.maker,
|
|
175
|
+
message.signer,
|
|
176
|
+
BigInt(message.tokenId),
|
|
177
|
+
BigInt(message.makerAmount),
|
|
178
|
+
BigInt(message.takerAmount),
|
|
179
|
+
message.side,
|
|
180
|
+
message.signatureType,
|
|
181
|
+
BigInt(message.timestamp),
|
|
182
|
+
message.metadata,
|
|
183
|
+
message.builder,
|
|
184
|
+
]));
|
|
185
|
+
const contentsTypeLength = ORDER_TYPE_STRING.length.toString(16).padStart(4, "0");
|
|
186
|
+
return `0x${innerSignature.slice(2)}${this.appDomainSeparator.slice(2)}${contentsHash.slice(2)}${toHex(ORDER_TYPE_STRING).slice(2)}${contentsTypeLength}`;
|
|
106
187
|
}
|
|
107
188
|
/**
|
|
108
189
|
* Generates the hash of the order from EIP712 typed data.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange.order.builder.js","sourceRoot":"","sources":["../../src/order-utils/exchange.order.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,MAAM,CAAC;
|
|
1
|
+
{"version":3,"file":"exchange.order.builder.js","sourceRoot":"","sources":["../../src/order-utils/exchange.order.builder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAgB,mBAAmB,EAAE,aAAa,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAE1F,OAAO,EAAE,uBAAuB,EAAE,MAAM,cAAc,CAAC;AACvD,OAAO,EACH,aAAa,EACb,eAAe,EACf,aAAa,EACb,gBAAgB,EAChB,YAAY,GACf,MAAM,2BAA2B,CAAC;AASnC,OAAO,EAAE,aAAa,EAAE,MAAM,kCAAkC,CAAC;AACjE,OAA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AO;SAClC,CAAC,CAAC;IACP,CAAC;CACJ"}
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare const PROTOCOL_NAME = "CTF Exchange";
|
|
2
|
-
export declare const PROTOCOL_VERSION = "
|
|
2
|
+
export declare const PROTOCOL_VERSION = "2";
|
|
3
3
|
export declare const ZX = "0x";
|
|
4
4
|
export declare const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
5
|
+
export declare const ZERO_BYTES32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
5
6
|
export declare const CALL_RESULTS_PREFIX = "CALL_RESULTS_";
|
|
6
7
|
export declare const EIP712_DOMAIN: {
|
|
7
8
|
name: string;
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
// Contract constants.
|
|
2
2
|
export const PROTOCOL_NAME = "CTF Exchange";
|
|
3
|
-
export const PROTOCOL_VERSION = "
|
|
3
|
+
export const PROTOCOL_VERSION = "2";
|
|
4
4
|
export const ZX = "0x";
|
|
5
5
|
export const ZERO_ADDRESS = "0x0000000000000000000000000000000000000000";
|
|
6
|
+
export const ZERO_BYTES32 = "0x0000000000000000000000000000000000000000000000000000000000000000";
|
|
6
7
|
export const CALL_RESULTS_PREFIX = "CALL_RESULTS_";
|
|
7
8
|
// EIP712 objects
|
|
8
9
|
export const EIP712_DOMAIN = [
|
|
@@ -15,14 +16,13 @@ export const ORDER_STRUCTURE = [
|
|
|
15
16
|
{ name: "salt", type: "uint256" },
|
|
16
17
|
{ name: "maker", type: "address" },
|
|
17
18
|
{ name: "signer", type: "address" },
|
|
18
|
-
{ name: "taker", type: "address" },
|
|
19
19
|
{ name: "tokenId", type: "uint256" },
|
|
20
20
|
{ name: "makerAmount", type: "uint256" },
|
|
21
21
|
{ name: "takerAmount", type: "uint256" },
|
|
22
|
-
{ name: "expiration", type: "uint256" },
|
|
23
|
-
{ name: "nonce", type: "uint256" },
|
|
24
|
-
{ name: "feeRateBps", type: "uint256" },
|
|
25
22
|
{ name: "side", type: "uint8" },
|
|
26
23
|
{ name: "signatureType", type: "uint8" },
|
|
24
|
+
{ name: "timestamp", type: "uint256" },
|
|
25
|
+
{ name: "metadata", type: "bytes32" },
|
|
26
|
+
{ name: "builder", type: "bytes32" },
|
|
27
27
|
];
|
|
28
28
|
//# sourceMappingURL=exchange.order.const.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange.order.const.js","sourceRoot":"","sources":["../../src/order-utils/exchange.order.const.ts"],"names":[],"mappings":"AAAA,sBAAsB;AACtB,MAAM,CAAC,MAAM,aAAa,GAAG,cAAc,CAAC;AAC5C,MAAM,CAAC,MAAM,gBAAgB,GAAG,GAAG,CAAC;AACpC,MAAM,CAAC,MAAM,EAAE,GAAG,IAAI,CAAC;AACvB,MAAM,CAAC,MAAM,YAAY,GAAG,4CAA4C,CAAC;AACzE,MAAM,CAAC,MAAM,mBAAmB,GAAG,eAAe,CAAC;AAEnD,iBAAiB;AACjB,MAAM,CAAC,MAAM,aAAa,GAAG;IACzB,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,QAAQ,EAAE;IAChC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;IACnC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;IACpC,EAAE,IAAI,EAAE,mBAAmB,EAAE,IAAI,EAAE,SAAS,EAAE;CACjD,CAAC;AAEF,MAAM,CAAC,MAAM,eAAe,GAAG;IAC3B,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,SAAS,EAAE;IACjC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;IAClC,EAAE,IAAI,EAAE,QAAQ,EAAE,IAAI,EAAE,SAAS,EAAE;IACnC,EAAE,IAAI,EAAE,
|
|
1
|
+
{"version":3,"file":"exchange.order.const.js","sourceRoot":"","sources":["../../src/order-utils/exchange.order.const.ts"],"names":[],"mappings":"AAAA,sBA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AAI,EAAE,SAAS,EAAE;IACrC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;CACvC,CAAC"}
|
|
@@ -11,7 +11,7 @@ export interface EIP712Parameter {
|
|
|
11
11
|
name: string;
|
|
12
12
|
type: string;
|
|
13
13
|
}
|
|
14
|
-
export type EIP712ObjectValue = string | number | EIP712Object;
|
|
14
|
+
export type EIP712ObjectValue = string | number | EIP712Object | undefined;
|
|
15
15
|
export interface EIP712Object {
|
|
16
16
|
[key: string]: EIP712ObjectValue;
|
|
17
17
|
}
|