Skip to content

Commit 7a4e50a

Browse files
authored
solana: fix carping constraint (#171)
Co-authored-by: A5 Pickle <a5-pickle@users.noreply.github.com>
1 parent b00b375 commit 7a4e50a

File tree

6 files changed

+14
-8
lines changed

6 files changed

+14
-8
lines changed

solana/programs/matching-engine/src/events/auction_updated.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -16,5 +16,5 @@ pub struct AuctionUpdated {
1616
pub token_balance_before: u64,
1717
pub amount_in: u64,
1818
pub total_deposit: u64,
19-
pub max_offer_price_allowed: u64,
19+
pub max_offer_price_allowed: Option<u64>,
2020
}

solana/programs/matching-engine/src/processor/auction/offer/improve.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub struct ImproveOffer<'info> {
3131
3232
require!(
3333
offer_price
34-
<= utils::auction::compute_min_allowed_offer(&active_auction.config, info),
34+
< utils::auction::compute_min_allowed_offer(&active_auction.config, info),
3535
MatchingEngineError::CarpingNotAllowed
3636
);
3737
@@ -144,7 +144,8 @@ pub fn improve_offer(ctx: Context<ImproveOffer>, offer_price: u64) -> Result<()>
144144
token_balance_before: offer_token.amount,
145145
amount_in: info.amount_in,
146146
total_deposit: info.total_deposit(),
147-
max_offer_price_allowed: utils::auction::compute_min_allowed_offer(config, info),
147+
max_offer_price_allowed: utils::auction::compute_min_allowed_offer(config, info)
148+
.checked_sub(1),
148149
});
149150
}
150151

solana/programs/matching-engine/src/processor/auction/offer/place_initial/cctp.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -177,7 +177,8 @@ pub fn place_initial_offer_cctp(
177177
token_balance_before: ctx.accounts.offer_token.amount,
178178
amount_in,
179179
total_deposit: info.total_deposit(),
180-
max_offer_price_allowed: utils::auction::compute_min_allowed_offer(config, info),
180+
max_offer_price_allowed: utils::auction::compute_min_allowed_offer(config, info)
181+
.checked_sub(1),
181182
});
182183

183184
// Finally transfer tokens from the offer authority's token account to the

solana/ts/src/idl/json/matching_engine.json

+3-1
Original file line numberDiff line numberDiff line change
@@ -3580,7 +3580,9 @@
35803580
},
35813581
{
35823582
"name": "max_offer_price_allowed",
3583-
"type": "u64"
3583+
"type": {
3584+
"option": "u64"
3585+
}
35843586
}
35853587
]
35863588
}

solana/ts/src/idl/ts/matching_engine.ts

+3-1
Original file line numberDiff line numberDiff line change
@@ -3586,7 +3586,9 @@ export type MatchingEngine = {
35863586
},
35873587
{
35883588
"name": "maxOfferPriceAllowed",
3589-
"type": "u64"
3589+
"type": {
3590+
"option": "u64"
3591+
}
35903592
}
35913593
]
35923594
}

solana/ts/src/matchingEngine/index.ts

+2-2
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,7 @@ export type AuctionUpdated = {
158158
tokenBalanceBefore: BN;
159159
amountIn: BN;
160160
totalDeposit: BN;
161-
maxOfferPriceAllowed: BN;
161+
maxOfferPriceAllowed: BN | null;
162162
};
163163

164164
export type OrderExecuted = {
@@ -2525,7 +2525,7 @@ export class MatchingEngineProgram {
25252525

25262526
async computeMinOfferDelta(offerPrice: Uint64): Promise<bigint> {
25272527
const { minOfferDeltaBps } = await this.fetchAuctionParameters();
2528-
return (uint64ToBigInt(offerPrice) * BigInt(minOfferDeltaBps)) / FEE_PRECISION_MAX;
2528+
return (uint64ToBigInt(offerPrice) * BigInt(minOfferDeltaBps)) / FEE_PRECISION_MAX + 1n;
25292529
}
25302530

25312531
async computeNotionalSecurityDeposit(amountIn: Uint64, configId?: number) {

0 commit comments

Comments
 (0)