Skip to content

What can the vault do?

FunctionWhoWhat it does
deposit(token, amount)AnyonePulls tokens into the vault
withdraw(token, amount, to)OwnerSends tokens out
swapViaRouter(tokenIn, amountIn, tokenOut, minOut, router, data, purpose)OperatorSends tokens to a router, then calls it
swapViaApproval(...)OperatorSame, but approves the router first
setOperator(address)OwnerChanges the operator
setRouter(address, bool)OwnerAllows or blocks a router
pause(), unpause()OwnerStops or resumes swaps
transferOwnership, acceptOwnershipOwner, then new ownerTwo-step owner change
sweepNative(to)OwnerSends out stray ETH

A swap checks six things:

  • The router is allowed.
  • The vault is not paused.
  • tokenIn is not tokenOut.
  • The call data is at least 4 bytes.
  • After the call, tokenOut grew by at least minOut.
  • tokenIn fell by at most amountIn.

purpose marks the reason. 0 is a gap trade. 1 is a buyback. The vault never sends ETH with a swap.

EventWhen
DepositTokens came in
WithdrawTokens went out
TradeA swap passed all checks

The operator sends 1,000 USDG to the router. It asks for at least 9.9 NVDA. The vault gets 9.95 NVDA. The check passes. A Trade event is written.

Read the deploy steps.