Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
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
3 changes: 3 additions & 0 deletions .solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,5 +8,8 @@ module.exports = {
'lib/AddressArrayUtils.sol',
'mocks',
'external',
// https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#why-are-send-and-transfer-throwing
'supplementary/PayableExchangeIssue.sol' // Transfer functions cannot be properly tested. See link above.

],
};
15 changes: 15 additions & 0 deletions contracts/core/interfaces/ICore.sol
Original file line number Diff line number Diff line change
Expand Up @@ -113,6 +113,21 @@ interface ICore {
)
external;

/**
* Issues a specified Set for a specified quantity to the recipient
* using the caller's components from the wallet and vault.
*
* @param _recipient Address to issue to
* @param _set Address of the Set to issue
* @param _quantity Number of tokens to issue
*/
function issueTo(
address _recipient,
address _set,
uint256 _quantity
)
external;

/**
* Converts user's components into Set Tokens held directly in Vault instead of user's account
*
Expand Down
34 changes: 34 additions & 0 deletions contracts/core/interfaces/IExchangeIssueModule.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
/*
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;
pragma experimental "ABIEncoderV2";

import { ExchangeIssueLibrary } from "../lib/ExchangeIssueLibrary.sol";

/**
* @title IExchangeIssueModule
* @author Set Protocol
*
* Interface for executing orders and issuing a Set
*/
interface IExchangeIssueModule {
function exchangeIssue(
ExchangeIssueLibrary.ExchangeIssueParams _exchangeIssueData,
bytes _orderData
)
public;
}
10 changes: 10 additions & 0 deletions contracts/core/interfaces/ISetToken.sol
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,16 @@ interface ISetToken {
view
returns(uint256[]);

/*
* Get the unit shares of the rebalancing Set
*
* @return unitShares Unit Shares of the base Set
*/
function unitShares()
external
view
returns(uint256);

/*
* Checks to make sure token is component of Set
*
Expand Down
38 changes: 38 additions & 0 deletions contracts/core/lib/ExchangeIssueLibrary.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
/*
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;
pragma experimental "ABIEncoderV2";


/**
* @title ExchangeIssueLibrary
* @author Set Protocol
*
* This library contains functions and structs to assist with parsing exchange issue data
*/
library ExchangeIssueLibrary {
// ============ Structs ============

struct ExchangeIssueParams {
address setAddress;
address paymentToken;
uint256 paymentTokenAmount;
uint256 quantity;
address[] requiredComponents;
uint256[] requiredComponentAmounts;
}
}
20 changes: 5 additions & 15 deletions contracts/core/modules/ExchangeIssueModule.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ pragma experimental "ABIEncoderV2";
import { ReentrancyGuard } from "openzeppelin-solidity/contracts/utils/ReentrancyGuard.sol";
import { SafeMath } from "openzeppelin-solidity/contracts/math/SafeMath.sol";

import { ExchangeIssueLibrary } from "../lib/ExchangeIssueLibrary.sol";
import { ExchangeHeaderLibrary } from "../lib/ExchangeHeaderLibrary.sol";
import { ExchangeValidationLibrary } from "../lib/ExchangeValidationLibrary.sol";
import { ExchangeWrapperLibrary } from "../lib/ExchangeWrapperLibrary.sol";
Expand All @@ -42,17 +43,6 @@ contract ExchangeIssueModule is
{
using SafeMath for uint256;

/* ============ Struct ============ */

struct ExchangeIssue {
address setAddress;
address paymentToken;
uint256 paymentTokenAmount;
uint256 quantity;
address[] requiredComponents;
uint256[] requiredComponentAmounts;
}

/* ============ Events ============ */

event LogExchangeIssue(
Expand Down Expand Up @@ -94,7 +84,7 @@ contract ExchangeIssueModule is
* @param _orderData Bytes array containing the exchange orders to execute
*/
function exchangeIssue(
ExchangeIssue memory _exchangeIssueData,
ExchangeIssueLibrary.ExchangeIssueParams memory _exchangeIssueData,
bytes _orderData
)
public
Expand Down Expand Up @@ -227,7 +217,7 @@ contract ExchangeIssueModule is
* @param _paymentTokenAmountUsed Amount of maker token used to source tokens
*/
function assertPostExchangeTokenBalances(
ExchangeIssue _exchangeIssueData,
ExchangeIssueLibrary.ExchangeIssueParams _exchangeIssueData,
uint256[] _requiredBalances,
uint256 _paymentTokenAmountUsed
)
Expand Down Expand Up @@ -256,7 +246,7 @@ contract ExchangeIssueModule is
* @return uint256[] Expected token balances after order execution
*/
function calculateRequiredTokenBalances(
ExchangeIssue _exchangeIssueData
ExchangeIssueLibrary.ExchangeIssueParams _exchangeIssueData
)
private
view
Expand Down Expand Up @@ -287,7 +277,7 @@ contract ExchangeIssueModule is
* @param _exchangeIssueData Exchange Issue object containing exchange data
*/
function validateExchangeIssue(
ExchangeIssue _exchangeIssueData
ExchangeIssueLibrary.ExchangeIssueParams _exchangeIssueData
)
private
view
Expand Down
36 changes: 36 additions & 0 deletions contracts/lib/IWETH.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
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;


/**
* @title WETH Interface
* @author Set Protocol
*
* Interface for Wrapped Ether. This interface allows for interaction for wrapped ether's deposit and withdrawal
* functionality.
*/
interface IWETH {
function deposit()
external
payable;

function withdraw(
uint256 wad
)
external;
}
14 changes: 14 additions & 0 deletions contracts/mocks/tokens/WethMock.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
pragma solidity 0.4.25;

import "canonical-weth/contracts/WETH9.sol";

contract WethMock is WETH9 {
constructor(
address initialAccount,
uint256 initialBalance
)
public
{
balanceOf[initialAccount] = initialBalance;
}
}
Loading