This repository has been archived by the owner on Jan 18, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
First pass at updating contracts to modular format. Further testing r… (
#287) * First pass at updating contracts to modular format. Further testing required. * Removed .only * Finished test coverage. * Remove .onlys * Added modules mapping to core to track approved modules and limit access to module only functions in core. * Formatting and removed deposit and withdraw from moduleInteration, with associated tests. * Removed module address setting and querying on rebalancingSetTokenFactory and exchangeWrappers. Added redeemModule. * Fixed some missing dependencies. * Added redeemModule tests. Updated redeemInternal to specify a burn address and increment address to meet all the burning variations. * Removed Ownable dependencies, small comment changes.
- Loading branch information
1 parent
9fe5475
commit 15af3fd
Showing
34 changed files
with
1,757 additions
and
227 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 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
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
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,159 @@ | ||
/* | ||
Copyright 2018 Set Labs Inc. | ||
Licensed under the Apache License, Version 2.0 (the "License"); | ||
you may not use this file except in compliance with the License. | ||
You may obtain a copy of the License at | ||
http://www.apache.org/licenses/LICENSE-2.0 | ||
Unless required by applicable law or agreed to in writing, software | ||
distributed under the License is distributed on an "AS IS" BASIS, | ||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
See the License for the specific language governing permissions and | ||
limitations under the License. | ||
*/ | ||
|
||
pragma solidity 0.4.25; | ||
|
||
import { ReentrancyGuard } from "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol"; | ||
import { CoreState } from "../lib/CoreState.sol"; | ||
import { ICoreAccounting } from "../interfaces/ICoreAccounting.sol"; | ||
import { ICoreIssuance } from "../interfaces/ICoreIssuance.sol"; | ||
|
||
/** | ||
* @title CoreModularInteraction | ||
* @author Set Protocol | ||
* | ||
* Extension used to expose internal accounting functions to module | ||
*/ | ||
|
||
|
||
contract CoreModuleInteraction is | ||
ICoreAccounting, | ||
ICoreIssuance, | ||
CoreState, | ||
ReentrancyGuard | ||
{ | ||
/** | ||
* Exposes internal function that deposits multiple tokens to the vault, to system | ||
* modules. Quantities should be in the order of the addresses of the tokens being | ||
* deposited. | ||
* | ||
* @param _from Address to transfer tokens from | ||
* @param _to Address to credit for deposits | ||
* @param _tokens Array of the addresses of the tokens being deposited | ||
* @param _quantities Array of the amounts of tokens to deposit | ||
*/ | ||
function batchDepositModule( | ||
address _from, | ||
address _to, | ||
address[] _tokens, | ||
uint256[] _quantities | ||
) | ||
external | ||
{ | ||
// Require that only modules can call function | ||
require( | ||
state.validModules[msg.sender], | ||
"Core.batchDepositModule: Sender not recognized module" | ||
); | ||
|
||
batchDepositInternal( | ||
_from, | ||
_to, | ||
_tokens, | ||
_quantities | ||
); | ||
} | ||
|
||
/** | ||
* Exposes internal function that withdraws multiple tokens from the vault, to system | ||
* modules. Quantities should be in the order of the addresses of the tokens being withdrawn. | ||
* | ||
* @param _from Address to decredit for withdrawals | ||
* @param _to Address to transfer tokens to | ||
* @param _tokens Array of the addresses of the tokens being withdrawn | ||
* @param _quantities Array of the amounts of tokens to withdraw | ||
*/ | ||
function batchWithdrawModule( | ||
address _from, | ||
address _to, | ||
address[] _tokens, | ||
uint256[] _quantities | ||
) | ||
external | ||
{ | ||
// Require that only modules can call function | ||
require( | ||
state.validModules[msg.sender], | ||
"Core.batchWithdrawModule: Sender not recognized module" | ||
); | ||
|
||
batchWithdrawInternal( | ||
_from, | ||
_to, | ||
_tokens, | ||
_quantities | ||
); | ||
} | ||
|
||
/** | ||
* Expose internal function that exchanges components for Set tokens, | ||
* accepting any owner, to system modules | ||
* | ||
* @param _owner Address to issue tokens to | ||
* @param _set Address of the Set to issue | ||
* @param _quantity Number of tokens to issue | ||
*/ | ||
function issueModule( | ||
address _owner, | ||
address _set, | ||
uint256 _quantity | ||
) | ||
external | ||
{ | ||
// Require that only modules can call function | ||
require( | ||
state.validModules[msg.sender], | ||
"Core.issueModule: Sender not recognized module" | ||
); | ||
|
||
issueInternal( | ||
_owner, | ||
_set, | ||
_quantity | ||
); | ||
} | ||
|
||
/** | ||
* Expose internal function that exchanges Set tokens for components, | ||
* accepting any owner, to system modules | ||
* | ||
* @param _burnAddress Address to burn token from | ||
* @param _incrementAddress Address to increment component tokens to | ||
* @param _set Address of the Set to redeem | ||
* @param _quantity Number of tokens to redeem | ||
*/ | ||
function redeemModule( | ||
address _burnAddress, | ||
address _incrementAddress, | ||
address _set, | ||
uint256 _quantity | ||
) | ||
external | ||
{ | ||
// Require that only modules can call function | ||
require( | ||
state.validModules[msg.sender], | ||
"Core.redeemModule: Sender not recognized module" | ||
); | ||
|
||
redeemInternal( | ||
_burnAddress, | ||
_incrementAddress, | ||
_set, | ||
_quantity | ||
); | ||
} | ||
} |
Oops, something went wrong.