@cowprotocol/sdk-trading 0.1.0-monorepo.2 → 0.1.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 +139 -72
- package/dist/index.d.mts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +13 -2
- package/dist/index.mjs +13 -2
- package/package.json +24 -24
package/README.md
CHANGED
|
@@ -64,13 +64,20 @@ You need:
|
|
|
64
64
|
|
|
65
65
|
```typescript
|
|
66
66
|
import { SupportedChainId, OrderKind, TradeParameters, TradingSdk } from '@cowprotocol/sdk-trading'
|
|
67
|
-
import {
|
|
68
|
-
import {
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
const adapter = new
|
|
67
|
+
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter'
|
|
68
|
+
import { createPublicClient, http, privateKeyToAccount } from 'viem'
|
|
69
|
+
import { sepolia } from 'viem/chains'
|
|
70
|
+
|
|
71
|
+
// There are EthersV5Adapter and EthersV6Adapter as well
|
|
72
|
+
// @cowprotocol/sdk-ethers-v5-adapter, @cowprotocol/sdk-ethers-v6-adapter
|
|
73
|
+
const adapter = new ViemAdapter({
|
|
74
|
+
provider: createPublicClient({
|
|
75
|
+
chain: sepolia,
|
|
76
|
+
transport: http('YOUR_RPC_URL')
|
|
77
|
+
}),
|
|
78
|
+
// You also can set `walletClient` instead of `signer` using `useWalletClient` from wagmi
|
|
79
|
+
signer: privateKeyToAccount('YOUR_PRIVATE_KEY' as `0x${string}`)
|
|
80
|
+
})
|
|
74
81
|
|
|
75
82
|
// Initialize the SDK
|
|
76
83
|
const sdk = new TradingSdk(
|
|
@@ -98,65 +105,24 @@ const orderId = await sdk.postSwapOrder(parameters)
|
|
|
98
105
|
console.log('Order created, id: ', orderId)
|
|
99
106
|
```
|
|
100
107
|
|
|
101
|
-
### Usage with Umbrella SDK
|
|
102
|
-
|
|
103
|
-
```typescript
|
|
104
|
-
import { CowSdk, SupportedChainId, OrderKind, TradeParameters } from '@cowprotocol/cow-sdk'
|
|
105
|
-
import { EthersV6Adapter } from '@cowprotocol/sdk-ethers-v6-adapter'
|
|
106
|
-
import { JsonRpcProvider, Wallet } from 'ethers'
|
|
107
|
-
|
|
108
|
-
// Configure the adapter
|
|
109
|
-
const provider = new JsonRpcProvider('YOUR_RPC_URL')
|
|
110
|
-
const wallet = new Wallet('YOUR_PRIVATE_KEY', provider)
|
|
111
|
-
const adapter = new EthersV6Adapter({ provider, signer: wallet })
|
|
112
|
-
|
|
113
|
-
// Initialize the unified SDK
|
|
114
|
-
const sdk = new CowSdk({
|
|
115
|
-
chainId: SupportedChainId.SEPOLIA,
|
|
116
|
-
adapter,
|
|
117
|
-
tradingOptions: {
|
|
118
|
-
traderParams: {
|
|
119
|
-
appCode: 'YOUR_APP_CODE',
|
|
120
|
-
},
|
|
121
|
-
options: {
|
|
122
|
-
chainId: SupportedChainId.SEPOLIA,
|
|
123
|
-
},
|
|
124
|
-
},
|
|
125
|
-
})
|
|
126
|
-
|
|
127
|
-
// Define trade parameters
|
|
128
|
-
const parameters: TradeParameters = {
|
|
129
|
-
kind: OrderKind.BUY,
|
|
130
|
-
sellToken: '0xfff9976782d46cc05630d1f6ebab18b2324d6b14',
|
|
131
|
-
sellTokenDecimals: 18,
|
|
132
|
-
buyToken: '0x0625afb445c3b6b7b929342a04a22599fd5dbb59',
|
|
133
|
-
buyTokenDecimals: 18,
|
|
134
|
-
amount: '120000000000000000',
|
|
135
|
-
}
|
|
136
|
-
|
|
137
|
-
// Post the order
|
|
138
|
-
const orderId = await sdk.trading.postSwapOrder(parameters)
|
|
139
|
-
console.log('Order created, id: ', orderId)
|
|
140
|
-
|
|
141
|
-
// Or you can just initialize the SDK and import the trading class in another file:
|
|
142
|
-
// you don't necessarily need to use the trading from inside of CowSdk:
|
|
143
|
-
//...
|
|
144
|
-
const sdk = new CowSdk({
|
|
145
|
-
chainId: SupportedChainId.SEPOLIA,
|
|
146
|
-
adapter,
|
|
147
|
-
})
|
|
148
|
-
// Other file:
|
|
149
|
-
import { TradingSdk } from '@cowprotocol/cow-sdk'
|
|
150
|
-
// parameters without passing the adapter. the adapter will be controlled by the umbrella
|
|
151
|
-
const trading = TradingSdk(...)
|
|
152
|
-
```
|
|
153
|
-
|
|
154
108
|
### Options
|
|
155
109
|
|
|
156
|
-
For detailed information about trading steps you can enable the SDK logging
|
|
110
|
+
For detailed information about trading steps you can enable the SDK logging:
|
|
157
111
|
|
|
158
112
|
```typescript
|
|
159
113
|
import { SupportedChainId, TradingSdk, TradingSdkOptions } from '@cowprotocol/cow-sdk'
|
|
114
|
+
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter'
|
|
115
|
+
import { createPublicClient, http, privateKeyToAccount } from 'viem'
|
|
116
|
+
import { sepolia } from 'viem/chains'
|
|
117
|
+
|
|
118
|
+
const adapter = new ViemAdapter({
|
|
119
|
+
provider: createPublicClient({
|
|
120
|
+
chain: sepolia,
|
|
121
|
+
transport: http('YOUR_RPC_URL')
|
|
122
|
+
}),
|
|
123
|
+
// You also can set `walletClient` instead of `signer` using `useWalletClient` from wagmi
|
|
124
|
+
signer: privateKeyToAccount('YOUR_PRIVATE_KEY' as `0x${string}`)
|
|
125
|
+
})
|
|
160
126
|
|
|
161
127
|
const traderParams = {
|
|
162
128
|
chainId: SupportedChainId.SEPOLIA,
|
|
@@ -166,11 +132,10 @@ const traderParams = {
|
|
|
166
132
|
|
|
167
133
|
const sdkOptions: TradingSdkOptions = {
|
|
168
134
|
enableLogging: true, // enables detailed logging of trading steps
|
|
169
|
-
utmContent: '🐮 moo-ving to defi 🐮', // custom UTM content for tracking
|
|
170
135
|
disableUtm: false, // set to true to disable UTM tracking completely
|
|
171
136
|
}
|
|
172
137
|
|
|
173
|
-
const sdk = new TradingSdk(traderParams, sdkOptions)
|
|
138
|
+
const sdk = new TradingSdk(traderParams, sdkOptions, adapter)
|
|
174
139
|
```
|
|
175
140
|
|
|
176
141
|
### getQuote
|
|
@@ -195,12 +160,24 @@ It can be used to create an order from the received quote.
|
|
|
195
160
|
|
|
196
161
|
```typescript
|
|
197
162
|
import { SupportedChainId, OrderKind, TradeParameters, TradingSdk } from '@cowprotocol/cow-sdk'
|
|
163
|
+
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter'
|
|
164
|
+
import { createPublicClient, http, privateKeyToAccount } from 'viem'
|
|
165
|
+
import { sepolia } from 'viem/chains'
|
|
166
|
+
|
|
167
|
+
const adapter = new ViemAdapter({
|
|
168
|
+
provider: createPublicClient({
|
|
169
|
+
chain: sepolia,
|
|
170
|
+
transport: http('YOUR_RPC_URL')
|
|
171
|
+
}),
|
|
172
|
+
// You also can set `walletClient` instead of `signer` using `useWalletClient` from wagmi
|
|
173
|
+
signer: privateKeyToAccount('YOUR_PRIVATE_KEY' as `0x${string}`)
|
|
174
|
+
})
|
|
198
175
|
|
|
199
176
|
// Proper adapter initialization (see setup example above)
|
|
200
177
|
const sdk = new TradingSdk({
|
|
201
178
|
chainId: SupportedChainId.SEPOLIA,
|
|
202
179
|
appCode: '<YOUR_APP_CODE>',
|
|
203
|
-
})
|
|
180
|
+
}, {}, adapter)
|
|
204
181
|
|
|
205
182
|
const parameters: TradeParameters = {
|
|
206
183
|
kind: OrderKind.BUY,
|
|
@@ -241,12 +218,24 @@ The parameters required are:
|
|
|
241
218
|
|
|
242
219
|
```typescript
|
|
243
220
|
import { SupportedChainId, OrderKind, TradeParameters, TradingSdk } from '@cowprotocol/cow-sdk'
|
|
221
|
+
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter'
|
|
222
|
+
import { createPublicClient, http, privateKeyToAccount } from 'viem'
|
|
223
|
+
import { sepolia } from 'viem/chains'
|
|
224
|
+
|
|
225
|
+
const adapter = new ViemAdapter({
|
|
226
|
+
provider: createPublicClient({
|
|
227
|
+
chain: sepolia,
|
|
228
|
+
transport: http('YOUR_RPC_URL')
|
|
229
|
+
}),
|
|
230
|
+
// You also can set `walletClient` instead of `signer` using `useWalletClient` from wagmi
|
|
231
|
+
signer: privateKeyToAccount('YOUR_PRIVATE_KEY' as `0x${string}`)
|
|
232
|
+
})
|
|
244
233
|
|
|
245
234
|
// Proper adapter initialization (see setup example above)
|
|
246
235
|
const sdk = new TradingSdk({
|
|
247
236
|
chainId: SupportedChainId.SEPOLIA,
|
|
248
237
|
appCode: '<YOUR_APP_CODE>',
|
|
249
|
-
})
|
|
238
|
+
}, {}, adapter)
|
|
250
239
|
|
|
251
240
|
const parameters: TradeParameters = {
|
|
252
241
|
kind: OrderKind.BUY,
|
|
@@ -283,12 +272,24 @@ And optional parameters:
|
|
|
283
272
|
|
|
284
273
|
```typescript
|
|
285
274
|
import { SupportedChainId, OrderKind, LimitTradeParameters, TradingSdk } from '@cowprotocol/cow-sdk'
|
|
275
|
+
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter'
|
|
276
|
+
import { createPublicClient, http, privateKeyToAccount } from 'viem'
|
|
277
|
+
import { sepolia } from 'viem/chains'
|
|
278
|
+
|
|
279
|
+
const adapter = new ViemAdapter({
|
|
280
|
+
provider: createPublicClient({
|
|
281
|
+
chain: sepolia,
|
|
282
|
+
transport: http('YOUR_RPC_URL')
|
|
283
|
+
}),
|
|
284
|
+
// You also can set `walletClient` instead of `signer` using `useWalletClient` from wagmi
|
|
285
|
+
signer: privateKeyToAccount('YOUR_PRIVATE_KEY' as `0x${string}`)
|
|
286
|
+
})
|
|
286
287
|
|
|
287
288
|
// Proper adapter initialization (see setup example above)
|
|
288
289
|
const sdk = new TradingSdk({
|
|
289
290
|
chainId: SupportedChainId.SEPOLIA,
|
|
290
291
|
appCode: '<YOUR_APP_CODE>',
|
|
291
|
-
})
|
|
292
|
+
}, {}, adapter)
|
|
292
293
|
|
|
293
294
|
const limitOrderParameters: LimitTradeParameters = {
|
|
294
295
|
kind: OrderKind.BUY,
|
|
@@ -316,12 +317,23 @@ But if you need more flexible way to create an order to sell native token, you c
|
|
|
316
317
|
|
|
317
318
|
```typescript
|
|
318
319
|
import { SupportedChainId, OrderKind, TradeParameters, TradingSdk } from '@cowprotocol/cow-sdk'
|
|
320
|
+
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter'
|
|
321
|
+
import { createPublicClient, http, privateKeyToAccount } from 'viem'
|
|
322
|
+
import { sepolia } from 'viem/chains'
|
|
323
|
+
|
|
324
|
+
const adapter = new ViemAdapter({
|
|
325
|
+
provider: createPublicClient({
|
|
326
|
+
chain: sepolia,
|
|
327
|
+
transport: http('YOUR_RPC_URL')
|
|
328
|
+
}),
|
|
329
|
+
signer: privateKeyToAccount('YOUR_PRIVATE_KEY' as `0x${string}`)
|
|
330
|
+
})
|
|
319
331
|
|
|
320
332
|
// Proper adapter initialization (see setup example above)
|
|
321
333
|
const sdk = new TradingSdk({
|
|
322
334
|
chainId: SupportedChainId.SEPOLIA,
|
|
323
335
|
appCode: '<YOUR_APP_CODE>',
|
|
324
|
-
})
|
|
336
|
+
}, {}, adapter)
|
|
325
337
|
|
|
326
338
|
const parameters: TradeParameters = {
|
|
327
339
|
kind: OrderKind.BUY,
|
|
@@ -353,12 +365,23 @@ import {
|
|
|
353
365
|
SigningScheme,
|
|
354
366
|
TradingSdk,
|
|
355
367
|
} from '@cowprotocol/cow-sdk'
|
|
368
|
+
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter'
|
|
369
|
+
import { createPublicClient, http, privateKeyToAccount } from 'viem'
|
|
370
|
+
import { sepolia } from 'viem/chains'
|
|
371
|
+
|
|
372
|
+
const adapter = new ViemAdapter({
|
|
373
|
+
provider: createPublicClient({
|
|
374
|
+
chain: sepolia,
|
|
375
|
+
transport: http('YOUR_RPC_URL')
|
|
376
|
+
}),
|
|
377
|
+
signer: privateKeyToAccount('YOUR_PRIVATE_KEY' as `0x${string}`)
|
|
378
|
+
})
|
|
356
379
|
|
|
357
380
|
// Proper adapter initialization (see setup example above)
|
|
358
381
|
const sdk = new TradingSdk({
|
|
359
382
|
chainId: SupportedChainId.SEPOLIA,
|
|
360
383
|
appCode: '<YOUR_APP_CODE>',
|
|
361
|
-
})
|
|
384
|
+
}, {}, adapter)
|
|
362
385
|
|
|
363
386
|
const parameters: TradeParameters = {
|
|
364
387
|
kind: OrderKind.BUY,
|
|
@@ -390,12 +413,23 @@ And then you need to send a transaction from `getPreSignTransaction` result in o
|
|
|
390
413
|
|
|
391
414
|
```typescript
|
|
392
415
|
import { SupportedChainId, OrderKind, TradeParameters, TradingSdk } from '@cowprotocol/cow-sdk'
|
|
416
|
+
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter'
|
|
417
|
+
import { createPublicClient, http, privateKeyToAccount } from 'viem'
|
|
418
|
+
import { sepolia } from 'viem/chains'
|
|
419
|
+
|
|
420
|
+
const adapter = new ViemAdapter({
|
|
421
|
+
provider: createPublicClient({
|
|
422
|
+
chain: sepolia,
|
|
423
|
+
transport: http('YOUR_RPC_URL')
|
|
424
|
+
}),
|
|
425
|
+
signer: privateKeyToAccount('YOUR_PRIVATE_KEY' as `0x${string}`)
|
|
426
|
+
})
|
|
393
427
|
|
|
394
428
|
// Proper adapter initialization (see setup example above)
|
|
395
429
|
const sdk = new TradingSdk({
|
|
396
430
|
chainId: SupportedChainId.SEPOLIA,
|
|
397
431
|
appCode: '<YOUR_APP_CODE>',
|
|
398
|
-
})
|
|
432
|
+
}, {}, adapter)
|
|
399
433
|
|
|
400
434
|
const parameters: TradeParameters = {
|
|
401
435
|
kind: OrderKind.BUY,
|
|
@@ -432,12 +466,23 @@ import {
|
|
|
432
466
|
SigningScheme,
|
|
433
467
|
TradingSdk,
|
|
434
468
|
} from '@cowprotocol/cow-sdk'
|
|
469
|
+
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter'
|
|
470
|
+
import { createPublicClient, http, privateKeyToAccount } from 'viem'
|
|
471
|
+
import { sepolia } from 'viem/chains'
|
|
472
|
+
|
|
473
|
+
const adapter = new ViemAdapter({
|
|
474
|
+
provider: createPublicClient({
|
|
475
|
+
chain: sepolia,
|
|
476
|
+
transport: http('YOUR_RPC_URL')
|
|
477
|
+
}),
|
|
478
|
+
signer: privateKeyToAccount('YOUR_PRIVATE_KEY' as `0x${string}`)
|
|
479
|
+
})
|
|
435
480
|
|
|
436
481
|
// Proper adapter initialization (see setup example above)
|
|
437
482
|
const sdk = new TradingSdk({
|
|
438
483
|
chainId: SupportedChainId.SEPOLIA,
|
|
439
484
|
appCode: '<YOUR_APP_CODE>',
|
|
440
|
-
})
|
|
485
|
+
}, {}, adapter)
|
|
441
486
|
|
|
442
487
|
const smartContractWalletAddress = '0x<smartContractWalletAddress>'
|
|
443
488
|
|
|
@@ -486,12 +531,23 @@ See `TradeOptionalParameters` type for more details.
|
|
|
486
531
|
|
|
487
532
|
```typescript
|
|
488
533
|
import { SupportedChainId, OrderKind, TradeParameters, TradingSdk } from '@cowprotocol/cow-sdk'
|
|
534
|
+
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter'
|
|
535
|
+
import { createPublicClient, http, privateKeyToAccount } from 'viem'
|
|
536
|
+
import { sepolia } from 'viem/chains'
|
|
537
|
+
|
|
538
|
+
const adapter = new ViemAdapter({
|
|
539
|
+
provider: createPublicClient({
|
|
540
|
+
chain: sepolia,
|
|
541
|
+
transport: http('YOUR_RPC_URL')
|
|
542
|
+
}),
|
|
543
|
+
signer: privateKeyToAccount('YOUR_PRIVATE_KEY' as `0x${string}`)
|
|
544
|
+
})
|
|
489
545
|
|
|
490
546
|
// Proper adapter initialization (see setup example above)
|
|
491
547
|
const sdk = new TradingSdk({
|
|
492
548
|
chainId: SupportedChainId.SEPOLIA,
|
|
493
549
|
appCode: '<YOUR_APP_CODE>',
|
|
494
|
-
})
|
|
550
|
+
}, {}, adapter)
|
|
495
551
|
|
|
496
552
|
const parameters: TradeParameters = {
|
|
497
553
|
kind: OrderKind.BUY,
|
|
@@ -532,12 +588,23 @@ import {
|
|
|
532
588
|
SwapAdvancedSettings,
|
|
533
589
|
PriceQuality,
|
|
534
590
|
} from '@cowprotocol/cow-sdk'
|
|
591
|
+
import { ViemAdapter } from '@cowprotocol/sdk-viem-adapter'
|
|
592
|
+
import { createPublicClient, http, privateKeyToAccount } from 'viem'
|
|
593
|
+
import { sepolia } from 'viem/chains'
|
|
594
|
+
|
|
595
|
+
const adapter = new ViemAdapter({
|
|
596
|
+
provider: createPublicClient({
|
|
597
|
+
chain: sepolia,
|
|
598
|
+
transport: http('YOUR_RPC_URL')
|
|
599
|
+
}),
|
|
600
|
+
signer: privateKeyToAccount('YOUR_PRIVATE_KEY' as `0x${string}`)
|
|
601
|
+
})
|
|
535
602
|
|
|
536
603
|
// Proper adapter initialization (see setup example above)
|
|
537
604
|
const sdk = new TradingSdk({
|
|
538
605
|
chainId: SupportedChainId.SEPOLIA,
|
|
539
606
|
appCode: '<YOUR_APP_CODE>',
|
|
540
|
-
})
|
|
607
|
+
}, {}, adapter)
|
|
541
608
|
|
|
542
609
|
const parameters: TradeParameters = {
|
|
543
610
|
kind: OrderKind.BUY,
|
package/dist/index.d.mts
CHANGED
|
@@ -240,8 +240,6 @@ type WithPartialTraderParams<T> = T & Partial<TraderParameters>;
|
|
|
240
240
|
interface TradingSdkOptions {
|
|
241
241
|
enableLogging: boolean;
|
|
242
242
|
orderBookApi: OrderBookApi;
|
|
243
|
-
utmContent?: string;
|
|
244
|
-
disableUtm?: boolean;
|
|
245
243
|
}
|
|
246
244
|
declare class TradingSdk {
|
|
247
245
|
traderParams: Partial<TraderParameters>;
|
package/dist/index.d.ts
CHANGED
|
@@ -240,8 +240,6 @@ type WithPartialTraderParams<T> = T & Partial<TraderParameters>;
|
|
|
240
240
|
interface TradingSdkOptions {
|
|
241
241
|
enableLogging: boolean;
|
|
242
242
|
orderBookApi: OrderBookApi;
|
|
243
|
-
utmContent?: string;
|
|
244
|
-
disableUtm?: boolean;
|
|
245
243
|
}
|
|
246
244
|
declare class TradingSdk {
|
|
247
245
|
traderParams: Partial<TraderParameters>;
|
package/dist/index.js
CHANGED
|
@@ -820,6 +820,14 @@ var TradingSdk = class {
|
|
|
820
820
|
}
|
|
821
821
|
setTraderParams(params) {
|
|
822
822
|
this.traderParams = { ...this.traderParams, ...params };
|
|
823
|
+
if (this.options.orderBookApi) {
|
|
824
|
+
if (params.chainId) {
|
|
825
|
+
this.options.orderBookApi.context.chainId = params.chainId;
|
|
826
|
+
}
|
|
827
|
+
if (params.env) {
|
|
828
|
+
this.options.orderBookApi.context.env = params.env;
|
|
829
|
+
}
|
|
830
|
+
}
|
|
823
831
|
return this;
|
|
824
832
|
}
|
|
825
833
|
async getQuote(params, advancedSettings) {
|
|
@@ -836,7 +844,10 @@ var TradingSdk = class {
|
|
|
836
844
|
tradeParameters: getTradeParametersAfterQuote({
|
|
837
845
|
quoteParameters: quoteResults.result.tradeParameters,
|
|
838
846
|
sellToken: params.sellToken
|
|
839
|
-
})
|
|
847
|
+
}),
|
|
848
|
+
// It's important to get a fresh instance of the signer
|
|
849
|
+
// Because quote might be called with another signer
|
|
850
|
+
signer: (0, import_sdk_common12.getGlobalAdapter)().signer
|
|
840
851
|
}
|
|
841
852
|
},
|
|
842
853
|
advancedSettings2
|
|
@@ -906,7 +917,7 @@ var TradingSdk = class {
|
|
|
906
917
|
const { chainId, signer, appCode, env } = params;
|
|
907
918
|
const traderParams = {
|
|
908
919
|
chainId: chainId || this.traderParams.chainId,
|
|
909
|
-
signer: signer || this.traderParams.signer,
|
|
920
|
+
signer: signer || this.traderParams.signer || (0, import_sdk_common12.getGlobalAdapter)().signer,
|
|
910
921
|
appCode: appCode || this.traderParams.appCode,
|
|
911
922
|
env: env || this.traderParams.env
|
|
912
923
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -785,6 +785,14 @@ var TradingSdk = class {
|
|
|
785
785
|
}
|
|
786
786
|
setTraderParams(params) {
|
|
787
787
|
this.traderParams = { ...this.traderParams, ...params };
|
|
788
|
+
if (this.options.orderBookApi) {
|
|
789
|
+
if (params.chainId) {
|
|
790
|
+
this.options.orderBookApi.context.chainId = params.chainId;
|
|
791
|
+
}
|
|
792
|
+
if (params.env) {
|
|
793
|
+
this.options.orderBookApi.context.env = params.env;
|
|
794
|
+
}
|
|
795
|
+
}
|
|
788
796
|
return this;
|
|
789
797
|
}
|
|
790
798
|
async getQuote(params, advancedSettings) {
|
|
@@ -801,7 +809,10 @@ var TradingSdk = class {
|
|
|
801
809
|
tradeParameters: getTradeParametersAfterQuote({
|
|
802
810
|
quoteParameters: quoteResults.result.tradeParameters,
|
|
803
811
|
sellToken: params.sellToken
|
|
804
|
-
})
|
|
812
|
+
}),
|
|
813
|
+
// It's important to get a fresh instance of the signer
|
|
814
|
+
// Because quote might be called with another signer
|
|
815
|
+
signer: getGlobalAdapter6().signer
|
|
805
816
|
}
|
|
806
817
|
},
|
|
807
818
|
advancedSettings2
|
|
@@ -871,7 +882,7 @@ var TradingSdk = class {
|
|
|
871
882
|
const { chainId, signer, appCode, env } = params;
|
|
872
883
|
const traderParams = {
|
|
873
884
|
chainId: chainId || this.traderParams.chainId,
|
|
874
|
-
signer: signer || this.traderParams.signer,
|
|
885
|
+
signer: signer || this.traderParams.signer || getGlobalAdapter6().signer,
|
|
875
886
|
appCode: appCode || this.traderParams.appCode,
|
|
876
887
|
env: env || this.traderParams.env
|
|
877
888
|
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cowprotocol/sdk-trading",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "CowProtocol trading",
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
6
|
"module": "./dist/index.mjs",
|
|
@@ -13,21 +13,7 @@
|
|
|
13
13
|
"publishConfig": {
|
|
14
14
|
"access": "public"
|
|
15
15
|
},
|
|
16
|
-
"scripts": {
|
|
17
|
-
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
18
|
-
"lint": "eslint src/**/*.ts",
|
|
19
|
-
"test": "jest",
|
|
20
|
-
"test:watch": "jest --watch",
|
|
21
|
-
"test:coverage": "jest --coverage --json --outputFile=jest.results.json && npx coveralls < ./coverage/lcov.info",
|
|
22
|
-
"test:coverage:html": "jest --silent=false --coverage --coverageReporters html",
|
|
23
|
-
"typecheck": "tsc --noEmit",
|
|
24
|
-
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
25
|
-
},
|
|
26
16
|
"devDependencies": {
|
|
27
|
-
"@cow-sdk/typescript-config": "workspace:*",
|
|
28
|
-
"@cowprotocol/sdk-ethers-v5-adapter": "workspace:*",
|
|
29
|
-
"@cowprotocol/sdk-ethers-v6-adapter": "workspace:*",
|
|
30
|
-
"@cowprotocol/sdk-viem-adapter": "workspace:*",
|
|
31
17
|
"@ethersproject/constants": "^5.7.0",
|
|
32
18
|
"@types/jest": "^29.5.12",
|
|
33
19
|
"@types/node": "^20.17.31",
|
|
@@ -41,15 +27,29 @@
|
|
|
41
27
|
"ethers-v6": "npm:ethers@^6.13.7",
|
|
42
28
|
"viem": "^2.28.4",
|
|
43
29
|
"ts-jest": "^29.0.0",
|
|
44
|
-
"tsx": "^4.19.4"
|
|
30
|
+
"tsx": "^4.19.4",
|
|
31
|
+
"@cow-sdk/typescript-config": "0.0.0-beta.0",
|
|
32
|
+
"@cowprotocol/sdk-ethers-v5-adapter": "0.1.0",
|
|
33
|
+
"@cowprotocol/sdk-ethers-v6-adapter": "0.1.0",
|
|
34
|
+
"@cowprotocol/sdk-viem-adapter": "0.1.0"
|
|
45
35
|
},
|
|
46
36
|
"dependencies": {
|
|
47
|
-
"
|
|
48
|
-
"@cowprotocol/sdk-
|
|
49
|
-
"@cowprotocol/sdk-app-data": "
|
|
50
|
-
"@cowprotocol/sdk-
|
|
51
|
-
"@cowprotocol/sdk-order-signing": "
|
|
52
|
-
"@cowprotocol/sdk-
|
|
53
|
-
"
|
|
37
|
+
"deepmerge": "^4.3.1",
|
|
38
|
+
"@cowprotocol/sdk-common": "0.1.0",
|
|
39
|
+
"@cowprotocol/sdk-app-data": "4.0.0",
|
|
40
|
+
"@cowprotocol/sdk-config": "0.1.0",
|
|
41
|
+
"@cowprotocol/sdk-order-signing": "0.1.0",
|
|
42
|
+
"@cowprotocol/sdk-order-book": "0.1.0",
|
|
43
|
+
"@cowprotocol/sdk-contracts-ts": "0.1.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsup src/index.ts --format esm,cjs --dts",
|
|
47
|
+
"lint": "eslint src/**/*.ts",
|
|
48
|
+
"test": "jest",
|
|
49
|
+
"test:watch": "jest --watch",
|
|
50
|
+
"test:coverage": "jest --coverage --json --outputFile=jest.results.json && npx coveralls < ./coverage/lcov.info",
|
|
51
|
+
"test:coverage:html": "jest --silent=false --coverage --coverageReporters html",
|
|
52
|
+
"typecheck": "tsc --noEmit",
|
|
53
|
+
"clean": "rm -rf .turbo && rm -rf node_modules && rm -rf dist"
|
|
54
54
|
}
|
|
55
|
-
}
|
|
55
|
+
}
|