diff --git a/contracts/Synth.sol b/contracts/Synth.sol index 8f57cb313d..d3bbb3c4af 100644 --- a/contracts/Synth.sol +++ b/contracts/Synth.sol @@ -289,6 +289,14 @@ contract Synth is ExternStateToken { emitBurned(account, amount); } + // Allow owner to set the total supply on import. + function setTotalSupply(uint amount) + external + optionalProxy_onlyOwner + { + totalSupply = amount; + } + // Allow synthetix to trigger a token fallback call from our synths so users get notified on // exchange as well as transfer function triggerTokenFallbackIfNeeded(address sender, address recipient, uint amount) diff --git a/contracts/SynthetixState.sol b/contracts/SynthetixState.sol index c32df51709..302cf8e829 100644 --- a/contracts/SynthetixState.sol +++ b/contracts/SynthetixState.sol @@ -71,6 +71,9 @@ contract SynthetixState is State, LimitedSetup { // Global debt pool tracking uint[] public debtLedger; + // Import state + uint public importedXDRAmount; + // A quantity of synths greater than this ratio // may not be issued against a given value of SNX. uint public issuanceRatio = SafeDecimalMath.unit() / 5; @@ -210,12 +213,15 @@ contract SynthetixState is State, LimitedSetup { // What is the value of the requested debt in XDRs? uint xdrValue = synthetix.effectiveValue("sUSD", amount, "XDR"); - // What is the value of all issued synths of the system (priced in XDRs)? - uint totalDebtIssued = synthetix.totalIssuedSynths("XDR"); + // What is the value that we've previously imported? + uint totalDebtIssued = importedXDRAmount; // What will the new total be including the new value? uint newTotalDebtIssued = xdrValue.add(totalDebtIssued); + // Save that for the next import. + importedXDRAmount = newTotalDebtIssued; + // What is their percentage (as a high precision int) of the total debt? uint debtPercentage = xdrValue.divideDecimalRoundPrecise(newTotalDebtIssued);