@orbs-network/spot 2.0.1 → 2.1.1
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 +27 -25
- package/config.json +20 -0
- package/index.css +92 -0
- package/index.html +50 -0
- package/out/02_DeployCosigner.s.sol/DeployCosigner.json +1 -1
- package/out/03_DeployReactor.s.sol/DeployReactor.json +1 -1
- package/out/04_DeployExecutor.s.sol/DeployExecutor.json +1 -1
- package/out/06_DeployDefaultAdapter.s.sol/DeployDefaultAdapter.json +1 -1
- package/out/06_DeployDelegatingAdapter.s.sol/DeployDelegatingAdapter.json +1 -1
- package/out/06_DeployP2Adapter.s.sol/DeployP2Adapter.json +1 -1
- package/out/06_DeployParaswapAdapter.s.sol/DeployParaswapAdapter.json +1 -1
- package/out/06_DeployUniversalAdapter.s.sol/DeployUniversalAdapter.json +1 -1
- package/out/BaseTest.sol/BaseTest.json +1 -1
- package/out/CosignatureLib.sol/CosignatureLib.json +1 -1
- package/out/CosignatureLib.t.sol/CosignatureLibTest.json +1 -1
- package/out/Cosigner.sol/Cosigner.json +1 -1
- package/out/Cosigner.t.sol/CosignerTest.json +1 -1
- package/out/Cosigner.t.sol/CosignerWrapper.json +1 -1
- package/out/CosignerIntegration.t.sol/CosignerIntegrationTest.json +1 -1
- package/out/DefaultDexAdapter.sol/DefaultDexAdapter.json +1 -1
- package/out/DefaultDexAdapter.t.sol/DefaultDexAdapterTest.json +1 -1
- package/out/DelegatingAdapter.sol/DelegatingAdapter.json +1 -1
- package/out/DelegatingAdapter.t.sol/DelegatingAdapterTest.json +1 -1
- package/out/DelegatingAdapter.t.sol/MockDelegateTarget.json +1 -1
- package/out/ExclusivityOverrideLib.t.sol/ExclusivityCaller.json +1 -1
- package/out/ExclusivityOverrideLib.t.sol/ExclusivityLibTest.json +1 -1
- package/out/Executor.sol/Executor.json +1 -1
- package/out/Executor.t.sol/ExecutorTest.json +1 -1
- package/out/ICommitteeSync.sol/ICommitteeSync.json +1 -1
- package/out/IExchangeAdapter.sol/IExchangeAdapter.json +1 -1
- package/out/IReactor.sol/IReactor.json +1 -1
- package/out/IReactorCallback.sol/IReactorCallback.json +1 -1
- package/out/IWrappedNative.sol/IWrappedNative.json +1 -1
- package/out/MockCommitteeSync.sol/MockCommitteeSync.json +1 -1
- package/out/MockReactor.sol/MockReactor.json +1 -1
- package/out/OrderLib.sol/OrderLib.json +1 -1
- package/out/OrderReactor.E2E.t.sol/OrderReactorE2ETest.json +1 -1
- package/out/OrderReactor.sol/OrderReactor.json +1 -1
- package/out/OrderReactorPause.t.sol/OrderReactorPauseTest.json +1 -1
- package/out/OrderReactorPause.t.sol/SimpleCallback.json +1 -1
- package/out/OrderValidationLib.Fuzz.t.sol/OrderValidationLibFuzzTest.json +1 -1
- package/out/OrderValidationLib.sol/OrderValidationLib.json +1 -1
- package/out/OrderValidationLib.t.sol/OrderValidationLibTest.json +1 -1
- package/out/P2DexAdapter.sol/P2DexAdapter.json +1 -1
- package/out/P2DexAdapter.t.sol/P2DexAdapterTest.json +1 -1
- package/out/ParaswapDexAdapter.sol/ParaswapDexAdapter.json +1 -1
- package/out/ParaswapDexAdapter.t.sol/ParaswapDexAdapterTest.json +1 -1
- package/out/RePermit.t.sol/RePermitTest.json +1 -1
- package/out/Refinery.t.sol/PayableTarget.json +1 -1
- package/out/Refinery.t.sol/RefineryTest.json +1 -1
- package/out/ResolutionLib.Fuzz.t.sol/ResolutionLibFuzzTest.json +1 -1
- package/out/ResolutionLib.sol/ResolutionLib.json +1 -1
- package/out/ResolutionLib.t.sol/ResolutionLibTest.json +1 -1
- package/out/SettlementLib.sol/SettlementLib.json +1 -1
- package/out/SettlementLib.t.sol/SettlementLibTest.json +1 -1
- package/out/SettlementLib.t.sol/SettlementWrapper.json +1 -1
- package/out/Settler.sol/Settler.json +1 -1
- package/out/Settler.t.sol/SettlerTest.json +1 -1
- package/out/SwapAdapter.sol/SwapAdapterMock.json +1 -1
- package/out/UniversalAdapter.sol/UniversalAdapter.json +1 -1
- package/out/UniversalAdapter.t.sol/UniversalAdapterTest.json +1 -1
- package/out/WM.t.sol/WMTest.json +1 -1
- package/out/WrappedNativeMock.sol/WrappedNativeMock.json +1 -1
- package/out/build-info/3df4e20ba14c59dd.json +1 -0
- package/out/build-info/465c047ca4b4665a.json +1 -0
- package/out/build-info/53b32d3edef4f2f5.json +1 -0
- package/out/build-info/60dfb67f4a3af77c.json +1 -0
- package/out/build-info/{4e40b5549a3a794d.json → 9750d071e9bed8fe.json} +1 -1
- package/package.json +4 -1
- package/skills/advanced-swap-orders/SKILL.md +54 -0
- package/skills/advanced-swap-orders/assets/repermit.skeleton.json +195 -0
- package/skills/advanced-swap-orders/assets/token-addressbook.md +97 -0
- package/skills/advanced-swap-orders/assets/web3-sign-and-submit.example.js +91 -0
- package/skills/advanced-swap-orders/manifest.json +70 -0
- package/skills/advanced-swap-orders/references/01-quickstart.md +13 -0
- package/skills/advanced-swap-orders/references/02-params.md +39 -0
- package/skills/advanced-swap-orders/references/03-sign.md +7 -0
- package/skills/advanced-swap-orders/references/04-patterns.md +12 -0
- package/skills/advanced-swap-orders/scripts/order.js +940 -0
|
@@ -0,0 +1,195 @@
|
|
|
1
|
+
{
|
|
2
|
+
"domain": {
|
|
3
|
+
"name": "RePermit",
|
|
4
|
+
"version": "1",
|
|
5
|
+
"chainId": "<CHAINID>",
|
|
6
|
+
"verifyingContract": "<REPERMIT>"
|
|
7
|
+
},
|
|
8
|
+
"primaryType": "RePermitWitnessTransferFrom",
|
|
9
|
+
"types": {
|
|
10
|
+
"RePermitWitnessTransferFrom": [
|
|
11
|
+
{
|
|
12
|
+
"name": "permitted",
|
|
13
|
+
"type": "TokenPermissions"
|
|
14
|
+
},
|
|
15
|
+
{
|
|
16
|
+
"name": "spender",
|
|
17
|
+
"type": "address"
|
|
18
|
+
},
|
|
19
|
+
{
|
|
20
|
+
"name": "nonce",
|
|
21
|
+
"type": "uint256"
|
|
22
|
+
},
|
|
23
|
+
{
|
|
24
|
+
"name": "deadline",
|
|
25
|
+
"type": "uint256"
|
|
26
|
+
},
|
|
27
|
+
{
|
|
28
|
+
"name": "witness",
|
|
29
|
+
"type": "Order"
|
|
30
|
+
}
|
|
31
|
+
],
|
|
32
|
+
"Exchange": [
|
|
33
|
+
{
|
|
34
|
+
"name": "adapter",
|
|
35
|
+
"type": "address"
|
|
36
|
+
},
|
|
37
|
+
{
|
|
38
|
+
"name": "ref",
|
|
39
|
+
"type": "address"
|
|
40
|
+
},
|
|
41
|
+
{
|
|
42
|
+
"name": "share",
|
|
43
|
+
"type": "uint32"
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "data",
|
|
47
|
+
"type": "bytes"
|
|
48
|
+
}
|
|
49
|
+
],
|
|
50
|
+
"Input": [
|
|
51
|
+
{
|
|
52
|
+
"name": "token",
|
|
53
|
+
"type": "address"
|
|
54
|
+
},
|
|
55
|
+
{
|
|
56
|
+
"name": "amount",
|
|
57
|
+
"type": "uint256"
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "maxAmount",
|
|
61
|
+
"type": "uint256"
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
"Order": [
|
|
65
|
+
{
|
|
66
|
+
"name": "reactor",
|
|
67
|
+
"type": "address"
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "executor",
|
|
71
|
+
"type": "address"
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
"name": "exchange",
|
|
75
|
+
"type": "Exchange"
|
|
76
|
+
},
|
|
77
|
+
{
|
|
78
|
+
"name": "swapper",
|
|
79
|
+
"type": "address"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"name": "nonce",
|
|
83
|
+
"type": "uint256"
|
|
84
|
+
},
|
|
85
|
+
{
|
|
86
|
+
"name": "start",
|
|
87
|
+
"type": "uint256"
|
|
88
|
+
},
|
|
89
|
+
{
|
|
90
|
+
"name": "deadline",
|
|
91
|
+
"type": "uint256"
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "chainid",
|
|
95
|
+
"type": "uint256"
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
"name": "exclusivity",
|
|
99
|
+
"type": "uint32"
|
|
100
|
+
},
|
|
101
|
+
{
|
|
102
|
+
"name": "epoch",
|
|
103
|
+
"type": "uint32"
|
|
104
|
+
},
|
|
105
|
+
{
|
|
106
|
+
"name": "slippage",
|
|
107
|
+
"type": "uint32"
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
"name": "freshness",
|
|
111
|
+
"type": "uint32"
|
|
112
|
+
},
|
|
113
|
+
{
|
|
114
|
+
"name": "input",
|
|
115
|
+
"type": "Input"
|
|
116
|
+
},
|
|
117
|
+
{
|
|
118
|
+
"name": "output",
|
|
119
|
+
"type": "Output"
|
|
120
|
+
}
|
|
121
|
+
],
|
|
122
|
+
"Output": [
|
|
123
|
+
{
|
|
124
|
+
"name": "token",
|
|
125
|
+
"type": "address"
|
|
126
|
+
},
|
|
127
|
+
{
|
|
128
|
+
"name": "limit",
|
|
129
|
+
"type": "uint256"
|
|
130
|
+
},
|
|
131
|
+
{
|
|
132
|
+
"name": "triggerLower",
|
|
133
|
+
"type": "uint256"
|
|
134
|
+
},
|
|
135
|
+
{
|
|
136
|
+
"name": "triggerUpper",
|
|
137
|
+
"type": "uint256"
|
|
138
|
+
},
|
|
139
|
+
{
|
|
140
|
+
"name": "recipient",
|
|
141
|
+
"type": "address"
|
|
142
|
+
}
|
|
143
|
+
],
|
|
144
|
+
"TokenPermissions": [
|
|
145
|
+
{
|
|
146
|
+
"name": "token",
|
|
147
|
+
"type": "address"
|
|
148
|
+
},
|
|
149
|
+
{
|
|
150
|
+
"name": "amount",
|
|
151
|
+
"type": "uint256"
|
|
152
|
+
}
|
|
153
|
+
]
|
|
154
|
+
},
|
|
155
|
+
"message": {
|
|
156
|
+
"permitted": {
|
|
157
|
+
"token": "<INTOKEN>",
|
|
158
|
+
"amount": "<INTOTALAMOUNT>"
|
|
159
|
+
},
|
|
160
|
+
"spender": "<REACTOR>",
|
|
161
|
+
"nonce": "<NONCE>",
|
|
162
|
+
"deadline": "<DEADLINE>",
|
|
163
|
+
"witness": {
|
|
164
|
+
"reactor": "<REACTOR>",
|
|
165
|
+
"executor": "<EXECUTOR>",
|
|
166
|
+
"exchange": {
|
|
167
|
+
"adapter": "<ADAPTER>",
|
|
168
|
+
"ref": "<REFERRER>",
|
|
169
|
+
"share": "<REFSHAREBPS>",
|
|
170
|
+
"data": "<ADAPTER_USER_DATA>"
|
|
171
|
+
},
|
|
172
|
+
"swapper": "<SWAPPER>",
|
|
173
|
+
"nonce": "<NONCE>",
|
|
174
|
+
"start": "<START>",
|
|
175
|
+
"deadline": "<DEADLINE>",
|
|
176
|
+
"chainid": "<CHAINID>",
|
|
177
|
+
"exclusivity": "<EXCLUSIVITYBPS>",
|
|
178
|
+
"epoch": "<EPOCHSECONDS>",
|
|
179
|
+
"slippage": "<SLIPPAGEBPS>",
|
|
180
|
+
"freshness": "<FRESHNESSSECONDS>",
|
|
181
|
+
"input": {
|
|
182
|
+
"token": "<INTOKEN>",
|
|
183
|
+
"amount": "<INCHUNKAMOUNT>",
|
|
184
|
+
"maxAmount": "<INTOTALAMOUNT>"
|
|
185
|
+
},
|
|
186
|
+
"output": {
|
|
187
|
+
"token": "<OUTTOKEN>",
|
|
188
|
+
"limit": "<OUTAMOUNTMIN>",
|
|
189
|
+
"triggerLower": "<OUTAMOUNTTRIGGERLOWER>",
|
|
190
|
+
"triggerUpper": "<OUTAMOUNTTRIGGERUPPER>",
|
|
191
|
+
"recipient": "<RECIPIENT>"
|
|
192
|
+
}
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
}
|
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
# Common Token Addressbook
|
|
2
|
+
|
|
3
|
+
## Ethereum (`1`)
|
|
4
|
+
|
|
5
|
+
1. `weth`: `0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2`
|
|
6
|
+
2. `wbtc`: `0x2260FAC5E5542a773Aa44fBCfeDf7C193bc2C599`
|
|
7
|
+
3. `usdc`: `0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48`
|
|
8
|
+
4. `usdt`: `0xdAC17F958D2ee523a2206206994597C13D831ec7`
|
|
9
|
+
5. `dai`: `0x6B175474E89094C44Da98b954EedeAC495271d0F`
|
|
10
|
+
6. `lusd`: `0x5f98805A4E8be255a32880FDeC7F6728C6568bA0`
|
|
11
|
+
7. `orbs`: `0xff56Cc6b1E6dEd347aA0B7676C85AB0B3D08B0FA`
|
|
12
|
+
|
|
13
|
+
## BNB Chain (`56`)
|
|
14
|
+
|
|
15
|
+
1. `wbnb`: `0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c`
|
|
16
|
+
2. `btcb`: `0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c`
|
|
17
|
+
3. `wbtc`: `0x0555e30da8f98308edb960aa94c0db47230d2b9c`
|
|
18
|
+
4. `usdc`: `0x8AC76a51cc950d9822D68b83fE1Ad97B32Cd580d`
|
|
19
|
+
5. `usdt`: `0x55d398326f99059fF775485246999027B3197955`
|
|
20
|
+
6. `usd1`: `0x8d0d000ee44948fc98c9b98a4fa4921476f08b0d`
|
|
21
|
+
7. `dai`: `0x1AF3F329e8BE154074D8769D1FFa4eE058B1DBc3`
|
|
22
|
+
8. `busd`: `0xe9e7CEA3DedcA5984780Bafc599bD69ADd087D56`
|
|
23
|
+
9. `weth`: `0x2170Ed0880ac9A755fd29B2688956BD959F933F8`
|
|
24
|
+
10. `orbs`: `0x43a8cab15D06d3a5fE5854D714C37E7E9246F170`
|
|
25
|
+
|
|
26
|
+
## Polygon (`137`)
|
|
27
|
+
|
|
28
|
+
1. `wmatic`: `0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270`
|
|
29
|
+
2. `wbtc`: `0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6`
|
|
30
|
+
3. `usdc`: `0x3c499c542cEF5E3811e1192ce70d8cC03d5c3359`
|
|
31
|
+
4. `usdc.e`: `0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174`
|
|
32
|
+
5. `usdt`: `0xc2132D05D31c914a87C6611C10748AEb04B58e8F`
|
|
33
|
+
6. `dai`: `0x8f3Cf7ad23Cd3CaDbD9735AFf958023239c6A063`
|
|
34
|
+
7. `weth`: `0x7ceb23fd6bc0add59e62ac25578270cff1b9f619`
|
|
35
|
+
8. `orbs`: `0x614389EaAE0A6821DC49062D56BDA3d9d45Fa2ff`
|
|
36
|
+
|
|
37
|
+
## Arbitrum One (`42161`)
|
|
38
|
+
|
|
39
|
+
1. `weth`: `0x82af49447d8a07e3bd95bd0d56f35241523fbab1`
|
|
40
|
+
2. `wbtc`: `0x2f2a2543b76a4166549f7aab2e75bef0aefc5b0f`
|
|
41
|
+
3. `usdc`: `0xaf88d065e77c8cC2239327C5EDb3A432268e5831`
|
|
42
|
+
4. `usdt`: `0xfd086bc7cd5c481dcc9c85ebe478a1c0b69fcbb9`
|
|
43
|
+
5. `dai`: `0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1`
|
|
44
|
+
6. `arb`: `0x912CE59144191C1204E64559FE8253a0e49E6548`
|
|
45
|
+
7. `orbs`: `0xf3C091ed43de9c270593445163a41A876A0bb3dd`
|
|
46
|
+
|
|
47
|
+
## Optimism (`10`)
|
|
48
|
+
|
|
49
|
+
1. `weth`: `0x4200000000000000000000000000000000000006`
|
|
50
|
+
2. `wbtc`: `0x68f180fcCe6836688e9084f035309E29Bf0A2095`
|
|
51
|
+
3. `usdc`: `0x7F5c764cBc14f9669B88837ca1490cCa17c31607`
|
|
52
|
+
4. `usdt`: `0x94b008aA00579c1307B0EF2c499aD98a8ce58e58`
|
|
53
|
+
5. `dai`: `0xDA10009cBd5D07dd0CeCc66161FC93D7c9000da1`
|
|
54
|
+
6. `op`: `0x4200000000000000000000000000000000000042`
|
|
55
|
+
|
|
56
|
+
## Avalanche (`43114`)
|
|
57
|
+
|
|
58
|
+
1. `wavax`: `0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7`
|
|
59
|
+
2. `wbtc`: `0x50b7545627a5162F82A992c33b87aDc75187B218`
|
|
60
|
+
3. `usdc`: `0xA7D7079b0FEaD91F3e65f86E8915Cb59c1a4C664`
|
|
61
|
+
4. `usdt`: `0xc7198437980c041c805A1EDcbA50c1Ce5db95118`
|
|
62
|
+
5. `dai`: `0xd586E7F844cEa2F87f50152665BCbc2C279D8d70`
|
|
63
|
+
6. `weth`: `0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB`
|
|
64
|
+
7. `orbs`: `0x340fE1D898ECCAad394e2ba0fC1F93d27c7b717A`
|
|
65
|
+
|
|
66
|
+
## Base (`8453`)
|
|
67
|
+
|
|
68
|
+
1. `weth`: `0x4200000000000000000000000000000000000006`
|
|
69
|
+
2. `usdc`: `0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913`
|
|
70
|
+
3. `dai`: `0x50c5725949A6F0c72E6C4a641F24049A917DB0Cb`
|
|
71
|
+
4. `cbbtc`: `0xcbb7c0000ab88b473b1f5afd9ef808440eed33bf`
|
|
72
|
+
|
|
73
|
+
## Mantle (`5000`)
|
|
74
|
+
|
|
75
|
+
1. `wmnt`: `0x78c1b0C915c4FAA5FffA6CAbf0219DA63d7f4cb8`
|
|
76
|
+
2. `weth`: `0xdeaddeaddeaddeaddeaddeaddeaddeaddead1111`
|
|
77
|
+
3. `usdc`: `0x09Bc4E0D864854c6aFB6eB9A9cdF58aC190D0dF9`
|
|
78
|
+
4. `usdt`: `0x201eba5cc46D216Ce6DC03F6a759e8E766e956Ae`
|
|
79
|
+
5. `usdt0`: `0x779Ded0c9e1022225f8E0630b35a9b54bE713736`
|
|
80
|
+
|
|
81
|
+
## Linea (`59144`)
|
|
82
|
+
|
|
83
|
+
1. `weth`: `0xe5D7C2a44FfDDf6b295A15c148167daaAf5Cf34f`
|
|
84
|
+
2. `wbtc`: `0x3aAB2285ddcDdaD8edf438C1bAB47e1a9D05a9b4`
|
|
85
|
+
3. `usdc`: `0x176211869cA2b568f2A7D4EE941E073a821EE1ff`
|
|
86
|
+
4. `usdt`: `0xA219439258ca9da29E9Cc4cE5596924745e12B93`
|
|
87
|
+
5. `dai`: `0x4AF15ec2A0BD43Db75dd04E62FAA3B8EF36b00d5`
|
|
88
|
+
|
|
89
|
+
## Sonic (`146`)
|
|
90
|
+
|
|
91
|
+
1. `ws`: `0x039e2fB66102314Ce7b64Ce5Ce3E5183bc94aD38`
|
|
92
|
+
2. `wbtc`: `0x0555E30da8f98308EdB960aa94C0Db47230d2B9c`
|
|
93
|
+
3. `weth`: `0x50c42dEAcD8Fc9773493ED674b675bE577f2634b`
|
|
94
|
+
4. `usdc`: `0x29219dd400f2Bf60E5a23d13Be72B486D4038894`
|
|
95
|
+
5. `usdt`: `0x6047828dc181963ba44974801FF68e538dA5eaF9`
|
|
96
|
+
6. `sfc`: `0xFC00FACE00000000000000000000000000000000`
|
|
97
|
+
|
|
@@ -0,0 +1,91 @@
|
|
|
1
|
+
// Example only. This flow uses eth_signTypedData_v4 via an injected provider,
|
|
2
|
+
// but any framework that signs the same prepared.typedData payload is valid.
|
|
3
|
+
|
|
4
|
+
import Web3 from "web3";
|
|
5
|
+
|
|
6
|
+
const DEPOSIT_DATA = "0xd0e30db0";
|
|
7
|
+
|
|
8
|
+
export async function approveSignAndSubmitOrder({
|
|
9
|
+
prepared,
|
|
10
|
+
account,
|
|
11
|
+
provider = window.ethereum,
|
|
12
|
+
wrappedNative,
|
|
13
|
+
nativeInputAmount,
|
|
14
|
+
sendApproval = false,
|
|
15
|
+
}) {
|
|
16
|
+
const web3 = new Web3(provider);
|
|
17
|
+
const normalizedAccount = account.toLowerCase();
|
|
18
|
+
const expectedSigner = prepared.signing.signer.toLowerCase();
|
|
19
|
+
|
|
20
|
+
// The EIP-712 signer must be the same address that created the order.
|
|
21
|
+
if (normalizedAccount !== expectedSigner) {
|
|
22
|
+
throw new Error(
|
|
23
|
+
`signer mismatch: expected ${prepared.signing.signer}, got ${account}`
|
|
24
|
+
);
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
// Native input is not supported by the order itself.
|
|
28
|
+
// If the input starts as the chain's native asset, wrap it to WNATIVE first.
|
|
29
|
+
if (
|
|
30
|
+
nativeInputAmount != null &&
|
|
31
|
+
nativeInputAmount !== "0" &&
|
|
32
|
+
nativeInputAmount !== "0x0"
|
|
33
|
+
) {
|
|
34
|
+
if (!wrappedNative) {
|
|
35
|
+
throw new Error("wrappedNative is required when nativeInputAmount is set");
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
await web3.eth.sendTransaction({
|
|
39
|
+
from: account,
|
|
40
|
+
to: wrappedNative,
|
|
41
|
+
data: DEPOSIT_DATA,
|
|
42
|
+
value: nativeInputAmount,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Approval is optional.
|
|
47
|
+
// Only send this transaction when the current ERC-20 allowance is lower than
|
|
48
|
+
// prepared.approval.amount, or when you know approval is still needed.
|
|
49
|
+
if (sendApproval) {
|
|
50
|
+
await web3.eth.sendTransaction({
|
|
51
|
+
from: account,
|
|
52
|
+
to: prepared.approval.tx.to,
|
|
53
|
+
data: prepared.approval.tx.data,
|
|
54
|
+
value: prepared.approval.tx.value,
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
// This example uses eth_signTypedData_v4, but any equivalent EIP-712 signer works.
|
|
59
|
+
const signature = await provider.request({
|
|
60
|
+
method: "eth_signTypedData_v4",
|
|
61
|
+
params: [account, JSON.stringify(prepared.typedData)],
|
|
62
|
+
});
|
|
63
|
+
|
|
64
|
+
// Submit the order payload plus the returned signature to the relay endpoint.
|
|
65
|
+
const response = await fetch(prepared.submit.url, {
|
|
66
|
+
method: "POST",
|
|
67
|
+
headers: {
|
|
68
|
+
"content-type": "application/json",
|
|
69
|
+
},
|
|
70
|
+
body: JSON.stringify({
|
|
71
|
+
...prepared.submit.body,
|
|
72
|
+
signature,
|
|
73
|
+
}),
|
|
74
|
+
});
|
|
75
|
+
|
|
76
|
+
const text = await response.text();
|
|
77
|
+
let body;
|
|
78
|
+
|
|
79
|
+
try {
|
|
80
|
+
body = JSON.parse(text);
|
|
81
|
+
} catch {
|
|
82
|
+
body = text;
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return {
|
|
86
|
+
ok: response.ok,
|
|
87
|
+
status: response.status,
|
|
88
|
+
signature,
|
|
89
|
+
body,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "advanced-swap-orders",
|
|
3
|
+
"description": "Prepare, sign, submit, and query non-custodial, decentralized, gasless swap orders and advanced order types on supported chains. Uses ownerless, immutable, audited, battle-tested, and verified contracts. Supports market, limit, stop-loss, take-profit, delayed-start, and chunked/TWAP-style orders with oracle-protected execution on every chunk. Includes automated execution through time as required by the order, EIP-712 signing, approval calldata, and order status lookup.",
|
|
4
|
+
"entrypoint": "SKILL.md",
|
|
5
|
+
"references": [
|
|
6
|
+
"references/01-quickstart.md",
|
|
7
|
+
"references/02-params.md",
|
|
8
|
+
"references/03-sign.md",
|
|
9
|
+
"references/04-patterns.md"
|
|
10
|
+
],
|
|
11
|
+
"scripts": [
|
|
12
|
+
"scripts/order.js"
|
|
13
|
+
],
|
|
14
|
+
"assets": [
|
|
15
|
+
"assets/token-addressbook.md",
|
|
16
|
+
"assets/repermit.skeleton.json",
|
|
17
|
+
"assets/web3-sign-and-submit.example.js"
|
|
18
|
+
],
|
|
19
|
+
"runtime": {
|
|
20
|
+
"url": "https://agents-sink.orbs.network",
|
|
21
|
+
"contracts": {
|
|
22
|
+
"zero": "0x0000000000000000000000000000000000000000",
|
|
23
|
+
"repermit": "0x00002a9C4D9497df5Bd31768eC5d30eEf5405000",
|
|
24
|
+
"reactor": "0x000000b33fE4fB9d999Dd684F79b110731c3d000",
|
|
25
|
+
"executor": "0x000642A0966d9bd49870D9519f76b5cf823f3000"
|
|
26
|
+
},
|
|
27
|
+
"chains": {
|
|
28
|
+
"1": {
|
|
29
|
+
"name": "Ethereum",
|
|
30
|
+
"adapter": "0xC1bB4d5071Fe7109ae2D67AE05826A3fe9116cfc"
|
|
31
|
+
},
|
|
32
|
+
"10": {
|
|
33
|
+
"name": "Optimism",
|
|
34
|
+
"adapter": "0xC5Aea83Fdd94A19fB2ce0B7207939C52825D3D3B"
|
|
35
|
+
},
|
|
36
|
+
"56": {
|
|
37
|
+
"name": "BNB Chain",
|
|
38
|
+
"adapter": "0x67Feba015c968c76cCB2EEabf197b4578640BE2C"
|
|
39
|
+
},
|
|
40
|
+
"137": {
|
|
41
|
+
"name": "Polygon",
|
|
42
|
+
"adapter": "0x75A3d70Fa6d054d31C896b9Cf8AB06b1c1B829B8"
|
|
43
|
+
},
|
|
44
|
+
"146": {
|
|
45
|
+
"name": "Sonic",
|
|
46
|
+
"adapter": "0x58fD209C81D84739BaD9c72C082350d67E713EEa"
|
|
47
|
+
},
|
|
48
|
+
"8453": {
|
|
49
|
+
"name": "Base",
|
|
50
|
+
"adapter": "0x5906C4dD71D5afFe1a8f0215409E912eB5d593AD"
|
|
51
|
+
},
|
|
52
|
+
"5000": {
|
|
53
|
+
"name": "Mantle",
|
|
54
|
+
"adapter": "0x9571D46B5A5AAb749E5aCd698D8F20814C7B23D3"
|
|
55
|
+
},
|
|
56
|
+
"42161": {
|
|
57
|
+
"name": "Arbitrum One",
|
|
58
|
+
"adapter": "0x026B8977319F67078e932a08feAcB59182B5380f"
|
|
59
|
+
},
|
|
60
|
+
"43114": {
|
|
61
|
+
"name": "Avalanche",
|
|
62
|
+
"adapter": "0x4F48041842827823D3750399eCa2832fC2E29201"
|
|
63
|
+
},
|
|
64
|
+
"59144": {
|
|
65
|
+
"name": "Linea",
|
|
66
|
+
"adapter": "0x55E4da2cd634729064bEb294EC682Dc94f5c3f24"
|
|
67
|
+
}
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
# Quickstart
|
|
2
|
+
|
|
3
|
+
1. Required fields: `chainId`, `swapper`, `input.token`, `input.amount`, `output.token`.
|
|
4
|
+
2. Read [02-params.md](02-params.md) for defaults, units, chunking semantics, native asset rules, and validation notes.
|
|
5
|
+
3. Read [04-patterns.md](04-patterns.md) to choose the right market, limit, stop-loss, take-profit, delayed, or chunked shape.
|
|
6
|
+
4. Prepare: `node scripts/order.js prepare --params <params.json|->`
|
|
7
|
+
5. If approval is needed, send `prepared.approval.tx`.
|
|
8
|
+
6. Infinite approval to `RePermit` is acceptable; no approval reset is needed.
|
|
9
|
+
7. Sign `prepared.typedData` as the `swapper`.
|
|
10
|
+
8. Read [03-sign.md](03-sign.md) for signature formats, submit modes, query usage, and direct onchain cancel.
|
|
11
|
+
9. Submit: `node scripts/order.js submit --prepared <prepared.json|-> --signature <0x...|json>`
|
|
12
|
+
10. Query: `node scripts/order.js query --swapper <0x...>` or `--hash <0x...>`
|
|
13
|
+
11. When measuring a fill onchain, sum both transfers to the swapper: the main fill and the surplus refund. Measuring only the main fill undercounts actual output by up to the slippage tolerance.
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
# Params
|
|
2
|
+
|
|
3
|
+
Use this file for field semantics, defaults, units, and validation. Use [04-patterns.md](04-patterns.md) for intent-to-parameter recipes.
|
|
4
|
+
|
|
5
|
+
1. Required: `chainId`, `swapper`, `input.token`, `input.amount`, `output.token`.
|
|
6
|
+
2. Optional: `input.maxAmount`, `nonce`, `start`, `deadline`, `epoch`, `slippage`, `output.limit`, `output.triggerLower`, `output.triggerUpper`, `output.recipient`.
|
|
7
|
+
3. `input.amount` is the fixed per-chunk size. `input.maxAmount` is total size and approval amount. If omitted, it defaults to `input.amount`. If it is not divisible by `input.amount`, the helper rounds it down to a whole number of chunks.
|
|
8
|
+
4. `output.limit`, `output.triggerLower`, and `output.triggerUpper` are output-token units per chunk.
|
|
9
|
+
5. Future `start` delays the first fill. `epoch` is the delay between chunks, but it is not exact: each chunk can fill anywhere inside its epoch window, only once. Large `epoch` is not a delayed order by itself.
|
|
10
|
+
6. Chunked orders should use `epoch > 0`; with `epoch = 0`, only the first chunk can fill.
|
|
11
|
+
7. Defaults:
|
|
12
|
+
- `input.maxAmount = input.amount`
|
|
13
|
+
- `nonce = now`
|
|
14
|
+
- `start = now`
|
|
15
|
+
- `epoch = 0` for single orders, `60` for chunked orders
|
|
16
|
+
- `deadline = start + 300 + chunkCount * epoch`
|
|
17
|
+
- `slippage = 500`
|
|
18
|
+
- `output.limit = 0`
|
|
19
|
+
- `output.recipient = swapper`
|
|
20
|
+
8. Higher slippage is still protected by oracle pricing and offchain executors.
|
|
21
|
+
9. `output.recipient` is dangerous to change away from `swapper`.
|
|
22
|
+
10. Native input is not supported. Wrap to WNATIVE first. Native output is supported with `output.token = 0x0000000000000000000000000000000000000000`.
|
|
23
|
+
11. Example:
|
|
24
|
+
|
|
25
|
+
```json
|
|
26
|
+
{
|
|
27
|
+
"chainId": 42161,
|
|
28
|
+
"swapper": "0x1111111111111111111111111111111111111111",
|
|
29
|
+
"input": {
|
|
30
|
+
"token": "0xaf88d065e77c8cC2239327C5EDb3A432268e5831",
|
|
31
|
+
"amount": "1000000"
|
|
32
|
+
},
|
|
33
|
+
"output": {
|
|
34
|
+
"token": "0x82af49447d8a07e3bd95bd0d56f35241523fbab1",
|
|
35
|
+
"limit": "0"
|
|
36
|
+
},
|
|
37
|
+
"epoch": 3600
|
|
38
|
+
}
|
|
39
|
+
```
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
# Sign And Submit
|
|
2
|
+
|
|
3
|
+
1. Sign `prepared.typedData` with any EIP-712-capable wallet or library. The signer must equal `swapper`. `eth_signTypedData_v4` is only one example.
|
|
4
|
+
2. Submit with `--prepared <prepared.json|->` and exactly one signature mode: `--signature <0x...|json>`, `--signature-file <sig.txt|sig.json|->`, or `--r <0x...> --s <0x...> --v <0x...>`.
|
|
5
|
+
3. The helper accepts a full 65-byte signature, a JSON string, or JSON/object `r/s/v`.
|
|
6
|
+
4. Query with `node scripts/order.js query --swapper <0x...>` or `--hash <0x...>`.
|
|
7
|
+
5. Cancel trustlessly onchain by calling `RePermit.cancel([digest])` as the swapper for the signed RePermit digest.
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
# Order Patterns
|
|
2
|
+
|
|
3
|
+
1. Market swap: `input.amount = input.maxAmount`, `output.limit = 0`.
|
|
4
|
+
2. Limit order: `input.amount = input.maxAmount`, `output.limit > 0`.
|
|
5
|
+
3. Stop-loss or take-profit: set `output.triggerLower` and/or `output.triggerUpper`.
|
|
6
|
+
4. Delayed order: set future `start`.
|
|
7
|
+
5. Chunked or TWAP-style: set `input.amount < input.maxAmount`.
|
|
8
|
+
6. Time-spaced chunked order: set `epoch > 0`. For example, `epoch = 60` means one chunk can fill once anywhere inside each 60-second epoch window.
|
|
9
|
+
7. `N chunks`: use one TWAP order instead of manually submitting `N` separate orders. Use `input.maxAmount` as the requested total amount, set `input.amount = floor(total / N)`, and accept any rounded-down remainder as dust.
|
|
10
|
+
8. If timing is omitted for a chunked or TWAP order, `epoch` defaults to `60`. Single orders default to `0`.
|
|
11
|
+
9. Native output: set `output.token = 0x0000000000000000000000000000000000000000`.
|
|
12
|
+
10. Best execution and oracle protection apply regardless of `output.limit`.
|