aegis-swap-widget 0.5.1 → 0.7.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/CHANGELOG.md +24 -0
- package/README.md +155 -3
- package/dist/aegis-swap-widget.js +8419 -7064
- package/dist/components/Slider.d.ts +15 -0
- package/dist/components/icons.d.ts +8 -0
- package/dist/format.d.ts +2 -0
- package/dist/index.d.ts +3 -2
- package/dist/partner-context.js +120 -0
- package/dist/styles.css +1 -1
- package/dist/widget/EngineAmountBox.d.ts +4 -3
- package/dist/widget/engine-controller/engineDisplay.d.ts +3 -0
- package/dist/widget/engine-controller/engineLifecycle.d.ts +16 -0
- package/dist/widget/engine-controller/useEngineBuySwapProps.d.ts +5 -2
- package/dist/widget/engine-controller/useEngineFills.d.ts +3 -1
- package/dist/widget/engine-ui/EngineBuyPanel.d.ts +7 -2
- package/dist/widget/engine-ui/EngineMarketDialog.d.ts +2 -1
- package/dist/widget/engine-ui/PartnerContextPanel.d.ts +13 -0
- package/dist/widget/partnerContext.d.ts +42 -0
- package/dist/widget/partnerMatch.d.ts +12 -0
- package/dist/widget/simpleBorrowMath.d.ts +20 -0
- package/dist/widget/simpleBorrowViewModel.d.ts +17 -0
- package/dist/widget/types.d.ts +291 -2
- package/dist/widget/useEngineController.d.ts +34 -14
- package/dist/widget/useHiddenUntilFound.d.ts +24 -0
- package/dist/widget/useSheetEntrance.d.ts +23 -0
- package/package.json +7 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,29 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
+
## 0.7.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- 0416588: Add controlled Engine market lookup by exact token resource identity so partner apps can switch Lend and Borrow markets without storing Engine market ids.
|
|
8
|
+
|
|
9
|
+
## 0.6.0
|
|
10
|
+
|
|
11
|
+
### Minor Changes
|
|
12
|
+
|
|
13
|
+
- d401c4d: Add optional partner context UI, host-owned action requirements, and one-shot launch intents that open a matching Engine Buy or Borrow market and prefill a concrete resource amount without submitting a transaction.
|
|
14
|
+
|
|
15
|
+
Adds the `partnerContext`, `partnerLaunchIntent`, `onPartnerLaunchIntentApplied`, `onPartnerAction`, and `onPartnerRequirementAction` props to `AegisEngineWidget`. The partner-neutral `PartnerActionRequirement` keeps host action semantics separate from the explicit Buy/Borrow launch event. The change also forwards `pools`/`poolIds` to the Buy surface and publishes the normalized contract from a new `aegis-swap-widget/partner-context` export. Omitting `partnerContext` keeps current behavior and performs no extra requests.
|
|
16
|
+
|
|
17
|
+
The `embedded` presentation is silent for aggregate partner facts and renders only a compact host-owned action requirement inside Buy or Borrow transaction content. The `showroom` presentation retains partner identity, environment, balances, activities, details, and navigation for integration evaluation.
|
|
18
|
+
|
|
19
|
+
API-backed partner amounts can additionally retain a validated raw base-unit integer and decimal scale. Partner blocks and action targets can carry observation and validity provenance; incomplete raw-amount or action-provenance pairs fail closed while the original display-only host shape remains compatible. Expired host requirements cannot produce a launch intent.
|
|
20
|
+
|
|
21
|
+
### Patch Changes
|
|
22
|
+
|
|
23
|
+
- d401c4d: Make collapsed Engine disclosures findable with the browser's page search. TX details, the Borrow/Lend details panel, the lifecycle card body and both position-row details now hide with `hidden="until-found"` instead of `visibility`, so Cmd/Ctrl+F, `#fragment` navigation and `#:~:text=` links reach their text and expand the panel that holds it.
|
|
24
|
+
|
|
25
|
+
Closed panels still leave the tab order — `content-visibility` skips its subtree the same way the previous `visibility` flip did — and the collapse animation is unchanged: searchability is re-armed only after the transition finishes. The attribute is applied only where the browser supports it (feature-detected via `beforematch`); elsewhere the previous `visibility` behavior is untouched. Panels also assert their own `display`, so a host stylesheet with an unguarded `[hidden] { display: none }` reset cannot flatten the accordion track.
|
|
26
|
+
|
|
3
27
|
## 0.5.1
|
|
4
28
|
|
|
5
29
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -58,6 +58,151 @@ export function Engine({ account, provider }) {
|
|
|
58
58
|
}
|
|
59
59
|
```
|
|
60
60
|
|
|
61
|
+
## Partner context and host action requirements
|
|
62
|
+
|
|
63
|
+
`partnerContext` adds optional, display-only facts from a game or partner. The
|
|
64
|
+
host must normalize this data on its server. Do not pass API keys, private
|
|
65
|
+
vendor responses, or wallet-specific context through shared URLs.
|
|
66
|
+
|
|
67
|
+
An `actionRequirement` is the host's authoritative statement of what a selected
|
|
68
|
+
partner action needs. The widget can display the shortfall and let the user
|
|
69
|
+
explicitly open Buy or Borrow. The choice creates an editable prefill; it never
|
|
70
|
+
submits a transaction or changes Aegis market data:
|
|
71
|
+
|
|
72
|
+
```tsx
|
|
73
|
+
import { AegisEngineWidget } from 'aegis-swap-widget'
|
|
74
|
+
import type { PartnerContext } from 'aegis-swap-widget/partner-context'
|
|
75
|
+
|
|
76
|
+
const partnerContext = {
|
|
77
|
+
partner: { id: 'wolf-game', name: 'Wolf Game' },
|
|
78
|
+
actionRequirement: {
|
|
79
|
+
id: 'upgrade-barn-water',
|
|
80
|
+
label: 'Upgrade Barn',
|
|
81
|
+
resource: {
|
|
82
|
+
chainId: 1,
|
|
83
|
+
address: '0x828B22c9ea1c20B551EeFC6198174C4bb7a8CBF6',
|
|
84
|
+
symbol: 'WATER',
|
|
85
|
+
},
|
|
86
|
+
requiredAmount: '1000',
|
|
87
|
+
availableAmount: '660',
|
|
88
|
+
shortfallAmount: '340',
|
|
89
|
+
resourceUse: 'consumed',
|
|
90
|
+
},
|
|
91
|
+
} satisfies PartnerContext
|
|
92
|
+
|
|
93
|
+
export function GameMarket() {
|
|
94
|
+
return (
|
|
95
|
+
<AegisEngineWidget
|
|
96
|
+
partnerContext={partnerContext}
|
|
97
|
+
partnerContextVariant="embedded"
|
|
98
|
+
onPartnerRequirementAction={(requirement, surface) => {
|
|
99
|
+
console.log(surface, requirement.id)
|
|
100
|
+
}}
|
|
101
|
+
onPartnerLaunchIntentApplied={(intent) => {
|
|
102
|
+
console.log('Editable amount applied', intent.amount)
|
|
103
|
+
}}
|
|
104
|
+
/>
|
|
105
|
+
)
|
|
106
|
+
}
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
`requiredAmount`, `availableAmount`, and `shortfallAmount` are canonical token-unit
|
|
110
|
+
decimal strings, not grouped text or raw base units. When `availableAmount` is
|
|
111
|
+
present, the shortfall must equal `max(required - available, 0)`. `resourceUse`
|
|
112
|
+
is host-owned disclosure: `'consumed'`, `'returned'`, or `'unknown'`. It does not
|
|
113
|
+
make Borrow a recommendation.
|
|
114
|
+
|
|
115
|
+
API-backed display amounts may also include `rawAmount` and `decimals`. Supply
|
|
116
|
+
both or neither. `rawAmount` is a canonical nonnegative base-unit integer; it
|
|
117
|
+
remains display-only and never becomes a transaction amount. Environment,
|
|
118
|
+
production, inventory, and activity blocks can carry a `PartnerObservation`
|
|
119
|
+
with `observedAt` and optional `validUntil`. An action target can carry the same
|
|
120
|
+
validity provenance plus a host-owned `reason`. Partial or malformed amount and
|
|
121
|
+
action-provenance blocks fail closed at the widget boundary. The launch helper
|
|
122
|
+
also rejects a requirement once its optional `expiresAt` deadline is reached.
|
|
123
|
+
|
|
124
|
+
If the host owns the action button outside the widget, keep using a separate
|
|
125
|
+
one-shot `partnerLaunchIntent`. The exported helper maps a validated requirement
|
|
126
|
+
to that event without duplicating its resource or amount:
|
|
127
|
+
|
|
128
|
+
```tsx
|
|
129
|
+
import { partnerLaunchIntentForRequirement } from 'aegis-swap-widget/partner-context'
|
|
130
|
+
|
|
131
|
+
const launchIntent = partnerLaunchIntentForRequirement(
|
|
132
|
+
partnerContext.actionRequirement,
|
|
133
|
+
'borrow',
|
|
134
|
+
crypto.randomUUID()
|
|
135
|
+
)
|
|
136
|
+
```
|
|
137
|
+
|
|
138
|
+
The equivalent launch intent is:
|
|
139
|
+
|
|
140
|
+
```ts
|
|
141
|
+
{
|
|
142
|
+
requestId: 'new-id-for-this-click',
|
|
143
|
+
source: 'action-requirement',
|
|
144
|
+
requirementId: 'upgrade-barn-water',
|
|
145
|
+
surface: 'borrow',
|
|
146
|
+
resource: {
|
|
147
|
+
chainId: 1,
|
|
148
|
+
address: '0x828B22c9ea1c20B551EeFC6198174C4bb7a8CBF6',
|
|
149
|
+
symbol: 'WATER',
|
|
150
|
+
},
|
|
151
|
+
amount: '340',
|
|
152
|
+
}
|
|
153
|
+
```
|
|
154
|
+
|
|
155
|
+
Pass that value through `partnerLaunchIntent` and clear it after
|
|
156
|
+
`onPartnerLaunchIntentApplied`. Use a new `requestId` for each external click.
|
|
157
|
+
Borrow fills the debt token's “I need” field. Buy uses the matching direct pool
|
|
158
|
+
and fills an exact-output Receive amount. The widget never submits automatically
|
|
159
|
+
and fails closed when the chain, market, token identity, or precision does not
|
|
160
|
+
match.
|
|
161
|
+
|
|
162
|
+
Use `partnerContextVariant="embedded"` inside an existing product shell. It is
|
|
163
|
+
silent unless the host supplies an `actionRequirement`; then the widget places
|
|
164
|
+
one compact purpose row beside the active Buy or Borrow transaction content.
|
|
165
|
+
Partner identity, weather, aggregate balances, activities, secondary details,
|
|
166
|
+
and navigation remain available only in the default `showroom` variant. If the
|
|
167
|
+
host already owns resource selection, pass the selected token through
|
|
168
|
+
`marketResource`. The widget resolves its eligible Lend/Borrow market from live
|
|
169
|
+
Engine discovery on the active chain by exact address and symbol:
|
|
170
|
+
|
|
171
|
+
```tsx
|
|
172
|
+
const wolfResources = {
|
|
173
|
+
WATER: {
|
|
174
|
+
chainId: 1,
|
|
175
|
+
address: '0x828B22c9ea1c20B551EeFC6198174C4bb7a8CBF6',
|
|
176
|
+
symbol: 'WATER',
|
|
177
|
+
},
|
|
178
|
+
// WOOD, GRASS, and STONE use the same shape.
|
|
179
|
+
} as const
|
|
180
|
+
|
|
181
|
+
<AegisEngineWidget
|
|
182
|
+
chainId={1}
|
|
183
|
+
enabledChainIds={[1]}
|
|
184
|
+
marketResource={wolfResources[selectedResource]}
|
|
185
|
+
/>
|
|
186
|
+
```
|
|
187
|
+
|
|
188
|
+
The resource chain must be the widget's active chain; Valley uses `chainId={1}`.
|
|
189
|
+
This controlled form hides the widget market picker. It selects only one exact,
|
|
190
|
+
surface-compatible match and fails closed when discovery returns none or more
|
|
191
|
+
than one. The host does not need to store Engine market ids. `marketResource`
|
|
192
|
+
locates the market; it does not lock which of the market's two tokens the user
|
|
193
|
+
chooses inside Lend or Borrow. If several Engine markets intentionally use the
|
|
194
|
+
same resource, add `marketId` only to disambiguate within those matches. A
|
|
195
|
+
mismatched id never bypasses resource identity. Use `defaultMarketId` when the
|
|
196
|
+
widget should own selection. The nested Buy surface remains independently
|
|
197
|
+
controlled through `buySwapConfig`; one-shot partner Buy intents already
|
|
198
|
+
resolve their matching direct pool.
|
|
199
|
+
|
|
200
|
+
Wolf Game's current aggregate API provides Community 12 balances, weather, and
|
|
201
|
+
harvesting data. It does not provide wallet-specific inventory, claimable
|
|
202
|
+
resources, energy timing, or a concrete action requirement. A Wolf host must
|
|
203
|
+
therefore create `actionRequirement` only from real game state. Do not derive it
|
|
204
|
+
from aggregate weather or inventory alone.
|
|
205
|
+
|
|
61
206
|
The Engine discovery surface defaults to Amplifi's public production REST API.
|
|
62
207
|
The production source implements
|
|
63
208
|
`GET /v1/engine/markets?chainId=`,
|
|
@@ -122,9 +267,11 @@ Product semantics are deliberately conservative:
|
|
|
122
267
|
impermanent-loss exposure.
|
|
123
268
|
- The widget does not claim borrowing is cheaper than buying without a
|
|
124
269
|
partner-provided returnability/consumption model and duration.
|
|
125
|
-
- Positions
|
|
126
|
-
presented as current health.
|
|
127
|
-
|
|
270
|
+
- Positions start from indexed discovery snapshots. Last-locked LTV is not
|
|
271
|
+
presented as current health. The management dialog rehydrates live RPC state
|
|
272
|
+
before it quotes and submits add-collateral, repay, idle-withdraw, loan-close,
|
|
273
|
+
and lend-redeem actions. A close that needs an idle-token rebalance asks the
|
|
274
|
+
user to repay first, then re-quote the close.
|
|
128
275
|
- Lender balances are indexed Engine share units, not token amounts; the widget
|
|
129
276
|
does not invent a token/USD value without a current share price.
|
|
130
277
|
|
|
@@ -766,6 +913,7 @@ No other props changed. See the [CHANGELOG](./CHANGELOG.md) for the full entry.
|
|
|
766
913
|
- `networkSelectorColorMode`: `'accent'` (default) keeps host-brand selector chrome; `'chain'` uses the built-in DFF chain palette for supported chains.
|
|
767
914
|
- `pools`: direct pool configs to render and swap against. This is the canonical config path.
|
|
768
915
|
- `defaultPoolId`: initial pool id when `pools` is provided.
|
|
916
|
+
- `poolId`: controlled active pool id. Pair with `onPoolChange` when the host owns pool selection; updates change the form in place.
|
|
769
917
|
- `poolIds`: optional pool id order/subset. Use this when the host wants to hide pools or control ordering.
|
|
770
918
|
- `defaultDirection`: `buy` (counter token into the pool token) or `sell` (pool token into the counter token). Defaults to `buy`.
|
|
771
919
|
- `defaultSlippagePercent`: number (canonical) or numeric string, in percent. Defaults to `1`.
|
|
@@ -779,7 +927,11 @@ No other props changed. See the [CHANGELOG](./CHANGELOG.md) for the full entry.
|
|
|
779
927
|
- `style`: optional root style object, useful for host layout constraints or CSS variables.
|
|
780
928
|
- `title`: optional widget heading. Swap and Engine default to empty for compact embedded chrome.
|
|
781
929
|
- `showNetworkSelector`: Engine header-network visibility: `'never'` (default), `'auto'`, or `'always'`. Cross-chain markets and tokens remain available in the full selectors when the header rail is hidden.
|
|
930
|
+
- `onSurfaceChange`: Engine callback fired when the active unified tab changes (`'buy'`, `'borrow'`, `'lend'`, or `'positions'`).
|
|
931
|
+
- `marketResource`: controlled Lend/Borrow market locator (`chainId`, token `address`, and `symbol`). On the active chain, the widget resolves one eligible Engine market, hides its picker, and fails closed on missing or ambiguous matches. It does not lock token direction. Use `marketId` only as an optional disambiguator for the same resource.
|
|
932
|
+
- `buySwapConfig`: optional host overrides for the nested Engine Buy surface only. Use it to constrain Buy to a chain, pool set, or controlled `poolId` without changing Engine market discovery or the Lend/Borrow/Positions surfaces.
|
|
782
933
|
- `showBuySettings`: show the Engine Buy surface's slippage-settings control. Defaults to `false`.
|
|
934
|
+
- `showAmountSlider`: amount-slider visibility on the Engine lend/borrow amount boxes: `'auto'` (default) shows sliders on the borrow surface only, sized against the wallet's borrowing limit; `'always'` adds the lend deposit slider; `'never'` hides every amount slider.
|
|
783
935
|
- `subtitle`: optional header eyebrow. Defaults to empty. Pass a string to show it.
|
|
784
936
|
- `ariaLabel`: optional accessible label for the widget region. Defaults to `Swap` for Swap and `Lend, borrow, and buy` for Engine.
|
|
785
937
|
- `theme`: `dark`, `light`, or `auto` (follows `prefers-color-scheme`). Defaults to `dark`.
|