Skip to content

Latest commit

 

History

History
183 lines (139 loc) · 4.15 KB

harmony-deployment.md

File metadata and controls

183 lines (139 loc) · 4.15 KB

Deploying Synthetix on Harmony

List of required repos

Synthetix:

https://github.com/ArtemKolodko/synthetix/tree/harmony_new_deployment

Synthetix UI:

https://github.com/ArtemKolodko/synthetix-js-monorepo/tree/harmony_support

Band oracle reader:

https://github.com/harmony-one/band-oracle-reader

Existed Band oracle feeds:

BTC: 0x4EdeeB8efa8e8dA1a68699D19BA9B85d78EAc565
ONE: 0x6cb4f021d163d38766e90534b21a71b2085b61a8
ETH: 0xf0184d340660cd3ce4944f0c6e1b63c85d78dbcd
1SY: 0xC0565A0aeccC60Ff1636f53c4dF26e228C4Dc139

Band oracle updater:

https://github.com/harmony-one/band-oracle-updater

Deployment steps

  1. Build Synthetix contracts (repo: synthetix):
yarn compile
  1. Compile contracts into build/compiled:
node publish build
  1. Create folder for new deployment:
mkdir ./publish/deployed/harmony4
  1. (Optional) Deploy Band oracles for each token from publish/deployed/harmony4/feeds.json (SNX, BTC, ETH, ...):

https://github.com/polymorpher/synthetix-v2/blob/band-oracle/oracle-notes.md

BandOracleReader sources:

https://github.com/harmony-one/band-oracle-reader

  1. Change oracle feed addresses, using contracts deployed on Step 1, or use existed oracle feeds from previous deployment.

Path: /publish/deployed/harmony4/feeds.json

Example with BTC token:

{
	"BTC": {
		"asset": "BTC",
		"feed": "0x4EdeeB8efa8e8dA1a68699D19BA9B85d78EAc565"
	}
}

Replace /publish/deployed/harmony4/deployment.json file with following structure:

{
	"targets": {},
	"sources": {}
}

Set all values in /publish/deployed/harmony4/config.json to "deploy":true.

Example:

{
	"SystemSettings": {
		"deploy": true
	},
	"SynthetixBridgeToOptimism": {
		"deploy": true
	},
	...
}
  1. Create .env file in root folder and add envs:
PRIVATE_KEY=0x123
DEPLOY_PRIVATE_KEY=0x123
PROVIDER_URL_MAINNET=https://api.harmony.one

Note that deployer account should have ONE tokens on balance

  1. Run Synthetix deployment
node publish deploy --network harmony --deployment-path ./publish/deployed/harmony4 --ignore-safety-checks
  1. Open Synthetix UI repo, install dependencies and copy content of a new folder:
synthetix/publish/deployed/harmony4

to

js-monorepo/v2/contracts/publish/deployed/harmony
  1. In Synthetix UI (js-monorepo) run script to build contract bindings:
cd /v2/contracts
yarn build
  1. In Synthetix UI navigate to v2/ui and run Synthetix client locally:
yarn dev
  1. Open http://localhost:3000/, Synthetix V2 client page should be displayed

  2. Launch BandOracleUpdater for all price feeds: https://github.com/harmony-one/band-oracle-updater

Create 1SY oracle feed

  1. Create new 1USDC/1SY liquidity pool on swap.country/pools

Reference: 1USDC / 1SY https://info.swap.harmony.one/#/harmony/pools/0xbc4af4ee9164c469b9e90f7d9b5f7854556133d6

  1. Clone https://github.com/polymorpher/synth-oracle and run forge build
  2. Create .env file in project root:
POOL_ADDRESS=0x1234 [pool address from Step1]
DEPLOYER_PRIVATE_KEY=0x5678 [your private key]
  1. Deploy new oracle contract:
./deploy.sh
...
Oracle address: 0xe3EAB0d319908c3Ca68076b208a9870571dDb03F
  1. Trade 1USDC / 1SY on swap.country and check the price:
cast call 0xe3EAB0d319908c3Ca68076b208a9870571dDb03F "latestAnswer()(int256)" --rpc-url https://api.harmony.one
  1. Set new oracle feed for 1SY token:

Open Synthetix repo and navigate to scripts folder:

cd harmony-scripts

Set newFeedAddress in update-feed.js script:

const exchangeRatesAddress = '0x4d6A3E4524a1b269C7E3564a22b908693Aa5186A';
...
const newFeedAddress = '0xe3EAB0d319908c3Ca68076b208a9870571dDb03F';

Run update script (you must be the owner of ExchangeRates contract):

node update-feed.js

Feed address updated