Synthetixio / synthetix

Synthetix Solidity smart contracts
https://synthetix.io/
MIT License
1.2k stars 594 forks source link

Gas Opt - issueSynths / burnSynths directly via issuer contract instead of Synthetix contract. #428

Open jacko125 opened 4 years ago

jacko125 commented 4 years ago

Currently Synthetix contract is permissioned to invoke issueSynths and burnSynths on issuer.sol. However these functions can be invoked directly via the issuer contract instead of jumping through Synthetix first.

Synthetix.sol

function issueSynths(uint amount) external optionalProxy {
    return issuer().issueSynths(messageSender, amount);
}

function issueMaxSynths() external optionalProxy {
    return issuer().issueMaxSynths(messageSender);
}

function burnSynths(uint amount) external optionalProxy {
    return issuer().burnSynths(messageSender, amount);
}

issuer.sol

function issueSynths(address from, uint amount)
    external
    onlySynthetix
// No need to check if price is stale, as it is checked in issuableSynths.
{

Remove or override functions for access direct via issuer.sol

modifier onlySynthetix() {
    require(msg.sender == address(synthetix()), "Issuer: Only the synthetix contract can perform this action");
    _;
}
jjgonecrypto commented 4 years ago

The only problem with this is breaking any existing integrations - do we want to go this direction?