-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #111 from CirclesUBI/20240222-group-mint
group mint
- Loading branch information
Showing
14 changed files
with
521 additions
and
62 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,64 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
pragma solidity >=0.8.13; | ||
|
||
import "./IMintPolicy.sol"; | ||
import "./Definitions.sol"; | ||
|
||
abstract contract MintPolicy is IMintPolicy { | ||
// External functions | ||
|
||
/** | ||
* @notice Simple mint policy that always returns true | ||
*/ | ||
function beforeMintPolicy( | ||
address, /*_minter*/ | ||
address, /*_group*/ | ||
address[] calldata, /*_collateral*/ | ||
uint256[] calldata, /*_amounts*/ | ||
bytes calldata /*_data*/ | ||
) external virtual override returns (bool) { | ||
return true; | ||
} | ||
|
||
/** | ||
* @notice Simple burn policy that always returns true | ||
*/ | ||
function beforeBurnPolicy(address, address, uint256, bytes calldata) external virtual override returns (bool) { | ||
return true; | ||
} | ||
|
||
/** | ||
* @notice Simple redeem policy that returns the redemption ids and values as requested in the data | ||
* @param _data Optional data bytes passed to redeem policy | ||
*/ | ||
function beforeRedeemPolicy( | ||
address, /*_operator*/ | ||
address, /*_redeemer*/ | ||
address, /*_group*/ | ||
uint256, /*_value*/ | ||
bytes calldata _data | ||
) | ||
external | ||
virtual | ||
override | ||
returns ( | ||
uint256[] memory _ids, | ||
uint256[] memory _values, | ||
uint256[] memory _burnIds, | ||
uint256[] memory _burnValues | ||
) | ||
{ | ||
// simplest policy is to return the collateral as the caller requests it in data | ||
BaseMintPolicyDefinitions.BaseRedemptionPolicy memory redemption = | ||
abi.decode(_data, (BaseMintPolicyDefinitions.BaseRedemptionPolicy)); | ||
|
||
// and no collateral gets burnt upon redemption | ||
_burnIds = new uint256[](0); | ||
_burnValues = new uint256[](0); | ||
|
||
// standard treasury checks whether the total sums add up to the amount of group Circles redeemed | ||
// so we can simply decode and pass the request back to treasury. | ||
// The redemption will fail if it does not contain (sufficient of) these Circles | ||
return (redemption.redemptionIds, redemption.redemptionValues, _burnIds, _burnValues); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
pragma solidity >=0.8.13; | ||
|
||
contract BaseMintPolicyDefinitions { | ||
// Type declarations | ||
|
||
/** | ||
* @notice Base redemption policy to user specify desired collateral to redeem | ||
*/ | ||
struct BaseRedemptionPolicy { | ||
uint256[] redemptionIds; | ||
uint256[] redemptionValues; | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,25 @@ | ||
// SPDX-License-Identifier: AGPL-3.0-only | ||
pragma solidity >=0.8.13; | ||
|
||
interface IMintPolicy { | ||
function beforeMintPolicy( | ||
address minter, | ||
address group, | ||
address[] calldata collateral, | ||
uint256[] calldata amounts, | ||
bytes calldata data | ||
) external returns (bool); | ||
|
||
function beforeRedeemPolicy(address operator, address redeemer, address group, uint256 value, bytes calldata data) | ||
external | ||
returns ( | ||
uint256[] memory redemptionIds, | ||
uint256[] memory redemptionValues, | ||
uint256[] memory burnIds, | ||
uint256[] memory burnValues | ||
); | ||
|
||
function beforeBurnPolicy(address burner, address group, uint256 value, bytes calldata data) | ||
external | ||
returns (bool); | ||
} |
Oops, something went wrong.