Skip to content

Commit 8b0e457

Browse files
committed
ported one test
1 parent f05a765 commit 8b0e457

9 files changed

+287
-480
lines changed

contracts/FPMMDeterministicFactory.sol

Lines changed: 14 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -25,26 +25,15 @@ contract FPMMDeterministicFactory is IERC1155Receiver {
2525
implementationMaster = new FixedProductMarketMaker();
2626
}
2727

28-
function supportsInterface(
29-
bytes4 interfaceId
30-
) external pure returns (bool) {
28+
function supportsInterface(bytes4 interfaceId) external pure returns (bool) {
3129
return interfaceId == type(IERC1155Receiver).interfaceId;
3230
}
3331

34-
function onERC1155Received(
35-
address,
36-
address,
37-
uint256 id,
38-
uint256 value,
39-
bytes calldata data
40-
) external returns (bytes4) {
41-
ConditionalTokens(msg.sender).safeTransferFrom(
42-
address(this),
43-
currentFunder,
44-
id,
45-
value,
46-
data
47-
);
32+
function onERC1155Received(address, address, uint256 id, uint256 value, bytes calldata data)
33+
external
34+
returns (bytes4)
35+
{
36+
ConditionalTokens(msg.sender).safeTransferFrom(address(this), currentFunder, id, value, data);
4837
return this.onERC1155Received.selector;
4938
}
5039

@@ -55,13 +44,7 @@ contract FPMMDeterministicFactory is IERC1155Receiver {
5544
uint256[] calldata values,
5645
bytes calldata data
5746
) external returns (bytes4) {
58-
ConditionalTokens(msg.sender).safeBatchTransferFrom(
59-
address(this),
60-
currentFunder,
61-
ids,
62-
values,
63-
data
64-
);
47+
ConditionalTokens(msg.sender).safeBatchTransferFrom(address(this), currentFunder, ids, values, data);
6548
return this.onERC1155BatchReceived.selector;
6649
}
6750

@@ -74,49 +57,28 @@ contract FPMMDeterministicFactory is IERC1155Receiver {
7457
uint256 initialFunds,
7558
uint256[] calldata distributionHint
7659
) external returns (FixedProductMarketMaker fixedProductMarketMaker) {
77-
fixedProductMarketMaker = FixedProductMarketMaker(
78-
Clones.cloneDeterministic(address(implementationMaster), salt)
79-
);
80-
fixedProductMarketMaker.initialize(
81-
conditionalTokens,
82-
collateralToken,
83-
conditionIds,
84-
fee
85-
);
60+
fixedProductMarketMaker =
61+
FixedProductMarketMaker(Clones.cloneDeterministic(address(implementationMaster), salt));
62+
fixedProductMarketMaker.initialize(conditionalTokens, collateralToken, conditionIds, fee);
8663

8764
emit FixedProductMarketMakerCreation(
88-
msg.sender,
89-
fixedProductMarketMaker,
90-
conditionalTokens,
91-
collateralToken,
92-
conditionIds,
93-
fee
65+
msg.sender, fixedProductMarketMaker, conditionalTokens, collateralToken, conditionIds, fee
9466
);
9567

9668
if (initialFunds > 0) {
9769
currentFunder = msg.sender;
9870

9971
// Transfer funding to this factory
100-
collateralToken.transferFrom(
101-
msg.sender,
102-
address(this),
103-
initialFunds
104-
);
72+
collateralToken.transferFrom(msg.sender, address(this), initialFunds);
10573

10674
// Approve the market maker to spend the funding from this factory
107-
collateralToken.approve(
108-
address(fixedProductMarketMaker),
109-
initialFunds
110-
);
75+
collateralToken.approve(address(fixedProductMarketMaker), initialFunds);
11176

11277
// Add funding to the market maker, which will spend the funds from this factory
11378
fixedProductMarketMaker.addFunding(initialFunds, distributionHint);
11479

11580
// Transfer the outcome tokens to the creator
116-
fixedProductMarketMaker.transfer(
117-
msg.sender,
118-
fixedProductMarketMaker.balanceOf(address(this))
119-
);
81+
fixedProductMarketMaker.transfer(msg.sender, fixedProductMarketMaker.balanceOf(address(this)));
12082

12183
currentFunder = address(0);
12284
}

0 commit comments

Comments
 (0)