[v1] sPMM liquidity integration
Contracts
Two main contracts of WOOFi's swap function are as follows:
WooPP.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.WooRouter.sol: the router contract that frontend users interact with. It interacts with the lower layerWooPP.solto 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) whenWooPP.soldoes not have sufficient liquidity.
Supported assets
WooPP.sol currently supports the following tokens. Quote token is the stablecoin and the rest are base tokens.
BNB
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
WBNB
0xbb4CdB9CBd36B01bD1cBaEBF2De08d9173bc095c
BTCB
0x7130d2A12B9BCbFAe4f2634d864A1Ee1Ce3Ead9c
ETH
0x2170ed0880ac9a755fd29b2688956bd959f933f8
WOO
0x4691937a7508860f876c9c0a2a617e7d9e945d4b
USDT
0x55d398326f99059fF775485246999027B3197955
AVAX
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
WAVAX
0xB31f66AA3C1e785363F0875A1B74E27b85FD66c7
BTC.b
0x152b9d0FdC40C096757F570A51E494bd4b943E50
WETH.e
0x49D5c2BdFfac6CE2BFdB6640F4F80f226bc10bAB
WOO.e
0xaBC9547B534519fF73921b1FBA6E672b5f58D083
USDC
0xB97EF9Ef8734C71904D8002F8b6Bc66Dd9c48a6E
FTM
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
WFTM
0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83
BTC
0x321162Cd933E2Be498Cd2267a90534A804051b11
ETH
0x74b23882a30290451A17c44f4F05243b6b58C76d
WOO
0x6626c47c00F1D87902fc13EECfaC3ed06D5E8D8a
USDC
0x04068DA6C83AFCFA0e13ba15A6696662335D5B75
MATIC
0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE
WMATIC
0x0d500B1d8E8eF31E21C99d1Db9A6444d3ADf1270
BTC
0x1BFD67037B42Cf73acF2047067bd4F2C47D9BfD6
ETH
0x7ceB23fD6bC0adD59E62ac25578270cFf1b9f619
WOO
0x1B815d120B3eF02039Ee11dC2d33DE7aA4a8C603
USDC
0x2791Bca1f2de4661ED88A30C99A7a9449Aa84174
Integrate WOOFi as a liquidity source
When integrating WOOFi as a liquidity source, you can either interact directly with WooPP.sol or throughWooRouter.sol.
Integrating WooPP.sol (recommended)
WooPP.sol (recommended) For aggregators or trading bots, we recommend integrate directly with WooPP.sol to be more gas efficient.
Contract addresses:
BNB Chain: 0xbf365Ce9cFcb2d5855521985E351bA3bcf77FD3F
Avalanche: 0x1df3009c57a8B143c6246149F00B090Bce3b8f88
Fantom: 0x9503E7517D3C5bc4f9E4A1c6AE4f8B33AC2546f2
Polygon: 0x7400B665C8f4f3a951a99f1ee9872efb8778723d
Interface:
Query & swap functions
Sample integration code (Yield Yak)
https://snowtrace.io/address/0xa64c5c58fc1510de3ff2ee644e030d666b660ea6#code
Integrating WooRouter.sol
WooRouter.sol A simpler way is calling WooRouter.sol contract which provides the similar query and swap as above. This way costs slightly more gas than directly integrating with WooPP.sol.
Contract addresses
BNB Chain: 0xcef5be73ae943b77f9bc08859367d923c030a269
Avalanche: 0x5AA6a4E96A9129562e2fc06660D07FEdDAAf7854
Fantom: 0x37b5a5a730dad670874f26cc5507bb1b9705e447
Polygon: 0x9D1A92e601db0901e69bd810029F2C14bCCA3128
Query function
Sample code to retrieve quote on selling 1 BTC:
Swap function
Sample code to swap 1 BTC to USDT:
sPMM offchain simulation
For aggregators running offchain routing simulation, you can find the typescript implementation of WOOFi's sPMM algorithm in the github.
Last updated
Was this helpful?
