@aegis-engine/core 0.1.0 → 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.
@@ -16,12 +16,11 @@ export type SwapExecutionResult = {
16
16
  /**
17
17
  * Builds the swap calldata, sends it, and waits for the receipt.
18
18
  *
19
- * Estimates gas with a 20% headroom bump, surfaces the optimistic hash through
20
- * `setTxHash` (and `onSubmitted`) before mining, then tracks replacements: a
21
- * wallet speed-up swaps in the hash that actually mines, while a wallet cancel
22
- * mines a no-op whose "successful" receipt must not count as a swap — so a
23
- * cancelled or reverted receipt throws. Setting the success status and the
24
- * post-success refreshes stay with the caller.
19
+ * Estimates gas with a 20% headroom bump, then hands off to
20
+ * `sendSwapTransactionAndAwait`, which surfaces the optimistic hash through
21
+ * `setTxHash`/`onSubmitted`, tracks wallet replacements, and rejects a cancelled
22
+ * or reverted receipt. Setting the success status and the post-success refreshes
23
+ * stay with the caller.
25
24
  */
26
25
  export declare function executeSwapTransaction({ wallet, publicClient, activeChain, market, inputToken, outputToken, swapQuote, permit, setStatus, setTxHash, onSubmitted }: {
27
26
  wallet: WalletSession;
@@ -0,0 +1,28 @@
1
+ import { type Address, type Chain, type Hex, type PublicClient, type TransactionReceipt } from 'viem';
2
+ import type { AegisSwapReceiptSummary } from '../transactionProgress';
3
+ import type { AegisSwapSubmitDetails, WalletSession } from './types';
4
+ /**
5
+ * Sends a prepared swap transaction and waits for its receipt.
6
+ *
7
+ * Surfaces the optimistic hash through `onHash` (and `onSubmitted`) before
8
+ * mining, then tracks replacements: a wallet speed-up swaps in the hash that
9
+ * actually mines, while a wallet cancel mines a no-op whose "successful" receipt
10
+ * must not count as a swap — so a cancelled or reverted receipt throws. Callers
11
+ * compute their own gas and pass it via `gas`, so each keeps its gas strategy
12
+ * (omit `gas` to let the wallet estimate).
13
+ */
14
+ export declare function sendSwapTransactionAndAwait(args: {
15
+ wallet: WalletSession;
16
+ publicClient: PublicClient;
17
+ chain: Chain;
18
+ to: Address;
19
+ data: Hex;
20
+ value: bigint;
21
+ gas?: bigint;
22
+ swapDetails: AegisSwapSubmitDetails;
23
+ onHash?: (hash: Hex | null) => void;
24
+ onSubmitted?: (hash: Hex, swap?: AegisSwapSubmitDetails) => void;
25
+ }): Promise<{
26
+ receipt: TransactionReceipt;
27
+ summary: AegisSwapReceiptSummary;
28
+ }>;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@aegis-engine/core",
3
- "version": "0.1.0",
3
+ "version": "0.1.2",
4
4
  "description": "React-free Aegis swap operations for direct Uniswap v4 pools and KyberSwap routes.",
5
5
  "license": "MIT",
6
6
  "type": "module",
@@ -18,13 +18,6 @@
18
18
  "README.md",
19
19
  "LICENSE"
20
20
  ],
21
- "scripts": {
22
- "typecheck": "tsc -p tsconfig.build.json --noEmit",
23
- "typecheck:test": "tsc -p tsconfig.test.json --noEmit",
24
- "test": "vitest run",
25
- "build": "vite build && tsc -p tsconfig.build.json",
26
- "prepack": "npm run build"
27
- },
28
21
  "peerDependencies": {
29
22
  "viem": "^2"
30
23
  },
@@ -34,5 +27,24 @@
34
27
  "viem": "^2.52.0",
35
28
  "vite": "^6.0.1",
36
29
  "vitest": "^4.1.8"
30
+ },
31
+ "dependencies": {
32
+ "zod": "^4.4.3"
33
+ },
34
+ "sideEffects": false,
35
+ "engines": {
36
+ "node": ">=22.14"
37
+ },
38
+ "repository": {
39
+ "type": "git",
40
+ "url": "git+https://github.com/amplifi-liquidity/aegis-widget.git",
41
+ "directory": "packages/core"
42
+ },
43
+ "bugs": "https://github.com/amplifi-liquidity/aegis-widget/issues",
44
+ "scripts": {
45
+ "typecheck": "tsc -p tsconfig.build.json --noEmit",
46
+ "typecheck:test": "tsc -p tsconfig.test.json --noEmit",
47
+ "test": "vitest run",
48
+ "build": "vite build && tsc -p tsconfig.build.json"
37
49
  }
38
- }
50
+ }
package/dist/config.d.ts DELETED
@@ -1,119 +0,0 @@
1
- import { type Address, type Chain, type Hex } from 'viem';
2
- export type AegisSwapBuiltInTokenSymbol = 'USDC' | 'WATER' | 'WOOD' | 'GRASS' | 'STONE';
3
- export type AegisSwapBuiltInAssetSymbol = Exclude<AegisSwapBuiltInTokenSymbol, 'USDC'>;
4
- export type AegisSwapBuiltInMarketId = 'WATER_USDC' | 'WOOD_USDC' | 'GRASS_USDC' | 'STONE_USDC';
5
- export type AegisSwapTokenSymbol = string;
6
- export type AegisSwapFeeConfig = {
7
- bps: number;
8
- recipient: Address;
9
- };
10
- export type AegisSwapToken = {
11
- chainId: number;
12
- address: Address;
13
- name: string;
14
- symbol: AegisSwapTokenSymbol;
15
- decimals: number;
16
- iconUrl?: string | null;
17
- };
18
- export type AegisPoolKey = {
19
- currency0: Address;
20
- currency1: Address;
21
- fee: number;
22
- tickSpacing: number;
23
- hooks: Address;
24
- };
25
- export type AegisSwapUniswapV4Contracts = {
26
- permit2: Address;
27
- quoter: Address;
28
- poolManager?: Address;
29
- positionDescriptor?: Address;
30
- positionManager?: Address;
31
- stateView?: Address;
32
- universalRouter?: Address;
33
- universalRouterV2_1_1?: Address;
34
- };
35
- export type AegisSwapUniswapV4ContractsInput = Partial<AegisSwapUniswapV4Contracts>;
36
- export type AegisSwapMarket = {
37
- id: string;
38
- chainId: number;
39
- symbol: AegisSwapTokenSymbol;
40
- poolId: Hex;
41
- poolKey: AegisPoolKey;
42
- token: AegisSwapToken;
43
- counterToken: AegisSwapToken;
44
- router: Address;
45
- permit2: Address;
46
- quoter: Address;
47
- label?: string;
48
- };
49
- export type AegisSwapChainConfig = {
50
- chainId: number;
51
- chain: Chain;
52
- name: string;
53
- router: Address;
54
- permit2: Address;
55
- quoter: Address;
56
- v4Contracts: AegisSwapUniswapV4Contracts;
57
- rpcUrls: string[];
58
- explorerTxUrl?: (hash: Hex) => string;
59
- poolExplorerUrl?: (poolId: Hex, market: AegisSwapMarket) => string;
60
- metadataEndpoint?: string | null;
61
- fee?: AegisSwapFeeConfig;
62
- };
63
- export type AegisSwapChainConfigInput = Partial<Omit<AegisSwapChainConfig, 'chainId' | 'v4Contracts' | 'fee'>> & {
64
- chainId?: number;
65
- v4Contracts?: AegisSwapUniswapV4ContractsInput;
66
- };
67
- export declare function getExplorerUrl(hash: Hex, chain: AegisSwapChainConfig): string;
68
- export type AegisSwapPoolConfig = {
69
- id: string;
70
- symbol?: AegisSwapTokenSymbol;
71
- chainId?: number;
72
- poolKey: AegisPoolKey;
73
- poolId?: Hex;
74
- token: AegisSwapToken;
75
- counterToken: AegisSwapToken;
76
- router?: Address;
77
- permit2?: Address;
78
- quoter?: Address;
79
- label?: string;
80
- };
81
- export declare const AEGIS_SWAP_CHAIN_ID = 1;
82
- export declare const AEGIS_SWAP_ROUTER: `0x${string}`;
83
- export declare const AEGIS_SWAP_HOOK: `0x${string}`;
84
- export declare const AEGIS_DYNAMIC_FEE_FLAG = 8388608;
85
- export declare const AEGIS_SWAP_DEFAULT_FEE_BPS = 50;
86
- export declare const AEGIS_SWAP_DEFAULT_FEE_RECIPIENT: `0x${string}`;
87
- export declare function createAegisSwapUniswapV4Contracts(input: AegisSwapUniswapV4ContractsInput): AegisSwapUniswapV4Contracts;
88
- export declare const UNISWAP_V4_CONTRACTS_BY_CHAIN: Record<number, AegisSwapUniswapV4Contracts>;
89
- export declare const AEGIS_SWAP_MAINNET_UNISWAP_V4_CONTRACTS: AegisSwapUniswapV4Contracts;
90
- export declare const AEGIS_SWAP_PERMIT2: `0x${string}`;
91
- export declare const AEGIS_SWAP_V4_QUOTER: `0x${string}`;
92
- export declare const AEGIS_SWAP_DEFAULT_RPC_URLS: string[];
93
- export declare const AEGIS_SWAP_DEFAULT_METADATA_ENDPOINT = "https://aegis.markets/graphql/meta";
94
- export declare const AEGIS_SWAP_MAINNET_CHAIN: AegisSwapChainConfig;
95
- export declare const AEGIS_SWAP_CHAINS: Record<number, AegisSwapChainConfig>;
96
- export declare const AEGIS_SWAP_TOKENS: Record<AegisSwapBuiltInTokenSymbol, AegisSwapToken>;
97
- export declare const AEGIS_SWAP_MARKETS: Record<AegisSwapBuiltInMarketId, AegisSwapMarket>;
98
- export declare const AEGIS_SWAP_DEFAULT_POOL_IDS: AegisSwapBuiltInMarketId[];
99
- export declare const AGGREGATED_SWAP_FEE_BPS = 50;
100
- export declare const AGGREGATED_SWAP_FEE_RECIPIENT: `0x${string}`;
101
- export type AggregatedSwapToken = AegisSwapToken;
102
- export type AggregatedSwapDefaultTokenSymbol = 'USDC' | 'USDT' | 'WETH' | 'ETH' | 'WBTC' | 'STETH';
103
- export type AggregatedSwapWolfGameTokenSymbol = AegisSwapBuiltInTokenSymbol | 'ETH';
104
- export type AggregatedSwapTokenSymbol = AggregatedSwapDefaultTokenSymbol | AggregatedSwapWolfGameTokenSymbol;
105
- export declare const AGGREGATED_SWAP_DEFAULT_TOKENS: Record<AggregatedSwapDefaultTokenSymbol, AggregatedSwapToken>;
106
- export declare const AGGREGATED_SWAP_WOLFGAME_TOKENS: Record<AggregatedSwapWolfGameTokenSymbol, AggregatedSwapToken>;
107
- export declare const AGGREGATED_SWAP_DEFAULT_TOKEN_LIST: AegisSwapToken[];
108
- export declare const AGGREGATED_SWAP_WOLFGAME_TOKEN_LIST: AegisSwapToken[];
109
- export declare const AGGREGATED_SWAP_TOKEN_PRESETS: {
110
- readonly default: AegisSwapToken[];
111
- readonly wolfgame: AegisSwapToken[];
112
- };
113
- export declare const AGGREGATED_SWAP_CURATED_TOKENS: Record<AggregatedSwapDefaultTokenSymbol, AegisSwapToken>;
114
- export declare function createAegisSwapChainConfig(input: AegisSwapChainConfigInput & {
115
- chainId: number;
116
- }, base?: AegisSwapChainConfig): AegisSwapChainConfig;
117
- export declare function createAegisSwapChains(chains?: Partial<Record<number, AegisSwapChainConfigInput>>): Record<number, AegisSwapChainConfig>;
118
- export declare function createAegisSwapPoolMarket(input: AegisSwapPoolConfig, chains?: Record<number, AegisSwapChainConfig>): AegisSwapMarket;
119
- export declare function createAegisSwapMarketsFromPools(pools: AegisSwapPoolConfig[] | undefined, chains?: Record<number, AegisSwapChainConfig>): Record<string, AegisSwapMarket>;