LogoLogo
1.0.0
1.0.0
  • About Saddle
  • Automated Market Makers
  • Saddle Pools
  • Community Pools
  • Layer 2 Guide
  • SDL Token
  • veSDL (vote escrowed) SDL
  • Cross Chain Gauges
  • Governance (SIPs)
  • Saddle Incentives
  • Saddle Protocol Stats
  • Yield Farming Tools
  • Build With Saddle
  • Smart Contract Security
  • Asset Specific Risks
  • Saddle FAQ
  • Glossary
  • How to Flash-loan Assets from Saddle
  • Contract Addresses
  • Solidity Docs
    • StakeableTokenWrapper
    • MathUtils
    • Swap
    • Allowlist
    • SwapUtils
    • OwnerPausable
    • LPToken
    • Interfaces
      • ISwap
      • IAllowlist
      • ISwapV1
      • ISwapGuarded
      • ISwapFlashLoan
      • IMetaSwap
      • IFlashLoanReceiver
    • Helper
      • Test
        • TestSwapReturnValues
      • GenericERC20
      • Multicall
      • Multicall2
      • FlashLoanBorrowerExample
    • Meta
      • MetaSwap
      • MetaSwapDeposit
      • MetaSwapUtils
    • Guarded
      • SwapGuarded
      • SwapUtilsGuarded
      • OwnerPausable
      • LPTokenGuarded
      • Allowlist
    • VirtualSwap
      • Bridge
      • Proxy
      • SynthSwapper
      • Target
Powered by GitBook
On this page
  • Functions:
  • Function constructor()
  • Function initialize()
  • Function swapSynth(bytes32 sourceKey, uint256 synthAmount, bytes32 destKey) → uint256
  • Parameters:
  • Return Values:
  • Function swapSynthToToken(contract ISwap swap, contract IERC20 tokenFrom, uint8 tokenFromIndex, uint8 tokenToIndex, uint256 tokenFromAmount, uint256 minAmount, uint256 deadline, address recipient) → contract IERC20, uint256
  • Parameters:
  • Function withdraw(contract IERC20 token, address recipient, uint256 withdrawAmount, bool shouldDestroy)
  • Parameters:
  • Function destroy()

Was this helpful?

  1. Solidity Docs
  2. VirtualSwap

SynthSwapper

PreviousProxyNextTarget

Last updated 2 years ago

Was this helpful?

Replacement of Virtual Synths in favor of gas savings. Allows swapping synths via the Synthetix protocol or Saddle's pools. The Bridge.sol contract will deploy minimal clones of this contract upon initiating any cross-asset swaps.

Functions:

Function constructor()

Initializes the contract when deploying this directly. This prevents others from calling initialize() on the target contract and setting themself as the owner.

Function initialize()

Sets the owner as the caller of this function

Function swapSynth(bytes32 sourceKey, uint256 synthAmount, bytes32 destKey) → uint256

Swaps the synth to another synth via the Synthetix protocol.

Parameters:

  • sourceKey: currency key of the source synth

  • synthAmount: amount of the synth to swap

  • destKey: currency key of the destination synth

Return Values:

  • amount of the destination synth received

Function swapSynthToToken(contract ISwap swap, contract IERC20 tokenFrom, uint8 tokenFromIndex, uint8 tokenToIndex, uint256 tokenFromAmount, uint256 minAmount, uint256 deadline, address recipient) → contract IERC20, uint256

Approves the given tokenFrom and swaps it to another token via the given swap pool.

Parameters:

  • swap: the address of a pool to swap through

  • tokenFrom: the address of the stored synth

  • tokenFromIndex: the index of the token to swap from

  • tokenToIndex: the token the user wants to swap to

  • tokenFromAmount: the amount of the token to swap

  • minAmount: the min amount the user would like to receive, or revert.

  • deadline: latest timestamp to accept this transaction

  • recipient: the address of the recipient

Function withdraw(contract IERC20 token, address recipient, uint256 withdrawAmount, bool shouldDestroy)

Withdraws the given amount of token to the recipient.

Parameters:

  • token: the address of the token to withdraw

  • recipient: the address of the account to receive the token

  • withdrawAmount: the amount of the token to withdraw

  • shouldDestroy: whether this contract should be destroyed after this call

Function destroy()

Destroys this contract. Only owner can call this function.

constructor()
initialize()
swapSynth(bytes32 sourceKey, uint256 synthAmount, bytes32 destKey)
swapSynthToToken(contract ISwap swap, contract IERC20 tokenFrom, uint8 tokenFromIndex, uint8 tokenToIndex, uint256 tokenFromAmount, uint256 minAmount, uint256 deadline, address recipient)
withdraw(contract IERC20 token, address recipient, uint256 withdrawAmount, bool shouldDestroy)
destroy()