Skip to content

Commit

Permalink
update Synth.sol
Browse files Browse the repository at this point in the history
  • Loading branch information
barrasso committed Mar 28, 2024
1 parent 364e542 commit da0ca3f
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 18 deletions.
23 changes: 6 additions & 17 deletions contracts/Synth.sol
Original file line number Diff line number Diff line change
Expand Up @@ -93,21 +93,13 @@ contract Synth is Owned, IERC20, ExternStateToken, MixinResolver, ISynth {
return super._internalTransfer(messageSender, to, value);
}

function transferFrom(
address from,
address to,
uint value
) public onlyProxyOrInternal returns (bool) {
function transferFrom(address from, address to, uint value) public onlyProxyOrInternal returns (bool) {
_ensureCanTransfer(from, value);

return _internalTransferFrom(from, to, value);
}

function transferFromAndSettle(
address from,
address to,
uint value
) public onlyProxyOrInternal returns (bool) {
function transferFromAndSettle(address from, address to, uint value) public onlyProxyOrInternal returns (bool) {
// Exchanger.settle() ensures synth is active
(, , uint numEntriesSettled) = exchanger().settle(from, currencyKey);

Expand Down Expand Up @@ -240,11 +232,7 @@ contract Synth is Owned, IERC20, ExternStateToken, MixinResolver, ISynth {

/* ========== INTERNAL FUNCTIONS ========== */

function _internalTransferFrom(
address from,
address to,
uint value
) internal returns (bool) {
function _internalTransferFrom(address from, address to, uint value) internal returns (bool) {
// Skip allowance update in case of infinite allowance
if (tokenState.allowance(from, messageSender) != uint(-1)) {
// Reduce the allowance by the amount we're transferring.
Expand All @@ -270,7 +258,7 @@ contract Synth is Owned, IERC20, ExternStateToken, MixinResolver, ISynth {
_;
}

modifier onlyProxyOrInternal {
modifier onlyProxyOrInternal() {
_onlyProxyOrInternal();
_;
}
Expand All @@ -291,11 +279,12 @@ contract Synth is Owned, IERC20, ExternStateToken, MixinResolver, ISynth {
/// which isn't supported due to SIP-238 for other callers
function _isInternalTransferCaller(address caller) internal view returns (bool) {
// These entries are not required or cached in order to allow them to not exist (==address(0))
// e.g. due to not being available on L2 or at some future point in time.
// e.g. due to not being available on L2 or at some future point time.
return
// ordered to reduce gas for more frequent calls
caller == resolver.getAddress("CollateralShort") ||
// not used frequently
caller == resolver.getAddress("DynamicSynthRedeemer") ||
caller == resolver.getAddress("SynthRedeemer") ||
caller == resolver.getAddress("WrapperFactory") || // transfer not used by users
// legacy
Expand Down
8 changes: 7 additions & 1 deletion test/contracts/Synth.js
Original file line number Diff line number Diff line change
Expand Up @@ -205,12 +205,18 @@ contract('Synth', async accounts => {
);
});

it('transfer does not revert from a whitelisted contract', async () => {
it('transfer does not revert from whitelisted contracts', async () => {
// set owner as SynthRedeemer
await addressResolver.importAddresses(['SynthRedeemer'].map(toBytes32), [owner], {
from: owner,
});
await sUSDImpl.transfer(account1, amount, { from: owner });

// set owner as DynamicSynthRedeemer
await addressResolver.importAddresses(['DynamicSynthRedeemer'].map(toBytes32), [owner], {
from: owner,
});
await sUSDImpl.transfer(account1, amount, { from: owner });
});
});
});
Expand Down

0 comments on commit da0ca3f

Please sign in to comment.