Synthetixio / synthetix-js

[deprecated] Please use https://github.com/Synthetixio/js-monorepo/tree/master/packages/contracts-interface
63 stars 43 forks source link

`snxjs.Depot.exchangeEtherForSNX` actually exchanges for sUSD #37

Open oleiba opened 4 years ago

oleiba commented 4 years ago

When doing:

snxjs.Depot.exchangeEtherForSNX({value: snxjs.util.parseEther(etherValue)})

what actually happens is exchanging ether for sUSD. I assume this is because the actual function in the contract which is called is the fallback function, which calls exchangeEtherForSynths (which exchanges for sUSD):

image

Instead - this function should eventually call the contract's fallback function which is exchangeEtherForSynthetix (which exchange for sUSD):

image

jjgonecrypto commented 4 years ago

Hi Oleiba, sorry for the confusion. We recently changed the code for Depot.sol in https://github.com/Synthetixio/synthetix/commit/4f87c3900f078b971e413f78596dc6ea9d5046de#diff-e2700c3c82fda0ce2018bb4e569ad9a0 (the Procyon release of v2.17.x). However, the existing Depot wasn't replaced as the existing Depot contract (https://contracts.synthetix.io/Depot) still has existing sUSD funds in it we need to be drained first.

As such, the Depot code in SynthetixJs is out of sync with the actual deployed version of Depot. This is an omission on our part - we didn't know of anyone automating against it and didn't think to make mention of this impact.

While the Depot is one way to get SNX, it's now deprecated in its current form and needs to be updated in a future release of Synthetix. In the meantime, can I suggest using the Uniswap SNX pool instead - https://uniswap.info/token/0xc011a73ee8576fb46f5e1c5751ca3b9fe0af2a6f. You can send the Uniswap SNX exchange ETH for SNX by invoking ethToTokenSwapInput on https://etherscan.io/address/0x3958b4ec427f8fa24eb60f42821760e88d485f7f/ - as per this example: https://etherscan.io/tx/0x1cc996a1073db604c07710cf3f76a82fe2df3224c5ed92ecdb805fb52544a894

Regardless I'll keep this open till we can remove the spurious entry in SynthetixJs.Depot.

cc @hav-noms