-
Notifications
You must be signed in to change notification settings - Fork 2
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
Include auction assets #19
base: main
Are you sure you want to change the base?
Conversation
mootz12
commented
Dec 25, 2024
- allow auction creates the ability to specify bid and lot assets in an auction
- add protections against potential misuse of assets to create weird / incomplete liquidations
match AuctionType::from_u32(e, auction_type) { | ||
AuctionType::UserLiquidation => { | ||
let auction_data = create_user_liq_auction_data(e, user, bid, lot, percent); | ||
storage::set_auction( | ||
e, | ||
&(AuctionType::UserLiquidation as u32), | ||
user, | ||
&auction_data, | ||
); | ||
auction_data | ||
} | ||
AuctionType::BadDebtAuction => { | ||
let auction_data = create_bad_debt_auction_data(e, user, bid, lot, percent); | ||
storage::set_auction( | ||
e, | ||
&(AuctionType::BadDebtAuction as u32), | ||
&user, | ||
&auction_data, | ||
); | ||
auction_data | ||
} | ||
AuctionType::InterestAuction => { | ||
let auction_data = create_interest_auction_data(e, user, bid, lot, percent); | ||
storage::set_auction( | ||
e, | ||
&(AuctionType::InterestAuction as u32), | ||
&user, | ||
&auction_data, | ||
); | ||
auction_data | ||
} | ||
} |
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.
This is seems repetitive you could instead return the result of the create_auction function and set it to a variable.
let auction_data = match AuctionType::from_u32(e, auction_type)
Probably also want to have a wild card case that throws an error.
pub block: u32, | ||
} | ||
|
||
/// Create a bad debt auction. Stores the resulting auction to the ledger to begin on the next block | ||
/// Create an new auction. Stores the resulting auction to the ledger to begin on the next block. |
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.
typo
backstop: &Address, | ||
assets: &Vec<Address>, | ||
user: &Address, | ||
bid: &Vec<Address>, |
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.
Is there a point to having this arg. Seems like it only serves to throw errors when called incorrectly by a user. Same goes for the lot on bad debt auctions. I suppose it could be confusing if a user specified something in the bid and it wasnt included.
@@ -43,53 +53,95 @@ pub fn create_user_liq_auction_data( | |||
panic_with_error!(e, PoolError::InvalidLiquidation); | |||
} | |||
|
|||
// if a >95% liquidation is requested, default to performing a 100% liquidation. | |||
// build position data from included assets | |||
let mut positions_incl = Positions::env_default(e); |
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.
I think auctioned_positions
might be a clearer variable name
) -> AuctionData { | ||
if storage::has_auction(e, &(AuctionType::InterestAuction as u32), backstop) { | ||
let backstop = storage::get_backstop(e); | ||
if user.clone() != backstop { |
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.
if user.clone() != backstop { | |
if user != &backstop { |
percent: u32, | ||
) -> AuctionData { | ||
let backstop = storage::get_backstop(e); | ||
if user.clone() != backstop { |
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.
ditto
) -> AuctionData { | ||
let user_clone = user.clone(); | ||
if user_clone == e.current_contract_address() || user_clone == storage::get_backstop(e) { |
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.
ditto