Skip to content

Commit 97b2bc4

Browse files
committed
Add across and celer integration
1 parent b19824c commit 97b2bc4

File tree

9 files changed

+546
-61
lines changed

9 files changed

+546
-61
lines changed

src/__specs__/cross-chain-ethereum-ethereum.spec.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,30 @@
11
import { Address, Amount } from "@safeblock/blockchain-utils"
2+
import { describe, expect, it } from "vitest"
23
import { PriceStorageExtension } from "~/extensions"
3-
import { baseUSDC, bnbDAI, bnbUSDT, mainnetUSDC, mainnetUSDT, sdkConfig } from "./utils/sdk-test-config"
44
import SafeBlockSDK from "~/sdk"
55
import { ExchangeRequest, SimulatedRoute } from "~/types"
6-
import { describe, it, expect } from "vitest"
6+
import { baseUSDC, bnbDAI, bnbUSDT, maticUSDC, maticUSDT, sdkConfig } from "./utils/sdk-test-config"
77

88
describe("Cross chain exchanges from Ethereum to Ethereum", async () => {
99
const sdk = new SafeBlockSDK(sdkConfig)
1010

1111
const usdtTokenRequest: ExchangeRequest = {
1212
exactInput: true,
13-
amountIn: new Amount(10, mainnetUSDC.decimals, true),
13+
amountIn: new Amount(10, maticUSDC.decimals, true),
1414
amountsOut: [new Amount(0, bnbUSDT.decimals, true)],
1515
amountOutReadablePercentages: [100],
16-
tokenIn: mainnetUSDC,
16+
tokenIn: maticUSDC,
1717
tokensOut: [bnbUSDT],
1818
slippageReadablePercent: 1
1919
}
2020

2121
const tokenTokenRequest: ExchangeRequest = {
2222
exactInput: true,
2323
amountIn: new Amount(10, bnbDAI.decimals, true),
24-
amountsOut: [new Amount(0, mainnetUSDT.decimals, true)],
24+
amountsOut: [new Amount(0, maticUSDT.decimals, true)],
2525
amountOutReadablePercentages: [100],
2626
tokenIn: bnbDAI,
27-
tokensOut: [mainnetUSDT],
27+
tokensOut: [maticUSDT],
2828
slippageReadablePercent: 1
2929
}
3030

src/__specs__/cross-chain.simulation.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import SafeBlockSDK from "~/sdk"
66
import SdkException, { SdkExceptionCode } from "~/sdk/sdk-exception"
77
import { BasicToken, ExchangeRequest } from "~/types"
88

9-
describe("Single chain simulation", async () => {
9+
describe("Cross chain simulation", async () => {
1010
const sdk = new SafeBlockSDK({
1111
...sdkConfig,
1212
contractAddresses: {

src/abis/AcrossABI.json

Lines changed: 249 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1,249 @@
1-
[{"inputs":[{"internalType":"address","name":"spokePool_","type":"address"},{"internalType":"address","name":"wrappedNative_","type":"address"}],"stateMutability":"nonpayable","type":"constructor"},{"inputs":[],"name":"AcrossFacet_NotSpokePool","type":"error"},{"inputs":[],"name":"TransferHelper_ApproveError","type":"error"},{"inputs":[],"name":"TransferHelper_TransferError","type":"error"},{"inputs":[],"name":"TransferHelper_TransferFromError","type":"error"},{"inputs":[],"name":"TransientStorageFacetLibrary_InvalidSenderAddress","type":"error"},{"anonymous":false,"inputs":[{"indexed":false,"internalType":"bytes","name":"errorMessage","type":"bytes"}],"name":"CallFailed","type":"event"},{"inputs":[{"internalType":"address","name":"tokenSent","type":"address"},{"internalType":"uint256","name":"amount","type":"uint256"},{"internalType":"address","name":"","type":"address"},{"internalType":"bytes","name":"message","type":"bytes"}],"name":"handleV3AcrossMessage","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"components":[{"internalType":"address","name":"recipient","type":"address"},{"internalType":"address","name":"inputToken","type":"address"},{"internalType":"address","name":"outputToken","type":"address"},{"internalType":"uint256","name":"inputAmount","type":"uint256"},{"internalType":"uint256","name":"outputAmountPercent","type":"uint256"},{"internalType":"uint256","name":"destinationChainId","type":"uint256"},{"internalType":"address","name":"exclusiveRelayer","type":"address"},{"internalType":"uint32","name":"quoteTimestamp","type":"uint32"},{"internalType":"uint32","name":"fillDeadline","type":"uint32"},{"internalType":"uint32","name":"exclusivityDeadline","type":"uint32"},{"internalType":"bytes","name":"message","type":"bytes"}],"internalType":"struct IAcrossFacet.V3AcrossDepositParams","name":"acrossDepositParams","type":"tuple"}],"name":"sendAcrossDepositV3","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"spokePool","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"}]
1+
[
2+
{
3+
"inputs": [
4+
{
5+
"internalType": "address",
6+
"name": "spokePool_",
7+
"type": "address"
8+
},
9+
{
10+
"internalType": "address",
11+
"name": "wrappedNative_",
12+
"type": "address"
13+
},
14+
{
15+
"internalType": "address",
16+
"name": "endpointV2",
17+
"type": "address"
18+
}
19+
],
20+
"stateMutability": "nonpayable",
21+
"type": "constructor"
22+
},
23+
{
24+
"inputs": [],
25+
"name": "AcrossFacet_NotSpokePool",
26+
"type": "error"
27+
},
28+
{
29+
"inputs": [],
30+
"name": "TransferHelper_ApproveError",
31+
"type": "error"
32+
},
33+
{
34+
"inputs": [],
35+
"name": "TransferHelper_TransferError",
36+
"type": "error"
37+
},
38+
{
39+
"anonymous": false,
40+
"inputs": [
41+
{
42+
"indexed": false,
43+
"internalType": "bytes",
44+
"name": "errorMessage",
45+
"type": "bytes"
46+
}
47+
],
48+
"name": "CallFailed",
49+
"type": "event"
50+
},
51+
{
52+
"inputs": [
53+
{
54+
"internalType": "address",
55+
"name": "tokenSent",
56+
"type": "address"
57+
},
58+
{
59+
"internalType": "uint256",
60+
"name": "amount",
61+
"type": "uint256"
62+
},
63+
{
64+
"internalType": "address",
65+
"name": "",
66+
"type": "address"
67+
},
68+
{
69+
"internalType": "bytes",
70+
"name": "message",
71+
"type": "bytes"
72+
}
73+
],
74+
"name": "handleV3AcrossMessage",
75+
"outputs": [],
76+
"stateMutability": "nonpayable",
77+
"type": "function"
78+
},
79+
{
80+
"inputs": [
81+
{
82+
"components": [
83+
{
84+
"internalType": "address",
85+
"name": "recipient",
86+
"type": "address"
87+
},
88+
{
89+
"internalType": "address",
90+
"name": "inputToken",
91+
"type": "address"
92+
},
93+
{
94+
"internalType": "address",
95+
"name": "outputToken",
96+
"type": "address"
97+
},
98+
{
99+
"internalType": "uint256",
100+
"name": "inputAmount",
101+
"type": "uint256"
102+
},
103+
{
104+
"internalType": "uint256",
105+
"name": "outputAmountPercent",
106+
"type": "uint256"
107+
},
108+
{
109+
"internalType": "uint256",
110+
"name": "destinationChainId",
111+
"type": "uint256"
112+
},
113+
{
114+
"internalType": "address",
115+
"name": "exclusiveRelayer",
116+
"type": "address"
117+
},
118+
{
119+
"internalType": "uint32",
120+
"name": "quoteTimestamp",
121+
"type": "uint32"
122+
},
123+
{
124+
"internalType": "uint32",
125+
"name": "fillDeadline",
126+
"type": "uint32"
127+
},
128+
{
129+
"internalType": "uint32",
130+
"name": "exclusivityDeadline",
131+
"type": "uint32"
132+
},
133+
{
134+
"internalType": "uint32",
135+
"name": "dstEid",
136+
"type": "uint32"
137+
},
138+
{
139+
"internalType": "bytes",
140+
"name": "extraData",
141+
"type": "bytes"
142+
}
143+
],
144+
"internalType": "struct IAcrossFacet.AcrossDepositParams",
145+
"name": "acrossDepositParams",
146+
"type": "tuple"
147+
}
148+
],
149+
"name": "sendAcrossDeposit",
150+
"outputs": [
151+
{
152+
"internalType": "bytes32[]",
153+
"name": "tokensAndAmounts",
154+
"type": "bytes32[]"
155+
}
156+
],
157+
"stateMutability": "nonpayable",
158+
"type": "function"
159+
},
160+
{
161+
"inputs": [
162+
{
163+
"components": [
164+
{
165+
"internalType": "address",
166+
"name": "recipient",
167+
"type": "address"
168+
},
169+
{
170+
"internalType": "address",
171+
"name": "inputToken",
172+
"type": "address"
173+
},
174+
{
175+
"internalType": "address",
176+
"name": "outputToken",
177+
"type": "address"
178+
},
179+
{
180+
"internalType": "uint256",
181+
"name": "inputAmount",
182+
"type": "uint256"
183+
},
184+
{
185+
"internalType": "uint256",
186+
"name": "outputAmountPercent",
187+
"type": "uint256"
188+
},
189+
{
190+
"internalType": "uint256",
191+
"name": "destinationChainId",
192+
"type": "uint256"
193+
},
194+
{
195+
"internalType": "address",
196+
"name": "exclusiveRelayer",
197+
"type": "address"
198+
},
199+
{
200+
"internalType": "uint32",
201+
"name": "quoteTimestamp",
202+
"type": "uint32"
203+
},
204+
{
205+
"internalType": "uint32",
206+
"name": "fillDeadline",
207+
"type": "uint32"
208+
},
209+
{
210+
"internalType": "uint32",
211+
"name": "exclusivityDeadline",
212+
"type": "uint32"
213+
},
214+
{
215+
"internalType": "bytes",
216+
"name": "message",
217+
"type": "bytes"
218+
}
219+
],
220+
"internalType": "struct IAcrossFacet.V3AcrossDepositParams",
221+
"name": "acrossDepositParams",
222+
"type": "tuple"
223+
}
224+
],
225+
"name": "sendAcrossDepositV3",
226+
"outputs": [
227+
{
228+
"internalType": "bytes32[]",
229+
"name": "tokensAndAmounts",
230+
"type": "bytes32[]"
231+
}
232+
],
233+
"stateMutability": "nonpayable",
234+
"type": "function"
235+
},
236+
{
237+
"inputs": [],
238+
"name": "spokePool",
239+
"outputs": [
240+
{
241+
"internalType": "address",
242+
"name": "",
243+
"type": "address"
244+
}
245+
],
246+
"stateMutability": "view",
247+
"type": "function"
248+
}
249+
]

src/abis/CelerCCTPFacet.json

Lines changed: 91 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,91 @@
1+
[
2+
{
3+
"inputs": [
4+
{
5+
"internalType": "address",
6+
"name": "circleBridge",
7+
"type": "address"
8+
},
9+
{
10+
"internalType": "address",
11+
"name": "endpointV2",
12+
"type": "address"
13+
},
14+
{
15+
"internalType": "address",
16+
"name": "USDC_",
17+
"type": "address"
18+
}
19+
],
20+
"stateMutability": "nonpayable",
21+
"type": "constructor"
22+
},
23+
{
24+
"inputs": [],
25+
"name": "TransferHelper_ApproveError",
26+
"type": "error"
27+
},
28+
{
29+
"inputs": [
30+
{
31+
"internalType": "uint256",
32+
"name": "amount",
33+
"type": "uint256"
34+
},
35+
{
36+
"internalType": "uint64",
37+
"name": "dstChainId",
38+
"type": "uint64"
39+
}
40+
],
41+
"name": "quoteTransfer",
42+
"outputs": [
43+
{
44+
"internalType": "uint256",
45+
"name": "amountOut",
46+
"type": "uint256"
47+
}
48+
],
49+
"stateMutability": "view",
50+
"type": "function"
51+
},
52+
{
53+
"inputs": [
54+
{
55+
"internalType": "uint64",
56+
"name": "dstChainId",
57+
"type": "uint64"
58+
},
59+
{
60+
"internalType": "address",
61+
"name": "recipient",
62+
"type": "address"
63+
},
64+
{
65+
"internalType": "uint32",
66+
"name": "dstEid",
67+
"type": "uint32"
68+
},
69+
{
70+
"internalType": "address",
71+
"name": "tokenOut",
72+
"type": "address"
73+
},
74+
{
75+
"internalType": "bytes",
76+
"name": "extraData",
77+
"type": "bytes"
78+
}
79+
],
80+
"name": "sendCircleBridge",
81+
"outputs": [
82+
{
83+
"internalType": "bytes32[]",
84+
"name": "tokensAndAmounts",
85+
"type": "bytes32[]"
86+
}
87+
],
88+
"stateMutability": "nonpayable",
89+
"type": "function"
90+
}
91+
]

0 commit comments

Comments
 (0)