@thirdfy/agent-cli 0.2.57 → 0.2.59
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 +12 -0
- package/README.md +5 -2
- package/package.json +1 -1
- package/src/cli/manifest.mjs +1 -1
- package/src/commands/avantis.mjs +53 -0
- package/src/commands/execute.mjs +5 -2
- package/src/commands/index.mjs +1 -0
- package/src/commands/venue.mjs +2 -2
- package/src/commands/wallet.mjs +3 -1
- package/src/core/actionTimeouts.mjs +1 -0
- package/src/core/fundingTokenIn.mjs +22 -0
- package/src/runtime/actions/selection.mjs +5 -0
- package/src/runtime/certification/venueActionSchemas.mjs +68 -0
- package/src/runtime/execution/lanes.mjs +27 -1
- package/src/runtime/execution/payloads.mjs +1 -6
- package/src/runtime/execution/runners.mjs +4 -1
- package/src/runtime/handlers.mjs +9 -0
- package/src/runtime/providerHints.mjs +108 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,18 @@ All notable changes to `@thirdfy/agent-cli` are documented here. The format is b
|
|
|
4
4
|
|
|
5
5
|
## [Unreleased]
|
|
6
6
|
|
|
7
|
+
## [0.2.59] - 2026-09-05
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
|
|
11
|
+
- `avantis` and `avantis-vault` provider hints, venue tooling (`venue readiness|setup|fund avantis`), and [`docs/providers/avantis.md`](./docs/providers/avantis.md). `get_avantis_*` actions classify as read-only. Place-order examples use Avantis `side` (`long`/`short`), not Hyperliquid `isBuy`. `agent_wallet` fills missing `traderAddress` on setup and status reads. Thirdfy mints the encrypted `avantis_delegate` credential. Do not paste a venue private key. Pairs with `thirdfy-mcp` **0.0.107** and Thirdfy API **3.14.21**.
|
|
12
|
+
|
|
13
|
+
## [0.2.58] - 2026-09-05
|
|
14
|
+
|
|
15
|
+
### Fixed
|
|
16
|
+
|
|
17
|
+
- `basedbid_buy` managed-wallet preflight no longer treats listing `tokenAddress` as an ERC-20 `tokenIn`. Buy spends native ETH, so a zero listing-token balance no longer blocks a funded wallet. `basedbid_sell` and earn deposits still fund from `tokenAddress`. Pairs with `thirdfy-mcp` **0.0.106**.
|
|
18
|
+
|
|
7
19
|
## [0.2.57] - 2026-09-04
|
|
8
20
|
|
|
9
21
|
### Added
|
package/README.md
CHANGED
|
@@ -40,9 +40,11 @@ Run without global install:
|
|
|
40
40
|
npx @thirdfy/agent-cli --help
|
|
41
41
|
```
|
|
42
42
|
|
|
43
|
-
## What's new in v0.2.
|
|
43
|
+
## What's new in v0.2.59
|
|
44
44
|
|
|
45
|
-
-
|
|
45
|
+
- Avantis Base perps: discover markets, complete onboarding on `agent_wallet`, then place or close with `side` `long` or `short`.
|
|
46
|
+
- Thirdfy mints and stores the `avantis_delegate` credential. Do not paste a venue private key.
|
|
47
|
+
- Venue tooling: `venue readiness`, `venue setup`, and `venue fund` for `avantis`.
|
|
46
48
|
- See [CHANGELOG.md](./CHANGELOG.md) and GitHub Releases for older versions.
|
|
47
49
|
|
|
48
50
|
## Quick start
|
|
@@ -322,6 +324,7 @@ Provider and venue guides are kept outside `README` so this page stays stable as
|
|
|
322
324
|
- Discovery: `catalogs list`, `actions` (optional `--provider`, `--chain-id`; see [`docs/command-reference.md`](./docs/command-reference.md) for trading vs earn vs prediction providers and case-insensitive matching)
|
|
323
325
|
- Execution: `preflight`, `run`, `intent-status`, `jeff preflight`, `jeff trade`, `jeff status`
|
|
324
326
|
- Polymarket: `polymarket status`, `polymarket setup`, `polymarket dry-run`
|
|
327
|
+
- Venue tooling: `venue readiness`, `venue setup`, `venue fund` (`polymarket`, `hyperliquid`, `lighter`, `avantis`)
|
|
325
328
|
- Hummingbot: `hummingbot status`, `connectors`, `executor-schema`, `executor-create`, `executor-stop`, `gateway-networks`, `gateway-connectors`
|
|
326
329
|
- Condor Pattern A: `condor policy-status`, `condor preflight`
|
|
327
330
|
- Managed signer execution: `wallet execute`, `wallet sign`, `wallet submit`, `agent run`
|
package/package.json
CHANGED
package/src/cli/manifest.mjs
CHANGED
|
@@ -103,7 +103,7 @@ export const CLI_MANIFEST = [
|
|
|
103
103
|
path: ['venue', 'readiness'],
|
|
104
104
|
handler: 'commandVenueReadiness',
|
|
105
105
|
options: ['auth', 'venue'],
|
|
106
|
-
description: 'Normalized venue readiness (polymarket, hyperliquid, lighter)',
|
|
106
|
+
description: 'Normalized venue readiness (polymarket, hyperliquid, lighter, avantis)',
|
|
107
107
|
args: { query: true },
|
|
108
108
|
tier: 'online',
|
|
109
109
|
},
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
export function createAvantisHelpers(deps) {
|
|
2
|
+
const { getPreparedParams, resolveManagedExecutionPreflight } = deps;
|
|
3
|
+
|
|
4
|
+
function avantisDefaultAddressParamForAction(action) {
|
|
5
|
+
const canonical = String(action || '')
|
|
6
|
+
.trim()
|
|
7
|
+
.toLowerCase()
|
|
8
|
+
.replace(/_/g, '-');
|
|
9
|
+
if (
|
|
10
|
+
canonical === 'get-avantis-open-orders' ||
|
|
11
|
+
canonical === 'get-avantis-positions' ||
|
|
12
|
+
canonical === 'get-avantis-allowance' ||
|
|
13
|
+
canonical === 'get-avantis-delegation-status' ||
|
|
14
|
+
canonical === 'get-avantis-setup-status' ||
|
|
15
|
+
canonical === 'get-avantis-funding-status' ||
|
|
16
|
+
canonical === 'get-avantis-onboarding-plan' ||
|
|
17
|
+
canonical === 'get-avantis-builder-fee-status' ||
|
|
18
|
+
canonical === 'get-avantis-referral-status' ||
|
|
19
|
+
canonical === 'get-avantis-referral-stats' ||
|
|
20
|
+
canonical === 'prepare-avantis-onboarding' ||
|
|
21
|
+
canonical === 'complete-avantis-onboarding'
|
|
22
|
+
) {
|
|
23
|
+
return 'traderAddress';
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
async function applyAvantisAgentWalletAddressDefault(ctx, flags, resolved, runMode) {
|
|
29
|
+
if (runMode !== 'agent_wallet') return null;
|
|
30
|
+
const paramName = avantisDefaultAddressParamForAction(resolved?.resolvedAction);
|
|
31
|
+
if (!paramName) return null;
|
|
32
|
+
const params = getPreparedParams(flags);
|
|
33
|
+
if (String(params?.[paramName] || '').trim()) return null;
|
|
34
|
+
if (String(params?.mainWalletAddress || params?.walletAddress || params?.userAddress || '').trim()) {
|
|
35
|
+
return null;
|
|
36
|
+
}
|
|
37
|
+
const preflight = await resolveManagedExecutionPreflight(ctx, flags, resolved, {
|
|
38
|
+
runMode: 'agent_wallet',
|
|
39
|
+
requireFundingCheck: false,
|
|
40
|
+
});
|
|
41
|
+
if (!preflight.success || !preflight.executionWalletAddress) return preflight;
|
|
42
|
+
flags.__preparedParams = {
|
|
43
|
+
...(params || {}),
|
|
44
|
+
[paramName]: preflight.executionWalletAddress,
|
|
45
|
+
};
|
|
46
|
+
return preflight;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
return {
|
|
50
|
+
avantisDefaultAddressParamForAction,
|
|
51
|
+
applyAvantisAgentWalletAddressDefault,
|
|
52
|
+
};
|
|
53
|
+
}
|
package/src/commands/execute.mjs
CHANGED
|
@@ -21,6 +21,7 @@ export function createExecuteCommands(deps) {
|
|
|
21
21
|
enforceChainCompatibility,
|
|
22
22
|
applyHyperliquidAgentWalletAddressDefault,
|
|
23
23
|
applyLighterAgentWalletAddressDefault,
|
|
24
|
+
applyAvantisAgentWalletAddressDefault,
|
|
24
25
|
runPreflightByMode,
|
|
25
26
|
runExecutionByMode,
|
|
26
27
|
applyExecutionFallbackHints,
|
|
@@ -43,7 +44,8 @@ async function commandPreflight(ctx, flags, capabilities) {
|
|
|
43
44
|
enforceChainCompatibility(capabilities, flags, runMode);
|
|
44
45
|
const managedPreflight =
|
|
45
46
|
(await applyHyperliquidAgentWalletAddressDefault(ctx, flags, resolved, runMode))
|
|
46
|
-
|| (await applyLighterAgentWalletAddressDefault(ctx, flags, resolved, runMode))
|
|
47
|
+
|| (await applyLighterAgentWalletAddressDefault(ctx, flags, resolved, runMode))
|
|
48
|
+
|| (await applyAvantisAgentWalletAddressDefault(ctx, flags, resolved, runMode));
|
|
47
49
|
const backendResult = await runPreflightByMode(runMode, ctx, flags, resolved, { hybridWalletMode, managedPreflight });
|
|
48
50
|
const normalized = applyExecutionFallbackHints(backendResult.normalized, {
|
|
49
51
|
flags,
|
|
@@ -96,7 +98,8 @@ async function commandRun(ctx, flags, capabilities) {
|
|
|
96
98
|
enforceChainCompatibility(capabilities, flags, runMode);
|
|
97
99
|
const managedPreflight =
|
|
98
100
|
(await applyHyperliquidAgentWalletAddressDefault(ctx, flags, resolved, runMode))
|
|
99
|
-
|| (await applyLighterAgentWalletAddressDefault(ctx, flags, resolved, runMode))
|
|
101
|
+
|| (await applyLighterAgentWalletAddressDefault(ctx, flags, resolved, runMode))
|
|
102
|
+
|| (await applyAvantisAgentWalletAddressDefault(ctx, flags, resolved, runMode));
|
|
100
103
|
const skipPreflight = Boolean(flags.skipPreflight);
|
|
101
104
|
const backendResult = await runExecutionByMode(runMode, ctx, flags, resolved, {
|
|
102
105
|
skipPreflight,
|
package/src/commands/index.mjs
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export { createPolymarketCommands, resolveConfigAgentKey } from './polymarket.mjs';
|
|
2
2
|
export { createHyperliquidHelpers } from './hyperliquid.mjs';
|
|
3
3
|
export { createLighterHelpers } from './lighter.mjs';
|
|
4
|
+
export { createAvantisHelpers } from './avantis.mjs';
|
|
4
5
|
export { createHummingbotCommands } from './hummingbot.mjs';
|
|
5
6
|
export { createCondorCommands } from './condor.mjs';
|
|
6
7
|
export { createExecuteCommands } from './execute.mjs';
|
package/src/commands/venue.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import { apiGet, apiPost } from '../core/http.mjs';
|
|
2
2
|
import { loadProfileConfig } from '../core/context.mjs';
|
|
3
3
|
|
|
4
|
-
const VENUES = new Set(['polymarket', 'hyperliquid', 'lighter']);
|
|
4
|
+
const VENUES = new Set(['polymarket', 'hyperliquid', 'lighter', 'avantis']);
|
|
5
5
|
|
|
6
6
|
function resolveVenue(flags) {
|
|
7
7
|
const fromQuery = Array.isArray(flags.query) ? flags.query[0] : flags.query;
|
|
8
8
|
const venue = String(flags.venue || fromQuery || '').trim().toLowerCase();
|
|
9
9
|
if (!VENUES.has(venue)) {
|
|
10
|
-
throw new Error(`Unsupported venue "${venue}". Use polymarket, hyperliquid, or
|
|
10
|
+
throw new Error(`Unsupported venue "${venue}". Use polymarket, hyperliquid, lighter, or avantis.`);
|
|
11
11
|
}
|
|
12
12
|
return venue;
|
|
13
13
|
}
|
package/src/commands/wallet.mjs
CHANGED
|
@@ -11,6 +11,7 @@ export function createWalletCommands(deps) {
|
|
|
11
11
|
enforceChainCompatibility,
|
|
12
12
|
applyHyperliquidAgentWalletAddressDefault,
|
|
13
13
|
applyLighterAgentWalletAddressDefault,
|
|
14
|
+
applyAvantisAgentWalletAddressDefault,
|
|
14
15
|
executeManagedWalletRun,
|
|
15
16
|
executeSelfRun,
|
|
16
17
|
submitSignedTx,
|
|
@@ -26,7 +27,8 @@ async function commandWalletExecute(ctx, flags, capabilities) {
|
|
|
26
27
|
enforceChainCompatibility(capabilities, normalizedFlags, 'agent_wallet');
|
|
27
28
|
const managedPreflight =
|
|
28
29
|
(await applyHyperliquidAgentWalletAddressDefault(ctx, normalizedFlags, resolved, 'agent_wallet'))
|
|
29
|
-
|| (await applyLighterAgentWalletAddressDefault(ctx, normalizedFlags, resolved, 'agent_wallet'))
|
|
30
|
+
|| (await applyLighterAgentWalletAddressDefault(ctx, normalizedFlags, resolved, 'agent_wallet'))
|
|
31
|
+
|| (await applyAvantisAgentWalletAddressDefault(ctx, normalizedFlags, resolved, 'agent_wallet'));
|
|
30
32
|
const skipPreflight = Boolean(normalizedFlags.skipPreflight);
|
|
31
33
|
const result = await executeManagedWalletRun(ctx, normalizedFlags, resolved, { skipPreflight, managedPreflight });
|
|
32
34
|
printEnvelope({
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import { normalizeActionKey } from './readOnlyActions.mjs';
|
|
2
|
+
|
|
3
|
+
/**
|
|
4
|
+
* Native-ETH spends pass `tokenAddress` as the listing or output, not the funding ERC-20.
|
|
5
|
+
* Sending that address as execution-wallet `tokenIn` checks the wrong balance and blocks buys.
|
|
6
|
+
*/
|
|
7
|
+
const NATIVE_ETH_SPEND_ACTIONS = new Set([
|
|
8
|
+
'basedbid_buy',
|
|
9
|
+
'basedbid_create_lbp',
|
|
10
|
+
'basedbid_create_flash',
|
|
11
|
+
'basedbid_create_board',
|
|
12
|
+
]);
|
|
13
|
+
|
|
14
|
+
export function resolveTokenInForFunding(params, action) {
|
|
15
|
+
if (!params || typeof params !== 'object') return '';
|
|
16
|
+
const explicit = String(params.tokenIn || '').trim();
|
|
17
|
+
if (explicit) return explicit;
|
|
18
|
+
const actionId = normalizeActionKey(action);
|
|
19
|
+
if (NATIVE_ETH_SPEND_ACTIONS.has(actionId)) return '';
|
|
20
|
+
if (params.amountEth != null && String(params.amountEth).trim() !== '') return '';
|
|
21
|
+
return String(params.tokenAddress || params.token || '').trim();
|
|
22
|
+
}
|
|
@@ -182,6 +182,8 @@ function inferActionProvider(action) {
|
|
|
182
182
|
if (knownMap[key]) return knownMap[key];
|
|
183
183
|
if (key.includes('hyperliquid')) return 'hyperliquid';
|
|
184
184
|
if (key.includes('lighter')) return 'lighter';
|
|
185
|
+
if (key.includes('avantis') && key.includes('vault')) return 'avantis-vault';
|
|
186
|
+
if (key.includes('avantis')) return 'avantis';
|
|
185
187
|
if (key.includes('bitfinex')) return 'bitfinex';
|
|
186
188
|
if (key.includes('polymarket') || key.includes('prediction')) return 'polymarket';
|
|
187
189
|
if (key.includes('vaults-fyi')) return 'vaults-fyi';
|
|
@@ -257,6 +259,9 @@ function actionMatchesProvider(action, requestedProvider, allActions) {
|
|
|
257
259
|
// Here resolved metadata already disagrees with the filter; fall back to action-key shape only.
|
|
258
260
|
if (requestedProvider === 'hyperliquid') return isProviderActionKey(action, 'hyperliquid');
|
|
259
261
|
if (requestedProvider === 'lighter') return isProviderActionKey(action, 'lighter');
|
|
262
|
+
if (requestedProvider === 'avantis') {
|
|
263
|
+
return isProviderActionKey(action, 'avantis') && !actionKey.includes('vault');
|
|
264
|
+
}
|
|
260
265
|
if (requestedProvider === 'polymarket') return isProviderActionKey(action, 'polymarket');
|
|
261
266
|
if (requestedProvider === 'bridge') {
|
|
262
267
|
// Hyperliquid Bridge2 and Lighter CCTP setup actions are owned by their perps providers, not cross-chain bridge.
|
|
@@ -182,6 +182,74 @@ export const VENUE_WRITE_ACTION_FIXTURES = [
|
|
|
182
182
|
},
|
|
183
183
|
validSample: { orderId: '0xabc' },
|
|
184
184
|
},
|
|
185
|
+
{
|
|
186
|
+
action: 'place_avantis_perps_order',
|
|
187
|
+
aliases: ['place-avantis-perps-order'],
|
|
188
|
+
provider: 'avantis',
|
|
189
|
+
authorityInputs: ['agentApiKey', 'estimatedAmountUsd'],
|
|
190
|
+
paramsSchema: {
|
|
191
|
+
type: 'object',
|
|
192
|
+
additionalProperties: false,
|
|
193
|
+
required: ['pairIndex', 'side', 'collateralUsdc', 'leverage'],
|
|
194
|
+
properties: {
|
|
195
|
+
pairIndex: { type: 'integer', minimum: 0 },
|
|
196
|
+
pair: { type: 'string', minLength: 1 },
|
|
197
|
+
side: { type: 'string', enum: ['long', 'short'] },
|
|
198
|
+
orderType: { type: 'string', enum: ['market', 'limit'] },
|
|
199
|
+
collateralUsdc: { type: 'number', minimum: 0 },
|
|
200
|
+
leverage: { type: 'number', minimum: 0 },
|
|
201
|
+
limitPrice: { type: 'number', minimum: 0 },
|
|
202
|
+
slippagePercent: { type: 'number', minimum: 0, maximum: 100 },
|
|
203
|
+
executionMode: { type: 'string', enum: ['relayer', 'direct'] },
|
|
204
|
+
confirmWrites: { type: 'boolean' },
|
|
205
|
+
},
|
|
206
|
+
},
|
|
207
|
+
validSample: {
|
|
208
|
+
pairIndex: 0,
|
|
209
|
+
side: 'long',
|
|
210
|
+
collateralUsdc: 10,
|
|
211
|
+
leverage: 10,
|
|
212
|
+
orderType: 'market',
|
|
213
|
+
},
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
action: 'cancel_avantis_perps_order',
|
|
217
|
+
aliases: ['cancel-avantis-perps-order'],
|
|
218
|
+
provider: 'avantis',
|
|
219
|
+
authorityInputs: ['agentApiKey'],
|
|
220
|
+
paramsSchema: {
|
|
221
|
+
type: 'object',
|
|
222
|
+
additionalProperties: false,
|
|
223
|
+
required: ['pairIndex', 'orderIndex'],
|
|
224
|
+
properties: {
|
|
225
|
+
pairIndex: { type: 'integer', minimum: 0 },
|
|
226
|
+
orderIndex: { type: 'integer', minimum: 0 },
|
|
227
|
+
executionMode: { type: 'string', enum: ['relayer', 'direct'] },
|
|
228
|
+
confirmWrites: { type: 'boolean' },
|
|
229
|
+
},
|
|
230
|
+
},
|
|
231
|
+
validSample: { pairIndex: 0, orderIndex: 1 },
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
action: 'close_avantis_position',
|
|
235
|
+
aliases: ['close-avantis-position'],
|
|
236
|
+
provider: 'avantis',
|
|
237
|
+
authorityInputs: ['agentApiKey', 'estimatedAmountUsd'],
|
|
238
|
+
paramsSchema: {
|
|
239
|
+
type: 'object',
|
|
240
|
+
additionalProperties: false,
|
|
241
|
+
required: ['pairIndex', 'tradeIndex'],
|
|
242
|
+
properties: {
|
|
243
|
+
pairIndex: { type: 'integer', minimum: 0 },
|
|
244
|
+
tradeIndex: { type: 'integer', minimum: 0 },
|
|
245
|
+
collateralToCloseUsdc: { type: 'number', minimum: 0 },
|
|
246
|
+
slippagePercent: { type: 'number', minimum: 0, maximum: 100 },
|
|
247
|
+
executionMode: { type: 'string', enum: ['relayer', 'direct'] },
|
|
248
|
+
confirmWrites: { type: 'boolean' },
|
|
249
|
+
},
|
|
250
|
+
},
|
|
251
|
+
validSample: { pairIndex: 0, tradeIndex: 0 },
|
|
252
|
+
},
|
|
185
253
|
];
|
|
186
254
|
|
|
187
255
|
export function fixtureCatalogActions() {
|
|
@@ -27,13 +27,39 @@ const OFFCHAIN_VENUE_ORDER_ACTIONS = new Set([
|
|
|
27
27
|
'condor-executor-create',
|
|
28
28
|
'condor_executor_stop',
|
|
29
29
|
'condor-executor-stop',
|
|
30
|
+
'place_avantis_perps_order',
|
|
31
|
+
'place-avantis-perps-order',
|
|
32
|
+
'cancel_avantis_perps_order',
|
|
33
|
+
'cancel-avantis-perps-order',
|
|
34
|
+
'close_avantis_position',
|
|
35
|
+
'close-avantis-position',
|
|
36
|
+
'update_avantis_tp_sl',
|
|
37
|
+
'update-avantis-tp-sl',
|
|
38
|
+
'cancel_avantis_tp_sl',
|
|
39
|
+
'cancel-avantis-tp-sl',
|
|
40
|
+
'place_avantis_twap_order',
|
|
41
|
+
'place-avantis-twap-order',
|
|
42
|
+
'close_avantis_twap_order',
|
|
43
|
+
'close-avantis-twap-order',
|
|
44
|
+
'cancel_avantis_twap_order',
|
|
45
|
+
'cancel-avantis-twap-order',
|
|
46
|
+
'place_avantis_coin_perps_order',
|
|
47
|
+
'place-avantis-coin-perps-order',
|
|
48
|
+
'increase_avantis_coin_position',
|
|
49
|
+
'increase-avantis-coin-position',
|
|
50
|
+
'close_avantis_coin_position',
|
|
51
|
+
'close-avantis-coin-position',
|
|
52
|
+
'place_avantis_mm_order',
|
|
53
|
+
'place-avantis-mm-order',
|
|
54
|
+
'cancel_avantis_mm_order',
|
|
55
|
+
'cancel-avantis-mm-order',
|
|
30
56
|
]);
|
|
31
57
|
function enforceOffchainVenueLaneCompatibility(action, runMode) {
|
|
32
58
|
const normalizedAction = String(action || '').trim().toLowerCase();
|
|
33
59
|
if (runMode !== 'self' || !OFFCHAIN_VENUE_ORDER_ACTIONS.has(normalizedAction)) return;
|
|
34
60
|
throw createCliError(
|
|
35
61
|
'OFFCHAIN_VENUE_ORDER_SELF_UNSUPPORTED',
|
|
36
|
-
'Polymarket CLOB, Hyperliquid perps, Lighter perps, Hummingbot executor, and Condor executor actions are offchain signed API actions, not EVM build-tx actions. Use self for setup/funding signatures, then run venue orders with --run-mode thirdfy, --run-mode hybrid, or --run-mode agent_wallet.',
|
|
62
|
+
'Polymarket CLOB, Hyperliquid perps, Lighter perps, Avantis perps, Hummingbot executor, and Condor executor actions are offchain signed API actions, not EVM build-tx actions. Use self for setup/funding signatures, then run venue orders with --run-mode thirdfy, --run-mode hybrid, or --run-mode agent_wallet.',
|
|
37
63
|
{
|
|
38
64
|
recommendedRunModes: ['thirdfy', 'hybrid', 'agent_wallet'],
|
|
39
65
|
setupOnlyRunMode: 'self',
|
|
@@ -4,6 +4,7 @@ import { loadProfileConfig } from '../../core/context.mjs';
|
|
|
4
4
|
import { createCliError } from '../../core/envelope.mjs';
|
|
5
5
|
import { normalizeRunMode, normalizeManagedRunMode, normalizeHybridWalletMode } from '../../core/runMode.mjs';
|
|
6
6
|
import { assertEarnclawPolymarketWriteIdempotency } from './earnclawRuntimeWriteGate.mjs';
|
|
7
|
+
import { resolveTokenInForFunding } from '../../core/fundingTokenIn.mjs';
|
|
7
8
|
export function createExecutionPayloads({ getPreparedParams, rawUnitsToDecimalString }) {
|
|
8
9
|
function buildBuildTxPayload(flags, resolvedAction) {
|
|
9
10
|
const runMode = String(flags.runMode || '').trim().toLowerCase() || 'self';
|
|
@@ -134,12 +135,6 @@ function buildManagedExecutePayload(flags, options) {
|
|
|
134
135
|
return payload;
|
|
135
136
|
}
|
|
136
137
|
|
|
137
|
-
function resolveTokenInForFunding(params) {
|
|
138
|
-
if (!params || typeof params !== 'object') return '';
|
|
139
|
-
const tokenIn = String(params.tokenIn || params.tokenAddress || params.token || '').trim();
|
|
140
|
-
return tokenIn;
|
|
141
|
-
}
|
|
142
|
-
|
|
143
138
|
function buildIntentPayload(flags, options) {
|
|
144
139
|
const runMode = String(options.runMode || flags.runMode || '').trim().toLowerCase() || 'thirdfy';
|
|
145
140
|
const payload = {
|
|
@@ -650,7 +650,10 @@ async function resolveManagedExecutionPreflight(ctx, flags, resolved, options =
|
|
|
650
650
|
signerMethod: 'managed_wallet_server',
|
|
651
651
|
};
|
|
652
652
|
}
|
|
653
|
-
const tokenIn = resolveTokenInForFunding(
|
|
653
|
+
const tokenIn = resolveTokenInForFunding(
|
|
654
|
+
getPreparedParams(flags),
|
|
655
|
+
resolved?.resolvedAction || flags.action
|
|
656
|
+
);
|
|
654
657
|
const query = new URLSearchParams({
|
|
655
658
|
userDid,
|
|
656
659
|
chainId: String(chainId),
|
package/src/runtime/handlers.mjs
CHANGED
|
@@ -4,6 +4,7 @@ import { createHummingbotCommands } from '../commands/hummingbot.mjs';
|
|
|
4
4
|
import { createCondorCommands } from '../commands/condor.mjs';
|
|
5
5
|
import { createHyperliquidHelpers } from '../commands/hyperliquid.mjs';
|
|
6
6
|
import { createLighterHelpers } from '../commands/lighter.mjs';
|
|
7
|
+
import { createAvantisHelpers } from '../commands/avantis.mjs';
|
|
7
8
|
import { createExecuteCommands } from '../commands/execute.mjs';
|
|
8
9
|
import { createWalletCommands } from '../commands/wallet.mjs';
|
|
9
10
|
import { createDelegationCommands } from '../commands/delegation.mjs';
|
|
@@ -126,6 +127,12 @@ export function createRuntimeHandlers(deps) {
|
|
|
126
127
|
});
|
|
127
128
|
const { applyLighterAgentWalletAddressDefault } = __lighter;
|
|
128
129
|
|
|
130
|
+
const __avantis = createAvantisHelpers({
|
|
131
|
+
getPreparedParams,
|
|
132
|
+
resolveManagedExecutionPreflight,
|
|
133
|
+
});
|
|
134
|
+
const { applyAvantisAgentWalletAddressDefault } = __avantis;
|
|
135
|
+
|
|
129
136
|
const __wallet = createWalletCommands({
|
|
130
137
|
resolveActionSelection,
|
|
131
138
|
prepareActionParamsForFlags,
|
|
@@ -134,6 +141,7 @@ export function createRuntimeHandlers(deps) {
|
|
|
134
141
|
enforceChainCompatibility,
|
|
135
142
|
applyHyperliquidAgentWalletAddressDefault,
|
|
136
143
|
applyLighterAgentWalletAddressDefault,
|
|
144
|
+
applyAvantisAgentWalletAddressDefault,
|
|
137
145
|
executeManagedWalletRun,
|
|
138
146
|
executeSelfRun,
|
|
139
147
|
submitSignedTx,
|
|
@@ -148,6 +156,7 @@ export function createRuntimeHandlers(deps) {
|
|
|
148
156
|
enforceChainCompatibility,
|
|
149
157
|
applyHyperliquidAgentWalletAddressDefault,
|
|
150
158
|
applyLighterAgentWalletAddressDefault,
|
|
159
|
+
applyAvantisAgentWalletAddressDefault,
|
|
151
160
|
runPreflightByMode,
|
|
152
161
|
runExecutionByMode,
|
|
153
162
|
applyExecutionFallbackHints,
|
|
@@ -196,6 +196,114 @@ export function createProviderHints({ getNegotiatedCapabilitiesCache }) {
|
|
|
196
196
|
'thirdfy-agent actions --provider lighter && thirdfy-agent preflight --action place_lighter_perps_order --params \'{"accountIndex":1,"apiKeyIndex":4,"marketId":0,"baseAmount":100,"price":310000,"isAsk":false,"orderType":"limit"}\'',
|
|
197
197
|
};
|
|
198
198
|
}
|
|
199
|
+
if (provider === 'avantis') {
|
|
200
|
+
return {
|
|
201
|
+
provider,
|
|
202
|
+
category: 'leveraged_perps',
|
|
203
|
+
canonicalWriteAction: 'place_avantis_perps_order',
|
|
204
|
+
readActions: [
|
|
205
|
+
'get_avantis_markets',
|
|
206
|
+
'get_avantis_pair',
|
|
207
|
+
'get_avantis_price',
|
|
208
|
+
'get_avantis_spread',
|
|
209
|
+
'get_avantis_positions',
|
|
210
|
+
'get_avantis_open_orders',
|
|
211
|
+
'get_avantis_allowance',
|
|
212
|
+
'get_avantis_delegation_status',
|
|
213
|
+
'get_avantis_funding_status',
|
|
214
|
+
'get_avantis_setup_status',
|
|
215
|
+
'get_avantis_onboarding_plan',
|
|
216
|
+
'get_avantis_builder_fee_status',
|
|
217
|
+
'get_avantis_referral_status',
|
|
218
|
+
'get_avantis_referral_stats',
|
|
219
|
+
],
|
|
220
|
+
orderManagementActions: [
|
|
221
|
+
'place_avantis_perps_order',
|
|
222
|
+
'cancel_avantis_perps_order',
|
|
223
|
+
'close_avantis_position',
|
|
224
|
+
'update_avantis_tp_sl',
|
|
225
|
+
'cancel_avantis_tp_sl',
|
|
226
|
+
'place_avantis_twap_order',
|
|
227
|
+
'close_avantis_twap_order',
|
|
228
|
+
'cancel_avantis_twap_order',
|
|
229
|
+
'place_avantis_coin_perps_order',
|
|
230
|
+
'increase_avantis_coin_position',
|
|
231
|
+
'close_avantis_coin_position',
|
|
232
|
+
'place_avantis_mm_order',
|
|
233
|
+
'cancel_avantis_mm_order',
|
|
234
|
+
'get_avantis_open_orders',
|
|
235
|
+
'get_avantis_positions',
|
|
236
|
+
],
|
|
237
|
+
setupActions: [
|
|
238
|
+
'get_avantis_funding_status',
|
|
239
|
+
'get_avantis_setup_status',
|
|
240
|
+
'get_avantis_onboarding_plan',
|
|
241
|
+
'prepare_avantis_onboarding',
|
|
242
|
+
'complete_avantis_onboarding',
|
|
243
|
+
'approve_avantis_builder_fee',
|
|
244
|
+
'revoke_avantis_builder_fee',
|
|
245
|
+
'set_avantis_referral_code',
|
|
246
|
+
'register_avantis_referral_code',
|
|
247
|
+
'claim_avantis_referral_rebate',
|
|
248
|
+
],
|
|
249
|
+
statusActions: [
|
|
250
|
+
'get_avantis_funding_status',
|
|
251
|
+
'get_avantis_setup_status',
|
|
252
|
+
'get_avantis_builder_fee_status',
|
|
253
|
+
'get_avantis_delegation_status',
|
|
254
|
+
],
|
|
255
|
+
recoveryActions: [
|
|
256
|
+
'get_avantis_positions',
|
|
257
|
+
'close_avantis_position',
|
|
258
|
+
],
|
|
259
|
+
decommissionExample:
|
|
260
|
+
'get_avantis_positions -> close_avantis_position -> withdraw-to-user on execution wallet (Base USDC)',
|
|
261
|
+
credentialType: 'avantis_delegate',
|
|
262
|
+
credentialUx:
|
|
263
|
+
'Thirdfy mints and stores the encrypted Avantis delegate. CLI callers use Thirdfy auth only. Do not paste a private key.',
|
|
264
|
+
recommendedFundingChainId: 8453,
|
|
265
|
+
supportedFundingSourceChains: [
|
|
266
|
+
{ chainId: 8453, name: 'Base', path: 'native USDC in managed execution wallet (recommended)' },
|
|
267
|
+
],
|
|
268
|
+
setupBlockers: [
|
|
269
|
+
'AVANTIS_USDC_BALANCE_REQUIRED',
|
|
270
|
+
'AVANTIS_USDC_ALLOWANCE_REQUIRED',
|
|
271
|
+
'AVANTIS_DELEGATION_REQUIRED',
|
|
272
|
+
'AVANTIS_DELEGATE_CREDENTIAL_REQUIRED',
|
|
273
|
+
],
|
|
274
|
+
setupWarnings: ['AVANTIS_BUILDER_TEMPLATE_UNWIRED'],
|
|
275
|
+
supportedChains: [8453],
|
|
276
|
+
funding:
|
|
277
|
+
'Fund the managed execution wallet on Base (8453) with native USDC. Minimum collateral follows the live catalog notional floor.',
|
|
278
|
+
laneCompatibility:
|
|
279
|
+
'Use agent_wallet for solo managed-wallet onboarding and perps writes after avantis_delegate credential is stored. Use thirdfy or hybrid for delegated capital. Thirdfy builds EIP-712 intents; the delegate credential signs batched-market submissions. Relayer is default. Builder-fee collection stays unwired until Avantis supplies a fee-enabled template.',
|
|
280
|
+
setupExample:
|
|
281
|
+
'actions --provider avantis -> get_avantis_funding_status -> complete_avantis_onboarding (agent_wallet on Base 8453) -> get_avantis_setup_status before place_avantis_perps_order. Do not call approve_avantis_builder_fee until setup status shows a wired template.',
|
|
282
|
+
example:
|
|
283
|
+
'thirdfy-agent actions --provider avantis && thirdfy-agent preflight --action place_avantis_perps_order --params \'{"pairIndex":0,"side":"long","collateralUsdc":10,"leverage":10,"orderType":"market"}\'',
|
|
284
|
+
};
|
|
285
|
+
}
|
|
286
|
+
if (provider === 'avantis-vault') {
|
|
287
|
+
return {
|
|
288
|
+
provider,
|
|
289
|
+
category: 'earn',
|
|
290
|
+
canonicalReadAction: 'get_avantis_vault_info',
|
|
291
|
+
canonicalWriteAction: 'deposit_avantis_vault',
|
|
292
|
+
readActions: ['get_avantis_vault_info', 'get_avantis_vault_position'],
|
|
293
|
+
orderManagementActions: [
|
|
294
|
+
'deposit_avantis_vault',
|
|
295
|
+
'request_avantis_vault_withdrawal',
|
|
296
|
+
'redeem_avantis_vault',
|
|
297
|
+
'claim_avantis_vault',
|
|
298
|
+
],
|
|
299
|
+
recommendedFundingChainId: 8453,
|
|
300
|
+
supportedChains: [8453],
|
|
301
|
+
funding: 'Fund the managed execution wallet on Base with native USDC before vault deposit.',
|
|
302
|
+
laneCompatibility: 'Avantis LP vault on Base. Use agent_wallet, thirdfy, or hybrid. Relayer is default.',
|
|
303
|
+
example:
|
|
304
|
+
'thirdfy-agent actions --provider avantis-vault && thirdfy-agent run --action get_avantis_vault_info --provider avantis-vault --json',
|
|
305
|
+
};
|
|
306
|
+
}
|
|
199
307
|
if (provider === 'bitfinex') {
|
|
200
308
|
return {
|
|
201
309
|
provider,
|