Skip to content
This repository was archived by the owner on Jan 18, 2023. It is now read-only.
Closed
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
2 changes: 1 addition & 1 deletion .solcover.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ module.exports = {
'mocks',
'external',
// https://github.com/sc-forks/solidity-coverage/blob/master/docs/faq.md#why-are-send-and-transfer-throwing
'supplementary/PayableExchangeIssuance.sol' // Transfer functions cannot be properly tested. See link above.
'supplementary/RebalancingSetExchangeIssuanceModule.sol' // Transfer functions cannot be properly tested. See link above.
],
};
6 changes: 3 additions & 3 deletions artifacts/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { LinearAuctionPriceCurve } from "./ts/LinearAuctionPriceCurve";
import { Median } from "./ts/Median";
import { NoDecimalTokenMock } from "./ts/NoDecimalTokenMock";
import { NoXferReturnTokenMock } from "./ts/NoXferReturnTokenMock";
import { PayableExchangeIssuance } from "./ts/PayableExchangeIssuance";
import { RebalancingSetExchangeIssuanceModule } from "./ts/RebalancingSetExchangeIssuanceModule";
import { RebalanceAuctionModule } from "./ts/RebalanceAuctionModule";
import { RebalancingHelperLibrary } from "./ts/RebalancingHelperLibrary";
import { RebalancingSetToken } from "./ts/RebalancingSetToken";
Expand Down Expand Up @@ -62,7 +62,7 @@ export {
MedianContract,
NoDecimalTokenMockContract,
NoXferReturnTokenMockContract,
PayableExchangeIssuanceContract,
RebalancingSetExchangeIssuanceModuleContract,
RebalanceAuctionModuleContract,
RebalancingSetTokenContract,
RebalancingSetTokenFactoryContract,
Expand Down Expand Up @@ -100,7 +100,7 @@ export {
Median,
NoDecimalTokenMock,
NoXferReturnTokenMock,
PayableExchangeIssuance,
RebalancingSetExchangeIssuanceModule,
RebalanceAuctionModule,
RebalancingHelperLibrary,
RebalancingSetToken,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,13 +32,13 @@ import { IWETH } from "../lib/IWETH.sol";


/**
* @title PayableExchangeIssuance
* @title RebalancingSetExchangeIssuanceModule
* @author Set Protocol
*
* The PayableExchangeIssuance supplementary smart contract allows a user to send Eth and atomically
* The RebalancingSetExchangeIssuanceModule supplementary smart contract allows a user to send Eth and atomically
* issue a rebalancing Set
*/
contract PayableExchangeIssuance is
contract RebalancingSetExchangeIssuanceModule is
ReentrancyGuard
{
using SafeMath for uint256;
Expand Down Expand Up @@ -77,7 +77,7 @@ contract PayableExchangeIssuance is
/* ============ Constructor ============ */

/**
* Constructor function for PayableExchangeIssuance
* Constructor function for RebalancingSetExchangeIssuanceModule
*
* @param _core The address of Core
* @param _transferProxy The address of the TransferProxy
Expand Down Expand Up @@ -125,7 +125,7 @@ contract PayableExchangeIssuance is
{
require( // coverage-disable-line
msg.sender == weth,
"PayableExchangeIssuance.fallback: Cannot receive ETH directly unless unwrapping WETH"
"RebalancingSetExchangeIssuanceModule.fallback: Cannot receive ETH directly unless unwrapping WETH"
);
}

Expand Down Expand Up @@ -239,6 +239,9 @@ contract PayableExchangeIssuance is
_orderData
);

// Loops through base set components and withdrawTo user if postive quantity


// Withdraw eth from WETH
uint256 wethBalance = ERC20Wrapper.balanceOf(
weth,
Expand Down Expand Up @@ -338,13 +341,13 @@ contract PayableExchangeIssuance is
// Require only 1 receive token
require(
_exchangeIssuanceParams.receiveTokens.length == 1,
"PayableExchangeIssuance.validateRedeemInputs: Only 1 Receive Token Allowed"
"RebalancingSetExchangeIssuanceModule.validateRedeemInputs: Only 1 Receive Token Allowed"
);

// Require receive token is weth
require(
weth == _exchangeIssuanceParams.receiveTokens[0],
"PayableExchangeIssuance.validateRedeemInputs: Receive token must be Weth"
"RebalancingSetExchangeIssuanceModule.validateRedeemInputs: Receive token must be Weth"
);

ISetToken rebalancingSet = ISetToken(_rebalancingSetAddress);
Expand All @@ -353,7 +356,7 @@ contract PayableExchangeIssuance is
address baseSet = rebalancingSet.getComponents()[0];
require(
baseSet == _exchangeIssuanceParams.setAddress,
"PayableExchangeIssuance.validateRedeemInputs: Base Set addresses must match"
"RebalancingSetExchangeIssuanceModule.validateRedeemInputs: Base Set addresses must match"
);

// Quantity of base Set must be the same as in exchange issuance params
Expand All @@ -364,7 +367,7 @@ contract PayableExchangeIssuance is
.div(rebalancingSetNaturalUnit);
require(
impliedBaseSetQuantity == _exchangeIssuanceParams.quantity,
"PayableExchangeIssuance.validateRedeemInputs: Base Set quantities must match"
"RebalancingSetExchangeIssuanceModule.validateRedeemInputs: Base Set quantities must match"
);
}
}
19 changes: 10 additions & 9 deletions deployments/stages/3_modules.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import {
ExchangeIssuanceModuleContract,
KyberNetworkWrapperContract,
LinearAuctionPriceCurveContract,
PayableExchangeIssuanceContract,
RebalancingSetExchangeIssuanceModuleContract,
RebalanceAuctionModuleContract,
RebalancingTokenIssuanceModuleContract,
ZeroExExchangeWrapperContract,
Expand All @@ -19,7 +19,7 @@ import { ERC20Wrapper } from '../../artifacts/ts/ERC20Wrapper';
import { ExchangeIssuanceModule } from '../../artifacts/ts/ExchangeIssuanceModule';
import { KyberNetworkWrapper } from '../../artifacts/ts/KyberNetworkWrapper';
import { LinearAuctionPriceCurve } from '../../artifacts/ts/LinearAuctionPriceCurve';
import { PayableExchangeIssuance } from '../../artifacts/ts/PayableExchangeIssuance';
import { RebalancingSetExchangeIssuanceModule } from '../../artifacts/ts/RebalancingSetExchangeIssuanceModule';
import { RebalanceAuctionModule } from '../../artifacts/ts/RebalanceAuctionModule';
import { RebalancingTokenIssuanceModule } from '../../artifacts/ts/RebalancingTokenIssuanceModule';
import { SetTokenLibrary } from '../../artifacts/ts/SetTokenLibrary';
Expand Down Expand Up @@ -53,7 +53,7 @@ export class ModulesStage implements DeploymentStageInterface {

await this.deployLinearAuctionPriceCurve();

await this.deployPayableExchangeIssuance();
await this.deployRebalancingSetExchangeIssuanceModule();
}

private async deployExchangeIssuanceModule(): Promise<ExchangeIssuanceModuleContract> {
Expand Down Expand Up @@ -131,12 +131,13 @@ export class ModulesStage implements DeploymentStageInterface {
return await RebalancingTokenIssuanceModuleContract.at(address, this._web3, TX_DEFAULTS);
}

private async deployPayableExchangeIssuance(): Promise<PayableExchangeIssuanceContract> {
const name = PayableExchangeIssuance.contractName;
private async deployRebalancingSetExchangeIssuanceModule():
Promise<RebalancingSetExchangeIssuanceModuleContract> {
const name = RebalancingSetExchangeIssuanceModule.contractName;
let address = await getContractAddress(name);

if (address) {
return await PayableExchangeIssuanceContract.at(address, this._web3, TX_DEFAULTS);
return await RebalancingSetExchangeIssuanceModuleContract.at(address, this._web3, TX_DEFAULTS);
}

const coreAddress = await getContractAddress(Core.contractName);
Expand All @@ -145,12 +146,12 @@ export class ModulesStage implements DeploymentStageInterface {
const erc20WrapperAddress = await getContractAddress(ERC20Wrapper.contractName);
const wethAddress = await findDependency(DEPENDENCY.WETH);

const originalByteCode = PayableExchangeIssuance.bytecode;
const originalByteCode = RebalancingSetExchangeIssuanceModule.bytecode;
const linkedByteCode = linkLibraries([
{ name: ERC20Wrapper.contractName, address: erc20WrapperAddress },
], originalByteCode);

const data = new this._web3.eth.Contract(PayableExchangeIssuance.abi).deploy({
const data = new this._web3.eth.Contract(RebalancingSetExchangeIssuanceModule.abi).deploy({
data: linkedByteCode,
arguments: [
coreAddress,
Expand All @@ -161,7 +162,7 @@ export class ModulesStage implements DeploymentStageInterface {
}).encodeABI();

address = await deployContract(data, this._web3, name);
return await PayableExchangeIssuanceContract.at(address, this._web3, TX_DEFAULTS);
return await RebalancingSetExchangeIssuanceModuleContract.at(address, this._web3, TX_DEFAULTS);
}

private async deployKyberWrapper(): Promise<KyberNetworkWrapperContract> {
Expand Down
18 changes: 12 additions & 6 deletions deployments/test/3_modules.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ import { Core } from '../../artifacts/ts/Core';
import { ExchangeIssuanceModule } from '../../artifacts/ts/ExchangeIssuanceModule';
import { KyberNetworkWrapper } from '../../artifacts/ts/KyberNetworkWrapper';
import { LinearAuctionPriceCurve } from '../../artifacts/ts/LinearAuctionPriceCurve';
import { PayableExchangeIssuance } from '../../artifacts/ts/PayableExchangeIssuance';
import { RebalancingSetExchangeIssuanceModule } from '../../artifacts/ts/RebalancingSetExchangeIssuanceModule';
import { RebalanceAuctionModule } from '../../artifacts/ts/RebalanceAuctionModule';
import { RebalancingTokenIssuanceModule } from '../../artifacts/ts/RebalancingTokenIssuanceModule';
import { ZeroExExchangeWrapper } from '../../artifacts/ts/ZeroExExchangeWrapper';
Expand Down Expand Up @@ -118,7 +118,10 @@ describe('Deployment: Modules', () => {

before(async () => {
const rebalanceAuctionAddress = await getContractAddress(RebalancingTokenIssuanceModule.contractName);
rebalanceTokenIssuanceModule = new web3.eth.Contract(RebalancingTokenIssuanceModule.abi, rebalanceAuctionAddress);
rebalanceTokenIssuanceModule = new web3.eth.Contract(
RebalancingTokenIssuanceModule.abi,
rebalanceAuctionAddress,
);
});

it('finds a valid contract at the address', async () => {
Expand Down Expand Up @@ -230,7 +233,7 @@ describe('Deployment: Modules', () => {
describe('Payable Exchange', () => {

/**
* Check if the PayableExchangeIssuance has been deployed with:
* Check if the RebalancingSetExchangeIssuanceModule has been deployed with:
* - Core
* - TransferProxy
* - ExchangeIssuanceModule
Expand All @@ -240,12 +243,15 @@ describe('Deployment: Modules', () => {
let payableExchangeWrapper;

before(async () => {
const payableExchangeAddress = await getContractAddress(PayableExchangeIssuance.contractName);
payableExchangeWrapper = new web3.eth.Contract(PayableExchangeIssuance.abi, payableExchangeAddress);
const payableExchangeAddress = await getContractAddress(RebalancingSetExchangeIssuanceModule.contractName);
payableExchangeWrapper = new web3.eth.Contract(
RebalancingSetExchangeIssuanceModule.abi,
payableExchangeAddress,
);
});

it('finds a valid contract at the address', async () => {
const code = await getContractCode(PayableExchangeIssuance.contractName, web3);
const code = await getContractCode(RebalancingSetExchangeIssuanceModule.contractName, web3);
expect(code.length).toBeGreaterThan(3);
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ import { BigNumberSetup } from '@utils/bigNumberSetup';
import {
CoreContract,
ExchangeIssuanceModuleContract,
PayableExchangeIssuanceContract,
RebalancingSetExchangeIssuanceModuleContract,
RebalancingSetTokenContract,
RebalancingSetTokenFactoryContract,
SetTokenContract,
Expand All @@ -26,7 +26,7 @@ import { ether } from '@utils/units';
import {
LogPayableExchangeIssue,
LogPayableExchangeRedeem,
} from '@utils/contract_logs/payableExchangeIssuance';
} from '@utils/contract_logs/rebalancingSetExchangeIssuanceModule';
import { expectRevertError } from '@utils/tokenAssertions';
import { getWeb3, getGasUsageInEth } from '@utils/web3Helper';
import {
Expand All @@ -46,14 +46,14 @@ const web3 = getWeb3();
const { expect } = chai;
const blockchain = new Blockchain(web3);
const Core = artifacts.require('Core');
const PayableExchangeIssuance = artifacts.require('PayableExchangeIssuance');
const RebalancingSetExchangeIssuanceModule = artifacts.require('RebalancingSetExchangeIssuanceModule');

const { SetProtocolTestUtils: SetTestUtils, SetProtocolUtils: SetUtils } = setProtocolUtils;
const setTestUtils = new SetTestUtils(web3);
const setUtils = new SetUtils(web3);
const { NULL_ADDRESS, ZERO } = SetUtils.CONSTANTS;

contract('PayableExchangeIssuance', accounts => {
contract('RebalancingSetExchangeIssuanceModule', accounts => {
const [
ownerAccount,
tokenPurchaser,
Expand All @@ -67,7 +67,7 @@ contract('PayableExchangeIssuance', accounts => {
let vault: VaultContract;
let rebalancingSetTokenFactory: RebalancingSetTokenFactoryContract;
let setTokenFactory: SetTokenFactoryContract;
let payableExchangeIssuance: PayableExchangeIssuanceContract;
let payableExchangeIssuance: RebalancingSetExchangeIssuanceModuleContract;
let weth: WethMockContract;

const coreWrapper = new CoreWrapper(ownerAccount, ownerAccount);
Expand All @@ -82,7 +82,7 @@ contract('PayableExchangeIssuance', accounts => {

before(async () => {
ABIDecoder.addABI(Core.abi);
ABIDecoder.addABI(PayableExchangeIssuance.abi);
ABIDecoder.addABI(RebalancingSetExchangeIssuanceModule.abi);

transferProxy = await coreWrapper.deployTransferProxyAsync();
vault = await coreWrapper.deployVaultAsync();
Expand All @@ -100,7 +100,7 @@ contract('PayableExchangeIssuance', accounts => {

weth = await erc20Wrapper.deployWrappedEtherAsync(ownerAccount);

payableExchangeIssuance = await coreWrapper.deployPayableExchangeIssuanceAsync(
payableExchangeIssuance = await coreWrapper.deployRebalancingSetExchangeIssuanceModuleAsync(
core.address,
transferProxy.address,
exchangeIssuanceModule.address,
Expand All @@ -118,7 +118,7 @@ contract('PayableExchangeIssuance', accounts => {

after(async () => {
ABIDecoder.removeABI(Core.abi);
ABIDecoder.removeABI(PayableExchangeIssuance.abi);
ABIDecoder.removeABI(RebalancingSetExchangeIssuanceModule.abi);
});

beforeEach(async () => {
Expand All @@ -132,8 +132,8 @@ contract('PayableExchangeIssuance', accounts => {
describe('#constructor', async () => {
const subjectCaller: Address = ownerAccount;

async function subject(): Promise<PayableExchangeIssuanceContract> {
return await coreWrapper.deployPayableExchangeIssuanceAsync(
async function subject(): Promise<RebalancingSetExchangeIssuanceModuleContract> {
return await coreWrapper.deployRebalancingSetExchangeIssuanceModuleAsync(
core.address,
transferProxy.address,
exchangeIssuanceModule.address,
Expand Down Expand Up @@ -506,7 +506,7 @@ contract('PayableExchangeIssuance', accounts => {
{ from: subjectCaller }
);

// Approve base component to PayableExchangeIssuance contract
// Approve base component to RebalancingSetExchangeIssuanceModule contract
await erc20Wrapper.approveTransfersAsync(
[rebalancingSetToken],
payableExchangeIssuance.address,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import ChaiSetup from '@utils/chaiSetup';
import { BigNumberSetup } from '@utils/bigNumberSetup';
import {
CoreContract,
PayableExchangeIssuanceContract,
RebalancingSetExchangeIssuanceModuleContract,
RebalancingSetTokenContract,
RebalancingSetTokenFactoryContract,
SetTokenContract,
Expand Down Expand Up @@ -51,7 +51,7 @@ contract('PayableExchangeIssuance::Scenarios', accounts => {
let core: CoreContract;
let rebalancingSetTokenFactory: RebalancingSetTokenFactoryContract;
let setTokenFactory: SetTokenFactoryContract;
let payableExchangeIssuance: PayableExchangeIssuanceContract;
let payableExchangeIssuance: RebalancingSetExchangeIssuanceModuleContract;
let weth: WethMockContract;

const coreWrapper = new CoreWrapper(ownerAccount, ownerAccount);
Expand All @@ -72,7 +72,7 @@ contract('PayableExchangeIssuance::Scenarios', accounts => {
rebalancingSetTokenFactory = await coreWrapper.getDeployedRebalancingSetTokenFactoryAsync();

weth = await erc20Wrapper.getDeployedWETHAsync();
payableExchangeIssuance = await coreWrapper.getDeployedPayableExchangeIssuanceModuleAsync();
payableExchangeIssuance = await coreWrapper.getDeployedRebalancingSetExchangeIssuanceModuleAsync();
});

after(async () => {
Expand Down
6 changes: 4 additions & 2 deletions utils/contracts.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ import { LinearAuctionPriceCurveContract } from '../types/generated/linear_aucti
import { MedianContract } from '../types/generated/median';
import { NoDecimalTokenMockContract } from '../types/generated/no_decimal_token_mock';
import { NoXferReturnTokenMockContract } from '../types/generated/no_xfer_return_token_mock';
import { PayableExchangeIssuanceContract } from '../types/generated/payable_exchange_issuance';
import {
RebalancingSetExchangeIssuanceModuleContract
} from '../types/generated/rebalancing_set_exchange_issuance_module';
import { PriceFeedContract } from '../types/generated/price_feed';
import { RebalanceAuctionModuleContract } from '../types/generated/rebalance_auction_module';
import { RebalanceAuctionModuleMockContract } from '../types/generated/rebalance_auction_module_mock';
Expand Down Expand Up @@ -86,7 +88,7 @@ export {
MedianContract,
NoDecimalTokenMockContract,
NoXferReturnTokenMockContract,
PayableExchangeIssuanceContract,
RebalancingSetExchangeIssuanceModuleContract,
PriceFeedContract,
RebalanceAuctionModuleContract,
RebalanceAuctionModuleMockContract,
Expand Down
Loading