@waiaas/actions 2.6.0-rc.10
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/LICENSE +21 -0
- package/README.md +158 -0
- package/dist/common/action-api-client.d.ts +14 -0
- package/dist/common/action-api-client.d.ts.map +1 -0
- package/dist/common/action-api-client.js +78 -0
- package/dist/common/action-api-client.js.map +1 -0
- package/dist/common/async-status-tracker.d.ts +62 -0
- package/dist/common/async-status-tracker.d.ts.map +1 -0
- package/dist/common/async-status-tracker.js +30 -0
- package/dist/common/async-status-tracker.js.map +1 -0
- package/dist/common/slippage.d.ts +15 -0
- package/dist/common/slippage.d.ts.map +1 -0
- package/dist/common/slippage.js +26 -0
- package/dist/common/slippage.js.map +1 -0
- package/dist/index.d.ts +41 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +98 -0
- package/dist/index.js.map +1 -0
- package/dist/providers/jupiter-swap/config.d.ts +16 -0
- package/dist/providers/jupiter-swap/config.d.ts.map +1 -0
- package/dist/providers/jupiter-swap/config.js +15 -0
- package/dist/providers/jupiter-swap/config.js.map +1 -0
- package/dist/providers/jupiter-swap/index.d.ts +11 -0
- package/dist/providers/jupiter-swap/index.d.ts.map +1 -0
- package/dist/providers/jupiter-swap/index.js +102 -0
- package/dist/providers/jupiter-swap/index.js.map +1 -0
- package/dist/providers/jupiter-swap/jupiter-api-client.d.ts +23 -0
- package/dist/providers/jupiter-swap/jupiter-api-client.d.ts.map +1 -0
- package/dist/providers/jupiter-swap/jupiter-api-client.js +37 -0
- package/dist/providers/jupiter-swap/jupiter-api-client.js.map +1 -0
- package/dist/providers/jupiter-swap/schemas.d.ts +743 -0
- package/dist/providers/jupiter-swap/schemas.d.ts.map +1 -0
- package/dist/providers/jupiter-swap/schemas.js +57 -0
- package/dist/providers/jupiter-swap/schemas.js.map +1 -0
- package/dist/providers/lifi/bridge-status-tracker.d.ts +37 -0
- package/dist/providers/lifi/bridge-status-tracker.d.ts.map +1 -0
- package/dist/providers/lifi/bridge-status-tracker.js +111 -0
- package/dist/providers/lifi/bridge-status-tracker.js.map +1 -0
- package/dist/providers/lifi/config.d.ts +27 -0
- package/dist/providers/lifi/config.d.ts.map +1 -0
- package/dist/providers/lifi/config.js +50 -0
- package/dist/providers/lifi/config.js.map +1 -0
- package/dist/providers/lifi/index.d.ts +16 -0
- package/dist/providers/lifi/index.d.ts.map +1 -0
- package/dist/providers/lifi/index.js +121 -0
- package/dist/providers/lifi/index.js.map +1 -0
- package/dist/providers/lifi/lifi-api-client.d.ts +29 -0
- package/dist/providers/lifi/lifi-api-client.d.ts.map +1 -0
- package/dist/providers/lifi/lifi-api-client.js +42 -0
- package/dist/providers/lifi/lifi-api-client.js.map +1 -0
- package/dist/providers/lifi/schemas.d.ts +713 -0
- package/dist/providers/lifi/schemas.d.ts.map +1 -0
- package/dist/providers/lifi/schemas.js +91 -0
- package/dist/providers/lifi/schemas.js.map +1 -0
- package/dist/providers/zerox-swap/config.d.ts +31 -0
- package/dist/providers/zerox-swap/config.d.ts.map +1 -0
- package/dist/providers/zerox-swap/config.js +70 -0
- package/dist/providers/zerox-swap/config.js.map +1 -0
- package/dist/providers/zerox-swap/index.d.ts +10 -0
- package/dist/providers/zerox-swap/index.d.ts.map +1 -0
- package/dist/providers/zerox-swap/index.js +131 -0
- package/dist/providers/zerox-swap/index.js.map +1 -0
- package/dist/providers/zerox-swap/schemas.d.ts +641 -0
- package/dist/providers/zerox-swap/schemas.d.ts.map +1 -0
- package/dist/providers/zerox-swap/schemas.js +59 -0
- package/dist/providers/zerox-swap/schemas.js.map +1 -0
- package/dist/providers/zerox-swap/zerox-api-client.d.ts +29 -0
- package/dist/providers/zerox-swap/zerox-api-client.d.ts.map +1 -0
- package/dist/providers/zerox-swap/zerox-api-client.js +43 -0
- package/dist/providers/zerox-swap/zerox-api-client.js.map +1 -0
- package/package.json +46 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 WAIaaS Contributors
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
# WAIaaS
|
|
2
|
+
|
|
3
|
+
**Wallet-as-a-Service for AI Agents**
|
|
4
|
+
|
|
5
|
+
[](LICENSE)
|
|
6
|
+
[](https://nodejs.org/)
|
|
7
|
+
[](#)
|
|
8
|
+
|
|
9
|
+
A self-hosted wallet daemon that lets AI agents perform on-chain transactions securely -- while the owner keeps full control of funds.
|
|
10
|
+
|
|
11
|
+
## The Problem
|
|
12
|
+
|
|
13
|
+
AI agents that need to transact on-chain face an impossible choice: hold private keys (and risk total loss if compromised) or depend on a centralized custodian (single point of failure, trust dependency).
|
|
14
|
+
|
|
15
|
+
WAIaaS bridges the gap -- agents handle small transactions instantly, large amounts require owner approval, and everything runs on your machine with no third-party dependency.
|
|
16
|
+
|
|
17
|
+
## How It Works
|
|
18
|
+
|
|
19
|
+
WAIaaS is a local daemon that sits between your AI agent and the blockchain:
|
|
20
|
+
|
|
21
|
+
- **3-tier authentication** -- Separate roles for the daemon operator (masterAuth), fund owner (ownerAuth), and AI agent (sessionAuth)
|
|
22
|
+
- **4-tier policy engine** -- Transactions are auto-classified by USD value into INSTANT / NOTIFY / DELAY / APPROVAL tiers
|
|
23
|
+
- **12 policy types** -- Cumulative spend limits, token allowlists, contract whitelists, approved spenders, and more
|
|
24
|
+
- **Defense in depth** -- Kill Switch, AutoStop engine, audit logging, 4-channel notifications
|
|
25
|
+
|
|
26
|
+
See [Security Model](docs/security-model.md) for full details.
|
|
27
|
+
|
|
28
|
+
## Quick Start
|
|
29
|
+
|
|
30
|
+
```bash
|
|
31
|
+
npm install -g @waiaas/cli
|
|
32
|
+
waiaas init # Create data directory + config.toml
|
|
33
|
+
waiaas start # Start daemon (sets master password on first run)
|
|
34
|
+
waiaas quickset --mode testnet # Create wallets + MCP sessions in one step
|
|
35
|
+
```
|
|
36
|
+
|
|
37
|
+
The `quickset` command does everything you need to get started:
|
|
38
|
+
|
|
39
|
+
1. Creates **Solana Devnet + EVM Sepolia** wallets automatically
|
|
40
|
+
2. Issues **MCP session tokens** for each wallet
|
|
41
|
+
3. Outputs a **Claude Desktop MCP config** snippet -- just copy and paste
|
|
42
|
+
|
|
43
|
+
> Starting with mainnet? Use `waiaas quickset --mode mainnet` to create Solana Mainnet + EVM Ethereum Mainnet wallets instead. Mainnet mode recommends configuring spending limits and registering an owner wallet for high-value transaction approval.
|
|
44
|
+
|
|
45
|
+
### Admin UI
|
|
46
|
+
|
|
47
|
+
After starting the daemon, manage everything from the admin panel at `http://127.0.0.1:3100/admin` (masterAuth required).
|
|
48
|
+
|
|
49
|
+
## Connect Your AI Agent
|
|
50
|
+
|
|
51
|
+
After quickset, choose one of two integration paths:
|
|
52
|
+
|
|
53
|
+
### Path A: MCP (Claude Desktop / Claude Code)
|
|
54
|
+
|
|
55
|
+
For AI agents that support the [Model Context Protocol](https://modelcontextprotocol.io):
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
# quickset already printed the MCP config JSON -- paste it into
|
|
59
|
+
# ~/Library/Application Support/Claude/claude_desktop_config.json
|
|
60
|
+
# Or auto-register with all wallets:
|
|
61
|
+
waiaas mcp setup --all
|
|
62
|
+
```
|
|
63
|
+
|
|
64
|
+
The daemon runs as an MCP server. Your agent calls wallet tools directly -- send tokens, check balances, manage policies -- all through the MCP protocol.
|
|
65
|
+
|
|
66
|
+
### Path B: Skill Files (Any AI Agent)
|
|
67
|
+
|
|
68
|
+
For agents that don't support MCP, or when you prefer REST API integration:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
npx @waiaas/skills add all
|
|
72
|
+
```
|
|
73
|
+
|
|
74
|
+
This adds `.skill.md` instruction files to your project. Include them in your agent's context and it learns the WAIaaS API automatically. Available skills: `quickstart`, `wallet`, `transactions`, `policies`, `admin`, `actions`, `x402`.
|
|
75
|
+
|
|
76
|
+
## Alternative: Docker
|
|
77
|
+
|
|
78
|
+
```bash
|
|
79
|
+
git clone https://github.com/minho-yoo/waiaas.git && cd waiaas
|
|
80
|
+
docker compose up -d
|
|
81
|
+
```
|
|
82
|
+
|
|
83
|
+
The daemon listens on `http://127.0.0.1:3100`.
|
|
84
|
+
|
|
85
|
+
## Using the SDK
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
import { WAIaaSClient } from '@waiaas/sdk';
|
|
89
|
+
|
|
90
|
+
const client = new WAIaaSClient({
|
|
91
|
+
baseUrl: 'http://127.0.0.1:3100',
|
|
92
|
+
sessionToken: process.env.WAIAAS_SESSION_TOKEN,
|
|
93
|
+
});
|
|
94
|
+
|
|
95
|
+
const balance = await client.getBalance();
|
|
96
|
+
console.log(`Balance: ${balance.balance} ${balance.symbol}`);
|
|
97
|
+
|
|
98
|
+
const tx = await client.sendToken({
|
|
99
|
+
to: 'recipient-address...',
|
|
100
|
+
amount: '0.1',
|
|
101
|
+
});
|
|
102
|
+
console.log(`Transaction: ${tx.id}`);
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
## Admin UI
|
|
106
|
+
|
|
107
|
+
Access the admin panel at `http://127.0.0.1:3100/admin` with your master password:
|
|
108
|
+
|
|
109
|
+
- **Dashboard** -- System overview, wallet balances, recent transactions
|
|
110
|
+
- **Wallets** -- Create, manage, and monitor wallets across chains; RPC endpoints, balance monitoring, and WalletConnect settings
|
|
111
|
+
- **Sessions** -- Issue and revoke agent session tokens; session lifetime and rate limit settings
|
|
112
|
+
- **Policies** -- Configure 12 policy types with visual form editors; default deny and tier settings
|
|
113
|
+
- **Notifications** -- Channel status and delivery logs; Telegram, Discord, ntfy, and Slack settings
|
|
114
|
+
- **Security** -- Kill Switch emergency controls, AutoStop protection rules, JWT rotation
|
|
115
|
+
- **System** -- API keys, display currency, price oracle, rate limits, log level, and daemon shutdown
|
|
116
|
+
|
|
117
|
+
Features include settings search (Ctrl+K / Cmd+K) and unsaved changes protection.
|
|
118
|
+
|
|
119
|
+
Enabled by default (`admin_ui = true` in config.toml).
|
|
120
|
+
|
|
121
|
+
## Supported Networks
|
|
122
|
+
|
|
123
|
+
| Chain | Environment | Networks |
|
|
124
|
+
|-------|-------------|----------|
|
|
125
|
+
| Solana | mainnet | mainnet |
|
|
126
|
+
| Solana | testnet | devnet, testnet |
|
|
127
|
+
| EVM | mainnet | ethereum-mainnet, polygon-mainnet, arbitrum-mainnet, optimism-mainnet, base-mainnet |
|
|
128
|
+
| EVM | testnet | ethereum-sepolia, polygon-amoy, arbitrum-sepolia, optimism-sepolia, base-sepolia |
|
|
129
|
+
|
|
130
|
+
13 networks total (Solana 3 + EVM 10).
|
|
131
|
+
|
|
132
|
+
## Features
|
|
133
|
+
|
|
134
|
+
- **Self-hosted local daemon** -- No central server; keys never leave your machine
|
|
135
|
+
- **Multi-chain** -- Solana (SPL / Token-2022) and EVM (ERC-20) via `IChainAdapter`
|
|
136
|
+
- **Token, contract, and DeFi** -- Native transfers, token transfers, contract calls, approve, batch transactions, Action Provider plugins (Jupiter Swap, etc.)
|
|
137
|
+
- **USD policy evaluation** -- Price oracles (CoinGecko / Pyth / Chainlink) evaluate all transactions in USD
|
|
138
|
+
- **x402 payments** -- Automatic HTTP 402 payment handling with EIP-3009 signatures
|
|
139
|
+
- **Multiple interfaces** -- REST API, TypeScript SDK, Python SDK, MCP server, CLI, Admin Web UI, Tauri Desktop, Telegram Bot
|
|
140
|
+
- **Skill files** -- Pre-built instruction files that teach AI agents how to use the API
|
|
141
|
+
|
|
142
|
+
## Documentation
|
|
143
|
+
|
|
144
|
+
| Document | Description |
|
|
145
|
+
|----------|-------------|
|
|
146
|
+
| [Security Model](docs/security-model.md) | Authentication, policy engine, Kill Switch, AutoStop |
|
|
147
|
+
| [Deployment Guide](docs/deployment.md) | Docker, npm, configuration reference |
|
|
148
|
+
| [API Reference](docs/api-reference.md) | REST API endpoints and authentication |
|
|
149
|
+
| [Agent Skills Integration](docs/guides/agent-skills-integration.md) | Universal guide for 27+ AI agent platforms |
|
|
150
|
+
| [Claude Code Integration](docs/guides/claude-code-integration.md) | Skill files + MCP server setup for Claude Code |
|
|
151
|
+
| [OpenClaw Integration](docs/guides/openclaw-integration.md) | Quick setup for OpenClaw bot |
|
|
152
|
+
| [Wallet SDK Integration](docs/wallet-sdk-integration.md) | Integration guide for wallet developers |
|
|
153
|
+
| [Why WAIaaS?](docs/why-waiaas/) | Background on AI agent wallet security |
|
|
154
|
+
| [Contributing](CONTRIBUTING.md) | Development setup, code style, testing, PR guidelines |
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
[MIT](LICENSE) -- Copyright (c) 2026 WAIaaS Contributors
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Base HTTP client for DeFi Action Providers.
|
|
3
|
+
* Uses native fetch + AbortController with Zod runtime validation.
|
|
4
|
+
*/
|
|
5
|
+
import type { z } from 'zod';
|
|
6
|
+
export declare class ActionApiClient {
|
|
7
|
+
private readonly timeoutMs;
|
|
8
|
+
private readonly headers;
|
|
9
|
+
private readonly _baseUrl;
|
|
10
|
+
constructor(baseUrl: string, timeoutMs?: number, headers?: Record<string, string>);
|
|
11
|
+
get<T>(path: string, schema: z.ZodType<T>, params?: Record<string, string>): Promise<T>;
|
|
12
|
+
post<T>(path: string, body: unknown, schema: z.ZodType<T>): Promise<T>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=action-api-client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-api-client.d.ts","sourceRoot":"","sources":["../../src/common/action-api-client.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,KAAK,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAG7B,qBAAa,eAAe;IAKxB,OAAO,CAAC,QAAQ,CAAC,SAAS;IAC1B,OAAO,CAAC,QAAQ,CAAC,OAAO;IAL1B,OAAO,CAAC,QAAQ,CAAC,QAAQ,CAAS;gBAGhC,OAAO,EAAE,MAAM,EACE,SAAS,GAAE,MAAe,EAC1B,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM;IAMjD,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;IA8BvF,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,EAAE,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC;CA6B7E"}
|
|
@@ -0,0 +1,78 @@
|
|
|
1
|
+
import { ChainError } from '@waiaas/core';
|
|
2
|
+
export class ActionApiClient {
|
|
3
|
+
timeoutMs;
|
|
4
|
+
headers;
|
|
5
|
+
_baseUrl;
|
|
6
|
+
constructor(baseUrl, timeoutMs = 10_000, headers = {}) {
|
|
7
|
+
this.timeoutMs = timeoutMs;
|
|
8
|
+
this.headers = headers;
|
|
9
|
+
// Ensure trailing slash so relative path resolution works correctly
|
|
10
|
+
this._baseUrl = baseUrl.endsWith('/') ? baseUrl : `${baseUrl}/`;
|
|
11
|
+
}
|
|
12
|
+
async get(path, schema, params) {
|
|
13
|
+
const url = new URL(path, this._baseUrl);
|
|
14
|
+
if (params)
|
|
15
|
+
Object.entries(params).forEach(([k, v]) => url.searchParams.set(k, v));
|
|
16
|
+
const controller = new AbortController();
|
|
17
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
18
|
+
try {
|
|
19
|
+
const res = await fetch(url.toString(), {
|
|
20
|
+
signal: controller.signal,
|
|
21
|
+
headers: this.headers,
|
|
22
|
+
});
|
|
23
|
+
if (!res.ok) {
|
|
24
|
+
const body = await res.text();
|
|
25
|
+
if (res.status === 429) {
|
|
26
|
+
throw new ChainError('ACTION_RATE_LIMITED', 'api', { message: `Rate limited: ${body}` });
|
|
27
|
+
}
|
|
28
|
+
throw new ChainError('ACTION_API_ERROR', 'api', { message: `API error ${res.status}: ${body}` });
|
|
29
|
+
}
|
|
30
|
+
const data = await res.json();
|
|
31
|
+
return schema.parse(data);
|
|
32
|
+
}
|
|
33
|
+
catch (err) {
|
|
34
|
+
if (err instanceof ChainError)
|
|
35
|
+
throw err;
|
|
36
|
+
if (err instanceof Error && err.name === 'AbortError') {
|
|
37
|
+
throw new ChainError('ACTION_API_TIMEOUT', 'api', { message: `API timeout after ${this.timeoutMs}ms` });
|
|
38
|
+
}
|
|
39
|
+
throw err;
|
|
40
|
+
}
|
|
41
|
+
finally {
|
|
42
|
+
clearTimeout(timeoutId);
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
async post(path, body, schema) {
|
|
46
|
+
const controller = new AbortController();
|
|
47
|
+
const timeoutId = setTimeout(() => controller.abort(), this.timeoutMs);
|
|
48
|
+
try {
|
|
49
|
+
const res = await fetch(new URL(path, this._baseUrl).toString(), {
|
|
50
|
+
method: 'POST',
|
|
51
|
+
signal: controller.signal,
|
|
52
|
+
headers: { ...this.headers, 'Content-Type': 'application/json' },
|
|
53
|
+
body: JSON.stringify(body),
|
|
54
|
+
});
|
|
55
|
+
if (!res.ok) {
|
|
56
|
+
const text = await res.text();
|
|
57
|
+
if (res.status === 429) {
|
|
58
|
+
throw new ChainError('ACTION_RATE_LIMITED', 'api', { message: `Rate limited: ${text}` });
|
|
59
|
+
}
|
|
60
|
+
throw new ChainError('ACTION_API_ERROR', 'api', { message: `API error ${res.status}: ${text}` });
|
|
61
|
+
}
|
|
62
|
+
const data = await res.json();
|
|
63
|
+
return schema.parse(data);
|
|
64
|
+
}
|
|
65
|
+
catch (err) {
|
|
66
|
+
if (err instanceof ChainError)
|
|
67
|
+
throw err;
|
|
68
|
+
if (err instanceof Error && err.name === 'AbortError') {
|
|
69
|
+
throw new ChainError('ACTION_API_TIMEOUT', 'api', { message: `API timeout after ${this.timeoutMs}ms` });
|
|
70
|
+
}
|
|
71
|
+
throw err;
|
|
72
|
+
}
|
|
73
|
+
finally {
|
|
74
|
+
clearTimeout(timeoutId);
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
//# sourceMappingURL=action-api-client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"action-api-client.js","sourceRoot":"","sources":["../../src/common/action-api-client.ts"],"names":[],"mappings":"AAKA,OAAO,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE1C,MAAM,OAAO,eAAe;IAKP;IACA;IALF,QAAQ,CAAS;IAElC,YACE,OAAe,EACE,YAAoB,MA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AAS,CAAC,IAAI,CAAC;aAC3B,CAAC,CAAC;YACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;gBACZ,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;gBAC9B,IAAI,GAAG,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;oBACvB,MAAM,IAAI,UAAU,CAAC,qBAAqB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,iBAAiB,IAAI,EAAE,EAAE,CAAC,CAAC;gBAC3F,CAAC;gBACD,MAAM,IAAI,UAAU,CAAC,kBAAkB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,aAAa,GAAG,CAAC,MAAM,KAAK,IAAI,EAAE,EAAE,CAAC,CAAC;YACnG,CAAC;YACD,MAAM,IAAI,GAAG,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC;YAC9B,OAAO,MAAM,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QAC5B,CAAC;QAAC,OAAO,GAAG,EAAE,CAAC;YACb,IAAI,GAAG,YAAY,UAAU;gBAAE,MAAM,GAAG,CAAC;YACzC,IAAI,GAAG,YAAY,KAAK,IAAI,GAAG,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;gBACtD,MAAM,IAAI,UAAU,CAAC,oBAAoB,EAAE,KAAK,EAAE,EAAE,OAAO,EAAE,qBAAqB,IAAI,CAAC,SAAS,IAAI,EAAE,CAAC,CAAC;YAC1G,CAAC;YACD,MAAM,GAAG,CAAC;QACZ,CAAC;gBAAS,CAAC;YACT,YAAY,CAAC,SAAS,CAAC,CAAC;QAC1B,CAAC;IACH,CAAC;CACF"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async Status Tracker interface and types for DeFi async operations.
|
|
3
|
+
*
|
|
4
|
+
* IAsyncStatusTracker defines the contract for polling-based status tracking
|
|
5
|
+
* of asynchronous blockchain operations (bridge transfers, unstaking, gas conditions).
|
|
6
|
+
*
|
|
7
|
+
* AsyncPollingService (daemon) uses these interfaces to generically poll
|
|
8
|
+
* registered trackers at configurable intervals.
|
|
9
|
+
*
|
|
10
|
+
* @see internal/objectives/m28-00-defi-basic-protocol-design.md (DEFI-04 ASNC-01)
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
/**
|
|
14
|
+
* All possible bridge_status values for the transactions table.
|
|
15
|
+
* Used as SSoT for DB CHECK constraint and Zod schema.
|
|
16
|
+
*/
|
|
17
|
+
export declare const BRIDGE_STATUS_VALUES: readonly ["PENDING", "COMPLETED", "FAILED", "BRIDGE_MONITORING", "TIMEOUT", "REFUNDED"];
|
|
18
|
+
/** Bridge status type derived from BRIDGE_STATUS_VALUES SSoT array. */
|
|
19
|
+
export type BridgeStatus = (typeof BRIDGE_STATUS_VALUES)[number];
|
|
20
|
+
/** Zod schema for bridge status validation (SSoT pattern). */
|
|
21
|
+
export declare const BridgeStatusEnum: z.ZodEnum<["PENDING", "COMPLETED", "FAILED", "BRIDGE_MONITORING", "TIMEOUT", "REFUNDED"]>;
|
|
22
|
+
/**
|
|
23
|
+
* Result returned by IAsyncStatusTracker.checkStatus().
|
|
24
|
+
*
|
|
25
|
+
* - state: current tracking state (PENDING continues polling, others are terminal or timeout)
|
|
26
|
+
* - details: optional tracker-specific metadata merged into bridge_metadata
|
|
27
|
+
* - nextIntervalOverride: optional override for next poll interval (ms)
|
|
28
|
+
*/
|
|
29
|
+
export interface AsyncTrackingResult {
|
|
30
|
+
state: 'PENDING' | 'COMPLETED' | 'FAILED' | 'TIMEOUT';
|
|
31
|
+
details?: Record<string, unknown>;
|
|
32
|
+
nextIntervalOverride?: number;
|
|
33
|
+
}
|
|
34
|
+
/**
|
|
35
|
+
* Contract for async status tracking implementations.
|
|
36
|
+
*
|
|
37
|
+
* Each tracker monitors a specific type of async operation:
|
|
38
|
+
* - BridgeStatusTracker: cross-chain bridge transfer completion
|
|
39
|
+
* - UnstakeStatusTracker: staking withdrawal completion
|
|
40
|
+
* - GasConditionTracker: gas price condition satisfaction
|
|
41
|
+
*
|
|
42
|
+
* Trackers are registered with AsyncPollingService which calls checkStatus()
|
|
43
|
+
* at pollIntervalMs intervals, up to maxAttempts times.
|
|
44
|
+
*/
|
|
45
|
+
export interface IAsyncStatusTracker {
|
|
46
|
+
/** Check the current status of an async operation. */
|
|
47
|
+
checkStatus(txId: string, metadata: Record<string, unknown>): Promise<AsyncTrackingResult>;
|
|
48
|
+
/** Tracker name used for registration and lookup (e.g., 'bridge', 'unstake', 'gas-condition'). */
|
|
49
|
+
readonly name: string;
|
|
50
|
+
/** Maximum number of poll attempts before timeout transition. */
|
|
51
|
+
readonly maxAttempts: number;
|
|
52
|
+
/** Polling interval in milliseconds between checkStatus() calls. */
|
|
53
|
+
readonly pollIntervalMs: number;
|
|
54
|
+
/**
|
|
55
|
+
* State transition when maxAttempts is exceeded:
|
|
56
|
+
* - 'TIMEOUT': Mark bridge_status as TIMEOUT (terminal)
|
|
57
|
+
* - 'BRIDGE_MONITORING': Transition to reduced-frequency monitoring
|
|
58
|
+
* - 'CANCELLED': Cancel the transaction (for GAS_WAITING timeout)
|
|
59
|
+
*/
|
|
60
|
+
readonly timeoutTransition: 'TIMEOUT' | 'BRIDGE_MONITORING' | 'CANCELLED';
|
|
61
|
+
}
|
|
62
|
+
//# sourceMappingURL=async-status-tracker.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-status-tracker.d.ts","sourceRoot":"","sources":["../../src/common/async-status-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAMxB;;;GAGG;AACH,eAAO,MAAM,oBAAoB,yFAOvB,CAAC;AAEX,uEAAuE;AACvE,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,oBAAoB,CAAC,CAAC,MAAM,CAAC,CAAC;AAEjE,8DAA8D;AAC9D,eAAO,MAAM,gBAAgB,2FAA+B,CAAC;AAM7D;;;;;;GAMG;AACH,MAAM,WAAW,mBAAmB;IAClC,KAAK,EAAE,SAAS,GAAG,WAAW,GAAG,QAAQ,GAAG,SAAS,CAAC;IACtD,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;IAClC,oBAAoB,CAAC,EAAE,MAAM,CAAC;CAC/B;AAMD;;;;;;;;;;GAUG;AACH,MAAM,WAAW,mBAAmB;IAClC,sDAAsD;IACtD,WAAW,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAE3F,kGAAkG;IAClG,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IAEtB,iEAAiE;IACjE,QAAQ,CAAC,WAAW,EAAE,MAAM,CAAC;IAE7B,oEAAoE;IACpE,QAAQ,CAAC,cAAc,EAAE,MAAM,CAAC;IAEhC;;;;;OAKG;IACH,QAAQ,CAAC,iBAAiB,EAAE,SAAS,GAAG,mBAAmB,GAAG,WAAW,CAAC;CAC3E"}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Async Status Tracker interface and types for DeFi async operations.
|
|
3
|
+
*
|
|
4
|
+
* IAsyncStatusTracker defines the contract for polling-based status tracking
|
|
5
|
+
* of asynchronous blockchain operations (bridge transfers, unstaking, gas conditions).
|
|
6
|
+
*
|
|
7
|
+
* AsyncPollingService (daemon) uses these interfaces to generically poll
|
|
8
|
+
* registered trackers at configurable intervals.
|
|
9
|
+
*
|
|
10
|
+
* @see internal/objectives/m28-00-defi-basic-protocol-design.md (DEFI-04 ASNC-01)
|
|
11
|
+
*/
|
|
12
|
+
import { z } from 'zod';
|
|
13
|
+
// ---------------------------------------------------------------------------
|
|
14
|
+
// Bridge status values (6-value enum for transactions.bridge_status column)
|
|
15
|
+
// ---------------------------------------------------------------------------
|
|
16
|
+
/**
|
|
17
|
+
* All possible bridge_status values for the transactions table.
|
|
18
|
+
* Used as SSoT for DB CHECK constraint and Zod schema.
|
|
19
|
+
*/
|
|
20
|
+
export const BRIDGE_STATUS_VALUES = [
|
|
21
|
+
'PENDING',
|
|
22
|
+
'COMPLETED',
|
|
23
|
+
'FAILED',
|
|
24
|
+
'BRIDGE_MONITORING',
|
|
25
|
+
'TIMEOUT',
|
|
26
|
+
'REFUNDED',
|
|
27
|
+
];
|
|
28
|
+
/** Zod schema for bridge status validation (SSoT pattern). */
|
|
29
|
+
export const BridgeStatusEnum = z.enum(BRIDGE_STATUS_VALUES);
|
|
30
|
+
//# sourceMappingURL=async-status-tracker.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"async-status-tracker.js","sourceRoot":"","sources":["../../src/common/async-status-tracker.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB,8EAA8E;AAC9E,4EAA4E;AAC5E,8EAA8E;AAE9E;;;GAGG;AACH,MAAM,CAAC,MAAM,oBAAoB,GAAG;IAClC,SAAS;IACT,WAAW;IACX,QAAQ;IACR,mBAAmB;IACnB,SAAS;IACT,UAAU;CACF,CAAC;AAKX,8DAA8D;AAC9D,MAAM,CAAC,MAAM,gBAAgB,GAAG,CAAC,CAAC,IAAI,CAAC,oBAAoB,CAAC,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slippage utilities with branded types to prevent unit confusion.
|
|
3
|
+
*/
|
|
4
|
+
export type SlippageBps = number & {
|
|
5
|
+
__brand: 'bps';
|
|
6
|
+
};
|
|
7
|
+
export type SlippagePct = number & {
|
|
8
|
+
__brand: 'pct';
|
|
9
|
+
};
|
|
10
|
+
export declare function asBps(value: number): SlippageBps;
|
|
11
|
+
export declare function asPct(value: number): SlippagePct;
|
|
12
|
+
export declare function clampSlippageBps(input: number, defaultBps: SlippageBps, maxBps: SlippageBps): SlippageBps;
|
|
13
|
+
export declare function bpsToPct(bps: SlippageBps): number;
|
|
14
|
+
export declare function pctToBps(pct: SlippagePct): SlippageBps;
|
|
15
|
+
//# sourceMappingURL=slippage.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slippage.d.ts","sourceRoot":"","sources":["../../src/common/slippage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;AACtD,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG;IAAE,OAAO,EAAE,KAAK,CAAA;CAAE,CAAC;AAEtD,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAKhD;AAED,wBAAgB,KAAK,CAAC,KAAK,EAAE,MAAM,GAAG,WAAW,CAKhD;AAED,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,WAAW,EAAE,MAAM,EAAE,WAAW,GAAG,WAAW,CAGzG;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,MAAM,CAEjD;AAED,wBAAgB,QAAQ,CAAC,GAAG,EAAE,WAAW,GAAG,WAAW,CAEtD"}
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Slippage utilities with branded types to prevent unit confusion.
|
|
3
|
+
*/
|
|
4
|
+
export function asBps(value) {
|
|
5
|
+
if (!Number.isInteger(value) || value < 1 || value > 10000) {
|
|
6
|
+
throw new Error(`Invalid bps value: ${value} (must be integer 1-10000)`);
|
|
7
|
+
}
|
|
8
|
+
return value;
|
|
9
|
+
}
|
|
10
|
+
export function asPct(value) {
|
|
11
|
+
if (value < 0.001 || value > 1.0) {
|
|
12
|
+
throw new Error(`Invalid pct value: ${value} (must be 0.001-1.0)`);
|
|
13
|
+
}
|
|
14
|
+
return value;
|
|
15
|
+
}
|
|
16
|
+
export function clampSlippageBps(input, defaultBps, maxBps) {
|
|
17
|
+
const value = input <= 0 ? defaultBps : Math.min(input, maxBps);
|
|
18
|
+
return asBps(Math.round(value));
|
|
19
|
+
}
|
|
20
|
+
export function bpsToPct(bps) {
|
|
21
|
+
return bps / 10000;
|
|
22
|
+
}
|
|
23
|
+
export function pctToBps(pct) {
|
|
24
|
+
return asBps(Math.round(pct * 10000));
|
|
25
|
+
}
|
|
26
|
+
//# sourceMappingURL=slippage.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"slippage.js","sourceRoot":"","sources":["../../src/common/slippage.ts"],"names":[],"mappings":"AAAA;;GAEG;AAKH,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,IAAI,CAAC,MAAM,CAAC,SAAS,CAAC,KAAK,CAAC,IAAI,KAAK,GAAG,CAAC,IAAI,KAAK,GAAG,KAAK,EAAE,CAAC;QAC3D,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,4BAA4B,CAAC,CAAC;IAC3E,CAAC;IACD,OAAO,KAAoB,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,KAAK,CAAC,KAAa;IACjC,IAAI,KAAK,GAAG,KAAK,IAAI,KAAK,GAAG,GAAG,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CAAC,sBAAsB,KAAK,sBAAsB,CAAC,CAAC;IACrE,CAAC;IACD,OAAO,KAAoB,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,gBAAgB,CAAC,KAAa,EAAE,UAAuB,EAAE,MAAmB;IAC1F,MAAM,KAAK,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,EAAE,MAAM,CAAC,CAAC;IAChE,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC;AAClC,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAgB;IACvC,OAAO,GAAG,GAAG,KAAK,CAAC;AACrB,CAAC;AAED,MAAM,UAAU,QAAQ,CAAC,GAAgB;IACvC,OAAO,KAAK,CAAC,IAAI,CAAC,KAAK,CAAC,GAAG,GAAG,KAAK,CAAC,CAAC,CAAC;AACxC,CAAC"}
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* WAIaaS built-in DeFi Action Provider implementations.
|
|
3
|
+
*
|
|
4
|
+
* Exports registerBuiltInProviders() for daemon lifecycle integration
|
|
5
|
+
* and individual provider classes for direct usage.
|
|
6
|
+
*/
|
|
7
|
+
import type { IActionProvider } from '@waiaas/core';
|
|
8
|
+
export { JupiterSwapActionProvider } from './providers/jupiter-swap/index.js';
|
|
9
|
+
export { JUPITER_PROGRAM_ID, JUPITER_SWAP_DEFAULTS } from './providers/jupiter-swap/config.js';
|
|
10
|
+
export type { JupiterSwapConfig } from './providers/jupiter-swap/config.js';
|
|
11
|
+
export { ZeroExSwapActionProvider } from './providers/zerox-swap/index.js';
|
|
12
|
+
export { ALLOWANCE_HOLDER_ADDRESSES, ZEROX_SWAP_DEFAULTS, CHAIN_ID_MAP, getAllowanceHolderAddress } from './providers/zerox-swap/config.js';
|
|
13
|
+
export type { ZeroExSwapConfig } from './providers/zerox-swap/config.js';
|
|
14
|
+
export { LiFiActionProvider } from './providers/lifi/index.js';
|
|
15
|
+
export { LIFI_DEFAULTS, LIFI_CHAIN_MAP, getLiFiChainId } from './providers/lifi/config.js';
|
|
16
|
+
export type { LiFiConfig } from './providers/lifi/config.js';
|
|
17
|
+
export { LiFiApiClient } from './providers/lifi/lifi-api-client.js';
|
|
18
|
+
export { BridgeStatusTracker, BridgeMonitoringTracker } from './providers/lifi/bridge-status-tracker.js';
|
|
19
|
+
export { ActionApiClient } from './common/action-api-client.js';
|
|
20
|
+
export { asBps, asPct, clampSlippageBps, bpsToPct, pctToBps } from './common/slippage.js';
|
|
21
|
+
export type { SlippageBps, SlippagePct } from './common/slippage.js';
|
|
22
|
+
export { BRIDGE_STATUS_VALUES, BridgeStatusEnum, } from './common/async-status-tracker.js';
|
|
23
|
+
export type { IAsyncStatusTracker, AsyncTrackingResult, BridgeStatus, } from './common/async-status-tracker.js';
|
|
24
|
+
/** Minimal settings reader interface compatible with SettingsService.get(). */
|
|
25
|
+
export interface SettingsReader {
|
|
26
|
+
get(key: string): string;
|
|
27
|
+
}
|
|
28
|
+
interface ProviderRegistry {
|
|
29
|
+
register(provider: IActionProvider): void;
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Register built-in DeFi action providers from Admin Settings.
|
|
33
|
+
*
|
|
34
|
+
* Reads provider config from SettingsReader (DB > config.toml > default fallback chain).
|
|
35
|
+
* Each provider is registered when its `actions.{name}_enabled` setting is 'true'.
|
|
36
|
+
*/
|
|
37
|
+
export declare function registerBuiltInProviders(registry: ProviderRegistry, settingsReader: SettingsReader): {
|
|
38
|
+
loaded: string[];
|
|
39
|
+
skipped: string[];
|
|
40
|
+
};
|
|
41
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,cAAc,CAAC;AAMpD,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAC/F,YAAY,EAAE,iBAAiB,EAAE,MAAM,oCAAoC,CAAC;AAE5E,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;AAC5I,YAAY,EAAE,gBAAgB,EAAE,MAAM,kCAAkC,CAAC;AAEzE,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,aAAa,EAAE,cAAc,EAAE,cAAc,EAAE,MAAM,4BAA4B,CAAC;AAC3F,YAAY,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AAC7D,OAAO,EAAE,aAAa,EAAE,MAAM,qCAAqC,CAAC;AACpE,OAAO,EAAE,mBAAmB,EAAE,uBAAuB,EAAE,MAAM,2CAA2C,CAAC;AAGzG,OAAO,EAAE,eAAe,EAAE,MAAM,+BAA+B,CAAC;AAChE,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,gBAAgB,EAAE,QAAQ,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAC;AAC1F,YAAY,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,sBAAsB,CAAC;AAGrE,OAAO,EACL,oBAAoB,EACpB,gBAAgB,GACjB,MAAM,kCAAkC,CAAC;AAC1C,YAAY,EACV,mBAAmB,EACnB,mBAAmB,EACnB,YAAY,GACb,MAAM,kCAAkC,CAAC;AAM1C,+EAA+E;AAC/E,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC;CAC1B;AAED,UAAU,gBAAgB;IACxB,QAAQ,CAAC,QAAQ,EAAE,eAAe,GAAG,IAAI,CAAC;CAC3C;AAED;;;;;GAKG;AACH,wBAAgB,wBAAwB,CACtC,QAAQ,EAAE,gBAAgB,EAC1B,cAAc,EAAE,cAAc,GAC7B;IAAE,MAAM,EAAE,MAAM,EAAE,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,CA6EzC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,98 @@
|
|
|
1
|
+
import { JupiterSwapActionProvider } from './providers/jupiter-swap/index.js';
|
|
2
|
+
import { ZeroExSwapActionProvider } from './providers/zerox-swap/index.js';
|
|
3
|
+
import { LiFiActionProvider } from './providers/lifi/index.js';
|
|
4
|
+
// Re-export provider classes
|
|
5
|
+
export { JupiterSwapActionProvider } from './providers/jupiter-swap/index.js';
|
|
6
|
+
export { JUPITER_PROGRAM_ID, JUPITER_SWAP_DEFAULTS } from './providers/jupiter-swap/config.js';
|
|
7
|
+
export { ZeroExSwapActionProvider } from './providers/zerox-swap/index.js';
|
|
8
|
+
export { ALLOWANCE_HOLDER_ADDRESSES, ZEROX_SWAP_DEFAULTS, CHAIN_ID_MAP, getAllowanceHolderAddress } from './providers/zerox-swap/config.js';
|
|
9
|
+
export { LiFiActionProvider } from './providers/lifi/index.js';
|
|
10
|
+
export { LIFI_DEFAULTS, LIFI_CHAIN_MAP, getLiFiChainId } from './providers/lifi/config.js';
|
|
11
|
+
export { LiFiApiClient } from './providers/lifi/lifi-api-client.js';
|
|
12
|
+
export { BridgeStatusTracker, BridgeMonitoringTracker } from './providers/lifi/bridge-status-tracker.js';
|
|
13
|
+
// Re-export common utilities
|
|
14
|
+
export { ActionApiClient } from './common/action-api-client.js';
|
|
15
|
+
export { asBps, asPct, clampSlippageBps, bpsToPct, pctToBps } from './common/slippage.js';
|
|
16
|
+
// Re-export async status tracker interface and types (v28.3 DEFI-04)
|
|
17
|
+
export { BRIDGE_STATUS_VALUES, BridgeStatusEnum, } from './common/async-status-tracker.js';
|
|
18
|
+
/**
|
|
19
|
+
* Register built-in DeFi action providers from Admin Settings.
|
|
20
|
+
*
|
|
21
|
+
* Reads provider config from SettingsReader (DB > config.toml > default fallback chain).
|
|
22
|
+
* Each provider is registered when its `actions.{name}_enabled` setting is 'true'.
|
|
23
|
+
*/
|
|
24
|
+
export function registerBuiltInProviders(registry, settingsReader) {
|
|
25
|
+
const loaded = [];
|
|
26
|
+
const skipped = [];
|
|
27
|
+
const providers = [
|
|
28
|
+
{
|
|
29
|
+
key: 'jupiter_swap',
|
|
30
|
+
enabledKey: 'actions.jupiter_swap_enabled',
|
|
31
|
+
factory: () => {
|
|
32
|
+
const config = {
|
|
33
|
+
enabled: true,
|
|
34
|
+
apiBaseUrl: settingsReader.get('actions.jupiter_swap_api_base_url'),
|
|
35
|
+
apiKey: settingsReader.get('actions.jupiter_swap_api_key'),
|
|
36
|
+
defaultSlippageBps: Number(settingsReader.get('actions.jupiter_swap_default_slippage_bps')),
|
|
37
|
+
maxSlippageBps: Number(settingsReader.get('actions.jupiter_swap_max_slippage_bps')),
|
|
38
|
+
maxPriceImpactPct: Number(settingsReader.get('actions.jupiter_swap_max_price_impact_pct')),
|
|
39
|
+
jitoTipLamports: Number(settingsReader.get('actions.jupiter_swap_jito_tip_lamports')),
|
|
40
|
+
requestTimeoutMs: Number(settingsReader.get('actions.jupiter_swap_request_timeout_ms')),
|
|
41
|
+
};
|
|
42
|
+
return new JupiterSwapActionProvider(config);
|
|
43
|
+
},
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
key: 'zerox_swap',
|
|
47
|
+
enabledKey: 'actions.zerox_swap_enabled',
|
|
48
|
+
factory: () => {
|
|
49
|
+
const config = {
|
|
50
|
+
enabled: true,
|
|
51
|
+
apiKey: settingsReader.get('actions.zerox_swap_api_key'),
|
|
52
|
+
defaultSlippageBps: Number(settingsReader.get('actions.zerox_swap_default_slippage_bps')),
|
|
53
|
+
maxSlippageBps: Number(settingsReader.get('actions.zerox_swap_max_slippage_bps')),
|
|
54
|
+
requestTimeoutMs: Number(settingsReader.get('actions.zerox_swap_request_timeout_ms')),
|
|
55
|
+
};
|
|
56
|
+
return new ZeroExSwapActionProvider(config);
|
|
57
|
+
},
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
key: 'lifi',
|
|
61
|
+
enabledKey: 'actions.lifi_enabled',
|
|
62
|
+
factory: () => {
|
|
63
|
+
const config = {
|
|
64
|
+
enabled: true,
|
|
65
|
+
apiBaseUrl: settingsReader.get('actions.lifi_api_base_url'),
|
|
66
|
+
apiKey: settingsReader.get('actions.lifi_api_key'),
|
|
67
|
+
defaultSlippagePct: Number(settingsReader.get('actions.lifi_default_slippage_pct')),
|
|
68
|
+
maxSlippagePct: Number(settingsReader.get('actions.lifi_max_slippage_pct')),
|
|
69
|
+
requestTimeoutMs: 15_000,
|
|
70
|
+
};
|
|
71
|
+
return new LiFiActionProvider(config);
|
|
72
|
+
},
|
|
73
|
+
},
|
|
74
|
+
];
|
|
75
|
+
for (const { key, enabledKey, factory } of providers) {
|
|
76
|
+
if (settingsReader.get(enabledKey) === 'true') {
|
|
77
|
+
try {
|
|
78
|
+
const provider = factory();
|
|
79
|
+
if (provider) {
|
|
80
|
+
registry.register(provider);
|
|
81
|
+
loaded.push(key);
|
|
82
|
+
}
|
|
83
|
+
else {
|
|
84
|
+
skipped.push(key);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
catch (err) {
|
|
88
|
+
console.warn(`Built-in provider '${key}' registration failed:`, err);
|
|
89
|
+
skipped.push(key);
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
else {
|
|
93
|
+
skipped.push(key);
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
return { loaded, skipped };
|
|
97
|
+
}
|
|
98
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAOA,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAE/D,6BAA6B;AAC7B,OAAO,EAAE,yBAAyB,EAAE,MAAM,mCAAmC,CAAC;AAC9E,OAAO,EAAE,kBAAkB,EAAE,qBAAqB,EAAE,MAAM,oCAAoC,CAAC;AAG/F,OAAO,EAAE,wBAAwB,EAAE,MAAM,iCAAiC,CAAC;AAC3E,OAAO,EAAE,0BAA0B,EAAE,mBAAmB,EAAE,YAAY,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAC;A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,UAAU,EAAE,OAAO,EAAE,IAAI,SAAS,EAAE,CAAC;QACrD,IAAI,cAAc,CAAC,GAAG,CAAC,UAAU,CAAC,KAAK,MAAM,EAAE,CAAC;YAC9C,IAAI,CAAC;gBACH,MAAM,QAAQ,GAAG,OAAO,EAAE,CAAC;gBAC3B,IAAI,QAAQ,EAAE,CAAC;oBACb,QAAQ,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;oBAC5B,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACnB,CAAC;qBAAM,CAAC;oBACN,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;gBACpB,CAAC;YACH,CAAC;YAAC,OAAO,GAAG,EAAE,CAAC;gBACb,OAAO,CAAC,IAAI,CAAC,sBAAsB,GAAG,wBAAwB,EAAE,GAAG,CAAC,CAAC;gBACrE,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;YACpB,CAAC;QACH,CAAC;aAAM,CAAC;YACN,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAED,OAAO,EAAE,MAAM,EAAE,OAAO,EAAE,CAAC;AAC7B,CAAC"}
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jupiter Swap configuration type and defaults.
|
|
3
|
+
*/
|
|
4
|
+
export interface JupiterSwapConfig {
|
|
5
|
+
enabled: boolean;
|
|
6
|
+
apiBaseUrl: string;
|
|
7
|
+
apiKey: string;
|
|
8
|
+
defaultSlippageBps: number;
|
|
9
|
+
maxSlippageBps: number;
|
|
10
|
+
maxPriceImpactPct: number;
|
|
11
|
+
jitoTipLamports: number;
|
|
12
|
+
requestTimeoutMs: number;
|
|
13
|
+
}
|
|
14
|
+
export declare const JUPITER_SWAP_DEFAULTS: JupiterSwapConfig;
|
|
15
|
+
export declare const JUPITER_PROGRAM_ID = "JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4";
|
|
16
|
+
//# sourceMappingURL=config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.d.ts","sourceRoot":"","sources":["../../../src/providers/jupiter-swap/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,iBAAiB;IAChC,OAAO,EAAE,OAAO,CAAC;IACjB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;IACvB,iBAAiB,EAAE,MAAM,CAAC;IAC1B,eAAe,EAAE,MAAM,CAAC;IACxB,gBAAgB,EAAE,MAAM,CAAC;CAC1B;AAED,eAAO,MAAM,qBAAqB,EAAE,iBASnC,CAAC;AAEF,eAAO,MAAM,kBAAkB,gDAAgD,CAAC"}
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Jupiter Swap configuration type and defaults.
|
|
3
|
+
*/
|
|
4
|
+
export const JUPITER_SWAP_DEFAULTS = {
|
|
5
|
+
enabled: false,
|
|
6
|
+
apiBaseUrl: 'https://api.jup.ag/swap/v1',
|
|
7
|
+
apiKey: '',
|
|
8
|
+
defaultSlippageBps: 50, // 0.5%
|
|
9
|
+
maxSlippageBps: 500, // 5%
|
|
10
|
+
maxPriceImpactPct: 1.0, // 1%
|
|
11
|
+
jitoTipLamports: 1000,
|
|
12
|
+
requestTimeoutMs: 10_000,
|
|
13
|
+
};
|
|
14
|
+
export const JUPITER_PROGRAM_ID = 'JUP6LkbZbjS1jKKwapdHNy74zcZ3tLUZoi5QNyVTaV4';
|
|
15
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../../../src/providers/jupiter-swap/config.ts"],"names":[],"mappings":"AAAA;;GAEG;AAaH,MAAM,CAAC,MAAM,qBAAqB,GAAsB;IACtD,OAAO,EAAE,KAAK;IACd,UAAU,EAAE,4BAA4B;IACxC,MAAM,EAAE,EAAE;IACV,kBAAkB,EAAE,EAAE,EAAK,OAAO;IAClC,cAAc,EAAE,GAAG,EAAQ,KAAK;IAChC,iBAAiB,EAAE,GAAG,EAAK,KAAK;IAChC,eAAe,EAAE,IAAI;IACrB,gBAAgB,EAAE,MAAM;CACzB,CAAC;AAEF,MAAM,CAAC,MAAM,kBAAkB,GAAG,6CAA6C,CAAC"}
|