Skip to content

Conversation

@KillariDev
Copy link
Collaborator

@KillariDev KillariDev commented Oct 6, 2025

Implements security pools

  • users can deposit rep
  • users can withdraw rep if terms allow (not too much security bond debt minted by the pool or the vault)
  • users can set their security bond allowance
  • queries for open oracle for price for operations, price remains valid for one hour
  • mock auction where users can pay what ever for rep with what ever amount of eth
  • doesn't handle security bond migration debt for auction buyers yet
  • no liquidations
  • security pool forking with zoltar
  • complete set creation and redeeming
  • no complete set transition to new pools yet
  • no yes/no/invalid shares yet
  • dynamic fees that are setup right away utilization changes

@KillariDev KillariDev changed the title Initial security pool draft Initial security pools Oct 22, 2025
@KillariDev KillariDev requested a review from MicahZoltu October 22, 2025 05:30
@KillariDev KillariDev marked this pull request as ready for review October 22, 2025 05:30
function participate(uint256 repToBuy) public payable {
require(auctionStarted > 0, 'Auction needs to have started');
require(!finalized, 'Already finalized');
require(msg.value > 0, 'need to invest with eth!');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Using ETH instead of WETH means we can't use the same contract for other tokens. However, it is generally much simpler to build things with ETH.

require(msg.value > 0, 'need to invest with eth!');
require(address(this).balance <= ethAmountToBuy, 'attempting to overfund');
require(totalRepPurchased + repToBuy <= repAvailable, 'attempt to buy too much rep');
purchasedRep[msg.sender] = repToBuy; // todo, currently anyone can buy with any price
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

For prototyping, how hard would it be to just have a linear countdown since start and just require the price matches exactly? With Interceptor testing we can make this exact I think, since we can control how many blocks after auction start block the participate function is called at.

}

function finalizeAuction() public {
//require(block.timestamp > auctionStarted + AUCTION_TIME, 'Auction needs to have ended first'); // caller checks
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why have the caller check instead of putting the check here?

I also think there is value in checking twice in situations like this until the final optimization stage of development. Better to play it safe until the last minute when we are gas optimizing.

require(msg.sender == owner, 'Only owner can finalize');
require(!finalized, 'Already finalized');
finalized = true;
(bool sent, ) = payable(owner).call{value: address(this).balance}('');
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Solidity still doesn't have a cleaner way to send ETH than this? 😢

Comment on lines +18 to +19
uint256 constant gasConsumedOpenOracleReportPrice = 100000; //TODO
uint32 constant gasConsumedSettlement = 1000000; //TODO
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I feel like these should be variables that are automatically updated each time these functions are called, so when gas price changes occur we correctly follow them.

truthAuctionStarted = block.timestamp;
parent.updateCollateralAmount();
uint256 parentCollateral = parent.completeSetCollateralAmount();
completeSetCollateralAmount = parentCollateral; // update to the real one, and not only to migrated amount
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Commenting style seems inconsistent. I prefer comments above, so they show up vertically inline when scanning the code.

Suggested change
completeSetCollateralAmount = parentCollateral; // update to the real one, and not only to migrated amount
// update to the real one, and not only to migrated amount
completeSetCollateralAmount = parentCollateral;

} else {
// we need to buy all the collateral that is missing (did not migrate)
uint256 ethToBuy = parentCollateral - parentCollateral * migratedRep / parent.repAtFork();
truthAuction.startAuction(ethToBuy, parent.repAtFork() - parent.repAtFork() / SecurityPoolUtils.MAX_AUCTION_VAULT_HAIRCUT_DIVISOR); // sell all but very small amount of REP for ETH. We cannot sell all for accounting purposes, as `poolOwnershipDenominator` cannot be infinite
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Last one I'll comment on, consider applying to all end-of-line comments.

Suggested change
truthAuction.startAuction(ethToBuy, parent.repAtFork() - parent.repAtFork() / SecurityPoolUtils.MAX_AUCTION_VAULT_HAIRCUT_DIVISOR); // sell all but very small amount of REP for ETH. We cannot sell all for accounting purposes, as `poolOwnershipDenominator` cannot be infinite
// sell all but very small amount of REP for ETH. We cannot sell all for accounting purposes, as `poolOwnershipDenominator` cannot be infinite
truthAuction.startAuction(ethToBuy, parent.repAtFork() - parent.repAtFork() / SecurityPoolUtils.MAX_AUCTION_VAULT_HAIRCUT_DIVISOR);

Comment on lines +11 to +12
uint256 constant MAX_RETENTION_RATE = 999_999_996_848_000_000; // ≈90% yearly
uint256 constant MIN_RETENTION_RATE = 999_999_977_880_000_000; // ≈50% yearly
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Compounded how often? Every second or continuous?

Comment on lines +8 to +16
/**
* @title OpenOracle
* @notice A trust-free price oracle that uses an escalating auction mechanism
* @dev This contract enables price discovery through economic incentives where
* expiration serves as evidence of a good price with appropriate parameters
* @author OpenOracle Team
* @custom:version 0.1.6
* @custom:documentation https://openprices.gitbook.io/openoracle-docs
*/
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should include a link to where the original source code lives.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Same for all other third party code that we vendor.

Comment on lines +6 to +9
"setup": "npm ci --ignore-scripts && npm run compile-contracts",
"compile-contracts": "tsc --project tsconfig-compile.json && node ./js/compile.js",
"test": "npx tsc && node --test",
"test-peripherals": "npx tsc && node --test ./js/tests/testPeripherals.js"
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should consider moving to Deno or Bun. Paul Miller recommends Bun, and I gave it a try and at least in one project it worked without any changes (other than s/node/bun/), but it is able to run TypeScript natively rather than having to compile it first. Useful for running test suites, and much faster than having to compile first. Plus no need for source maps which is a minor but nice bonus.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants