This sip builds on top of SIP-267's direct integration functionality in order to offer an end-to-end cross-asset swap function at reduced fees, built on top of Synthetix's atomic exchanges and Curve's stable swap pools.
CurveIntegration sip allows users to trade between non-synths at reduced fees, with the trade executing by hoping over curve stable-swap pools along side Synthetix's atomic swap function.
A user would be able to spend
synthEquivalent and receive another
synthEquivalent with the swap taking place with the following route:
synthover curve's stable swaps (USDC to sUSD)
synthwith atomic swaps (sUSD to sETH)
synthEquivalentover curve's stable swaps (sETH to wETH)
As an implementation note, no partial trades are allowed and the full route from
synthEquivalent needs to be executed atomically within the same transaction.
CurveIntegration contract takes advantage of the slippage model incorporated within curve's stable-swap pools, helping stall toxic volume to the extent of the imbalance in individual curve pools. This allows the protocol to lower Synthetix's exchange fees with the help of SIP-267's override function and designate the 30 bp uniswap pool as a source of pricing. Therefore, swaps that do not take place within the
CurveIntegration contract would continue to trade using the pricing of the 5 bp uniswap pool, at their own independently configured fees.
- All the synth tokens that can be traded within the
CurveIntegrationcontract need be assigned respective
setSynthEquivalentfunction. The designated
synthEquivalenttokens need to exist in the Curve Stable-Swap pools specified in the next section.
For example sUSD would be assigned USDC as synthEquivalent and sETH would have wETH as synthEquivalent.
- ETH cannot be designated as a
synthEquivalent, hence a
wETH/sETHcurve stable swap pool would need to be created.
synthpair need to be mapped to a specific curve pool containing the respective these tokens. The specification would be done by calling
setCurvePoolForSynthExchangefunction which takes in the address of the curve contract as an argument as well as the currencyKey of the synth.
- No curve meta-pools can be configured, as the curve pool needs to contain both the
CurveIntegration contract needs to be pointed to the
DirectIntegration contract, in order to be able to trade atomically with Synthetix's atomic function and retrieve the respective fee and pricing parameters, taking into account overrides.
CurveIntegrationcontract uses the curve pool swap function
StableSwap.exchange_underlyingto trade a specified amount of tokens. The swap return amount is obtained using the
sourceEquivalentis the token spent by the user
sourceSynthis the synth obtained by trading the
sourceEquivalenttoken on the specified curve stable swap pool
destinationSynthis the synth obtained by trading the
sourceSynthover Synthetix's atomic exchange
destinationEquivalentis token received by the user when trading
destinationSynthon the specified stable swap curve pool
Crv(sourceEquivalent,sourceSynth)is the rate of exchange obtained from curve, swapping a
sourceSynthper unit of
Atomic(sourceSynth,destinationSynth)is Synthetix's atomic rate of exchange of a
destinationSynthtoken per unit of
Crv(destinationSynth,destinationEquivalent)is the rate of exchange obtained from curve, swapping a
destinationEquivalenttoken per unit of
Curve Integration Pricing Function:
The CurveIntegration price is obtained using the function below:
Crv(sourceEquivalent,sourceSynth) * Atomic(sourceSynth,destinationSynth) * Crv(destinationSynth,destinationEquivalent)
Note that both the
Synthetixfill price are dependent on the amount of exchange at each step.
getReturnAmount function would be incorporated into the
CurveIntegration which takes in the following arguments:
- The address of the
- The address
sourceAmountrepresenting the amount spent by the user
The function returns the amount expected to be received in
destinationEquivalent token, by trading over the
In case a synth is tagged to trade at the pure chainlink price, then the chainlink price used to fetch the price over atomic pricing.
It is worth nothing that with the current implementation of the atomic swaps functionality, the protocol does not need to map synths that trade at the pure chainlink price to
synthEquivalents, since no uniswap pool is used. However, in order for the
CurveIntegration contract to be able to handle swaps with synths that trade at pure chainlink price, a
synthEquivalent needs to be designated.
minReturn function will be incorporated into
CurveIntegration swap function, representing the minimum return amount a user accepts to receive in
synthEquivalent for the amount of
synthEquivalent spent. In case the return amount is below the
minReturn, the transaction reverts.
setCurvePoolForSynthExchangeallows the Spartan Council to designate the Curve Stable-Swap contract over which the
setSynthEquivalentallows the Spartan Council to designate the respective equivalent for each synth that can be traded on Crv pools.
SIP rejected by author as the SIP-267 implementation does not require that SIP-268 be implemented as any address can be configured for integration.
Copyright and related rights waived via CC0.