@aegis-engine/core 0.1.1 → 0.1.2

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 CHANGED
@@ -99,6 +99,68 @@ For production integrations, prefer passing your own viem `PublicClient` backed
99
99
  by your RPC provider. `createSwapPublicClient` is a convenience fallback for
100
100
  simple integrations and demos.
101
101
 
102
+ ## Backend V1 API
103
+
104
+ The V1 backend/indexer contract is exposed as typed REST helpers. This is the
105
+ public boundary for widget/core integrations once the backend service is live:
106
+ AppSync, DynamoDB, indexer reads, provider adapters, quote storage, route hashes,
107
+ allowlists, and final simulation stay behind the backend.
108
+
109
+ ```ts
110
+ import { createAegisBackendApiClient } from '@aegis-engine/core'
111
+
112
+ const aegisApi = createAegisBackendApiClient({
113
+ baseUrl: 'https://api.aegis.markets'
114
+ })
115
+
116
+ const config = await aegisApi.config()
117
+ const tokens = await aegisApi.tokens({ chainId: 1 })
118
+ const markets = await aegisApi.markets({ chainId: 1 })
119
+
120
+ const quote = await aegisApi.quote({
121
+ chainId: 1,
122
+ provider: 'aegis-direct-v4',
123
+ marketId: 'WATER_USDC',
124
+ mode: 'exactIn',
125
+ tokenIn: '0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48',
126
+ tokenOut: '0x828B22c9ea1c20B551EeFC6198174C4bb7a8CBF6',
127
+ amountIn: '1000000',
128
+ slippageBps: config.quote.defaultSlippageBps,
129
+ account
130
+ })
131
+
132
+ const build = await aegisApi.build({
133
+ quoteId: quote.quoteId,
134
+ account,
135
+ recipient: account
136
+ })
137
+ ```
138
+
139
+ The backend endpoints are:
140
+
141
+ - `GET /v1/health`
142
+ - `GET /v1/config`
143
+ - `GET /v1/tokens?chainId=1`
144
+ - `GET /v1/tokens/by-address?chainId=1&addresses=0x...,0x...`
145
+ - `GET /v1/markets?chainId=1`
146
+ - `POST /v1/swap/quote`
147
+ - `POST /v1/swap/build`
148
+ - `GET /v1/status/tx/:chainId/:txHash`
149
+
150
+ `quote` returns a short-lived `quoteId`, `quoteHash`, `routeHash`, expiry, gas,
151
+ approval, and normalized fee data. `build` accepts only `quoteId`, `account`,
152
+ `recipient`, and an optional Permit2 signature; token amounts, slippage, provider
153
+ route data, router addresses, and spender addresses are not accepted in the
154
+ build request. The backend must reject expired or tampered quotes, validate the
155
+ chain/router/spender/pool allowlists, and simulate the unsigned transaction
156
+ before returning wallet-ready `tx` data.
157
+
158
+ Core still includes direct-pool and Kyber client-side helpers for the current
159
+ widget flow. Those helpers are transitional for swap execution: once the backend
160
+ service is available, production widget paths should fetch config, tokens,
161
+ markets, quotes, builds, and transaction status through this REST client while
162
+ wallet signing and transaction sending remain client-side.
163
+
102
164
  ## Direct Pool Market Config
103
165
 
104
166
  The direct pool operations take an `AegisSwapMarket`. Hosts can build one from
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Polls an ERC-20 allowance read until it covers `minimum`, then asserts it did.
3
+ * Shared by the direct-pool and KyberSwap approval flows after they submit an
4
+ * approval transaction: a confirmed approval whose allowance is still short means
5
+ * the wallet approved a smaller amount, so the swap must not proceed.
6
+ */
7
+ export declare function confirmAllowanceReached(read: () => Promise<bigint>, minimum: bigint): Promise<bigint>;