Skip to main content

IRouter Interface

The IRouter interface defines the functions available in the Router contract, which serves as a central entry point for user interactions with the Satoshi Perps protocol.

Plugin Management

Allows users to register a plugin that can execute actions on their behalf.
Removes a previously registered plugin.
Approves a plugin to use the user’s tokens via the Router.
Transfers tokens from an account to a receiver, can only be called by an approved plugin.
Increases a position for an account, can only be called by an approved plugin.
Decreases a position for an account, can only be called by an approved plugin.

Token Operations

Approves a specific token to be spent by the specified spender.
Swaps tokens through the Vault’s swap mechanism.
Swaps ETH to tokens through the Vault’s swap mechanism.
Swaps tokens to ETH through the Vault’s swap mechanism.

ETH Handling

Unwraps WETH to ETH and sends it to the specified receiver.
Deposits tokens directly to the liquidity pool in the Vault.
Converts ETH to WETH and sends it to the Vault.

Access Verification

Returns whether a plugin is registered for an account.
Returns whether a plugin is approved for an account.

Usage Notes

  • Before a plugin can execute actions on behalf of a user, the user must first register it using addPlugin() and then approve it using approvePlugin().
  • The Router delegates actual execution to the Vault but serves as a security layer and convenience wrapper.
  • ETH handling functions provide convenience methods for working with ETH in a WETH-based system.

Security Considerations

  • Only approved plugins can execute actions on behalf of users
  • Users should only approve trusted plugins as they will have significant control over the user’s funds
  • The Router does not hold user funds; it merely facilitates transfers and approvals