githubEdit

Integrate WOOFi as a liquidity source on EVM

Contracts

There are two main contracts of WOOFi's Swap:

  • WooRouterV2.sol: the router contract that frontend users interact with. It interacts with the lower layer WooPPV2.sol to execute the sell logic and send back users the desired amount of tokens. This contract also implements the logic to route user orders to 3rd party aggregator (e.g. 1inch) when WooPPV2.sol does not have sufficient liquidity.

  • WooPPV2.sol: the main swap contract that handles the logic operation, including setting the token info, calculating slippage, calculating the exchange amount and executing trades. it stores all tokens that are supported for trading. In this contract, it defines quote token and base token. Quote token is the reference token (i.e. stablecoins) in the contract and there is only one quote token. The contract can have multiple base tokens and they can be added by the strategist.

Supported assets

Adding IntegrationHelper.sol

WooPPV2.sol has one quote token which is typically the dominant stablecoin of each chain and multiple base tokens. A IntegrationHelper.sol contract is deployed on each supported chain which contains the address of the quote token and the list of tradable base token addresses in WooPPV2.sol.

The latest list of supported tokens can be retrieved via the getSupportTokens() function which will return two values:

  • first value: quoteToken address

  • second value: array of baseToken addresses

Contract addresses:

Arbitrum: 0x28D2B949024FE50627f1EbC5f0Ca3Ca721148E40arrow-up-right

Avalanche: 0x020630613E296c3E9b06186f630D1bF97A2B6Ad1arrow-up-right

BSC: 0xAA9c15cd603428cA8ddD45e933F8EfE3Afbcc173arrow-up-right

Optimism - 0x96329d66074EB8386Ae8bFD6698B2E3FDA87e15Earrow-up-right

Polygon POS - 0x7Ba560eB735AbDCf9a3a5692272652A0cc81850darrow-up-right

zkSync Era - 0x636DfeB023463F176f87D61E3B604231986bd935arrow-up-right

Linea - 0x7e1996945eA8866DE873179DC1677E93A4380107arrow-up-right

Base - 0xC4E9B633685461E7B7A807D12a246C81f96F31B8arrow-up-right

Mantle - 0x86b223E83D2FA43456b433687c8F47A35a9bE24Carrow-up-right

Sonic - 0xc8521e41DE46036A61c562062862681f0060CD7Earrow-up-right

Berachain - 0x14B435b68e031226ACc4d328a69e294686C3176earrow-up-right

HyperEVM - 0xee8318e9d597bf9df6148e86d4e35a8bc14eea88envelope

Monad - 0xAeE024fAA57C4DB20ac0666a1D5297d5F1c95AfEarrow-up-right

Integrate WOOFi as a liquidity source

When integrating WOOFi as a liquidity source, you can either interact with WooRouterV2.sol or WooPPV2.sol.

Integrating WooRouterV2.sol

The straightforward way is interacting with WooRouterV2.sol contract which provides the query and swap for any two specified tokens. It streamlined the logic of swapping native blockchain assets and swapping between any of the two supported assets, which simplifies the integration for apps that do not have an existing aggregation logic.

Contract addresses:

  • Same address across Arbitrum, Avalanche, BSC, Optimism, Polygon PoS, Linea, Base, Mantle, Sonic: 0x4c4AF8DBc524681930a27b2F1Af5bcC8062E6fB7

  • zkSync: 0x09873bfECA34F1Acd0a7e55cDA591f05d8a75369

Interface

Sample code

Integrating WooPPV2.sol

Another way is to integrate directly with WooPPV2.sol. This approach is slightly more gas efficient, but it requires writing the smart contract code and manually send the fromToken to WooPPV2.sol, which a better choice for apps that already have an aggregation logic.

Contract addresses:

  • Same address across Arbitrum, Avalanche, BSC, Optimism, Polygon PoS, Linea, Base, Mantle, Sonic: 0x5520385bFcf07Ec87C4c53A7d8d65595Dff69FA4

  • zkSync Era: 0xE656d70bc3550e3EEE9dE7dC79367A44Fd13d975

Interface

Sample code

Price check with Wooracle

WOOFi's oracle has a few price checks implemented. You can find the addresses of the wooracle contract in On-chain price feeds.

  • checking against the 3rd party oracle price e.g. ChainLink and Pyth

  • set the price range a swap can be executed against the current price

Last updated

Was this helpful?