Discussion: AMM Functionality

Purpose;
Thread for ideas for further functionality in the AMM hosted at Fixed Forex can be discussed & debated

Current Capabilities;
Current functionality allows for swaps;

  • From DAI or sUSD to any ibXXX asset

OR;

  • From ibEUR to sUSD

Limitations;
Swaps that trade via route through other sXXX stables (via Atomic Swaps) are limited in availability to when fiat forex market Oracles are reporting see “Circuit Breakers” section here

Note; direct swaps between ibXXX <> ibXXX or sXXX <> sXXX are currently limited by lack of integration of swaps via Atomic Exchange through sXXX assets

Technical;
Current contract address can be found;

  • Swaps via Synthetix Atomic Exchange function;
    • 0x58d288812A2d67F520335e99A9718c04B8f2a3D4
  • Swaps via DAI (inbound only);
    • 0x0a0B06322825cb979678C722BA9932E0e4B5fd90

Note; AMM contracts do not appear to be public in the Keep3r Github

1 Like

Suggestion;
I’d like to kick things off, with a suggestion to modify the ibAMM (0x58d288812A2d67F520335e99A9718c04B8f2a3D4) to allow for direct swaps from sUSD to ANY sXXX stable asset of the following sXXX types;

  • sEUR; 0xD71eCFF9342A5Ced620049e616c5035F1dB98620
  • sCHF; 0x0F83287FF768D1c1e17a42F44d644D7F22e8ee1d
  • sGBP; 0x97fe22E7341a0Cd8Db6F6C021A24Dc8f4DAD855F
  • sAUD; 0xF48e200EAF9906362BB1442fca31e0835773b8B4
  • sKRW; 0x269895a3dF4D73b077Fc823dD6dA1B95f72Aaf9B
  • sJPY; 0xF6b1C627e95BFc3c1b4c9B825a032Ff0fBf3e07d

Motivation;
This change will have no impact on any treasury held assets, nor will it have any impact on ibXXX assets loaned. It wouldl benefit protocol in two notable ways;

  1. Ease of use for end-users vs having to utilize an external service (such as Kwenta)

  2. With treasury controlled curve directing emissions due to return to incentivizing ibXXX+sXXX stable curve pools & with pools currently being off-peg - this would allow;

  • end-users ease of access to the pools on the Synthtix stable side
  • benefit restoration of peg due to the fact that any user entering the pool single-sided via the under-balanced asset will receive a bonus for depositing into the pool

Due to need for re-peg of pools, would recommend these swap options are offered at no additional fee. Due to the atomic exchange capabilities enabled by Synthetix users will incur base fees as per SCCP-190 & may be subject to change in future SCCPs although will incur no slippage

As these changes will help user-enablement to restore peg on ibXXX+sXXX pools - then it follows that peg valuations being within a tight range is also likely to restore confidence in any potential borrowers of ibXXX assets from Iron Bank - which should be considered a critical need for generating revenues for vested KP3R token holders

Execution;
Can be enabled by modifying current contract to;

  • List address for each Synth detailed above
  • ‘quote_snx’ for sUSD to sXXX
  • ‘swap_snx’ via ‘snx.exchangeAtomically’
  • return sXXX to sender

Should also include notice on web frontend of hours of operation

Timing;
Ideally, this change would be enabled in time for incentives returning to ibXXX+sXXX pools, due on 14th July

Technical Reference;

  • Fixed Forex ib_amm contract at;
    • 0x58d288812A2d67F520335e99A9718c04B8f2a3D4
  • Atomic Swap info via Synthetix at;
    • SIP-89 for (now historical) Virtual Synths
    • SIP-120 for Atomic Exchange Functions on L1
    • SIP-198 for Update to Atomic Exchange Function which allows trading at pure chainlink price
    • SIP-220 for Update on Exchange Fee System
  • Synthetix fee updates;
    • SCCP-190 for Update Fees & Atomic Volatility Circuit Breaker Parameters

Note;

  • SIP = Synthetix Improvement Proposals
  • SCCP = Synthetix Configuration Change Proposals
    These are the formal mechanisms Synthetix uses for making changes to the protocol. SIPs are usually smart contract level changes, whilst SCCPs are usually configuration variables

Additional Considerations;
Functionality could be further enhanced by enabling inbound routing via the sUSD pool on curve which would mean the following assets could be accepted as inbound swaps;

  • DAI
  • USDC
  • USDT

Therefore routing all DAI/USDC/USDT via the pool & swapping to sUSD before quoting and exchanging atomically to the sXXX asset

If added, this should include passthrough of curve incurred fees and notice of slippage to user

1 Like

In addition to the above, an early version of cross-stable forex swaps could be implemented, which is detailed below.

Note; there are some additional considerations with regards to optimal conditions or further optimization that should be considered when weighing up benefits & timing of implementation that are further highlighted below.

Suggestion;
Enable swaps between;

  • ibXXX to any other ibXXX asset
  • sXXX to any other (fiat) sXXX asset
  • ibXXX to any other (fiat) sXXX asset

Motivation;
This will enable liquidity miners farming the Fixed Forex stable pools on curve automatic routing to move capital between liquidity pools via the Fixed Forex AMM, with the flexibility to move between pools to deploy assets on either side of the LP.

This could be particularly appealing/useful where a bonus is available to enter onto one side of the LP pair during off-peg situations.

Depending on liquidity pools being in balance, this could allow for exchange between non-USD stables at fiat FX rates (minus any slippage caused by pool imbalance)

Execution;
Requires AMM contracts to be further updated/modified to allow for the following routings scenarios;

Note; all routes must transit swap through USD stables due to lack of availability for any Oracles that track valuations of non-USD fiat to fiat exchange

ibXXX any other ibXXX asset;

  • Routing as follows;
    • Route originating ibXXX asset via curve pool where paired with sXXX (i.e. exchange ibXXX for sXXX asset via curve pool)
    • Atomically Exchange sXXX asset for user desired fiat sXXX asset (via Synthetix)
    • Route sXXX via relevant curve pool where paired with ibXXX to swap for ibXXX asset
  • Fees incurred via Curve & Atomic Exchange should be passed onto user, therefore requires functionality to quote swap costs to user;
    • Note, incurs fees from Curve & fees from Atomic Exchange
  • Note; limited by liquidity available in curve pools at time of swap, possibly incurring slippage where pools off-balance

sXXX any other sXXX asset;

  • Routing as follows;
    • Route originating sXXX asset via Atomically Exchange, swapping asset for ANY other fiat sXXX asset
    • Atomically Exchange originating sXXX for any other sXXX stable asset
  • Fees incurred via Atomic Exchange should be passed onto user, therefore requires functionality to quote swap costs to user;
    • Note; incurs fees associated with Atomic Exchange

ibXXX any other sXXX asset;

  • Routing as follows;
    • Route originating ibXXX asset via curve pool where paired with sXXX (i.e. exchange ibXXX for sXXX asset via curve pool)
    • Route originating sXXX asset via Atomically Exchange, swapping asset for user desired fiat asset version of sXXX
  • Fees incurred via Curve & Atomic Exchange should be passed onto user, therefore requires functionality to quote swap costs to user;
    • Note; incurs fees associated with Atomic Exchange & Curve fees
  • Note; limited by liquidity available in curve pools at time of swap, possibly incurring slippage where pools off-balance

Considerations;
Due to risk of curve pool balance being directly impacted by implementation would recommend the following are considered as mandatory prerequisites that must be in place prior to implementation;

  • A consistent pool incentivization strategy (i.e. one that regularly ensures predictable incentivisation for LPers) inclusive of;
    • Directed CRV emissions to gauges via gauge controlling assets (i.e. veCRV or vlCVX)
    • Dynamic utilization of OLM rewards to flexibly incentivize pools Option 2 or 4 from this post)
  • Availability of paired stable assets on chain (i.e. via lending markets etc.)
  • AMO, PSM, or other pegging mechanisms/functions for Fixed Forex being enabled & actively in place prior to launch

A further consideration is that should technical changes or innovations at Chainlink or the Synthetix team enable the possibility of;

  • Exchange availability outside of limitation of circuit breaker on Oracle availability

Then routing methods should be reviewed and modified accordingly.

Additional Opportunities;
The lack of availability for swaps outside of oracle availability & circuit breaker could be somewhat mitigated if the following steps were undertaken;

  • Any USD funds received in AMM used for directly acquiring ibXXX stables continue to be deposited in the sUSD+3CRV curve pool, earning rewards on total position
  • The Keep3r team periodically withdraw some sUSD funds and proactively swap via Atomic Exchange based on anticipated demand prior to periods where the fiat oracles stop reporting & Atomic Exchange circuit breaker comes into effect
  • Keep3r treasury then deposits available sXXX assets into the AMM contract to be used for swaps between ibXXX < > ibXXX through the routing highlighted above, but instead of using the Atomic Exchange leg utilizing sXXX treasury held funds
  • A fee can be applied to account for risk of fiat exchange movements over the period FX markets are closed & oracles are not reporting
  • Profits on fees can be reutilized by the Keep3r treasury to repay outstanding Iron Bank loans & where loans & potentially split with vKP3R holders
  • Fees could be set at a level consistent with Atomic Exchange so from a UX experience there is little difference during these periods
1 Like

If this was enabled then the current method where the AMM is borrowing funds from Iron Bank based on USD stable exchanges-in can be ceased this would be far more efficient for users and the protocol.

Most of these opportunities can actually be disguarded if instead the AMM is adjusted to route any inbound USD stable swaps through the sUSD curve pools at;

Since the USD stables would just pass through the contract via the curve pool then enable the atomic exchange between sUSD & the sXXX (& onto ibXXX if user desired) then there is no need for any funds to be held by the treasury

Relevant Synthetix Contracts;

End Result - Options available in UI

Fully dependent on Curve pool slippage;

  • Exchange DAI/USDC/USDT/FRAX for sUSD
  • Exchange sUSD for DAI/USDC/USDT/FRAX

Dependent on availability & pricing of AtomicExchange;

  • Exchange sUSD for ANY sXXX fiat/stable
  • Exchange ANY sXXX fiat/stable for ANY other sXXX fiat/stable
  • Exchange ANY sXXX fiat/stable for sUSD

Dependant on Curve pool slippage;

  • Exchange ANY ibXXX for ANY sXXX fiat/stable
  • Exchange ANY sXXX for ANY ibXXX fiat/stable

Bonus if routing can be added to the contract to simplify inputs & output exchange offerings (i.e. with hops between Curve & AtomicExchange)