diff --git a/contracts/connectors/synthetix.sol b/contracts/connectors/synthetix.sol index 66ffd2b..ce91ebb 100644 --- a/contracts/connectors/synthetix.sol +++ b/contracts/connectors/synthetix.sol @@ -13,22 +13,16 @@ interface IStakingRewards { } contract SynthetixStakingHelper is DSMath, Stores { - IStakingRewards stakingContract; - - constructor(address _synthetixStakingAddr) public { - stakingContract = IStakingRewards(_synthetixStakingAddr); - } - /** * @dev Return Synthetix staking pool address. */ - function getSynthetixStakingAddr(address token) virtual internal { + function getSynthetixStakingAddr(address token) virtual internal returns (address) { if (token == address(0x075b1bb99792c9E1041bA13afEf80C91a1e70fB3)){ // SBTC - stakingContract = IStakingRewards(0x13C1542A468319688B89E323fe9A3Be3A90EBb27); + return 0x13C1542A468319688B89E323fe9A3Be3A90EBb27; } else if (token == address(0xC25a3A3b969415c80451098fa907EC722572917F)){ // SUSD - stakingContract = IStakingRewards(0xDCB6A51eA3CA5d3Fd898Fd6564757c7aAeC3ca92); + return 0xDCB6A51eA3CA5d3Fd898Fd6564757c7aAeC3ca92; } else { revert("token-not-found"); } @@ -44,8 +38,6 @@ contract SynthetixStakingHelper is DSMath, Stores { contract SynthetixStaking is SynthetixStakingHelper { - constructor(address _synthetixStakingAddr) SynthetixStakingHelper(_synthetixStakingAddr) public {} - // Events event LogDeposit( address token, @@ -79,7 +71,7 @@ contract SynthetixStaking is SynthetixStakingHelper { uint setId ) external payable { uint _amt = getUint(getId, amt); - getSynthetixStakingAddr(token); + IStakingRewards stakingContract = IStakingRewards(getSynthetixStakingAddr(token)); TokenInterface _stakeToken = TokenInterface(token); _amt = _amt == uint(-1) ? _stakeToken.balanceOf(address(this)) : _amt; @@ -109,7 +101,7 @@ contract SynthetixStaking is SynthetixStakingHelper { uint setIdReward ) external payable { uint _amt = getUint(getId, amt); - getSynthetixStakingAddr(token); + IStakingRewards stakingContract = IStakingRewards(getSynthetixStakingAddr(token)); TokenInterface snxToken = TokenInterface(getSnxAddr()); uint intialBal = snxToken.balanceOf(address(this)); @@ -146,7 +138,7 @@ contract SynthetixStaking is SynthetixStakingHelper { address token, uint setId ) external payable { - getSynthetixStakingAddr(token); + IStakingRewards stakingContract = IStakingRewards(getSynthetixStakingAddr(token)); TokenInterface snxToken = TokenInterface(getSnxAddr()); uint intialBal = snxToken.balanceOf(address(this)); @@ -165,7 +157,4 @@ contract SynthetixStaking is SynthetixStakingHelper { contract ConnectSynthetixStaking is SynthetixStaking { string public name = "synthetix-staking-v1"; - - constructor(address _synthetixStakingAddr) SynthetixStaking(_synthetixStakingAddr) public {} - } diff --git a/contracts/tests/MockSynthetix.sol b/contracts/tests/MockSynthetix.sol index 9afed3a..80fe315 100644 --- a/contracts/tests/MockSynthetix.sol +++ b/contracts/tests/MockSynthetix.sol @@ -5,11 +5,13 @@ import { ConnectSynthetixStaking } from "../connectors/synthetix.sol"; contract MockSynthetixStaking is ConnectSynthetixStaking{ address public synthetixStakingAddr; - constructor(address _synthetixStakingAddr) ConnectSynthetixStaking(_synthetixStakingAddr) public { + constructor(address _synthetixStakingAddr) public { synthetixStakingAddr = _synthetixStakingAddr; } - function getSynthetixStakingAddr(address token) override internal{} + function getSynthetixStakingAddr(address token) override internal returns (address) { + return synthetixStakingAddr; + } function emitEvent(bytes32 eventCode, bytes memory eventData) override internal {} diff --git a/migrations/2_deploy_connector.js b/migrations/2_deploy_connector.js index c096106..63dbb27 100644 --- a/migrations/2_deploy_connector.js +++ b/migrations/2_deploy_connector.js @@ -1,7 +1,7 @@ // const CurveProtocol = artifacts.require("CurveProtocol"); // const ConnectSBTCCurve = artifacts.require("ConnectSBTCCurve"); -const MockContract = artifacts.require("MockContract"); -const MockSynthetixStaking = artifacts.require("MockSynthetixStaking"); +// const MockContract = artifacts.require("MockContract"); +// const MockSynthetixStaking = artifacts.require("MockSynthetixStaking"); // const ConnectSynthetixStaking = artifacts.require("ConnectSynthetixStaking"); // const connectorsABI = require("../test/abi/connectors.json"); @@ -11,10 +11,10 @@ const MockSynthetixStaking = artifacts.require("MockSynthetixStaking"); module.exports = async function(deployer) { // deployer.deploy(CurveProtocol); // let connectorLength = await connectorInstance.methods.connectorLength().call(); - deployer.deploy(MockContract).then(function () { - // return deployer.deploy(MockSynthetixStaking, MockContract.address, 1, +connectorLength + 1); - // return deployer.deploy(ConnectSynthetixStaking, MockContract.address); - return deployer.deploy(MockSynthetixStaking, MockContract.address); - }); + // deployer.deploy(MockContract).then(function () { + // // return deployer.deploy(MockSynthetixStaking, MockContract.address, 1, +connectorLength + 1); + // // return deployer.deploy(ConnectSynthetixStaking, MockContract.address); + // return deployer.deploy(MockSynthetixStaking, MockContract.address); + // }); };