@cowprotocol/sdk-bridging 4.0.3 → 4.0.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/README.md +0 -66
- package/package.json +10 -10
package/README.md
CHANGED
|
@@ -18,8 +18,6 @@ yarn add @cowprotocol/sdk-bridging
|
|
|
18
18
|
|
|
19
19
|
## Usage
|
|
20
20
|
|
|
21
|
-
### Individual package usage
|
|
22
|
-
|
|
23
21
|
```typescript
|
|
24
22
|
import {
|
|
25
23
|
SupportedChainId,
|
|
@@ -85,70 +83,6 @@ if (confirm(`You will get at least: ${buyAmount}, ok?`)) {
|
|
|
85
83
|
}
|
|
86
84
|
```
|
|
87
85
|
|
|
88
|
-
### Usage with CoW SDK
|
|
89
|
-
|
|
90
|
-
```typescript
|
|
91
|
-
import {
|
|
92
|
-
CowSdk,
|
|
93
|
-
SupportedChainId,
|
|
94
|
-
QuoteBridgeRequest,
|
|
95
|
-
OrderKind,
|
|
96
|
-
assertIsBridgeQuoteAndPost,
|
|
97
|
-
} from '@cowprotocol/cow-sdk'
|
|
98
|
-
import { EthersV6Adapter } from '@cowprotocol/sdk-ethers-v6-adapter'
|
|
99
|
-
import { JsonRpcProvider, Wallet } from 'ethers'
|
|
100
|
-
|
|
101
|
-
// Configure the adapter
|
|
102
|
-
const provider = new JsonRpcProvider('YOUR_RPC_URL')
|
|
103
|
-
const wallet = new Wallet('YOUR_PRIVATE_KEY', provider)
|
|
104
|
-
const adapter = new EthersV6Adapter({ provider, signer: wallet })
|
|
105
|
-
|
|
106
|
-
// Initialize the unified SDK
|
|
107
|
-
const sdk = new CowSdk({
|
|
108
|
-
chainId: SupportedChainId.ARBITRUM_ONE, // Source chain
|
|
109
|
-
adapter,
|
|
110
|
-
})
|
|
111
|
-
|
|
112
|
-
const parameters: QuoteBridgeRequest = {
|
|
113
|
-
// Cross-chain orders are always SELL orders (BUY not supported yet)
|
|
114
|
-
kind: OrderKind.SELL,
|
|
115
|
-
|
|
116
|
-
// Sell token (and source chain)
|
|
117
|
-
sellTokenChainId: SupportedChainId.ARBITRUM_ONE,
|
|
118
|
-
sellTokenAddress: '0x82aF49447D8a07e3bd95BD0d56f35241523fBab1',
|
|
119
|
-
sellTokenDecimals: 18,
|
|
120
|
-
|
|
121
|
-
// Buy token (and target chain)
|
|
122
|
-
buyTokenChainId: SupportedChainId.BASE,
|
|
123
|
-
buyTokenAddress: '0x4200000000000000000000000000000000000006',
|
|
124
|
-
buyTokenDecimals: 18,
|
|
125
|
-
|
|
126
|
-
// Amount to sell
|
|
127
|
-
amount: '120000000000000000',
|
|
128
|
-
|
|
129
|
-
signer: adapter.signer,
|
|
130
|
-
|
|
131
|
-
// Optional parameters
|
|
132
|
-
appCode: 'YOUR_APP_CODE',
|
|
133
|
-
}
|
|
134
|
-
|
|
135
|
-
const quoteResult = await bridgingSdk.getQuote(parameters)
|
|
136
|
-
assertIsBridgeQuoteAndPost(quoteResult)
|
|
137
|
-
const { swap, bridge, postSwapOrderFromQuote } = quoteResult
|
|
138
|
-
|
|
139
|
-
// Display all data related to the swap and bridge
|
|
140
|
-
console.log('Swap info', swap)
|
|
141
|
-
console.log('Bridge info', bridge)
|
|
142
|
-
|
|
143
|
-
// Get the buy amount after slippage in the target chain
|
|
144
|
-
const { buyAmount } = bridge.amountsAndCosts.afterSlippage
|
|
145
|
-
|
|
146
|
-
if (confirm(`You will get at least: ${buyAmount}, ok?`)) {
|
|
147
|
-
const orderId = await postSwapOrderFromQuote()
|
|
148
|
-
console.log('Order created, id: ', orderId)
|
|
149
|
-
}
|
|
150
|
-
```
|
|
151
|
-
|
|
152
86
|
## Multi-Provider Quote Comparison
|
|
153
87
|
|
|
154
88
|
The `getMultiQuotes()` method allows you to get quotes from multiple bridge providers simultaneously, with support for progressive results as each provider responds.
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@cowprotocol/sdk-bridging",
|
|
3
|
-
"version": "4.0.
|
|
3
|
+
"version": "4.0.4",
|
|
4
4
|
"description": "Bridging for CoW Protocol",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -21,14 +21,14 @@
|
|
|
21
21
|
"dependencies": {
|
|
22
22
|
"@defuse-protocol/one-click-sdk-typescript": "0.1.1-0.2",
|
|
23
23
|
"json-stable-stringify": "^1.3.0",
|
|
24
|
-
"@cowprotocol/sdk-app-data": "5.1.
|
|
24
|
+
"@cowprotocol/sdk-app-data": "5.1.1",
|
|
25
25
|
"@cowprotocol/sdk-common": "0.10.2",
|
|
26
26
|
"@cowprotocol/sdk-config": "2.0.0",
|
|
27
|
-
"@cowprotocol/sdk-cow-shed": "0.3.
|
|
27
|
+
"@cowprotocol/sdk-cow-shed": "0.3.9",
|
|
28
28
|
"@cowprotocol/sdk-order-book": "3.0.0",
|
|
29
|
-
"@cowprotocol/sdk-
|
|
30
|
-
"@cowprotocol/sdk-
|
|
31
|
-
"@cowprotocol/sdk-
|
|
29
|
+
"@cowprotocol/sdk-weiroll": "0.1.31",
|
|
30
|
+
"@cowprotocol/sdk-contracts-ts": "3.0.2",
|
|
31
|
+
"@cowprotocol/sdk-trading": "2.0.4"
|
|
32
32
|
},
|
|
33
33
|
"devDependencies": {
|
|
34
34
|
"@types/jest": "^29.4.0",
|
|
@@ -44,10 +44,10 @@
|
|
|
44
44
|
"typescript": "^5.2.2",
|
|
45
45
|
"viem": "^2.28.4",
|
|
46
46
|
"@cow-sdk/typescript-config": "0.0.0-beta.0",
|
|
47
|
-
"@cowprotocol/sdk-ethers-
|
|
48
|
-
"@cowprotocol/sdk-ethers-
|
|
49
|
-
"@cowprotocol/sdk-
|
|
50
|
-
"@cowprotocol/sdk-
|
|
47
|
+
"@cowprotocol/sdk-ethers-v5-adapter": "0.4.5",
|
|
48
|
+
"@cowprotocol/sdk-ethers-v6-adapter": "0.4.5",
|
|
49
|
+
"@cowprotocol/sdk-viem-adapter": "0.3.19",
|
|
50
|
+
"@cowprotocol/sdk-order-signing": "1.0.2"
|
|
51
51
|
},
|
|
52
52
|
"scripts": {
|
|
53
53
|
"build": "tsup src/index.ts --format esm,cjs --dts",
|