Skip to content

Latest commit

 

History

History
71 lines (48 loc) · 4.28 KB

TIP-161.md

File metadata and controls

71 lines (48 loc) · 4.28 KB
id Title Status Author Description Discussions to Created
TIP-161 Add MultiCollateral onramp (offramp) support to Thales Draft @Danijel Add support for multiple collateral to be used as onramp or offramp with Thales products discord 2023-08-09

Abstract

This TIP proposes to add the contract MultiCollateralOnOffRamp as part of Thales protocol.

Motivation

Thales already supports multiple stable coins as options for onramp with its AMMs. This integration leverages curve sUSD pool on Optimism to support USDC, USDT and DAI as onramp.
As Thales protocol focuses on user experience and decentralized third party clients, the need to allow onramps such as ETH/WETH or e.g. OP and ARB on corresponding chains has been discussed.

Additionally, on Arbitrum with the addition of native USDC, there is confussion among users on which one is supported on Thales. This new contract aims to allow both to be supported with seamless user experience.

Specification

The new contract will allow a whitelisted contract to call it and swap the supported collateral into the native collateral Thales uses on the given chain (sUSD on Optimism, USDC on other chains). The native collateral will be referred as sUSD in the rest of the specification section for convenience.

The contract will have a list of supported onramp collaterals and will know the best path to use to swap it into sUSD.
The logic that was used for curve onramp for USDC, USDT and DAI will be moved to this contract.

Supported collateral on Optimism will be:

  • OP
  • ETH
  • WETH
  • USDC
  • USDT
  • DAI

During the implementation, it was observed that the best path for a given trade is not always simple. To get the best rate, a client that want to integrate uniswap contracts, would have to use the SDK and pass a route to the contract. A decision was made that this would make potential integrations very difficult for integrators without centralized dependancies, so for simplicity we went with static routes that are defined for each collateral separately.

The following is what will be supported on Optimism with pDAO being allowed to make changes to these ad hoc as it finds more optimal solutions:

  • OP -> the swap would occur via WETH pools as proxu (this will be default solution for any new collateral via uniswap)
  • ETH -> it will be wrapped to WETH and then swapped directly via sUSD-WETH pool
  • WET -> swapped to sUSD directly via sUSD - WETH pool
  • USDC, USDT and DAI will continue to use curve as before

The contract will have a variable that controls minimum to receive for a given onramp. The variable is tentatively set to 2%. This means that the contract guarantees that any given onramp wont have more than a 2% slippage compared to the Chainlink price feed.

The use of Chainlink price feeds for minimum to receive, as well as maximum to receive, together with non-reentrancy Open Zeppelin modifiers, protects against any exploitable scenario.

The contract will initially only support onramp and will be added to products and chains as protocol DAO and dev team in general prioritizes it. No new TIPs are required for new collaterals.

Variables

All variables are listed before and can be changed by pDAO ad hoc.

mapping(address => bool) public ammsSupported;
mapping(address => bool) public collateralSupported;
ISwapRouter public swapRouter;
IPriceFeed public priceFeed;
address public WETH9;
address public usdc;
address public usdt;
address public dai;
bool public curveOnrampEnabled;
uint public maxAllowedPegSlippagePercentage;
ICurveSUSD public curveSUSD;
mapping(address => bytes) public pathPerCollateral;
mapping(address => bytes32) public priceFeedKeyPerCollateral;

Implementation

https://github.com/thales-markets/contracts/blob/speed_markets_cleansed/contracts/SpeedMarkets/MultiCollateralOnOffRamp.sol

Copyright

Copyright and related rights waived via CC0.