aegis-swap-widget 0.3.3 → 0.3.5
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/CHANGELOG.md +49 -0
- package/README.md +119 -44
- package/dist/abis.d.ts +0 -73
- package/dist/aegis-swap-widget.js +3412 -2396
- package/dist/config/chains.d.ts +11 -0
- package/dist/config/constants.d.ts +8 -0
- package/dist/config/contracts.d.ts +6 -0
- package/dist/config/createMarket.d.ts +3 -0
- package/dist/config/index.d.ts +7 -0
- package/dist/config/markets.d.ts +3 -0
- package/dist/config/tokens.d.ts +11 -0
- package/dist/{config.d.ts → config/types.d.ts} +5 -26
- package/dist/core.d.ts +4 -14
- package/dist/core.js +9 -64
- package/dist/encoding.d.ts +0 -29
- package/dist/hooks/useSubmitSwap.d.ts +11 -29
- package/dist/hooks/useSwapQuote.d.ts +3 -2
- package/dist/index.d.ts +3 -1
- package/dist/metadata-D56OpXF2.js +379 -0
- package/dist/permit.d.ts +1 -47
- package/dist/quote/aggregatedSwapQuote.d.ts +5 -0
- package/dist/services/kyberSwap.d.ts +84 -0
- package/dist/styles.css +1 -1
- package/dist/types/aggregatedSwap.d.ts +29 -0
- package/dist/widget/AegisAggregatedSwapWidget.d.ts +3 -0
- package/dist/widget/AmountField.d.ts +5 -1
- package/dist/widget/SwapWidgetShell.d.ts +51 -0
- package/dist/widget/TokenSelector.d.ts +13 -0
- package/dist/widget/types.d.ts +23 -2
- package/dist/widget/useAggregatedSwapController.d.ts +75 -0
- package/dist/widget/useRailAutoReset.d.ts +11 -0
- package/dist/widget/useStatusSurface.d.ts +32 -0
- package/dist/widget/useSwapController.d.ts +10 -9
- package/dist/widget/useWidgetStyle.d.ts +13 -0
- package/dist/widget/viewState.d.ts +22 -2
- package/package.json +23 -21
- package/dist/polling-e6X8l7pt.js +0 -1252
- package/dist/swap/authorizePermit.d.ts +0 -30
- package/dist/swap/executeSwapTransaction.d.ts +0 -39
- package/dist/swap/types.d.ts +0 -7
package/CHANGELOG.md
CHANGED
|
@@ -1,13 +1,43 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.3.5
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- 155f6d5: Route Connect wallet and network-switch CTAs through wallet actions before swap validation. Derive the aggregated widget's submit `data-action` from the wallet connection state so it reports `connect` instead of `swap` while the CTA reads "Connect wallet".
|
|
8
|
+
|
|
9
|
+
Confirm the wallet actually moved to the target chain before the network-switch
|
|
10
|
+
CTA advances, instead of optimistically marking it switched.
|
|
11
|
+
|
|
12
|
+
- Updated dependencies [d38966f]
|
|
13
|
+
- @aegis-engine/core@0.1.3
|
|
14
|
+
|
|
15
|
+
## 0.3.4
|
|
16
|
+
|
|
17
|
+
### Patch Changes
|
|
18
|
+
|
|
19
|
+
- effa726: Consume shared logic from @aegis-engine/core via workspace dependency; new ./core subpath re-export; GRASS_USDC routes through the 30-tick reference pool
|
|
20
|
+
- Updated dependencies [effa726]
|
|
21
|
+
- @aegis-engine/core@0.1.2
|
|
22
|
+
|
|
3
23
|
All notable changes to this project are documented in this file.
|
|
4
24
|
|
|
5
25
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.1.0/),
|
|
6
26
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html).
|
|
7
27
|
|
|
28
|
+
## [0.3.3] - 2026-06-08
|
|
29
|
+
|
|
30
|
+
### Fixed
|
|
31
|
+
|
|
32
|
+
- Re-pointed the bundled `GRASS_USDC` market to the 30-tick-spacing pool
|
|
33
|
+
(`0xc516dba7bd70aa2dcb986bb1c27208ea29ecd097fa0ce636611e88e54ae4444d`)
|
|
34
|
+
designated by the Aegis pools API as the reference pool holding the deep
|
|
35
|
+
liquidity.
|
|
36
|
+
|
|
8
37
|
## [0.3.2] - 2026-06-08
|
|
9
38
|
|
|
10
39
|
### Added
|
|
40
|
+
|
|
11
41
|
- Added controlled Trade details drawer state via `executionDetailsOpen` and
|
|
12
42
|
`onExecutionDetailsOpenChange`. Hosts can now coordinate the drawer with
|
|
13
43
|
their own layout while the widget keeps its existing uncontrolled
|
|
@@ -16,6 +46,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
16
46
|
## [0.3.1] - 2026-06-08
|
|
17
47
|
|
|
18
48
|
### Added
|
|
49
|
+
|
|
19
50
|
- Added a `Trade` / `Latest tx` switch inside the Trade details drawer. After a
|
|
20
51
|
successful swap, the drawer opens to a session-local receipt showing the
|
|
21
52
|
latest confirmed transaction's received amount, network fee, gas price, gas
|
|
@@ -24,6 +55,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
24
55
|
wallet-step hint before approval or Permit2 signing.
|
|
25
56
|
|
|
26
57
|
### Changed
|
|
58
|
+
|
|
27
59
|
- Softened the widget chrome by replacing several resting borders with tonal
|
|
28
60
|
elevation, quieter segmented controls, and a tighter Trade details surface.
|
|
29
61
|
- Reskinned the local demo surface so the playground reads like a host app demo
|
|
@@ -31,6 +63,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
31
63
|
- Resolved OS theme changes through `useSyncExternalStore`.
|
|
32
64
|
|
|
33
65
|
### Documentation
|
|
66
|
+
|
|
34
67
|
- Clarified the widget integration contract: production props stay real, while
|
|
35
68
|
demo wallets, fake transaction flows, scenario controls, and mock host shells
|
|
36
69
|
belong in the separate playground.
|
|
@@ -38,15 +71,18 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
38
71
|
## [0.3.0] - 2026-06-08
|
|
39
72
|
|
|
40
73
|
### Removed (breaking)
|
|
74
|
+
|
|
41
75
|
- `targets` prop — use `poolIds` (identical `string[]` shape).
|
|
42
76
|
- `markets` prop — use `pools`; `Object.values(markets)` migrates an existing map.
|
|
43
77
|
- `defaultDirection` values `'intoTarget'` / `'outOfTarget'` — use `'buy'` / `'sell'`.
|
|
44
78
|
|
|
45
79
|
### Changed (breaking)
|
|
80
|
+
|
|
46
81
|
- Renamed `showApprovalModeControl` → `showApprovalMode`, pairing it with
|
|
47
82
|
`defaultApprovalMode`.
|
|
48
83
|
|
|
49
84
|
### Migration
|
|
85
|
+
|
|
50
86
|
- `targets={ids}` → `poolIds={ids}`
|
|
51
87
|
- `markets={map}` → `pools={Object.values(map)}`
|
|
52
88
|
- `defaultDirection="intoTarget"` → `defaultDirection="buy"`
|
|
@@ -54,6 +90,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
54
90
|
- `showApprovalModeControl={x}` → `showApprovalMode={x}`
|
|
55
91
|
|
|
56
92
|
### Internal
|
|
93
|
+
|
|
57
94
|
- Refactored the widget into a `useSwapController` hook (state, derivation, and
|
|
58
95
|
hook orchestration) over a thin presentational component, decomposed the swap
|
|
59
96
|
money path into pure `src/swap/` modules (`authorizePermit`,
|
|
@@ -61,6 +98,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
61
98
|
single `useChangeEmitter` primitive. No public behavior change.
|
|
62
99
|
|
|
63
100
|
### Added
|
|
101
|
+
|
|
64
102
|
- Toast notifications as an alternative transaction-status surface: new
|
|
65
103
|
`statusSurface` prop (`'rail'` default, `'toast'`, `'both'`, `'none'`) plus
|
|
66
104
|
`toastPosition`. One toast per swap attempt morphs loading → success/error in
|
|
@@ -116,6 +154,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
116
154
|
`SubmitStatus`, `TransactionProgressState`, and the `isUserRejectedError` helper.
|
|
117
155
|
|
|
118
156
|
### Changed
|
|
157
|
+
|
|
119
158
|
- The branded header (`title`/`subtitle`) is now text-only: the Aegis logomark no longer
|
|
120
159
|
renders next to host-provided titles. Aegis attribution lives solely in the
|
|
121
160
|
"Powered by Aegis" footer.
|
|
@@ -147,6 +186,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
147
186
|
labels.
|
|
148
187
|
|
|
149
188
|
### Fixed
|
|
189
|
+
|
|
150
190
|
- Keyboard focus no longer reshapes controls: the global `:focus-visible` rule forced
|
|
151
191
|
a 6px border-radius onto every focused element, visibly squaring the circular flip
|
|
152
192
|
button; the ring now follows each element's own radius.
|
|
@@ -157,6 +197,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
157
197
|
## [0.2.0] - 2026-06-05
|
|
158
198
|
|
|
159
199
|
### Added
|
|
200
|
+
|
|
160
201
|
- Premium embeddable swap surface with collapsible trade details, route chip, token icons,
|
|
161
202
|
Ethereum light/dark assets, and host-controlled execution details.
|
|
162
203
|
- Exact-vs-max approval mode support, defaulting to exact approvals with Permit2 fallback.
|
|
@@ -166,6 +207,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
166
207
|
organized under `tests/`.
|
|
167
208
|
|
|
168
209
|
### Changed
|
|
210
|
+
|
|
169
211
|
- The public widget entrypoint now delegates to focused widget modules instead of carrying
|
|
170
212
|
the entire implementation in `src/index.tsx`.
|
|
171
213
|
- Quote and router encoding paths are hardened around calldata construction, stale quote
|
|
@@ -174,12 +216,14 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
174
216
|
- The default approval mode is `exact`; hosts can still opt into `max`.
|
|
175
217
|
|
|
176
218
|
### Deprecated
|
|
219
|
+
|
|
177
220
|
- `targets` remains available as a backwards-compatible alias for `poolIds` and will be
|
|
178
221
|
removed in `0.3.0`.
|
|
179
222
|
|
|
180
223
|
## [0.1.3] - 2026-06-05
|
|
181
224
|
|
|
182
225
|
### Added
|
|
226
|
+
|
|
183
227
|
- Per-chain internal fee: `fee` field on `AegisSwapChainConfig`, so the output-token
|
|
184
228
|
fee applies to any bundled chain that sets one (mainnet keeps its 50 bps fee).
|
|
185
229
|
- Package metadata (`license`, `repository`, `homepage`, `bugs`, `keywords`) and a
|
|
@@ -190,6 +234,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
190
234
|
tarballs always contain a fresh build.
|
|
191
235
|
|
|
192
236
|
### Changed
|
|
237
|
+
|
|
193
238
|
- `resolveWidgetFee` now reads the per-chain `fee` from the resolved chain config
|
|
194
239
|
instead of hardcoding Ethereum mainnet. Default mainnet behavior is unchanged.
|
|
195
240
|
- Swap submission re-quotes immediately before building calldata so the on-chain
|
|
@@ -200,6 +245,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
200
245
|
from the bundle).
|
|
201
246
|
|
|
202
247
|
### Removed
|
|
248
|
+
|
|
203
249
|
- `dist/` build artifacts are no longer committed to git (rebuilt on pack/publish).
|
|
204
250
|
|
|
205
251
|
## [0.1.2] - 2026-06-04
|
|
@@ -209,16 +255,19 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|
|
209
255
|
> next published version.
|
|
210
256
|
|
|
211
257
|
### Added
|
|
258
|
+
|
|
212
259
|
- Adjustable internal widget swap fee, fixed to Ethereum mainnet (50 bps).
|
|
213
260
|
- Exact-output swaps and a 5-second quote refresh.
|
|
214
261
|
- Per-chain Uniswap v4 contract config (`UNISWAP_V4_CONTRACTS_BY_CHAIN`).
|
|
215
262
|
|
|
216
263
|
### Changed
|
|
264
|
+
|
|
217
265
|
- Display token amounts are rounded (local only; not in the published 0.1.2 tarball).
|
|
218
266
|
|
|
219
267
|
## [0.1.0] - 2026-06-04
|
|
220
268
|
|
|
221
269
|
### Added
|
|
270
|
+
|
|
222
271
|
- Initial embeddable direct-pool Aegis swap widget for WATER, WOOD, GRASS, and STONE.
|
|
223
272
|
- Generic pool widget API; ERC-20 → Permit2 approval and Permit2 batch signing.
|
|
224
273
|
|
package/README.md
CHANGED
|
@@ -4,9 +4,9 @@ Embeddable React swap widget for Aegis direct pools. Import the component, impor
|
|
|
4
4
|
|
|
5
5
|
The host app normally only renders `<AegisSwapWidget />`. Quoting, token approval, Permit2 signing, and swap submission are handled inside the widget.
|
|
6
6
|
|
|
7
|
-
|
|
8
|
-
creates an exact-output swap. Active quotes refresh
|
|
9
|
-
amount is valid.
|
|
7
|
+
In the direct-pool widget, typing in the Sell field creates an exact-input swap
|
|
8
|
+
and typing in the Buy field creates an exact-output swap. Active quotes refresh
|
|
9
|
+
every five seconds while the amount is valid.
|
|
10
10
|
|
|
11
11
|
Widget swaps apply an internal output-token fee per configured chain. The bundled
|
|
12
12
|
Ethereum mainnet config carries a fixed 50 bps fee to
|
|
@@ -20,7 +20,8 @@ npm install aegis-swap-widget
|
|
|
20
20
|
```
|
|
21
21
|
|
|
22
22
|
Peer dependencies (provided by the host app): `react >=18 <20`, `react-dom >=18 <20`,
|
|
23
|
-
and `viem ^2`. The package is ESM-only
|
|
23
|
+
and `viem ^2`. The package is ESM-only. Its only runtime dependencies are
|
|
24
|
+
`@aegis-engine/core` (the swap engine) and `lucide-react` (icons).
|
|
24
25
|
|
|
25
26
|
## Basic Usage
|
|
26
27
|
|
|
@@ -46,10 +47,14 @@ Token icons are hydrated from the same metadata table used by the Aegis website:
|
|
|
46
47
|
|
|
47
48
|
`aegis-swap-widget` is the production widget SDK. It uses real providers, RPCs,
|
|
48
49
|
pool config, approvals, Permit2 authorization, swap submission, and callbacks.
|
|
50
|
+
Pull requests publish the package demo to the Cloudflare Pages branch URL
|
|
51
|
+
reported by Wrangler, for example
|
|
52
|
+
`https://pr-<number>.aegis-widget-preview.pages.dev`.
|
|
49
53
|
|
|
50
54
|
Demo wallets, fake transaction flows, scenario controls, and mock host shells
|
|
51
|
-
belong in the
|
|
52
|
-
props, so an embedded widget cannot accidentally
|
|
55
|
+
belong in the playground app (`apps/playground` in this monorepo). They are not
|
|
56
|
+
exposed as production widget props, so an embedded widget cannot accidentally
|
|
57
|
+
run in a fake mode.
|
|
53
58
|
|
|
54
59
|
Hosts should customize through `pools`, `chains`, `rpcUrls`,
|
|
55
60
|
`metadataEndpoint`, wallet/provider callbacks, status surfaces, `accentColor`,
|
|
@@ -90,26 +95,19 @@ tokens — is documented in [DESIGN.md](./DESIGN.md).
|
|
|
90
95
|
|
|
91
96
|
## Configure Pools
|
|
92
97
|
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
98
|
+
Out of the box, `<AegisSwapWidget />` exposes the bundled WATER, WOOD, GRASS,
|
|
99
|
+
and STONE mainnet pools. Use `poolIds` when a host wants a different built-in
|
|
100
|
+
pool order or subset:
|
|
96
101
|
|
|
97
102
|
```tsx
|
|
98
|
-
import { AegisSwapWidget
|
|
103
|
+
import { AegisSwapWidget } from 'aegis-swap-widget'
|
|
99
104
|
import 'aegis-swap-widget/styles.css'
|
|
100
105
|
|
|
101
|
-
const pools = [
|
|
102
|
-
AEGIS_SWAP_MARKETS.WATER_USDC,
|
|
103
|
-
AEGIS_SWAP_MARKETS.WOOD_USDC,
|
|
104
|
-
AEGIS_SWAP_MARKETS.GRASS_USDC,
|
|
105
|
-
AEGIS_SWAP_MARKETS.STONE_USDC,
|
|
106
|
-
]
|
|
107
|
-
|
|
108
106
|
export function Swap() {
|
|
109
107
|
return (
|
|
110
108
|
<AegisSwapWidget
|
|
111
|
-
pools={pools}
|
|
112
109
|
defaultPoolId="WATER_USDC"
|
|
110
|
+
poolIds={['WATER_USDC', 'WOOD_USDC', 'GRASS_USDC', 'STONE_USDC']}
|
|
113
111
|
theme="dark"
|
|
114
112
|
accentColor="#31d48a"
|
|
115
113
|
/>
|
|
@@ -117,16 +115,68 @@ export function Swap() {
|
|
|
117
115
|
}
|
|
118
116
|
```
|
|
119
117
|
|
|
120
|
-
Use `defaultPoolId` to choose which pool opens first
|
|
118
|
+
Use `defaultPoolId` to choose which pool opens first:
|
|
121
119
|
|
|
122
120
|
```tsx
|
|
123
|
-
<AegisSwapWidget
|
|
124
|
-
pools={pools}
|
|
125
|
-
defaultPoolId="GRASS_USDC"
|
|
126
|
-
poolIds={['GRASS_USDC', 'WATER_USDC']}
|
|
127
|
-
/>
|
|
121
|
+
<AegisSwapWidget defaultPoolId="GRASS_USDC" />
|
|
128
122
|
```
|
|
129
123
|
|
|
124
|
+
## Aggregated Token Presets
|
|
125
|
+
|
|
126
|
+
`AegisAggregatedSwapWidget` exposes only the tokens passed through its `tokens`
|
|
127
|
+
prop. The bundled widget currently defaults to the Wolf Game preset:
|
|
128
|
+
|
|
129
|
+
- `USDC`
|
|
130
|
+
- `ETH`
|
|
131
|
+
- `WATER`
|
|
132
|
+
- `WOOD`
|
|
133
|
+
- `GRASS`
|
|
134
|
+
- `STONE`
|
|
135
|
+
|
|
136
|
+
The general Ethereum preset is exported for hosts that want the standard list:
|
|
137
|
+
|
|
138
|
+
- `USDC`
|
|
139
|
+
- `USDT`
|
|
140
|
+
- `WETH`
|
|
141
|
+
- `ETH`
|
|
142
|
+
- `WBTC`
|
|
143
|
+
- `stETH`
|
|
144
|
+
|
|
145
|
+
```tsx
|
|
146
|
+
import { AegisAggregatedSwapWidget } from 'aegis-swap-widget'
|
|
147
|
+
import {
|
|
148
|
+
AGGREGATED_SWAP_DEFAULT_TOKEN_LIST,
|
|
149
|
+
AGGREGATED_SWAP_WOLFGAME_TOKEN_LIST,
|
|
150
|
+
} from '@aegis-engine/core'
|
|
151
|
+
|
|
152
|
+
export function WolfGameSwap() {
|
|
153
|
+
return <AegisAggregatedSwapWidget tokens={AGGREGATED_SWAP_WOLFGAME_TOKEN_LIST} />
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
export function DefaultEthereumSwap() {
|
|
157
|
+
return (
|
|
158
|
+
<AegisAggregatedSwapWidget
|
|
159
|
+
tokens={AGGREGATED_SWAP_DEFAULT_TOKEN_LIST}
|
|
160
|
+
defaultInputTokenSymbol="USDC"
|
|
161
|
+
defaultOutputTokenSymbol="USDT"
|
|
162
|
+
/>
|
|
163
|
+
)
|
|
164
|
+
}
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
## Kyber Exact-Output Limitation
|
|
168
|
+
|
|
169
|
+
`AegisAggregatedSwapWidget` is exact-input only. The KyberSwap Aggregator V1 EVM
|
|
170
|
+
route endpoint is built around `amountIn` route discovery and does not provide a
|
|
171
|
+
native exact-output route request, so the widget does not let users type a fixed
|
|
172
|
+
Buy amount for Kyber aggregated swaps.
|
|
173
|
+
|
|
174
|
+
Practically, the Sell field is editable and the Buy field displays the quoted
|
|
175
|
+
output. Direct-pool `AegisSwapWidget` can still support exact-output swaps
|
|
176
|
+
because it quotes and encodes against the Uniswap V4 pool directly.
|
|
177
|
+
|
|
178
|
+
Reference: [KyberSwap Aggregator API EVM swaps](https://docs.kyberswap.com/kyberswap-solutions/kyberswap-aggregator/aggregator-api-specification/evm-swaps).
|
|
179
|
+
|
|
130
180
|
## Fees
|
|
131
181
|
|
|
132
182
|
The widget applies an internal output-token fee per chain. Each bundled chain config
|
|
@@ -139,15 +189,42 @@ This fee is internal to the widget and is not configured by host sites — host
|
|
|
139
189
|
overrides cannot set or change it. Chains added later carry a fee only when their
|
|
140
190
|
bundled config provides one.
|
|
141
191
|
|
|
192
|
+
For `AegisAggregatedSwapWidget`, the fee is taken by the KyberSwap route itself.
|
|
193
|
+
On Ethereum mainnet, every aggregated route request includes these Kyber fee
|
|
194
|
+
parameters:
|
|
195
|
+
|
|
196
|
+
```text
|
|
197
|
+
feeAmount=50
|
|
198
|
+
chargeFeeBy=currency_out
|
|
199
|
+
isInBps=true
|
|
200
|
+
feeReceiver=0x8ea2C7de60ef1Cd4dcE64ea2DDDe2f99F0127eFC
|
|
201
|
+
```
|
|
202
|
+
|
|
203
|
+
`chargeFeeBy=currency_out` means the fee is collected in the output token. The
|
|
204
|
+
widget first asks Kyber for a route with those fee params, then passes Kyber's
|
|
205
|
+
returned `routeSummary` unchanged into `route/build`. The calldata returned by
|
|
206
|
+
Kyber is what the user's wallet signs, so fee collection is encoded in the
|
|
207
|
+
router transaction rather than handled by a separate widget transfer. The swap
|
|
208
|
+
recipient remains the user's wallet; the fee receiver receives the 50 bps
|
|
209
|
+
output-token fee from the routed swap.
|
|
210
|
+
|
|
211
|
+
The quoted output shown in the widget is the user's net output after Kyber's
|
|
212
|
+
fee handling. `onSubmitted` includes `feeAmount` and `feeBps` for host analytics,
|
|
213
|
+
but the widget does not render a separate fee row in Trade details.
|
|
214
|
+
|
|
215
|
+
For direct-pool `AegisSwapWidget`, the same internal output-token fee is encoded
|
|
216
|
+
directly into the Universal Router command. Exact-input direct swaps use a
|
|
217
|
+
`TAKE_PORTION` output leg before the user's output `TAKE`.
|
|
218
|
+
|
|
142
219
|
For custom assets, provide full pool and token metadata:
|
|
143
220
|
|
|
144
221
|
```tsx
|
|
222
|
+
import { AegisSwapWidget } from 'aegis-swap-widget'
|
|
145
223
|
import {
|
|
146
|
-
AegisSwapWidget,
|
|
147
224
|
AEGIS_DYNAMIC_FEE_FLAG,
|
|
148
225
|
AEGIS_SWAP_HOOK,
|
|
149
226
|
type AegisSwapPoolConfig,
|
|
150
|
-
} from 'aegis-
|
|
227
|
+
} from '@aegis-engine/core'
|
|
151
228
|
|
|
152
229
|
const pools: AegisSwapPoolConfig[] = [
|
|
153
230
|
{
|
|
@@ -204,14 +281,15 @@ import { mainnet } from 'viem/chains'
|
|
|
204
281
|
/>
|
|
205
282
|
```
|
|
206
283
|
|
|
207
|
-
Uniswap v4 deployments are configured per chain.
|
|
284
|
+
Uniswap v4 deployments are configured per chain. `@aegis-engine/core` exports
|
|
208
285
|
`UNISWAP_V4_CONTRACTS_BY_CHAIN` for the supported mainnet deployments listed in
|
|
209
286
|
the official Uniswap v4 deployment docs: Ethereum, Optimism, Unichain, Polygon,
|
|
210
287
|
Base, and Arbitrum.
|
|
211
288
|
|
|
212
289
|
```tsx
|
|
213
290
|
import { base } from 'viem/chains'
|
|
214
|
-
import {
|
|
291
|
+
import { AegisSwapWidget } from 'aegis-swap-widget'
|
|
292
|
+
import { UNISWAP_V4_CONTRACTS_BY_CHAIN } from '@aegis-engine/core'
|
|
215
293
|
|
|
216
294
|
<AegisSwapWidget
|
|
217
295
|
chainId={8453}
|
|
@@ -351,7 +429,7 @@ the pending/mining shimmer is always a full-width top-border sweep.
|
|
|
351
429
|
|
|
352
430
|
Errors never appear in `status` (the submit machine resets to `'idle'`); read
|
|
353
431
|
them from `progress === 'error'` plus `error`. For classifying the raw `Error`
|
|
354
|
-
from `onError`, `isUserRejectedError`
|
|
432
|
+
from `onError`, import `isUserRejectedError` from `@aegis-engine/core`.
|
|
355
433
|
|
|
356
434
|
Success clears itself after confirming (by default a 3s hold plus the 420ms
|
|
357
435
|
rail fade-out), the widget resets and emits a final
|
|
@@ -579,7 +657,7 @@ function Swap() {
|
|
|
579
657
|
|
|
580
658
|
## Default Markets
|
|
581
659
|
|
|
582
|
-
The
|
|
660
|
+
The widget includes built-in mainnet direct-pool configs for:
|
|
583
661
|
|
|
584
662
|
- `USDC / WATER`
|
|
585
663
|
- `USDC / WOOD`
|
|
@@ -587,8 +665,8 @@ The package ships mainnet direct-pool configs for:
|
|
|
587
665
|
- `USDC / STONE`
|
|
588
666
|
|
|
589
667
|
These use the Aegis mainnet router `0x00581261a1200956ea05d1810fF28ffd66D8E254`
|
|
590
|
-
and the Ethereum
|
|
591
|
-
|
|
668
|
+
and the Ethereum Uniswap v4 Permit2 and Quoter addresses from
|
|
669
|
+
`@aegis-engine/core`.
|
|
592
670
|
|
|
593
671
|
## License
|
|
594
672
|
|
|
@@ -597,23 +675,20 @@ MIT.
|
|
|
597
675
|
## Local Demo
|
|
598
676
|
|
|
599
677
|
```bash
|
|
600
|
-
|
|
601
|
-
|
|
678
|
+
pnpm install # at the monorepo root
|
|
679
|
+
pnpm --filter aegis-swap-widget dev
|
|
602
680
|
```
|
|
603
681
|
|
|
604
682
|
## Releasing
|
|
605
683
|
|
|
606
|
-
|
|
607
|
-
|
|
608
|
-
|
|
684
|
+
Releases are automated with [changesets](https://github.com/changesets/changesets)
|
|
685
|
+
from the monorepo root — no manual `npm version`/`npm publish`. `dist/` is not
|
|
686
|
+
committed; the `prepack` hook rebuilds it on every pack/publish, and
|
|
687
|
+
`prepublishOnly` runs the typecheck + test gate.
|
|
609
688
|
|
|
610
689
|
```bash
|
|
611
|
-
|
|
612
|
-
|
|
613
|
-
|
|
614
|
-
# Move CHANGELOG [Unreleased] entries under the new version heading.
|
|
615
|
-
npm version minor # e.g. 0.2.1 -> 0.3.0 for a breaking 0.x release; commits and tags vX.Y.Z
|
|
616
|
-
git push origin main --follow-tags
|
|
617
|
-
npm publish --access public # prepublishOnly gate + prepack build run automatically
|
|
690
|
+
pnpm changeset # in your PR: pick aegis-swap-widget + bump, write the entry
|
|
691
|
+
# Merge the PR; the Release workflow opens a "Version Packages" PR on main.
|
|
692
|
+
# Merging that PR publishes to npm via OIDC trusted publishing.
|
|
618
693
|
npm view aegis-swap-widget version
|
|
619
694
|
```
|
package/dist/abis.d.ts
CHANGED
|
@@ -1,76 +1,3 @@
|
|
|
1
|
-
export declare const AEGIS_ROUTER_ABI: readonly [{
|
|
2
|
-
readonly type: "function";
|
|
3
|
-
readonly name: "execute";
|
|
4
|
-
readonly stateMutability: "payable";
|
|
5
|
-
readonly inputs: readonly [{
|
|
6
|
-
readonly name: "batches";
|
|
7
|
-
readonly type: "tuple[]";
|
|
8
|
-
readonly components: readonly [{
|
|
9
|
-
readonly name: "requiresV4Unlock";
|
|
10
|
-
readonly type: "bool";
|
|
11
|
-
}, {
|
|
12
|
-
readonly name: "actions";
|
|
13
|
-
readonly type: "bytes";
|
|
14
|
-
}, {
|
|
15
|
-
readonly name: "params";
|
|
16
|
-
readonly type: "bytes[]";
|
|
17
|
-
}];
|
|
18
|
-
}, {
|
|
19
|
-
readonly name: "deadline";
|
|
20
|
-
readonly type: "uint256";
|
|
21
|
-
}];
|
|
22
|
-
readonly outputs: readonly [];
|
|
23
|
-
}, {
|
|
24
|
-
readonly type: "function";
|
|
25
|
-
readonly name: "multicall";
|
|
26
|
-
readonly stateMutability: "payable";
|
|
27
|
-
readonly inputs: readonly [{
|
|
28
|
-
readonly name: "data";
|
|
29
|
-
readonly type: "bytes[]";
|
|
30
|
-
}];
|
|
31
|
-
readonly outputs: readonly [{
|
|
32
|
-
readonly name: "results";
|
|
33
|
-
readonly type: "bytes[]";
|
|
34
|
-
}];
|
|
35
|
-
}, {
|
|
36
|
-
readonly type: "function";
|
|
37
|
-
readonly name: "permitBatch";
|
|
38
|
-
readonly stateMutability: "payable";
|
|
39
|
-
readonly inputs: readonly [{
|
|
40
|
-
readonly name: "owner";
|
|
41
|
-
readonly type: "address";
|
|
42
|
-
}, {
|
|
43
|
-
readonly name: "permitBatch";
|
|
44
|
-
readonly type: "tuple";
|
|
45
|
-
readonly components: readonly [{
|
|
46
|
-
readonly name: "details";
|
|
47
|
-
readonly type: "tuple[]";
|
|
48
|
-
readonly components: readonly [{
|
|
49
|
-
readonly name: "token";
|
|
50
|
-
readonly type: "address";
|
|
51
|
-
}, {
|
|
52
|
-
readonly name: "amount";
|
|
53
|
-
readonly type: "uint160";
|
|
54
|
-
}, {
|
|
55
|
-
readonly name: "expiration";
|
|
56
|
-
readonly type: "uint48";
|
|
57
|
-
}, {
|
|
58
|
-
readonly name: "nonce";
|
|
59
|
-
readonly type: "uint48";
|
|
60
|
-
}];
|
|
61
|
-
}, {
|
|
62
|
-
readonly name: "spender";
|
|
63
|
-
readonly type: "address";
|
|
64
|
-
}, {
|
|
65
|
-
readonly name: "sigDeadline";
|
|
66
|
-
readonly type: "uint256";
|
|
67
|
-
}];
|
|
68
|
-
}, {
|
|
69
|
-
readonly name: "signature";
|
|
70
|
-
readonly type: "bytes";
|
|
71
|
-
}];
|
|
72
|
-
readonly outputs: readonly [];
|
|
73
|
-
}];
|
|
74
1
|
export declare const PERMIT2_ABI: readonly [{
|
|
75
2
|
readonly type: "function";
|
|
76
3
|
readonly name: "approve";
|