The smart contracts which make up the Oikos system. (Oikos.cash)

Usage no npm install needed!

<script type="module">
  import oikosOikosBsc from 'https://cdn.skypack.dev/@oikos/oikos-bsc';



Build Status CircleCI codecov npm version Discord Twitter Follow

Synthetix is a crypto-backed synthetic asset platform.

It is a multi-token system, powered by SNX, the Synthetix Network Token. SNX holders can stake SNX to issue Synths, on-chain synthetic assets via the Mintr dApp The network currently supports an ever growing list of synthetic assets. Please see the list of the deployed contracts on MAIN and TESTNETS Synths can be traded using synthetix.exchange

Synthetix uses a proxy system so that upgrades will not be disruptive to the functionality of the contract. This smooths user interaction, since new functionality will become available without any interruption in their experience. It is also transparent to the community at large, since each upgrade is accompanied by events announcing those upgrades. New releases are managed via the Synthetix Improvement Proposal (SIP) system similar to the EF's EIPs

Prices are committed on chain by a trusted oracle. Moving to a decentralised oracle is phased in with the first phase completed for all forex prices using Chainlink

Please note that this repository is under development.

For the latest system documentation see docs.synthetix.io



Discord Twitter Follow

For a guide from the community, see synthetix.community

Repo Guide


A note on the branches used in this repo.

  • master represents the contracts live on bsc and all testnets.
  • alpha is for the newest version of contracts, and is reserved for deploys to testnet
  • beta is for promoted alpha contracts, and is reserved for deploys to rinkeby
  • release-candidate is for promoted beta contracts, and is reserved for deploys to ropsten

When a new version of the contracts makes its way through all testnets, it eventually becomes promoted in master, with semver reflecting contract changes in the major or minor portion of the version (depending on backwards compatibility). patch changes are simply for changes to the JavaScript interface.


Build Status CircleCI codecov

Please see docs.synthetix.io/contracts/testing for an overview of the automated testing methodologies.

Module Usage

npm version

This repo may be installed via npm install to support both node.js scripting applications and Solidity contract development.


:100: Please see our walkthrus for code examples in both JavaScript and Solidity: docs.synthetix.io/contracts/walkthrus

Solidity API

All interfaces are available via the path synthetix/contracts/interfaces.

:zap: In your code, the key is to use IAddressResolver which can be tied to the immutable proxy: ReadProxyAddressResolver (introduced in SIP-57). You can then fetch Synthetix, FeePool, Depot, et al via IAddressResolver.getAddress(bytes32 name) where name is the bytes32 version of the contract name (case-sensitive). Or you can fetch any synth using IAddressResolver.getSynth(bytes32 synth) where synth is the bytes32 name of the synth (e.g. iETH, sUSD, sDEFI).


npm install synthetix

then you can write Solidity as below (using a compiler that links named imports via node_modules):

pragma solidity 0.5.16;

import 'synthetix/contracts/interfaces/IAddressResolver.sol';
import 'synthetix/contracts/interfaces/ISynthetix.sol';

contract MyContract {
    // This should be instantiated with our ReadProxyAddressResolver
    // it's a ReadProxy that won't change, so safe to code it here without a setter
    // see https://docs.synthetix.io/addresses for addresses in bsc and testnets
    IAddressResolver public synthetixResolver;

    constructor(IAddressResolver _snxResolver) public {
        synthetixResolver = _snxResolver;

    function synthetixIssue() external {
        ISynthetix synthetix = synthetixResolver.getAddress('Synthetix');
        require(synthetix != address(0), 'Synthetix is missing from Synthetix resolver');

        // Issue for msg.sender = address(MyContract)

    function synthetixIssueOnBehalf(address user) external {
        ISynthetix synthetix = synthetixResolver.getAddress('Synthetix');
        require(synthetix != address(0), 'Synthetix is missing from Synthetix resolver');

        // Note: this will fail if `DelegateApprovals.approveIssueOnBehalf(address(MyContract))` has
        // not yet been invoked by the `user`

Node.js API

  • getAST({ source, match = /^contracts\// }) Returns the Abstract Syntax Tree (AST) for all compiled sources. Optionally add source to restrict to a single contract source, and set match to an empty regex if you'd like all source ASTs including third party contracts
  • getPathToNetwork({ network, file = '' }) Returns the path to the folder (or file within the folder) for the given network
  • getSource({ network }) Return abi and bytecode for a contract source
  • getSuspensionReasons({ code }) Return mapping of SystemStatus suspension codes to string reasons
  • getSynths({ network }) Return the list of synths for a network
  • getTarget({ network }) Return the information about a contract's address and source file. The contract names are those specified in docs.synthetix.io/addresses
  • getUsers({ network }) Return the list of user accounts within the Synthetix protocol (e.g. owner, fee, etc)
  • getVersions({ network, byContract = false }) Return the list of deployed versions to the network keyed by tagged version. If byContract is true, it keys by contract name.
  • networks Return the list of supported networks
  • toBytes32 Convert any string to a bytes32 value

Via code

const snx = require('synthetix');

{ 'contracts/AddressResolver.sol':
   { imports:
      [ 'contracts/Owned.sol',
        'contracts/interfaces/ISynthetix.sol' ],
     contracts: { AddressResolver: [Object] },
     interfaces: {},
     libraries: {} },
   { imports: [],
     contracts: { Owned: [Object] },
     interfaces: {},
     libraries: {} },

snx.getAST({ source: 'Synthetix.sol' });
{ imports:
   [ 'contracts/ExternStateToken.sol',
     'contracts/interfaces/IRewardsDistribution.sol' ],
   { Synthetix:
      { functions: [Array],
        events: [Array],
        variables: [Array],
        modifiers: [Array],
        structs: [],
        inherits: [Array] } },
  interfaces: {},
  libraries: {} }

// Get the path to the network
snx.getPathToNetwork({ network: 'bsc' });

// retrieve an object detailing the contract ABI and bytecode
snx.getSource({ network: 'rinkeby', contract: 'Proxy' });
  bytecode: '0..0',
  abi: [ ... ]

    1: 'System Upgrade',
    2: 'Market Closure',
    3: 'Circuit breaker',
    99: 'Emergency',

// retrieve the array of synths used
snx.getSynths({ network: 'rinkeby' }).map(({ name }) => name);
// ['sUSD', 'sEUR', ...]

// retrieve an object detailing the contract deployed to the given network.
snx.getTarget({ network: 'rinkeby', contract: 'ProxySynthetix' });
    name: 'ProxySynthetix',
  address: '0x322A3346bf24363f451164d96A5b5cd5A7F4c337',
  source: 'Proxy',
  link: 'https://rinkeby.etherscan.io/address/0x322A3346bf24363f451164d96A5b5cd5A7F4c337',
  timestamp: '2019-03-06T23:05:43.914Z',
  txn: '',
    network: 'rinkeby'

// retrieve the list of system user addresses
snx.getUsers({ network: 'bsc' });
[ { name: 'owner',
    address: '0xEb3107117FEAd7de89Cd14D463D340A2E6917769' },
  { name: 'deployer',
    address: '0xDe910777C787903F78C89e7a0bf7F4C435cBB1Fe' },
  { name: 'marketClosure',
    address: '0xC105Ea57Eb434Fbe44690d7Dec2702e4a2FBFCf7' },
  { name: 'oracle',
    address: '0xaC1ED4Fabbd5204E02950D68b6FC8c446AC95362' },
  { name: 'fee',
    address: '0xfeEFEEfeefEeFeefEEFEEfEeFeefEEFeeFEEFEeF' },
  { name: 'zero',
    address: '0x0000000000000000000000000000000000000000' } ]

{ 'v2.21.12-107':
   { tag: 'v2.21.12-107',
     fulltag: 'v2.21.12-107',
     release: 'Hadar',
     network: 'testnet',
     date: '2020-05-08T12:52:06-04:00',
     commit: '19997724bc7eaceb902c523a6742e0bd74fc75cb',
         contracts: { ReadProxyAddressResolver: [Object] }

// [ 'local', 'testnet', 'rinkeby', 'ropsten', 'bsc' ]

// '0x7355534400000000000000000000000000000000000000000000000000000000'

As a CLI tool

Same as above but as a CLI tool that outputs JSON, using names without the get prefixes:

$ npx synthetix ast contracts/Synth.sol
  "imports": [
    # ...

$ npx synthetix bytes32 sUSD

$ npx synthetix networks
[ 'local', 'kovan', 'rinkeby', 'ropsten', 'bsc' ]

$ npx synthetix source --network rinkeby --contract Proxy
  "bytecode": "0..0",
  "abi": [ ... ]

$ npx synthetix suspension-reason --code 2
Market Closure

$ npx synthetix synths --network rinkeby --key name
["sUSD", "sEUR", ... ]

$ npx synthetix target --network rinkeby --contract ProxySynthetix
  "name": "ProxySynthetix",
  "address": "0x322A3346bf24363f451164d96A5b5cd5A7F4c337",
  "source": "Proxy",
  "link": "https://rinkeby.etherscan.io/address/0x322A3346bf24363f451164d96A5b5cd5A7F4c337",
  "timestamp": "2019-03-06T23:05:43.914Z",
  "network": "rinkeby"

$ npx synthetix users --network bsc --user oracle
  "name": "oracle",
  "address": "0xaC1ED4Fabbd5204E02950D68b6FC8c446AC95362"

$ npx synthetix versions
  "v2.0-19": {
    "tag": "v2.0-19",
    "fulltag": "v2.0-19",
    "release": "",
    "network": "bsc",
    "date": "2019-03-11T18:17:52-04:00",
    "commit": "eeb271f4fdd2e615f9dba90503f42b2cb9f9716e",
    "contracts": {
      "Depot": {
        "address": "0x172E09691DfBbC035E37c73B62095caa16Ee2388",
        "status": "replaced",
        "replaced_in": "v2.18.1"
      "ExchangeRates": {
        "address": "0x73b172756BD5DDf0110Ba8D7b88816Eb639Eb21c",
        "status": "replaced",
        "replaced_in": "v2.1.11"

      # ...


$ npx synthetix versions --by-contract
  "Depot": [
      "address": "0x172E09691DfBbC035E37c73B62095caa16Ee2388",
      "status": "replaced",
      "replaced_in": "v2.18.1"
      "address": "0xE1f64079aDa6Ef07b03982Ca34f1dD7152AA3b86",
      "status": "current"
  "ExchangeRates": [
      "address": "0x73b172756BD5DDf0110Ba8D7b88816Eb639Eb21c",
      "status": "replaced",
      "replaced_in": "v2.1.11"

    # ...

  # ...