# Privacy API Reference

## <mark style="color:purple;">Privacy API Reference</mark>

APIs for integrating with Macro's privacy features.

### <mark style="color:purple;">Privacy Profiles API</mark>

**Detect and respect Privacy Profiles:**

#### macro\_getCurrentProfile

Get information about active profile.

```javascript
const profile = await ethereum.request({
  method: 'macro_getCurrentProfile'
});

// Returns:
// {
//   name: 'Work',
//   id: 'profile_xyz',
//   color: '#3B82F6',
//   type: 'work' // 'work' | 'degen' | 'anon' | 'custom'
// }
```

Use case: Adapt UI based on profile type.

### <mark style="color:purple;">VPN API</mark>

**Check and suggest VPN usage:**

#### macro\_getVPNStatus

```javascript
const status = await ethereum.request({
  method: 'macro_getVPNStatus'
});

// Returns:
// {
//   enabled: true,
//   connected: true,
//   exitRegion: 'DE',
//   entryNode: 'node-us-1',
//   exitNode: 'node-de-3',
//   routeHealth: 'good',
//   latency: 52,
//   hops: 3
// }
```

#### macro\_suggestVPN

Suggest user enable VPN (doesn't force).

```javascript
await ethereum.request({
  method: 'macro_suggestVPN',
  params: [{
    reason: 'For privacy when interacting with this dApp',
    required: false // If true, blocks interaction until VPN enabled
  }]
});
```

User sees: Non-intrusive suggestion to enable VPN.

### <mark style="color:purple;">Signing Policy API</mark>

**Integrate with signing sandbox:**

#### macro\_getSigningPolicy

Get current policy for your dApp.

```javascript
const policy = await ethereum.request({
  method: 'macro_getSigningPolicy',
  params: [window.location.origin]
});

// Returns:
// {
//   maxApproval: '1000000000000000000',
//   maxGasPrice: '100000000000',
//   allowedFunctions: ['swap', 'deposit'],
//   blockedFunctions: [],
//   requiresHardwareWallet: false,
//   riskLevel: 'medium' // 'low' | 'medium' | 'high'
// }
```

#### macro\_requestTransactionPreview

Request transaction preview before sending.

```javascript
const preview = await ethereum.request({
  method: 'macro_requestTransactionPreview',
  params: [{
    from: '0x...',
    to: '0x...',
    data: '0x...',
    value: '0x...'
  }]
});

// Returns:
// {
//   decodedFunction: 'swapExactETHForTokens',
//   parameters: {
//     amountOutMin: '...',
//     path: ['0xC02...', '0x6B1...'],
//     to: '0x...',
//     deadline: '...'
//   },
//   riskAssessment: 'low',
//   estimatedGas: '150000',
//   willApprove: true // Based on current policy
// }
```

Use case: Show preview in your UI before requesting signature.

### <mark style="color:purple;">Privacy Mixer API</mark>

**Integrate mixer functionality:**

#### macro\_getMixerStatus

Check mixer availability.

```javascript
const status = await ethereum.request({
  method: 'macro_getMixerStatus'
});

// Returns:
// {
//   available: true,
//   supportedTokens: ['ETH', '0x6B17...'], // Token addresses
//   minimumAmount: '100000000000000000', // 0.1 ETH
//   anonymitySetSize: 1247, // Current pool size
//   averageDelay: 2400 // seconds
// }
```

#### macro\_estimateMixerFee

Estimate mixing fee.

```javascript
const fee = await ethereum.request({
  method: 'macro_estimateMixerFee',
  params: [{
    token: 'ETH',
    amount: '1000000000000000000'
  }]
});

// Returns:
// {
//   fee: '10000000000000000', // 0.01 ETH
//   feePercentage: 1.0
// }
```

### <mark style="color:purple;">Private Swap API</mark>

**MEV-protected swaps:**

#### macro\_estimatePrivateSwap

Estimate swap outcome.

```javascript
const estimate = await ethereum.request({
  method: 'macro_estimatePrivateSwap',
  params: [{
    fromToken: 'ETH',
    toToken: '0x6B17...',
    amount: '1000000000000000000'
  }]
});

// Returns:
// {
//   estimatedOutput: '2547...',
//   priceImpact: 0.23,
//   route: ['ETH', 'USDC', 'DAI'],
//   fee: '3000000000000000' // 0.003 ETH
// }
```

### <mark style="color:purple;">Best Practices</mark>

**When using privacy APIs:**

* Request privacy features, don't require them
* Explain why privacy features benefit the user
* Provide graceful fallback if feature unavailable
* Respect user's privacy settings
* Don't fingerprint or track users who use privacy features

***

Performance Optimization Guide
