SIP-267: Direct Integration

Author
StatusApproved
TypeGovernance
NetworkEthereum & Optimism
ImplementorTBD
ReleaseTBD
ProposalLoading status...
Created2022-07-28

Simple Summary

This SIP proposes to implement a direct integration contract that allows integrators to tap into Synthetix's exchange functionalities with a customized set parameters.

Abstract

The direct integration contract allows the Synthetix protocol to create a unique enviroment for integrators, allowing access to Synthetix's exchange functionalities with custom parameters that fit individual use cases. Although this sip is built on top of v2x, it fits in the spirit of what we should expect with Synthetix v3, where different markets can be created and tailored for specific offerings and use cases.

Motivation

There are a number of benefits to the Synthetix protocol from having a direct integration path with partners:

  • Lyra's uses Synthetix's exchange functionalities in to offer it's users options trading venue with an integrated amm model which embeds slippage.
  • Curve also provides Synthetix with pools that allow for cross-asset swaps with built-in slippage.

Both these protocols have a significantly reduced chance of latency attacks, due to their protocol's incorporation of slippage constraining toxic flow to a certain extent. Providing these special DirectIntegration routes into Synthetix's exchange functionalities isolates the trade flow to a certain extent and allows us to offer more competitive offerings via lower fees.

Direct Integration Workflow

The workflow of adding a directing integration external contract to interact with Synthetix exchange functions is as follows:

  • The entity submits a SIP specifying the motivation behind the integration, the benefits to and risks undertaken by SNX stakers. The SIP should include the following:

    a) The address of the contract and the exchange functionality it's integrating into. In case the address is yet to be available, the SIP needs to be amended at later date, and the amendment approved by the Spartan Council via re-vote.

    b) The parameter overrides involved. If the default parameters are to be used, then no override needs to be specified in the SIP.

  • The author of the integration needs to find the necessary ressource to create the integration contract

  • The contract is submitted to Synthetix's auditors and Core-Contributors for review

  • If no objection from auditors/Core-Contributors and all the previous requirements are met (in terms of gathering the necessary vote), the contract is incorporated into the DirectIntegration contract with the specified parameter overrides.

Specification

Technical Specification

The DirectIntegration contract allows the Spartan Council to approve an external contract, not owned or managed by the Synthetix protocol, to interact with the Synthetix's core exchange functionalities at specified parameters. If the parameter specified under addIntegration was set to 0x, then the default parameters configuration would be used. Below are the functionalities configurable within the DirectIntegration contract:

setIntegration

setIntegration allows the protocol to specify the exchange functionalities that go through the DirectIntegration contract. It takes in the following structure:

  • The exchange function as the key, i.e.exchange(bytes32,uint,bytes32)
  • The list of parameters that govern that exchange function as the value of the structure i.e. [setExchangeFeeRateForSynths, setExchangeDynamicFeeWeightDecay,setExchangeDynamicFeeThreshold,setExchangeDynamicFeeRounds, setExchangeMaxDynamicFee]

addIntegration

addIntegration function allows the protocol to specify the contracts that are allowed to interact with one of the exchange functions at specified parameters. The addIntegration function takes in the following structure:

  • The address of the integrators' contract as the key
  • A list of sub-structures with each element of that list containing:
    • The exchange function signature being the key i.e. exchange(bytes32,uint,bytes32)
    • The parameter signature and the override value of that parameter i.e. {setExchangeFeeRateForSynths:(sETH,30bp)}

Note that specifying any of the aforementioned parameters as 0x, leads to the default system parameters being configured.

Get Integration Parameters

This is a getter function that can be used to read the configured parameters. The getIntegrationParameters function takes in the following arguments:

  • The address of the external contract
  • An identifier of a parameter (i.e. setAtomicExchangeFeeRate)

The function returns a list of parameters and their respective values specified on a given contract that can interact with DirectIntegration. For example calling the getIntegration function with a previously specified address and setAtomicExchangeFeeRate returns all the fees configured for the different synths.

Resume / Pause Integration

The SystemStatus would include resumeIntegration and pauseIntegration functions, that take in the external contract address and allows pdao to suspend and resume interaction with external contracts.

Direct Integration Universe

Below is a list of functionalities as well as the configurable parameters:

  • exchange(bytes32,uint,bytes32): [setExchangeFeeRateForSynths, setExchangeDynamicFeeWeightDecay,setExchangeDynamicFeeThreshold,setExchangeDynamicFeeRounds, setExchangeMaxDynamicFee]
  • exchangeWithTracking(bytes32,uint,bytes32,address,bytes32): [setExchangeFeeRateForSynths, setExchangeDynamicFeeWeightDecay,setExchangeDynamicFeeThreshold,setExchangeDynamicFeeRounds, setExchangeMaxDynamicFee]
  • exchangeWithTrackingForInitiator(bytes32,uint,bytes32,address,bytes32): [setExchangeFeeRateForSynths, setExchangeDynamicFeeWeightDecay,setExchangeDynamicFeeThreshold,setExchangeDynamicFeeRounds, setExchangeMaxDynamicFee]
  • exchangeOnBehalfWithTracking(address,bytes32,uint,bytes32,address,bytes32): [setExchangeFeeRateForSynths, setExchangeDynamicFeeWeightDecay,setExchangeDynamicFeeThreshold,setExchangeDynamicFeeRounds, setExchangeMaxDynamicFee]
  • exchangeAtomically(bytes32,uint,bytes32,bytes32,uint): [setDexPriceAggregator,setAtomicExchangeFeeRate,setAtomicMaxVolumePerBlock,atomicVolatilityUpdateThreshold,atomicVolatilityConsiderationWindow]

Other Important Considerations:

In future SIP's, such as SIP-265, the direct integration universe would need to be updated as to incorporate new parameters and functions configured into synthetix's systems.

Test Cases

Configurable Values (Via SCCP)

Below is a list of values configurable via SIP or SCCP:

  • setIntegration: This will allow the protocol to configure exchange functions that go through DirectIntegration contract
  • addIntegration: This allows the protocol to specify contracts that can interact with Synthetix through the DirectIntegration contract, with specified exchange functions at respective parameters.
  • pauseIntegration and resumeIntegration can be called by pDAO to cease and resume interaction on the DirectIntegration contract. Note that pauseIntegration can be called by pdao in case of emergencies, but resumeIntegration requires an SCCP.

Copyright and related rights waived via CC0.