Skip to content
Open
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
26 changes: 26 additions & 0 deletions Contracts/MockUSDC.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,26 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "@openzeppelin/contracts/token/ERC20/ERC20.sol";
import "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";

contract MockUSDC is ERC20 {
using SafeERC20 for IERC20;

constructor() ERC20("Mock USDC", "USDC") {
//1000000 USDC minted
_mint(msg.sender, 1000000 * (10 ** uint256(decimals())));
}

function decimals() public pure override returns (uint8) {
return 6;
}

function mint(address receiver) public {
_mint(receiver, 10000 * (10 ** uint256(decimals())));
}

receive() external payable {}

fallback() external payable {}
}
27 changes: 15 additions & 12 deletions Contracts/Positions.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,16 @@

pragma solidity ^0.8.0;

/// @title POP-Protocol-v1 Position/Asset Contract.
/// @author Anuj Tanwar aka br0wnD3v

/// @notice Trading contract deploys this contract each time a new asset is to be traded/listed.
/// Is an ERC721 contract.
/// Mint/Burn functions enable a user to hold a Perpetual position or burn the position.

/// @notice In Testing Phase.
/// @notice Not Audited.

import "./interfaces/IPositions.sol";

import "@openzeppelin/contracts/access/Ownable.sol";
Expand All @@ -20,7 +30,6 @@ struct PositionToken {
uint256[] position;
uint256[] multiplicator;
address owner;
uint256 fee;
uint256 size;
uint256 strikeUpper;
uint256 strikeLower;
Expand All @@ -35,13 +44,9 @@ contract POP_Positions is Ownable, ERC721, IPositions {
address public immutable POP_TRADING_CONTRACT;
bytes32 public immutable PARENT_PRODUCT;

mapping(uint256 => PositionToken) private idToPosition;
uint256 public immutable SELF_LIMIT;

event PositionStatus(
address indexed owner,
uint256 indexed positionId,
bool indexed isOpen
);
mapping(uint256 => PositionToken) private idToPosition;

modifier onlyPOP_Trading() {
if (_msgSender() != POP_TRADING_CONTRACT)
Expand All @@ -60,12 +65,14 @@ contract POP_Positions is Ownable, ERC721, IPositions {
constructor(
bytes32 _parentProduct,
string memory _productName,
string memory _productSymbol
string memory _productSymbol,
uint256 _intervals
) ERC721(_productName, _productSymbol) {
nextTokenId.increment();

PARENT_PRODUCT = _parentProduct;
POP_TRADING_CONTRACT = _msgSender();
SELF_LIMIT = _intervals;
}

function getNextId() external view returns (uint256) {
Expand Down Expand Up @@ -108,8 +115,6 @@ contract POP_Positions is Ownable, ERC721, IPositions {

nextTokenId.increment();

emit PositionStatus(_owner, positionId, true);

return positionId;
}

Expand All @@ -120,8 +125,6 @@ contract POP_Positions is Ownable, ERC721, IPositions {

currentPosition.isOpen = false;
_burn(_positionId);

emit PositionStatus(currentPosition.owner, _positionId, false);
}

function update(
Expand Down
51 changes: 51 additions & 0 deletions Contracts/SequencerArray.sol
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
//SPDX-License-Identifier:MIT

pragma solidity ^0.8.0;

import "@openzeppelin/contracts/access/Ownable.sol";

contract SequencerArray is Ownable {
bytes32 private primaryServiceHash;
uint256 private primaryUpdatedTimestamp;
bytes32 private secondaryServiceHash;
uint256 private secondaryUpdatedTimestamp;

event updatedPrimary(
bytes32 indexed prev,
bytes32 indexed updated,
uint256 indexed timestamp
);
event updatedSecondary(
bytes32 indexed prev,
bytes32 indexed updated,
uint256 indexed timestamp
);

constructor() {}

function getLatest() external view returns (bytes32) {
if (
primaryUpdatedTimestamp > secondaryUpdatedTimestamp &&
primaryServiceHash != bytes32(0)
) return primaryServiceHash;
else return secondaryServiceHash;
}

function updatePrimary(bytes32 _updated) external onlyOwner {
bytes32 old = primaryServiceHash;
primaryServiceHash = _updated;
primaryUpdatedTimestamp = block.timestamp;
emit updatedPrimary(old, primaryServiceHash, primaryUpdatedTimestamp);
}

function updateSecondary(bytes32 _updated) external onlyOwner {
bytes32 old = secondaryServiceHash;
secondaryServiceHash = _updated;
secondaryUpdatedTimestamp = block.timestamp;
emit updatedSecondary(
old,
secondaryServiceHash,
secondaryUpdatedTimestamp
);
}
}
Loading