Skip to content
Merged
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
34 changes: 18 additions & 16 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "auctioneer-bot",
"version": "3.1.2",
"version": "3.1.3",
"main": "index.js",
"type": "module",
"scripts": {
Expand Down
11 changes: 10 additions & 1 deletion src/auction.ts
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ export async function calculateBlockFillAndPercent(
);

// attempt to repay any liabilities the filler has took on from the bids
let allBidLiabilitiesRepaid = true;
for (const [assetId, amount] of loopScaledAuction.data.bid) {
const balance = loopFillerBalances.get(assetId) ?? 0n;
if (balance > 0n && amount > 0n) {
Expand All @@ -185,6 +186,9 @@ export async function calculateBlockFillAndPercent(
// 100n prevents dust positions from being created, and is deducted from the repaid liability
const amountAsUnderlying = reserve.toAssetFromDToken(amount) + 100n;
const repaidLiability = amountAsUnderlying <= balance ? amountAsUnderlying : balance;
if (amountAsUnderlying > balance) {
allBidLiabilitiesRepaid = false;
}
const effectiveLiability =
FixedMath.toFloat(repaidLiability - 100n, reserve.config.decimals) *
reserve.getLiabilityFactor() *
Expand All @@ -197,7 +201,11 @@ export async function calculateBlockFillAndPercent(
address: assetId,
amount: repaidLiability,
});
} else {
allBidLiabilitiesRepaid = false;
}
} else if (amount > 0n) {
allBidLiabilitiesRepaid = false;
}
}

Expand All @@ -215,12 +223,13 @@ export async function calculateBlockFillAndPercent(
}
}

if (limitToHF < 0) {
if (limitToHF < 0 && !allBidLiabilitiesRepaid) {
// if we still are under the health factor, we need to try and add more of the fillers primary asset as collateral
const primaryBalance = loopFillerBalances.get(poolConfig.primaryAsset) ?? 0n;
const primaryReserve = pool.reserves.get(poolConfig.primaryAsset);
const primaryOraclePrice = poolOracle.getPriceFloat(poolConfig.primaryAsset);
if (
pool.metadata.status <= 3 && // don't add collateral if pool is frozen
primaryReserve !== undefined &&
primaryOraclePrice !== undefined &&
primaryBalance > 0n
Expand Down
Loading
Loading