Skip to content
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

Auction scripts #345

Open
wants to merge 29 commits into
base: main
Choose a base branch
from
Open

Auction scripts #345

wants to merge 29 commits into from

Conversation

ylv-io
Copy link
Collaborator

@ylv-io ylv-io commented Feb 18, 2025

Description

Type of change

  • Bug fix
  • New feature
  • Breaking change
  • Dependency changes
  • Deployment
  • Forge Script
  • Code refactor / cleanup
  • Documentation or wording changes
  • Other

Checklist:

  • The diff is legible and has no extraneous changes
  • Complex code has been commented, including external interfaces
  • Tests have 100% code coverage
  • The base branch is either main, or there's a description of how to merge

Issue Resolution

…, fetch-bids.sh to gather bid data, clear-auction.js to execute auction logic, and initial data files bids.txt and users.txt.
… update allocation logic, and improve file handling.
…BigInt precision, improved comments, and adjusted token scaling to 18 decimals.
…dify USDC refund logic to clamp at 1, and increase totalTokens to 40,000.
Copy link

github-actions bot commented Feb 18, 2025

Slither report

THIS CHECKLIST IS NOT COMPLETE. Use --show-ignored-findings to show all the results.
Summary

unchecked-transfer

Impact: High
Confidence: Medium

function withdraw(address asset, uint256 amount) public returns (uint256) {
address pool = poolAddressProvider.getPool();
// If amount is max uint256, withdraw all available
if (amount == type(uint256).max) {
amount = IERC20(IAavePool(pool).getReserveData(asset).aTokenAddress).balanceOf(address(this));
}
// Withdraw from Aave
IAavePool(pool).withdraw(asset, amount, address(this));
// Send the fee to the Safe
uint256 fee = amount * FEE / 1e18;
IERC20(asset).transfer(safe, fee);
return amount - fee;
}

Copy link

codecov bot commented Feb 18, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 89.25%. Comparing base (9f53019) to head (c141d86).

Additional details and impacted files
@@            Coverage Diff             @@
##             main     #345      +/-   ##
==========================================
+ Coverage   89.11%   89.25%   +0.13%     
==========================================
  Files          42       42              
  Lines        2656     2652       -4     
==========================================
  Hits         2367     2367              
+ Misses        289      285       -4     
Files with missing lines Coverage Δ
src/tokens/bridged/BridgedKinto.sol 95.23% <100.00%> (+15.23%) ⬆️

let tokensAccumulated = 0n;
let finalPrice = 0n;

for (const bid of bids) {
Copy link
Contributor

Choose a reason for hiding this comment

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

not sure if this logic is correct.

You are assuming people are getting the tokens at their bid price which is incorrect.

For example I bid 30, you bid 30 and the third person bids 10.

I should be getting my tokens at 10 not at 30, so to calculate tokens accumulated you need to use 10 not 30

Copy link
Contributor

@rrecuero rrecuero Feb 18, 2025

Choose a reason for hiding this comment

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

otherwise we are not grabbing the real last bid, we are finishing up earlier than we should

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

It doesn't assume people are getting the tokens at their bid. The first look is only to calculate how many tokens people are willing to buy.

Copy link
Contributor

Choose a reason for hiding this comment

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

but youa re using this to calculate the finalPrice

// 1) Sort bids by maxPrice (desc), then priority (desc)
bids.sort((a, b) => {
if (b.maxPrice === a.maxPrice) {
return Number(b.priority - a.priority);
Copy link
Contributor

Choose a reason for hiding this comment

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

how are you calculating priority? Take into account that within engen, the engen balance matters and then emissaries and then people sorted by their K balance

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah, calculating priority would be another script, as we have to fetch data for Engen and Balances.


tokensAccumulated += tokensDemanded;
if (tokensAccumulated >= totalTokens) {
finalPrice = bid.maxPrice;
Copy link
Contributor

Choose a reason for hiding this comment

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

this is what I think is incorrect

Copy link
Contributor

Choose a reason for hiding this comment

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

this is like the worst case. Because if I bid $300 for $30, you are only accumulating 10 tokens but in reality maybe you should have accumulated 30

Copy link
Contributor

Choose a reason for hiding this comment

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

so you would run out of tokens earlier

Copy link
Contributor

Choose a reason for hiding this comment

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

That's why I think the loop needs to be over each bid price first, and then over bids. It needs to be a double loop

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yeah. I agree. thanks.

…rm-price auction aiming to raise a specified total USDC amount, added verification for allocations, and adjusted scripts for setting auction root.
…y amount, including `fetch-users-k.sh` for parallel processing of user balances and `sort-by-amount.sh` for sorting results numerically in descending order.
…ess, bidAmount, bidPrice, saleAlloc, and usdcAlloc without proofs.
…fixVotingSupply function, and adjust migration script and test artifacts accordingly.
Copy link

openzeppelin-code bot commented Feb 21, 2025

Auction scripts

Generated at commit: 390507d92d0ec7e270a79fe84c7beb89efb80d6d

🚨 Report Summary

Severity Level Results
Contracts Critical
High
Medium
Low
Note
Total
4
2
0
12
39
57
Dependencies Critical
High
Medium
Low
Note
Total
0
0
0
0
0
0

For more details view the full report in OpenZeppelin Code Inspector

…157-transfer-k-investor.s.sol, adjust amounts and addresses, and update JSON files with new transaction hashes, block numbers, and timestamps.
… update deployment addresses, and reflect changes in transaction and receipt logs.
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.

2 participants