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

scripts/lib/__tests__/create-wallet.test.js

View on GitHub
import { describe, it, expect, beforeEach, afterEach } from 'vitest';
import { mkdirSync, rmSync, writeFileSync, existsSync, statSync, readFileSync } from 'fs';
import { join } from 'path';
import { tmpdir } from 'os';
import { execFileSync } from 'child_process';
import { fileURLToPath } from 'url';
import { dirname } from 'path';

// sodium-native and bip39-mnemonic are CJS; load via createRequire
import { createRequire } from 'module';
const require = createRequire(import.meta.url);

const __filename = fileURLToPath(import.meta.url);
const __dirname = dirname(__filename);

const CREATE_WALLET_SCRIPT = join(__dirname, '..', 'create-wallet.js');

// ---------------------------------------------------------------------------
// Helpers
// ---------------------------------------------------------------------------

function runCreateWallet(args, { expectSuccess = true } = {}) {
  try {
    const output = execFileSync(process.execPath, [CREATE_WALLET_SCRIPT, ...args], {
      encoding: 'utf8',
      env: { ...process.env },
    });
    if (!expectSuccess) {
      throw new Error(`Expected failure but succeeded with output: ${output}`);
    }
    return { stdout: output, exitCode: 0 };
  } catch (err) {
    if (expectSuccess) {
      throw err;
    }
    return {
      stdout: err.stdout || '',
      stderr: err.stderr || '',
      exitCode: err.status || 1,
    };
  }
}

// ---------------------------------------------------------------------------
// Fixtures
// ---------------------------------------------------------------------------

let testDir;

beforeEach(() => {
  testDir = join(
    tmpdir(),
    `create-wallet-test-${Date.now()}-${Math.random().toString(36).slice(2)}`,
  );
  mkdirSync(testDir, { recursive: true });
});

afterEach(() => {
  rmSync(testDir, { recursive: true, force: true });
});

// ---------------------------------------------------------------------------
// Tests
// ---------------------------------------------------------------------------

describe('create-wallet.js', () => {
  it('creates vault file and outputs valid Ethereum address', () => {
    const passwordFile = join(testDir, '.wdk_password');
    const vaultFile = join(testDir, '.wdk_vault');
    writeFileSync(passwordFile, 'my-strong-password-123');

    const { stdout } = runCreateWallet([
      '--password-file', passwordFile,
      '--vault-file', vaultFile,
    ]);

    const result = JSON.parse(stdout);
    expect(result).toHaveProperty('address');
    expect(result).toHaveProperty('vaultFile');
    expect(result.address).toMatch(/^0x[0-9a-fA-F]{40}$/);
    expect(result.vaultFile).toBe(vaultFile);
    expect(existsSync(vaultFile)).toBe(true);
  });

  it('vault file has correct JSON structure', () => {
    const passwordFile = join(testDir, '.wdk_password');
    const vaultFile = join(testDir, '.wdk_vault');
    writeFileSync(passwordFile, 'my-strong-password-123');

    runCreateWallet([
      '--password-file', passwordFile,
      '--vault-file', vaultFile,
    ]);

    const vault = JSON.parse(readFileSync(vaultFile, 'utf8'));
    expect(vault).toHaveProperty('encryptedEntropy');
    expect(vault).toHaveProperty('salt');
    expect(typeof vault.encryptedEntropy).toBe('string');
    expect(typeof vault.salt).toBe('string');
    // salt should be 16 bytes = 32 hex chars
    expect(vault.salt).toHaveLength(32);
  });

  it('errors if vault already exists without --force', () => {
    const passwordFile = join(testDir, '.wdk_password');
    const vaultFile = join(testDir, '.wdk_vault');
    writeFileSync(passwordFile, 'my-strong-password-123');
    writeFileSync(vaultFile, '{}'); // pre-existing vault

    const result = runCreateWallet([
      '--password-file', passwordFile,
      '--vault-file', vaultFile,
    ], { expectSuccess: false });

    expect(result.exitCode).not.toBe(0);
    expect(result.stderr).toMatch(/already exists/i);
  });

  it('overwrites existing vault with --force', () => {
    const passwordFile = join(testDir, '.wdk_password');
    const vaultFile = join(testDir, '.wdk_vault');
    writeFileSync(passwordFile, 'my-strong-password-123');
    writeFileSync(vaultFile, '{}'); // pre-existing vault

    const { stdout } = runCreateWallet([
      '--password-file', passwordFile,
      '--vault-file', vaultFile,
      '--force',
    ]);

    const result = JSON.parse(stdout);
    expect(result.address).toMatch(/^0x[0-9a-fA-F]{40}$/);
  });

  it('errors if password is too short (< 12 characters)', () => {
    const passwordFile = join(testDir, '.wdk_password');
    const vaultFile = join(testDir, '.wdk_vault');
    writeFileSync(passwordFile, 'short');

    const result = runCreateWallet([
      '--password-file', passwordFile,
      '--vault-file', vaultFile,
    ], { expectSuccess: false });

    expect(result.exitCode).not.toBe(0);
    expect(result.stderr).toMatch(/password/i);
  });

  it('vault is decryptable by signer.js (round-trip test)', async () => {
    const passwordFile = join(testDir, '.wdk_password');
    const vaultFile = join(testDir, '.wdk_vault');
    const password = 'my-strong-password-123';
    writeFileSync(passwordFile, password);

    const { stdout } = runCreateWallet([
      '--password-file', passwordFile,
      '--vault-file', vaultFile,
    ]);

    const { address: createdAddress } = JSON.parse(stdout);

    // Now use signer.js to decrypt the vault and verify we get the same address
    const { createSigner } = await import('../signer.js');
    const cfg = {
      env: {
        WALLET_MODE: 'wdk',
        WDK_VAULT_FILE: vaultFile,
        WDK_PASSWORD_FILE: passwordFile,
      },
      yaml: {},
      configDir: testDir,
    };

    const wallet = await createSigner(cfg, null);
    expect(wallet.address.toLowerCase()).toBe(createdAddress.toLowerCase());
  });

  it('sets vault file permissions to 600', () => {
    const passwordFile = join(testDir, '.wdk_password');
    const vaultFile = join(testDir, '.wdk_vault');
    writeFileSync(passwordFile, 'my-strong-password-123');

    runCreateWallet([
      '--password-file', passwordFile,
      '--vault-file', vaultFile,
    ]);

    const stat = statSync(vaultFile);
    // mode & 0o777 should be 0o600
    expect(stat.mode & 0o777).toBe(0o600);
  });
});
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