@polymarket/clob-client 4.22.2 → 4.22.4
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/package.json +3 -3
- package/dist/client.d.ts +0 -105
- package/dist/client.js +0 -812
- package/dist/client.js.map +0 -1
- package/dist/config.d.ts +0 -12
- package/dist/config.js +0 -33
- package/dist/config.js.map +0 -1
- package/dist/constants.d.ts +0 -3
- package/dist/constants.js +0 -10
- package/dist/constants.js.map +0 -1
- package/dist/endpoints.d.ts +0 -47
- package/dist/endpoints.js +0 -60
- package/dist/endpoints.js.map +0 -1
- package/dist/errors.d.ts +0 -2
- package/dist/errors.js +0 -6
- package/dist/errors.js.map +0 -1
- package/dist/headers/index.d.ts +0 -7
- package/dist/headers/index.js +0 -45
- package/dist/headers/index.js.map +0 -1
- package/dist/http-helpers/index.d.ts +0 -18
- package/dist/http-helpers/index.js +0 -116
- package/dist/http-helpers/index.js.map +0 -1
- package/dist/index.d.ts +0 -5
- package/dist/index.js +0 -9
- package/dist/index.js.map +0 -1
- package/dist/order-builder/builder.d.ts +0 -19
- package/dist/order-builder/builder.js +0 -32
- package/dist/order-builder/builder.js.map +0 -1
- package/dist/order-builder/helpers.d.ts +0 -49
- package/dist/order-builder/helpers.js +0 -292
- package/dist/order-builder/helpers.js.map +0 -1
- package/dist/order-builder/index.d.ts +0 -1
- package/dist/order-builder/index.js +0 -5
- package/dist/order-builder/index.js.map +0 -1
- package/dist/signing/constants.d.ts +0 -14
- package/dist/signing/constants.js +0 -19
- package/dist/signing/constants.js.map +0 -1
- package/dist/signing/eip712.d.ts +0 -10
- package/dist/signing/eip712.js +0 -39
- package/dist/signing/eip712.js.map +0 -1
- package/dist/signing/hmac.d.ts +0 -9
- package/dist/signing/hmac.js +0 -32
- package/dist/signing/hmac.js.map +0 -1
- package/dist/signing/index.d.ts +0 -2
- package/dist/signing/index.js +0 -6
- package/dist/signing/index.js.map +0 -1
- package/dist/types.d.ts +0 -410
- package/dist/types.js +0 -34
- package/dist/types.js.map +0 -1
- package/dist/utilities.d.ts +0 -15
- package/dist/utilities.js +0 -89
- package/dist/utilities.js.map +0 -1
|
@@ -1,292 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.calculateSellMarketPrice = exports.calculateBuyMarketPrice = exports.createMarketOrder = exports.buildMarketOrderCreationArgs = exports.getMarketOrderRawAmounts = exports.createOrder = exports.buildOrderCreationArgs = exports.getOrderRawAmounts = exports.buildOrder = exports.ROUNDING_CONFIG = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const units_1 = require("@ethersproject/units");
|
|
6
|
-
const order_utils_1 = require("@polymarket/order-utils");
|
|
7
|
-
const types_1 = require("../types");
|
|
8
|
-
const utilities_1 = require("../utilities");
|
|
9
|
-
const config_1 = require("../config");
|
|
10
|
-
exports.ROUNDING_CONFIG = {
|
|
11
|
-
"0.1": {
|
|
12
|
-
price: 1,
|
|
13
|
-
size: 2,
|
|
14
|
-
amount: 3,
|
|
15
|
-
},
|
|
16
|
-
"0.01": {
|
|
17
|
-
price: 2,
|
|
18
|
-
size: 2,
|
|
19
|
-
amount: 4,
|
|
20
|
-
},
|
|
21
|
-
"0.001": {
|
|
22
|
-
price: 3,
|
|
23
|
-
size: 2,
|
|
24
|
-
amount: 5,
|
|
25
|
-
},
|
|
26
|
-
"0.0001": {
|
|
27
|
-
price: 4,
|
|
28
|
-
size: 2,
|
|
29
|
-
amount: 6,
|
|
30
|
-
},
|
|
31
|
-
};
|
|
32
|
-
/**
|
|
33
|
-
* Generate and sign a order
|
|
34
|
-
*
|
|
35
|
-
* @param signer
|
|
36
|
-
* @param exchangeAddress ctf exchange contract address
|
|
37
|
-
* @param chainId
|
|
38
|
-
* @param OrderData
|
|
39
|
-
* @returns SignedOrder
|
|
40
|
-
*/
|
|
41
|
-
const buildOrder = (signer, exchangeAddress, chainId, orderData) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
42
|
-
const cTFExchangeOrderBuilder = new order_utils_1.ExchangeOrderBuilder(exchangeAddress, chainId, signer);
|
|
43
|
-
return cTFExchangeOrderBuilder.buildSignedOrder(orderData);
|
|
44
|
-
});
|
|
45
|
-
exports.buildOrder = buildOrder;
|
|
46
|
-
const getOrderRawAmounts = (side, size, price, roundConfig) => {
|
|
47
|
-
const rawPrice = (0, utilities_1.roundNormal)(price, roundConfig.price);
|
|
48
|
-
if (side === types_1.Side.BUY) {
|
|
49
|
-
// force 2 decimals places
|
|
50
|
-
const rawTakerAmt = (0, utilities_1.roundDown)(size, roundConfig.size);
|
|
51
|
-
let rawMakerAmt = rawTakerAmt * rawPrice;
|
|
52
|
-
if ((0, utilities_1.decimalPlaces)(rawMakerAmt) > roundConfig.amount) {
|
|
53
|
-
rawMakerAmt = (0, utilities_1.roundUp)(rawMakerAmt, roundConfig.amount + 4);
|
|
54
|
-
if ((0, utilities_1.decimalPlaces)(rawMakerAmt) > roundConfig.amount) {
|
|
55
|
-
rawMakerAmt = (0, utilities_1.roundDown)(rawMakerAmt, roundConfig.amount);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
return {
|
|
59
|
-
side: order_utils_1.Side.BUY,
|
|
60
|
-
rawMakerAmt,
|
|
61
|
-
rawTakerAmt,
|
|
62
|
-
};
|
|
63
|
-
}
|
|
64
|
-
else {
|
|
65
|
-
const rawMakerAmt = (0, utilities_1.roundDown)(size, roundConfig.size);
|
|
66
|
-
let rawTakerAmt = rawMakerAmt * rawPrice;
|
|
67
|
-
if ((0, utilities_1.decimalPlaces)(rawTakerAmt) > roundConfig.amount) {
|
|
68
|
-
rawTakerAmt = (0, utilities_1.roundUp)(rawTakerAmt, roundConfig.amount + 4);
|
|
69
|
-
if ((0, utilities_1.decimalPlaces)(rawTakerAmt) > roundConfig.amount) {
|
|
70
|
-
rawTakerAmt = (0, utilities_1.roundDown)(rawTakerAmt, roundConfig.amount);
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
return {
|
|
74
|
-
side: order_utils_1.Side.SELL,
|
|
75
|
-
rawMakerAmt,
|
|
76
|
-
rawTakerAmt,
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
};
|
|
80
|
-
exports.getOrderRawAmounts = getOrderRawAmounts;
|
|
81
|
-
/**
|
|
82
|
-
* Translate simple user order to args used to generate Orders
|
|
83
|
-
*/
|
|
84
|
-
const buildOrderCreationArgs = (signer, maker, signatureType, userOrder, roundConfig) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
85
|
-
const { side, rawMakerAmt, rawTakerAmt } = (0, exports.getOrderRawAmounts)(userOrder.side, userOrder.size, userOrder.price, roundConfig);
|
|
86
|
-
const makerAmount = (0, units_1.parseUnits)(rawMakerAmt.toString(), config_1.COLLATERAL_TOKEN_DECIMALS).toString();
|
|
87
|
-
const takerAmount = (0, units_1.parseUnits)(rawTakerAmt.toString(), config_1.COLLATERAL_TOKEN_DECIMALS).toString();
|
|
88
|
-
let taker;
|
|
89
|
-
if (typeof userOrder.taker !== "undefined" && userOrder.taker) {
|
|
90
|
-
taker = userOrder.taker;
|
|
91
|
-
}
|
|
92
|
-
else {
|
|
93
|
-
taker = "0x0000000000000000000000000000000000000000";
|
|
94
|
-
}
|
|
95
|
-
let feeRateBps;
|
|
96
|
-
if (typeof userOrder.feeRateBps !== "undefined" && userOrder.feeRateBps) {
|
|
97
|
-
feeRateBps = userOrder.feeRateBps.toString();
|
|
98
|
-
}
|
|
99
|
-
else {
|
|
100
|
-
feeRateBps = "0";
|
|
101
|
-
}
|
|
102
|
-
let nonce;
|
|
103
|
-
if (typeof userOrder.nonce !== "undefined" && userOrder.nonce) {
|
|
104
|
-
nonce = userOrder.nonce.toString();
|
|
105
|
-
}
|
|
106
|
-
else {
|
|
107
|
-
nonce = "0";
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
maker,
|
|
111
|
-
taker,
|
|
112
|
-
tokenId: userOrder.tokenID,
|
|
113
|
-
makerAmount,
|
|
114
|
-
takerAmount,
|
|
115
|
-
side,
|
|
116
|
-
feeRateBps,
|
|
117
|
-
nonce,
|
|
118
|
-
signer,
|
|
119
|
-
expiration: (userOrder.expiration || 0).toString(),
|
|
120
|
-
signatureType,
|
|
121
|
-
};
|
|
122
|
-
});
|
|
123
|
-
exports.buildOrderCreationArgs = buildOrderCreationArgs;
|
|
124
|
-
const createOrder = (eoaSigner, chainId, signatureType, funderAddress, userOrder, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
125
|
-
const eoaSignerAddress = yield eoaSigner.getAddress();
|
|
126
|
-
// If funder address is not given, use the signer address
|
|
127
|
-
const maker = funderAddress === undefined ? eoaSignerAddress : funderAddress;
|
|
128
|
-
const contractConfig = (0, config_1.getContractConfig)(chainId);
|
|
129
|
-
const orderData = yield (0, exports.buildOrderCreationArgs)(eoaSignerAddress, maker, signatureType, userOrder, exports.ROUNDING_CONFIG[options.tickSize]);
|
|
130
|
-
const exchangeContract = options.negRisk
|
|
131
|
-
? contractConfig.negRiskExchange
|
|
132
|
-
: contractConfig.exchange;
|
|
133
|
-
return (0, exports.buildOrder)(eoaSigner, exchangeContract, chainId, orderData);
|
|
134
|
-
});
|
|
135
|
-
exports.createOrder = createOrder;
|
|
136
|
-
const getMarketOrderRawAmounts = (side, amount, price, roundConfig) => {
|
|
137
|
-
// force 2 decimals places
|
|
138
|
-
const rawPrice = (0, utilities_1.roundDown)(price, roundConfig.price);
|
|
139
|
-
if (side === types_1.Side.BUY) {
|
|
140
|
-
const rawMakerAmt = (0, utilities_1.roundDown)(amount, roundConfig.size);
|
|
141
|
-
let rawTakerAmt = rawMakerAmt / rawPrice;
|
|
142
|
-
if ((0, utilities_1.decimalPlaces)(rawTakerAmt) > roundConfig.amount) {
|
|
143
|
-
rawTakerAmt = (0, utilities_1.roundUp)(rawTakerAmt, roundConfig.amount + 4);
|
|
144
|
-
if ((0, utilities_1.decimalPlaces)(rawTakerAmt) > roundConfig.amount) {
|
|
145
|
-
rawTakerAmt = (0, utilities_1.roundDown)(rawTakerAmt, roundConfig.amount);
|
|
146
|
-
}
|
|
147
|
-
}
|
|
148
|
-
return {
|
|
149
|
-
side: order_utils_1.Side.BUY,
|
|
150
|
-
rawMakerAmt,
|
|
151
|
-
rawTakerAmt,
|
|
152
|
-
};
|
|
153
|
-
}
|
|
154
|
-
else {
|
|
155
|
-
const rawMakerAmt = (0, utilities_1.roundDown)(amount, roundConfig.size);
|
|
156
|
-
let rawTakerAmt = rawMakerAmt * rawPrice;
|
|
157
|
-
if ((0, utilities_1.decimalPlaces)(rawTakerAmt) > roundConfig.amount) {
|
|
158
|
-
rawTakerAmt = (0, utilities_1.roundUp)(rawTakerAmt, roundConfig.amount + 4);
|
|
159
|
-
if ((0, utilities_1.decimalPlaces)(rawTakerAmt) > roundConfig.amount) {
|
|
160
|
-
rawTakerAmt = (0, utilities_1.roundDown)(rawTakerAmt, roundConfig.amount);
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
return {
|
|
164
|
-
side: order_utils_1.Side.SELL,
|
|
165
|
-
rawMakerAmt,
|
|
166
|
-
rawTakerAmt,
|
|
167
|
-
};
|
|
168
|
-
}
|
|
169
|
-
};
|
|
170
|
-
exports.getMarketOrderRawAmounts = getMarketOrderRawAmounts;
|
|
171
|
-
/**
|
|
172
|
-
* Translate simple user market order to args used to generate Orders
|
|
173
|
-
*/
|
|
174
|
-
const buildMarketOrderCreationArgs = (signer, maker, signatureType, userMarketOrder, roundConfig) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
175
|
-
const { side, rawMakerAmt, rawTakerAmt } = (0, exports.getMarketOrderRawAmounts)(userMarketOrder.side, userMarketOrder.amount, userMarketOrder.price || 1, roundConfig);
|
|
176
|
-
const makerAmount = (0, units_1.parseUnits)(rawMakerAmt.toString(), config_1.COLLATERAL_TOKEN_DECIMALS).toString();
|
|
177
|
-
const takerAmount = (0, units_1.parseUnits)(rawTakerAmt.toString(), config_1.COLLATERAL_TOKEN_DECIMALS).toString();
|
|
178
|
-
let taker;
|
|
179
|
-
if (typeof userMarketOrder.taker !== "undefined" && userMarketOrder.taker) {
|
|
180
|
-
taker = userMarketOrder.taker;
|
|
181
|
-
}
|
|
182
|
-
else {
|
|
183
|
-
taker = "0x0000000000000000000000000000000000000000";
|
|
184
|
-
}
|
|
185
|
-
let feeRateBps;
|
|
186
|
-
if (typeof userMarketOrder.feeRateBps !== "undefined" && userMarketOrder.feeRateBps) {
|
|
187
|
-
feeRateBps = userMarketOrder.feeRateBps.toString();
|
|
188
|
-
}
|
|
189
|
-
else {
|
|
190
|
-
feeRateBps = "0";
|
|
191
|
-
}
|
|
192
|
-
let nonce;
|
|
193
|
-
if (typeof userMarketOrder.nonce !== "undefined" && userMarketOrder.nonce) {
|
|
194
|
-
nonce = userMarketOrder.nonce.toString();
|
|
195
|
-
}
|
|
196
|
-
else {
|
|
197
|
-
nonce = "0";
|
|
198
|
-
}
|
|
199
|
-
return {
|
|
200
|
-
maker,
|
|
201
|
-
taker,
|
|
202
|
-
tokenId: userMarketOrder.tokenID,
|
|
203
|
-
makerAmount,
|
|
204
|
-
takerAmount,
|
|
205
|
-
side,
|
|
206
|
-
feeRateBps,
|
|
207
|
-
nonce,
|
|
208
|
-
signer,
|
|
209
|
-
expiration: "0",
|
|
210
|
-
signatureType,
|
|
211
|
-
};
|
|
212
|
-
});
|
|
213
|
-
exports.buildMarketOrderCreationArgs = buildMarketOrderCreationArgs;
|
|
214
|
-
const createMarketOrder = (eoaSigner, chainId, signatureType, funderAddress, userMarketOrder, options) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
215
|
-
const eoaSignerAddress = yield eoaSigner.getAddress();
|
|
216
|
-
// If funder address is not given, use the signer address
|
|
217
|
-
const maker = funderAddress === undefined ? eoaSignerAddress : funderAddress;
|
|
218
|
-
const contractConfig = (0, config_1.getContractConfig)(chainId);
|
|
219
|
-
const orderData = yield (0, exports.buildMarketOrderCreationArgs)(eoaSignerAddress, maker, signatureType, userMarketOrder, exports.ROUNDING_CONFIG[options.tickSize]);
|
|
220
|
-
const exchangeContract = options.negRisk
|
|
221
|
-
? contractConfig.negRiskExchange
|
|
222
|
-
: contractConfig.exchange;
|
|
223
|
-
return (0, exports.buildOrder)(eoaSigner, exchangeContract, chainId, orderData);
|
|
224
|
-
});
|
|
225
|
-
exports.createMarketOrder = createMarketOrder;
|
|
226
|
-
/**
|
|
227
|
-
* calculateBuyMarketPrice calculates the market price to buy a $$ amount
|
|
228
|
-
* @param positions
|
|
229
|
-
* @param amountToMatch worth to buy
|
|
230
|
-
* @returns
|
|
231
|
-
*/
|
|
232
|
-
const calculateBuyMarketPrice = (positions, amountToMatch, orderType) => {
|
|
233
|
-
if (!positions.length) {
|
|
234
|
-
throw new Error("no match");
|
|
235
|
-
}
|
|
236
|
-
let sum = 0;
|
|
237
|
-
/*
|
|
238
|
-
Asks:
|
|
239
|
-
[
|
|
240
|
-
{ price: '0.6', size: '100' },
|
|
241
|
-
{ price: '0.55', size: '100' },
|
|
242
|
-
{ price: '0.5', size: '100' }
|
|
243
|
-
]
|
|
244
|
-
So, if the amount to match is $150 that will be reached at first position so price will be 0.6
|
|
245
|
-
*/
|
|
246
|
-
for (let i = positions.length - 1; i >= 0; i--) {
|
|
247
|
-
const p = positions[i];
|
|
248
|
-
sum += parseFloat(p.size) * parseFloat(p.price);
|
|
249
|
-
if (sum >= amountToMatch) {
|
|
250
|
-
return parseFloat(p.price);
|
|
251
|
-
}
|
|
252
|
-
}
|
|
253
|
-
if (orderType === types_1.OrderType.FOK) {
|
|
254
|
-
throw new Error("no match");
|
|
255
|
-
}
|
|
256
|
-
return parseFloat(positions[0].price);
|
|
257
|
-
};
|
|
258
|
-
exports.calculateBuyMarketPrice = calculateBuyMarketPrice;
|
|
259
|
-
/**
|
|
260
|
-
* calculateSellMarketPrice calculates the market price to sell a shares
|
|
261
|
-
* @param positions
|
|
262
|
-
* @param amountToMatch sells to share
|
|
263
|
-
* @returns
|
|
264
|
-
*/
|
|
265
|
-
const calculateSellMarketPrice = (positions, amountToMatch, orderType) => {
|
|
266
|
-
if (!positions.length) {
|
|
267
|
-
throw new Error("no match");
|
|
268
|
-
}
|
|
269
|
-
let sum = 0;
|
|
270
|
-
/*
|
|
271
|
-
Bids:
|
|
272
|
-
[
|
|
273
|
-
{ price: '0.4', size: '100' },
|
|
274
|
-
{ price: '0.45', size: '100' },
|
|
275
|
-
{ price: '0.5', size: '100' }
|
|
276
|
-
]
|
|
277
|
-
So, if the amount to match is 300 that will be reached at the first position so price will be 0.4
|
|
278
|
-
*/
|
|
279
|
-
for (let i = positions.length - 1; i >= 0; i--) {
|
|
280
|
-
const p = positions[i];
|
|
281
|
-
sum += parseFloat(p.size);
|
|
282
|
-
if (sum >= amountToMatch) {
|
|
283
|
-
return parseFloat(p.price);
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
if (orderType === types_1.OrderType.FOK) {
|
|
287
|
-
throw new Error("no match");
|
|
288
|
-
}
|
|
289
|
-
return parseFloat(positions[0].price);
|
|
290
|
-
};
|
|
291
|
-
exports.calculateSellMarketPrice = calculateSellMarketPrice;
|
|
292
|
-
//# sourceMappingURL=helpers.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"helpers.js","sourceRoot":"","sources":["../../src/order-builder/helpers.ts"],"names":[],"mappings":";;;;AAEA,gDAAkD;AAClD,yDAMiC;AACjC,oCAUkB;AAClB,4CAA8E;AAC9E,sCAAyE;AAE5D,QAAA,eAAe,GAAkC;IAC1D,KAAK,EAAE;QACH,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,CAAC;KACZ;IACD,MAAM,EAAE;QACJ,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,CAAC;QACP,MAAM,EAAE,CAAC;KACZ;IACD,OAAO,EAAE;QACL,KAAK,EAAE,CAAC;QACR,IAAI,EAAE,CAAC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;IACZ;;;;;;;;MAQE;IACF,KAAK,IAAI,CAAC,GAAG,SAAS,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC,IAAI,CAAC,EAAE,CAAC,EAAE,EAAE;QAC5C,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,CAAC;QACvB,GAAG,IAAI,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QAC1B,IAAI,GAAG,IAAI,aAAa,EAAE;YACtB,OAAO,UAAU,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;SAC9B;KACJ;IACD,IAAI,SAAS,KAAK,iBAAS,CAAC,GAAG,EAAE;QAC7B,MAAM,IAAI,KAAK,CAAC,UAAU,CAAC,CAAC;KAC/B;IACD,OAAO,UAAU,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC;AAC1C,CAAC,CAAC;AA7BW,QAAA,wBAAwB,4BA6BnC"}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from "./builder";
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/order-builder/index.ts"],"names":[],"mappings":";;;AAAA,oDAA0B"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export declare const CLOB_DOMAIN_NAME = "ClobAuthDomain";
|
|
2
|
-
export declare const CLOB_VERSION = "1";
|
|
3
|
-
export declare const MSG_TO_SIGN = "This message attests that I control the given wallet";
|
|
4
|
-
export declare const CLOB_DOMAIN: {
|
|
5
|
-
name: string;
|
|
6
|
-
version: string;
|
|
7
|
-
chainId: number;
|
|
8
|
-
};
|
|
9
|
-
export declare const CLOB_TYPES: {
|
|
10
|
-
ClobAuth: {
|
|
11
|
-
name: string;
|
|
12
|
-
type: string;
|
|
13
|
-
}[];
|
|
14
|
-
};
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CLOB_TYPES = exports.CLOB_DOMAIN = exports.MSG_TO_SIGN = exports.CLOB_VERSION = exports.CLOB_DOMAIN_NAME = void 0;
|
|
4
|
-
exports.CLOB_DOMAIN_NAME = "ClobAuthDomain";
|
|
5
|
-
exports.CLOB_VERSION = "1";
|
|
6
|
-
exports.MSG_TO_SIGN = "This message attests that I control the given wallet";
|
|
7
|
-
exports.CLOB_DOMAIN = {
|
|
8
|
-
name: exports.CLOB_DOMAIN_NAME,
|
|
9
|
-
version: exports.CLOB_VERSION,
|
|
10
|
-
chainId: 1,
|
|
11
|
-
};
|
|
12
|
-
exports.CLOB_TYPES = {
|
|
13
|
-
ClobAuth: [
|
|
14
|
-
{ name: "address", type: "address" },
|
|
15
|
-
{ name: "timestamp", type: "string" },
|
|
16
|
-
{ name: "message", type: "string" },
|
|
17
|
-
],
|
|
18
|
-
};
|
|
19
|
-
//# sourceMappingURL=constants.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../src/signing/constants.ts"],"names":[],"mappings":";;;AAAa,QAAA,gBAAgB,GAAG,gBAAgB,CAAC;AACpC,QAAA,YAAY,GAAG,GAAG,CAAC;AACnB,QAAA,WAAW,GAAG,sDAAsD,CAAC;AAErE,QAAA,WAAW,GAAG;IACvB,IAAI,EAAE,wBAAgB;IACtB,OAAO,EAAE,oBAAY;IACrB,OAAO,EAAE,CAAC;CACb,CAAC;AAEW,QAAA,UAAU,GAAG;IACtB,QAAQ,EAAE;QACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;QACpC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;QACrC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;KACtC;CACJ,CAAC"}
|
package/dist/signing/eip712.d.ts
DELETED
|
@@ -1,10 +0,0 @@
|
|
|
1
|
-
import { Wallet } from "@ethersproject/wallet";
|
|
2
|
-
import { JsonRpcSigner } from "@ethersproject/providers";
|
|
3
|
-
import { Chain } from "src/types";
|
|
4
|
-
/**
|
|
5
|
-
* Builds the canonical Polymarket CLOB EIP712 signature
|
|
6
|
-
* @param signer
|
|
7
|
-
* @param ts
|
|
8
|
-
* @returns string
|
|
9
|
-
*/
|
|
10
|
-
export declare const buildClobEip712Signature: (signer: Wallet | JsonRpcSigner, chainId: Chain, timestamp: number, nonce: number) => Promise<string>;
|
package/dist/signing/eip712.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildClobEip712Signature = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const constants_1 = require("./constants");
|
|
6
|
-
/**
|
|
7
|
-
* Builds the canonical Polymarket CLOB EIP712 signature
|
|
8
|
-
* @param signer
|
|
9
|
-
* @param ts
|
|
10
|
-
* @returns string
|
|
11
|
-
*/
|
|
12
|
-
const buildClobEip712Signature = (signer, chainId, timestamp, nonce) => tslib_1.__awaiter(void 0, void 0, void 0, function* () {
|
|
13
|
-
const address = yield signer.getAddress();
|
|
14
|
-
const ts = `${timestamp}`;
|
|
15
|
-
const domain = {
|
|
16
|
-
name: "ClobAuthDomain",
|
|
17
|
-
version: "1",
|
|
18
|
-
chainId: chainId,
|
|
19
|
-
};
|
|
20
|
-
const types = {
|
|
21
|
-
ClobAuth: [
|
|
22
|
-
{ name: "address", type: "address" },
|
|
23
|
-
{ name: "timestamp", type: "string" },
|
|
24
|
-
{ name: "nonce", type: "uint256" },
|
|
25
|
-
{ name: "message", type: "string" },
|
|
26
|
-
],
|
|
27
|
-
};
|
|
28
|
-
const value = {
|
|
29
|
-
address,
|
|
30
|
-
timestamp: ts,
|
|
31
|
-
nonce,
|
|
32
|
-
message: constants_1.MSG_TO_SIGN,
|
|
33
|
-
};
|
|
34
|
-
// eslint-disable-next-line no-underscore-dangle
|
|
35
|
-
const sig = yield signer._signTypedData(domain, types, value);
|
|
36
|
-
return sig;
|
|
37
|
-
});
|
|
38
|
-
exports.buildClobEip712Signature = buildClobEip712Signature;
|
|
39
|
-
//# sourceMappingURL=eip712.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"eip712.js","sourceRoot":"","sources":["../../src/signing/eip712.ts"],"names":[],"mappings":";;;;AAEA,2CAA0C;AAG1C;;;;;GAKG;AACI,MAAM,wBAAwB,GAAG,CACpC,MAA8B,EAC9B,OAAc,EACd,SAAiB,EACjB,KAAa,EACE,EAAE;IACjB,MAAM,OAAO,GAAG,MAAM,MAAM,CAAC,UAAU,EAAE,CAAC;IAC1C,MAAM,EAAE,GAAG,GAAG,SAAS,EAAE,CAAC;IAE1B,MAAM,MAAM,GAAG;QACX,IAAI,EAAE,gBAAgB;QACtB,OAAO,EAAE,GAAG;QACZ,OAAO,EAAE,OAAO;KACnB,CAAC;IAEF,MAAM,KAAK,GAAG;QACV,QAAQ,EAAE;YACN,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,SAAS,EAAE;YACpC,EAAE,IAAI,EAAE,WAAW,EAAE,IAAI,EAAE,QAAQ,EAAE;YACrC,EAAE,IAAI,EAAE,OAAO,EAAE,IAAI,EAAE,SAAS,EAAE;YAClC,EAAE,IAAI,EAAE,SAAS,EAAE,IAAI,EAAE,QAAQ,EAAE;SACtC;KACJ,CAAC;IACF,MAAM,KAAK,GAAG;QACV,OAAO;QACP,SAAS,EAAE,EAAE;QACb,KAAK;QACL,OAAO,EAAE,uBAAW;KACvB,CAAC;IACF,gDAAgD;IAChD,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,MAAM,EAAE,KAAK,EAAE,KAAK,CAAC,CAAC;IAC9D,OAAO,GAAG,CAAC;AACf,CAAC,CAAA,CAAC;AAhCW,QAAA,wBAAwB,4BAgCnC"}
|
package/dist/signing/hmac.d.ts
DELETED
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Builds the canonical Polymarket CLOB HMAC signature
|
|
3
|
-
* @param signer
|
|
4
|
-
* @param key
|
|
5
|
-
* @param secret
|
|
6
|
-
* @param passphrase
|
|
7
|
-
* @returns string
|
|
8
|
-
*/
|
|
9
|
-
export declare const buildPolyHmacSignature: (secret: string, timestamp: number, method: string, requestPath: string, body?: string) => string;
|
package/dist/signing/hmac.js
DELETED
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildPolyHmacSignature = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const crypto_1 = tslib_1.__importDefault(require("crypto"));
|
|
6
|
-
function replaceAll(s, search, replace) {
|
|
7
|
-
return s.split(search).join(replace);
|
|
8
|
-
}
|
|
9
|
-
/**
|
|
10
|
-
* Builds the canonical Polymarket CLOB HMAC signature
|
|
11
|
-
* @param signer
|
|
12
|
-
* @param key
|
|
13
|
-
* @param secret
|
|
14
|
-
* @param passphrase
|
|
15
|
-
* @returns string
|
|
16
|
-
*/
|
|
17
|
-
const buildPolyHmacSignature = (secret, timestamp, method, requestPath, body) => {
|
|
18
|
-
let message = timestamp + method + requestPath;
|
|
19
|
-
if (body !== undefined) {
|
|
20
|
-
message += body;
|
|
21
|
-
}
|
|
22
|
-
const base64Secret = Buffer.from(secret, "base64");
|
|
23
|
-
const hmac = crypto_1.default.createHmac("sha256", base64Secret);
|
|
24
|
-
const sig = hmac.update(message).digest("base64");
|
|
25
|
-
// NOTE: Must be url safe base64 encoding, but keep base64 "=" suffix
|
|
26
|
-
// Convert '+' to '-'
|
|
27
|
-
// Convert '/' to '_'
|
|
28
|
-
const sigUrlSafe = replaceAll(replaceAll(sig, "+", "-"), "/", "_");
|
|
29
|
-
return sigUrlSafe;
|
|
30
|
-
};
|
|
31
|
-
exports.buildPolyHmacSignature = buildPolyHmacSignature;
|
|
32
|
-
//# sourceMappingURL=hmac.js.map
|
package/dist/signing/hmac.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"hmac.js","sourceRoot":"","sources":["../../src/signing/hmac.ts"],"names":[],"mappings":";;;;AAAA,4DAA4B;AAE5B,SAAS,UAAU,CAAC,CAAS,EAAE,MAAc,EAAE,OAAe;IAC1D,OAAO,CAAC,CAAC,KAAK,CAAC,MAAM,CAAC,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACI,MAAM,sBAAsB,GAAG,CAClC,MAAc,EACd,SAAiB,EACjB,MAAc,EACd,WAAmB,EACnB,IAAa,EACP,EAAE;IACR,IAAI,OAAO,GAAG,SAAS,GAAG,MAAM,GAAG,WAAW,CAAC;IAC/C,IAAI,IAAI,KAAK,SAAS,EAAE;QACpB,OAAO,IAAI,IAAI,CAAC;KACnB;IACD,MAAM,YAAY,GAAG,MAAM,CAAC,IAAI,CAAC,MAAM,EAAE,QAAQ,CAAC,CAAC;IACnD,MAAM,IAAI,GAAG,gBAAM,CAAC,UAAU,CAAC,QAAQ,EAAE,YAAY,CAAC,CAAC;IACvD,MAAM,GAAG,GAAG,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC;IAElD,qEAAqE;IACrE,qBAAqB;IACrB,qBAAqB;IACrB,MAAM,UAAU,GAAG,UAAU,CAAC,UAAU,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;IACnE,OAAO,UAAU,CAAC;AACtB,CAAC,CAAC;AApBW,QAAA,sBAAsB,0BAoBjC"}
|
package/dist/signing/index.d.ts
DELETED
package/dist/signing/index.js
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/signing/index.ts"],"names":[],"mappings":";;;AAAA,mDAAyB;AACzB,iDAAuB"}
|