Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Reserve supports multiple exchanges #6299

Merged
merged 44 commits into from
Jan 17, 2021
Merged

Conversation

martinvol
Copy link
Contributor

@martinvol martinvol commented Dec 18, 2020

Description

Allows the reserve to allow multiple exchanges to pull assets without a limit.

Added governable variables:

isExchangeSpender

Other changes

some more testing

Tested

Unit test added.

Related issues

Backwards compatibility

During the migrations, an exchange needs to be set.

@martinvol martinvol force-pushed the martinvol/multipleExchangeSpenders branch from d521aa5 to 1bd660c Compare January 4, 2021 12:21
@nategraf nategraf removed their request for review January 4, 2021 18:26
@martinvol martinvol requested a review from nambrot January 5, 2021 15:33
Copy link
Contributor

@nambrot nambrot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great job! Just minor comments

packages/protocol/test/stability/reserve.ts Outdated Show resolved Hide resolved
packages/protocol/test/stability/reserve.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@yorhodes yorhodes left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🚀

@@ -311,6 +311,11 @@ contract Reserve is
emit SpenderRemoved(spender);
}

function _isAllowedToSpendExchange(address spender) private view returns (bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why not making this public?

await assertRevert(reserve.removeExchangeSpender(nonOwner, 0, { from: nonOwner }))
})

// TODO should allow exchange
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove TODO?

@martinvol martinvol added the automerge Have PR merge automatically when checks pass label Jan 17, 2021
@mergify mergify bot merged commit 9a8dcf0 into master Jan 17, 2021
@mergify mergify bot deleted the martinvol/multipleExchangeSpenders branch January 17, 2021 04:15
@martinvol martinvol restored the martinvol/multipleExchangeSpenders branch January 26, 2021 15:06

/**
* @notice Takes away an address's permission to spend Reserve funds without limits.
* @param spender The address that is to be no longer allowed to spend Reserve funds.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing parameter in natspec

emit SpenderRemoved(spender);
}

function isAllowedToSpendExchange(address spender) public view returns (bool) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Missing natspec

emit ExchangeSpenderRemoved(spender);
}

function getExchangeSpenders() public view returns (address[] memory) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we remove this? exchangeSpenderAddresses is a public variable so this is redundant

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like this is only used for testing-- think it's worth removing? iirc there isn't a clean way of getting exchangeSpenderAddresses.length from web3 to properly iterate through. Because it's already in there for CR3 I don't think we would gain much now from removing it, if anything it would introduce backward incompatibility

emit SpenderRemoved(spender);
}

function isAllowedToSpendExchange(address spender) public view returns (bool) {
return
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this function necessary? Please include a comment explaining why isExchangeSpender is not enough, and the conditions that need to be met for this function to be deprecated

await reserve.addExchangeSpender(exchangeAddress)
await reserve.addExchangeSpender(accounts[1])
const spenders = await reserve.getExchangeSpenders()
assert.equal(spenders.length, 2)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You should be able to check lists with the same contents in a single assert statement.

})

it('only allows owner', async () => {
await assertRevert(reserve.removeExchangeSpender(nonOwner, 0, { from: nonOwner }))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should the first argument be exchangeSpenderAddress?

})
})

it('has the right list of exchange spenders', async () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed?

@asaj
Copy link
Contributor

asaj commented Jan 29, 2021

Can you flesh out the PR description a bit more?

@asaj asaj mentioned this pull request Jan 29, 2021
3 tasks
@aaronmgdr aaronmgdr deleted the martinvol/multipleExchangeSpenders branch August 16, 2023 03:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
automerge Have PR merge automatically when checks pass
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Reserve.sol should be able to send Celo to multiple exchanges
5 participants