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

feat: change recoveryRate to uint256 #3

Merged
merged 2 commits into from
Oct 28, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
42 changes: 28 additions & 14 deletions EIPS/eip-5827.md
Original file line number Diff line number Diff line change
Expand Up @@ -33,14 +33,14 @@ pragma solidity ^0.8.0;

interface IERC5827 /* is ERC20, ERC165 */ {
/*
* Note: the ERC-165 identifier for this interface is 0xT0D0.
* 0xT0D0 ===
* bytes4(keccak256('approveRenewable(address,uint256,uint192)')) ^
* bytes4(keccak256('renewableAllowance(address,address)')) ^
* bytes4(keccak256('approve(address,uint256)') ^
* bytes4(keccak256('transferFrom(address,address,uint256)') ^
* bytes4(keccak256('allowance(address,address)') ^
*/
* Note: the ERC-165 identifier for this interface is 0x93cd7af6.
* 0x93cd7af6 ===
* bytes4(keccak256('approveRenewable(address,uint256,uint256)')) ^
* bytes4(keccak256('renewableAllowance(address,address)')) ^
* bytes4(keccak256('approve(address,uint256)') ^
* bytes4(keccak256('transferFrom(address,address,uint256)') ^
* bytes4(keccak256('allowance(address,address)') ^
*/

/*
* @notice Emitted when a new renewable allowance is set.
Expand All @@ -53,7 +53,7 @@ interface IERC5827 /* is ERC20, ERC165 */ {
address indexed _owner,
address indexed _spender,
uint256 _value,
uint192 _recoveryRate
uint256 _recoveryRate
);

/*
Expand All @@ -67,7 +67,7 @@ interface IERC5827 /* is ERC20, ERC165 */ {
function approveRenewable(
address _spender,
uint256 _value,
uint192 _recoveryRate
uint256 _recoveryRate
) external returns (bool success);

/// Overridden EIP-20 functions
Expand All @@ -80,7 +80,7 @@ interface IERC5827 /* is ERC20, ERC165 */ {
function renewableAllowance(address _owner, address _spender)
external
view
returns (uint256 amount, uint192 recoveryRate);
returns (uint256 amount, uint256 recoveryRate);

/*
* @notice Grants a (non-increasing) allowance of _value to _spender.
Expand Down Expand Up @@ -122,14 +122,21 @@ Base method `approve(address _spender, uint256 _value)` MUST set `recoveryRate`

Both `allowance()` and `transferFrom()` MUST be updated to include allowance recovery logic.

`_value` within `approveRenewable(address _spender, uint256 _value, uint192 _recoveryRate)` method sets both initial allowance amount and the maximum allowance limit it can regain to.
`_value` within `approveRenewable(address _spender, uint256 _value, uint256 _recoveryRate)` method sets both initial allowance amount and the maximum allowance limit it can regain to.

### Additional interfaces

Existing EIP-20 tokens can delegate allowance enforcement to a proxy contract that implements this specification. Additional query function exist to get the underlying EIP-20 token.

```solidity
interface IERC5827Proxy {

/*
* Note: the ERC-165 identifier for this interface is 0xc55dae63.
* 0xc55dae63 ===
* bytes4(keccak256('baseToken()')
*/

/*
* @notice Get the underlying base token being proxied.
* @returns baseToken address of the base token
Expand All @@ -143,6 +150,13 @@ Automatic Expiration
```solidity
interface IERC5827Expirable {

/*
* Note: the ERC-165 identifier for this interface is 0x46c5b619.
* 0x46c5b619 ===
* bytes4(keccak256('approveRenewable(address,uint256,uint256,uint64)')) ^
* bytes4(keccak256('renewableAllowance(address,address)')) ^
*/

/*
* @notice Grants an allowance of `_value` to `_spender` initially, which recovers over time based on `_recoveryRate` up to a limit of `_value`. The allowance expires at `_expiration`.
* SHOULD throw when `_recoveryRate` is larger than `_value`.
Expand All @@ -155,7 +169,7 @@ interface IERC5827Expirable {
function approveRenewable(
address _spender,
uint256 _value,
uint192 _recoveryRate,
uint256 _recoveryRate,
uint64 _expiration
) external returns (bool success);

Expand All @@ -168,7 +182,7 @@ interface IERC5827Expirable {
function renewableAllowance(address _owner, address _spender)
external
view
returns (uint256 amount, uint192 recoveryRate, uint64 expiration);
returns (uint256 amount, uint256 recoveryRate, uint64 expiration);
}
```

Expand Down