Skip to content

LeoYeAI/agent-master-skills / skills/aurehub-xaut-trade

xaut-trade

Flagged

Buy or sell XAUT (Tether Gold) on Ethereum. Supports market orders (Uniswap V3) and limit orders (UniswapX). Wallet modes: Foundry keystore or WDK. Delegates non-XAUT intents to registered skills (e.g. Polymarket prediction markets, Hyperliquid trading). Triggers: buy XAUT, XAUT trade, swap USDT for XAUT, sell XAUT, swap XAUT for USDT, limit order, limit buy XAUT, limit sell XAUT, check limit order, cancel limit order, XAUT when, create wallet, setup wallet, polymarket, prediction market, bet on, odds on, hyperliquid, perp, perpetual, long, short, open long, open short, close position, leverage.

FileKindSize
README.mdmarkdown15.0 KB
SKILL.mdskill md29.2 KB
SKILL.tests.yamlconfig12.1 KB
_meta.jsonconfig991 B
config.example.yamlconfig1.7 KB
references/balance.mdmarkdown2.6 KB
references/buy.mdmarkdown3.8 KB
references/limit-order-buy-place.mdmarkdown4.6 KB
references/limit-order-cancel.mdmarkdown2.2 KB
references/limit-order-sell-place.mdmarkdown4.8 KB
references/limit-order-status.mdmarkdown1.6 KB
references/live-trading-runbook.mdmarkdown3.9 KB
references/onboarding.mdmarkdown12.9 KB
references/quote.mdmarkdown2.0 KB
references/sell.mdmarkdown5.9 KB
references/skill-delegation.mdmarkdown2.8 KB
references/wallet-modes.mdmarkdown1.3 KB
scripts/__tests__/helpers.test.jsscript2.7 KB
scripts/__tests__/integration.test.jsscript1.2 KB
scripts/__tests__/swap-cli.test.jsscript3.7 KB
scripts/__tests__/wallet-init.test.jsscript10.7 KB
scripts/helpers.jsscript1.2 KB
scripts/lib/__tests__/config.test.jsscript2.9 KB
scripts/lib/__tests__/create-wallet.test.jsscript6.1 KB
scripts/lib/__tests__/erc20.test.jsscript3.3 KB
scripts/lib/__tests__/provider.test.jsscript7.6 KB
scripts/lib/__tests__/signer.test.jsscript7.6 KB
scripts/lib/__tests__/uniswap.test.jsscript3.6 KB
scripts/lib/config.jsscript4.3 KB
scripts/lib/create-wallet.jsscript5.7 KB
scripts/lib/erc20.jsscript3.8 KB
scripts/lib/export-seed.jsscript6.5 KB
scripts/lib/provider.jsscript8.3 KB
scripts/lib/signer.jsscript6.8 KB
scripts/lib/uniswap.jsscript5.3 KB
scripts/limit-order.jsscript13.6 KB
scripts/package-lock.jsonmanifest182.2 KB
scripts/package.jsonmanifest703 B
scripts/setup.shscript29.5 KB
scripts/swap.jsscript15.7 KB

references/sell.md

View on GitHub
# Sell Execution (XAUT -> USDT)

All commands below assume CWD is `$SCRIPTS_DIR` and env is sourced. Each Bash block must begin with `source ~/.aurehub/.env` and `cd "$SCRIPTS_DIR"`.

## 0. Pre-execution Declaration

- Current stage must be `Ready to Execute`
- Quote and explicit user confirmation must already be complete
- Full command must be displayed before execution

## 1. Input Validation

User provides XAUT amount (e.g. `0.01`).

**Precision check**: if the input has more than 6 decimal places (e.g. `0.0000001`), hard-stop:

> XAUT supports a maximum of 6 decimal places. The minimum tradeable unit is 0.000001 XAUT. Please adjust the input amount.

## 2. Quote

```bash
source ~/.aurehub/.env
cd "$SCRIPTS_DIR"
RESULT=$(node swap.js quote --side sell --amount <XAUT_AMOUNT>)
echo "$RESULT"
```

Output:

```json
{
  "side": "sell",
  "amountIn": "<XAUT_AMOUNT>",
  "amountOut": "30.5",
  "amountOutRaw": "30500000",
  "sqrtPriceX96": "...",
  "gasEstimate": "150000"
}
```

Extract values:

```bash
AMOUNT_OUT=$(echo "$RESULT" | node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).amountOut")
AMOUNT_OUT_RAW=$(echo "$RESULT" | node -p "JSON.parse(require('fs').readFileSync(0,'utf8')).amountOutRaw")
```

Calculate `minAmountOut` using `risk.default_slippage_bps` from config.yaml:

```bash
DEFAULT_SLIPPAGE_BPS=$(node -e "const c=require('js-yaml').load(require('fs').readFileSync(require('os').homedir()+'/.aurehub/config.yaml','utf8')); console.log((c.risk||{}).default_slippage_bps||50)")
MIN_AMOUNT_OUT=$(node -p "Math.trunc($AMOUNT_OUT_RAW * (10000 - $DEFAULT_SLIPPAGE_BPS) / 10000)")
```

Reference rate (for Preview display; both tokens have 6 decimals so divide directly):

```
Reference rate = amountOut / amountIn  (USDT/XAUT, human-readable)
```

## 3. Preview Output

Must include at minimum:

- Input amount (user-provided form)
- Estimated USDT received (`amountOut`, human-readable)
- Reference rate: `1 XAUT ~ X USDT`
- Slippage setting and `minAmountOut`
- Risk indicators (large trade / slippage / gas)

**Large-trade check**: convert `amountOut` (USDT) to USD value; if it exceeds `risk.large_trade_usd`, require double confirmation.

## 4. Confirmation Gate

Trade execution confirmation follows the threshold-based policy (see Section 9 — Mandatory Rules):

- `< risk.confirm_trade_usd`: show full preview, then execute without blocking confirmation
- `>= risk.confirm_trade_usd` and `< risk.large_trade_usd`: single confirmation
- `>= risk.large_trade_usd` or estimated slippage exceeds `risk.max_slippage_bps_warn`: double confirmation

Accepted confirmation phrases: "confirm approve", "confirm swap"

## 5. Allowance Check

```bash
source ~/.aurehub/.env
cd "$SCRIPTS_DIR"
node swap.js allowance --token XAUT
```

Output:

```json
{
  "address": "0x...",
  "token": "XAUT",
  "allowance": "0.0",
  "spender": "0x..."
}
```

If allowance < `AMOUNT_IN`, approve first.

## 6. Approve (XAUT is standard ERC-20)

**XAUT does not require a prior reset** — approve directly:

```bash
source ~/.aurehub/.env
cd "$SCRIPTS_DIR"
APPROVE_RESULT=$(node swap.js approve --token XAUT --amount <XAUT_AMOUNT>)
echo "$APPROVE_RESULT"
```

Output:

```json
{
  "address": "0x...",
  "token": "XAUT",
  "amount": "<XAUT_AMOUNT>",
  "spender": "0x...",
  "txHash": "0x..."
}
```

Report: `Approve tx: https://etherscan.io/tx/<txHash>`

> Note: Unlike USDT, XAUT does not require `approve(0)` to reset before approving.

## 7. Swap Execution

```bash
source ~/.aurehub/.env
cd "$SCRIPTS_DIR"
SWAP_RESULT=$(node swap.js swap --side sell --amount <XAUT_AMOUNT> --min-out <MIN_AMOUNT_OUT>)
echo "$SWAP_RESULT"
```

Output:

```json
{
  "address": "0x...",
  "side": "sell",
  "amountIn": "<XAUT_AMOUNT>",
  "minAmountOut": "<MIN_AMOUNT_OUT>",
  "txHash": "0x...",
  "status": "success",
  "gasUsed": "180000"
}
```

Report: `Swap tx: https://etherscan.io/tx/<txHash>`

> On failure (`"status": "failed"`), report retry suggestions.

## 7a. Swap Error Recovery

**CRITICAL**: If the swap command returns an error, exits with a non-zero code, or returns `"status": "unconfirmed"`:

1. **Do NOT retry immediately.** The transaction may have been broadcast and mined despite the RPC error.
2. Check the current balance:
   ```bash
   source ~/.aurehub/.env
   cd "$SCRIPTS_DIR"
   node swap.js balance
   ```
3. Compare the XAUT balance against the pre-swap balance (from pre-flight):
   - **If XAUT balance decreased by the trade amount** → the swap **succeeded**. Proceed to Result Verification (Step 8). Do NOT re-approve or re-swap.
   - **If XAUT balance is unchanged** → the swap did **not** execute. Safe to retry from Step 5 (Allowance Check).
4. If a `txHash` was returned (including in the `"unconfirmed"` response), verify on Etherscan: `https://etherscan.io/tx/<txHash>`

> **Why this matters**: RPC nodes can return errors (e.g. 400, 504, "Unknown block") even when the transaction was successfully broadcast and mined. Retrying without checking balance will execute a **duplicate trade**, costing the user double.

## 8. Result Verification

Post-swap balance:

```bash
source ~/.aurehub/.env
cd "$SCRIPTS_DIR"
node swap.js balance
```

Return:
- tx hash
- Post-trade balances (XAUT, USDT, ETH)
- on failure, return retry suggestions (reduce sell amount / increase slippage tolerance / check nonce and gas)

## 9. Mandatory Rules

- Before every on-chain write (approve, swap), remind the user: "About to execute an on-chain write"
- Trade execution confirmation follows:
  - `< risk.confirm_trade_usd`: show full preview, then execute without blocking confirmation
  - `>= risk.confirm_trade_usd` and `< risk.large_trade_usd`: single confirmation
  - `>= risk.large_trade_usd` or estimated slippage exceeds `risk.max_slippage_bps_warn`: double confirmation
- Approval confirmation follows `risk.approve_confirmation_mode` with force override:
  - If approve amount `> risk.approve_force_confirm_multiple * AMOUNT_IN`, require explicit approval confirmation
- Hard-stop if input precision exceeds 6 decimal places
reverse-engineer-anythingmorluto/reaReverse engineer native, managed, Electron/JavaScript, packaged, firmware, and browser targets with REA, and build agent environments (AgentEnv bundles) of web applications from a live instance or a capture, and of Linux desktop apps with a task from a request. Use shipped-artifact or requested runtime evidence to explain features, compare versions, decompile code, or guide a reconstruction. Skip REA for ordinary source-repository architecture analysis.Stars: 472kUpdated Claude CodeCodexVerifiedInstall
diagnosing-superpowersobra/superpowersUse when a superpowers session went wrong and your human partner wants to know why — repeated work, ignored plans, stumbles, poor results, a skill that didn't fire, "it took too long", "why is it so expensive", "what is it doing" — or wants to build a bug report for the superpowers maintainers, for the current session or a past one identified by id or path, on any harness.Stars: 322kUpdated Claude CodeCodexVerifiedInstall
dispatching-parallel-agentsobra/superpowersUse when facing 2+ independent tasks that can be worked on without shared state or sequential dependenciesStars: 322kUpdated Claude CodeCodexVerifiedInstall
executing-plansobra/superpowersUse when executing an implementation plan in the current session as the implementer yourself — your human partner chose inline execution, or no subagent tool is availableStars: 322kUpdated Claude CodeCodexVerifiedInstall