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

Include auction assets #19

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

Include auction assets #19

wants to merge 3 commits into from

Conversation

mootz12
Copy link
Contributor

@mootz12 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

@mootz12 mootz12 linked an issue Dec 25, 2024 that may be closed by this pull request
Comment on lines +85 to 116
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
}
}
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 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.
Copy link
Contributor

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>,
Copy link
Contributor

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);
Copy link
Contributor

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 {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
if user.clone() != backstop {
if user != &backstop {

percent: u32,
) -> AuctionData {
let backstop = storage::get_backstop(e);
if user.clone() != backstop {
Copy link
Contributor

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) {
Copy link
Contributor

Choose a reason for hiding this comment

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

ditto

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.

Better asset control for auction creation
2 participants