Security

Security best practices and considerations for VinuSwap integration.

Smart Contract Security

Audited Codebase

VinuSwap is based on Uniswap V3, one of the most thoroughly audited DeFi protocols. The core AMM logic inherits security properties from the battle-tested Uniswap V3 codebase.

Key Security Features

1. Reentrancy Protection

All state-changing functions use the lock modifier:

modifier lock() {
    require(slot0.unlocked, 'LOK');
    slot0.unlocked = false;
    _;
    slot0.unlocked = true;
}

2. Callback Validation

Periphery contracts validate callbacks to prevent malicious contracts from stealing tokens:

3. Integer Overflow Protection

  • Core contracts use Solidity 0.7.6 with explicit overflow checks

  • Critical math operations use safe math libraries

  • Q64.96 fixed-point arithmetic prevents precision loss

4. Access Control

  • Factory ownership is transferable but protected

  • Pool owner actions are restricted to factory owner

  • Fee manager changes require owner authorization

Integration Security

Slippage Protection

Always set amountOutMinimum or amountInMaximum:

Deadline Protection

Always set reasonable deadlines:

Price Manipulation Resistance

Use TWAP for price-sensitive operations:

Token Approval Security

Approve only what's needed:

Common Vulnerabilities

1. Front-Running

Risk: Transactions visible in mempool can be front-run.

Mitigation:

  • Use tight slippage tolerances

  • Consider private transaction services

  • Use commit-reveal schemes for large trades

2. Sandwich Attacks

Risk: Attackers can sandwich your trade with buy/sell orders.

Mitigation:

  • Set appropriate sqrtPriceLimitX96

  • Use shorter deadlines

  • Split large trades

3. Oracle Manipulation

Risk: Large trades can manipulate spot prices within a single block.

Mitigation:

  • Never use spot price for critical decisions

  • Use TWAP with sufficient history

  • Consider multiple oracle sources

4. Rounding Errors

Risk: Precision loss in calculations.

Mitigation:

  • Use full precision libraries

  • Round in protocol's favor for fees

  • Test edge cases thoroughly

Callback Security

When implementing callbacks, always verify the caller:

Note: VinuSwap uses Uniswap V3 callback interface names for compatibility.

Position Security

Locked Positions

VinuSwap supports position locking to prevent transfers:

NFT Safety

  • Store position NFTs in secure wallets

  • Consider multi-sig for high-value positions

  • Be cautious with NFT approvals

Deployment Security

Pre-Deployment Checklist

Post-Deployment Verification

Emergency Procedures

If You Suspect a Vulnerability

  1. Do not publicly disclose the vulnerability

  2. Document the issue thoroughly

  3. Contact the VinuSwap security team

  4. Allow time for mitigation before disclosure

Incident Response

  • Monitor for unusual activity

  • Have emergency contacts ready

  • Prepare withdrawal procedures

  • Document all actions taken

Security Resources

Tools

  • Slither - Static analysis

  • Mythril - Symbolic execution

  • Echidna - Fuzzing

  • Foundry - Testing framework

References

Last updated