The Depot is a place to deposit any excess sUSD for others to purchase it with ETH. On testnets it also allows you to exchange testnet ETH for SNX.
Notice
The Depot also supports exchanging SNX for ETH via any SNX the contract holds, however it will send all proceeds to the contract's fundsWalet, so
it's only used on testnets to allow developers to purchase testnet SNX (see testnets)
Note: while the depositing of sUSD can be done in Mintr, the exchanging of ETH for sUSD has no corresponding controls in the Synthetix dApps (it is however used in third parties aggregators).
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});(async()=>{try{// send transactionconsttxn=awaitsnxjs.Depot.exchangeEtherForSynths({value:snxjs.utils.parseEther('0.01'),// Send 0.01 ETH});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);constcontract='Depot';const{abi}=synthetix.getSource({network,contract});const{address}=synthetix.getTarget({network,contract});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-contractsconstDepot=newethers.Contract(address,abi,signer);(async()=>{try{// send transactionconsttxn=awaitDepot.exchangeEtherForSynths({value:ethers.utils.parseEther('0.01')});// 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/IDepot.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;}functionsynthetixExchangeETHForSynths()external{IDepotdepot=synthetixResolver.getAddress("Depot");require(depot!=address(0),"Depot is missing from Synthetix resolver");uintetherAmount=1e15;// 0.001 ETH// Eitherdepot.exchangeEtherForSynths.value(etherAmount)();// or simplydepot.transfer(etherAmount);}}