Projects that join the Synthetix Volume Program earn a 25% rebate on fees generated from synth swaps. To apply for the Volume Program, fill out our application form.
Once accepted to the Volume Program, you can use the code functions below to track your volume and earn fees. For more information, check out SIP 63.
Note: Synthetix uses a proxy system. The ABI of the underlying Synthetix ProxyERC20 contract you need is Synthetix. Learn more about how proxies work by visiting the overview page.
const{SynthetixJs}=require('synthetix-js');constprivateKey='0x'+'1'.repeat(64);// don't actually put a private key in code obviously// parameters: default provider, default networkId, private key as a stringconstnetworkId=3;// ropsten, (use 1 for mainnet)constsigner=newSynthetixJs.signers.PrivateKey(null,networkId,privateKey);constsnxjs=newSynthetixJs({signer,networkId});const{toUtf8Bytes32,parseEther}=snxjs.utils;(async()=>{try{constuserAddress='0x0000000000000000000000000000000000000001';// send transactionconsttxn=awaitsnxjs.Synthetix.exchangeWithTracking(toUtf8Bytes32('sUSD'),parseEther('0.001'),toUtf8Bytes32('iETH'),userAddress,toUtf8Bytes32('1inch'));console.log('hash is mining',txn.hash);// wait for miningawaittxn.wait();// fetch logs of transactionconst{logs}=awaitsigner.provider.getTransactionReceipt(txn.hash);// show themconsole.log(JSON.stringify(logs,null,'\t'));}catch(err){console.log('Error',err);}})();
constsynthetix=require('synthetix');// nodejsconstethers=require('ethers');// nodejs// or using ES modules:// import synthetix from 'synthetix';// import ethers from 'ethers';constnetwork='ropsten';constprovider=ethers.getDefaultProvider(network==='mainnet'?'homestead':network);const{address}=synthetix.getTarget({network,contract:'ProxyERC20'});const{abi}=synthetix.getSource({network,contract:'Synthetix'});constprivateKey='0x'+'1'.repeat(64);// don't actually put a private key in code obviouslyconstsigner=newethers.Wallet(privateKey).connect(provider);// see https://docs.ethers.io/ethers.js/html/api-contract.html#connecting-to-existing-contractsconstSynthetix=newethers.Contract(address,abi,signer);const{toBytes32}=synthetix;(async()=>{try{constuserAddress='0x0000000000000000000000000000000000000001';// send transactionconsttxn=awaitSynthetix.exchangeWithTracking(toBytes32('sUSD'),ethers.utils.parseEther('0.001'),toBytes32('iETH'),userAddress,toBytes32('1inch'));// wait for miningawaittxn.wait();// fetch logs of transactionconst{logs}=awaitprovider.getTransactionReceipt(txn.hash);// displayconsole.log(JSON.stringify(logs,null,'\t'));}catch(err){console.log('Error',err);}})();
pragma solidity0.5.16;import"synthetix/contracts/interfaces/IAddressResolver.sol";import"synthetix/contracts/interfaces/ISynthetix.sol";contractMyContract{// 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 mainnet and testnetsIAddressResolverpublicsynthetixResolver;constructor(IAddressResolver_snxResolver)public{synthetixResolver=_snxResolver;}functionsynthetixExchange(bytes32src,uintamount,bytes32dest,addressoriginator,bytes32trackingCode)external{)ISynthetixsynthetix=synthetixResolver.getAddress("Synthetix");require(synthetix!=address(0),"Synthetix is missing from Synthetix resolver");// This check is what synthetix.exchange() will perform, added here for explicitnessrequire(!synthetix.isWaitingPeriod(src),"Cannot exchange during the waiting period");// Exchange for msg.sender = address(MyContract)synthetix.exchangeWithTracking(src,amount,dest,originator,trackingCode);// Note: due to Fee Reclamation in SIP-37, the following actions will fail if attempted in the// same block (the waiting period for the "to" synth must first expire)// synthetixResolver.getSynth(dest).transfer(address(0), 1e12)// synthetix.exchange(dest, 1e12, "sBTC");// synthetix.settle(dest);}functionsynthetixExchangeOnBehalf(addressuser,bytes32src,uintamount,bytes32dest,addressoriginator,bytes32trackingCode)external{ISynthetixsynthetix=synthetixResolver.getAddress("Synthetix");require(synthetix!=address(0),"Synthetix is missing from Synthetix resolver");// This check is what synthetix.exchange() will perform, added here for explicitnessrequire(!synthetix.isWaitingPeriod(src),"Cannot exchange during the waiting period");// Note: this will fail if `DelegateApprovals.approveExchangeOnBehalf(address(MyContract))` has// not yet been invoked by the usersynthetix.exchangeOnBehalfWithTracking(user,src,amount,dest,originator,trackingCode);// Note: due to Fee Reclamation in SIP-37, the following actions will fail if attempted in the// same block (the waiting period for dest must first expire)// synthetixResolver.getSynth(dest).transferFrom(user, address(0), 1e12)// synthetix.exchangeOnBehalf(user, dest, 1e12, "sBTC");// synthetixResolver.getAddress("Exchanger").settle(user, dest)}}