-
Notifications
You must be signed in to change notification settings - Fork 3
Complete set mirror #116
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Complete set mirror #116
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,67 @@ | ||
| pragma solidity 0.8.29; | ||
|
|
||
| import { IERC20 } from "./IERC20.sol"; | ||
| import { ERC1155 } from "./ERC1155.sol"; | ||
| import { Constants } from "./Constants.sol"; | ||
| import { TokenId } from "./TokenId.sol"; | ||
| import { IOICash } from "./IOICash.sol"; | ||
|
|
||
| contract AugurConstantProductShareToken is ERC1155 { | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Does this actually need to be an ERC1155? I think the minimum requirement is that a user can "roll their keys", but I don't know if we need full 1155 support? I'm not sure if it helps us to remove ERC-1155 dependency though.
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It probably doesn't need the full ERC1155 but I think we wouldn't gain much by ripping out functionality. There shouldn't be much overhead of those features in its operation within our system. Its a good mental construct too for understanding how the system is operating and what state looks like. |
||
|
|
||
| IERC20 public dai = IERC20(Constants.DAI_ADDRESS); | ||
| IOICash public constant cash = IOICash(Constants.AUGUR_OICASH); | ||
| uint256 public constant numTicks = 1000; | ||
|
|
||
| constructor() { | ||
| dai.approve(Constants.AUGUR_ADDRESS, 2**256-1); | ||
| } | ||
|
|
||
| function buyCompleteSets(address acpm, address account, uint256 setsToBuy) external { | ||
| uint256 amountInDai = setsToBuy * numTicks; | ||
| dai.transferFrom(msg.sender, address(this), amountInDai); | ||
| cash.deposit(amountInDai); | ||
|
|
||
| uint256[] memory tokenIds = new uint256[](3); | ||
| uint256[] memory values = new uint256[](3); | ||
|
|
||
| tokenIds[0] = TokenId.getTokenId(acpm, 0); | ||
| tokenIds[1] = TokenId.getTokenId(acpm, 1); | ||
| tokenIds[2] = TokenId.getTokenId(acpm, 2); | ||
| values[0] = setsToBuy; | ||
| values[1] = setsToBuy; | ||
| values[2] = setsToBuy; | ||
|
|
||
| _mintBatch(account, tokenIds, values, bytes(""), false); | ||
| } | ||
|
|
||
| function sellCompleteSets(address acpm, address holder, address recipient, uint256 setsToSell) external { | ||
| require(holder == msg.sender || isApprovedForAll(holder, msg.sender) == true, "ERC1155: need operator approval to sell complete sets"); | ||
|
|
||
| uint256[] memory tokenIds = new uint256[](3); | ||
| uint256[] memory values = new uint256[](3); | ||
|
|
||
| tokenIds[0] = TokenId.getTokenId(acpm, 0); | ||
| tokenIds[1] = TokenId.getTokenId(acpm, 1); | ||
| tokenIds[2] = TokenId.getTokenId(acpm, 2); | ||
| values[0] = setsToSell; | ||
| values[1] = setsToSell; | ||
| values[2] = setsToSell; | ||
|
|
||
| _burnBatch(holder, tokenIds, values, bytes(""), false); | ||
|
|
||
| cash.withdraw(setsToSell * numTicks); | ||
| dai.transfer(recipient, dai.balanceOf(address(this))); | ||
| } | ||
|
|
||
| function unsafeTransferFrom(address _from, address _to, uint256 _id, uint256 _value) public { | ||
| _transferFrom(_from, _to, _id, _value, bytes(""), false); | ||
| } | ||
|
|
||
| function unsafeBatchTransferFrom(address _from, address _to, uint256[] memory _ids, uint256[] memory _values) public { | ||
| _batchTransferFrom(_from, _to, _ids, _values, bytes(""), false); | ||
| } | ||
|
|
||
| function onBurn(uint256 _tokenId, address _target, uint256 _amount) internal override {} | ||
| function onMint(uint256 _tokenId, address _target, uint256 _amount) internal override {} | ||
| function onTokenTransfer(uint256 _tokenId, address _from, address _to, uint256 _value) internal override {} | ||
| } | ||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It feels like we should fold this, the pool, and the router all into a single contract to minimize the amount of moving around assets we need to do? Or would we gain little benefit from such a combination?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yea thats the next thing I plan to take a stab at once this is in. Will involve a core contract that uses delegate calls for at least some of the implementation though bc of size constraints.