Skip to content

Commit 2a1bc23

Browse files
committed
refactor(managed-wallet): drop dead uakt bid-price ceiling, uact only
Deployments are uact-denominated, so the per-denom absolute ceiling only needs uact. Remove the unused UAKT config key and the uakt branch; the relative check is denom-agnostic and unaffected. A non-uact bid simply has no absolute cap and relies on the relative check.
1 parent fc31e75 commit 2a1bc23

3 files changed

Lines changed: 13 additions & 21 deletions

File tree

apps/api/src/billing/config/env.config.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ export const envSchema = z
5959
.transform(val => val === "true"),
6060
MANAGED_WALLET_BID_PRICE_WARN_MULTIPLIER: z.number({ coerce: true }).positive().default(5),
6161
MANAGED_WALLET_BID_PRICE_BLOCK_MULTIPLIER: z.number({ coerce: true }).positive().default(10),
62-
MANAGED_WALLET_BID_PRICE_ABSOLUTE_MAX_UAKT: z.number({ coerce: true }).positive().optional(),
6362
MANAGED_WALLET_BID_PRICE_ABSOLUTE_MAX_UACT: z.number({ coerce: true }).positive().optional(),
6463
TX_SIGNER_BASE_URL: z.string()
6564
})

apps/api/src/billing/services/lease-bid-price-guard/lease-bid-price-guard.service.spec.ts

Lines changed: 10 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ describe(LeaseBidPriceGuardService.name, () => {
2929
message: expect.stringContaining("cheapest competing bid")
3030
});
3131
expect(logger.error).toHaveBeenCalledWith(
32-
expect.objectContaining({ event: "LEASE_BLOCKED_EXCESSIVE_BID_PRICE", reason: "relative", provider: "akash1prov", denom: "uakt" })
32+
expect.objectContaining({ event: "LEASE_BLOCKED_EXCESSIVE_BID_PRICE", reason: "relative", provider: "akash1prov", denom: "uact" })
3333
);
3434
});
3535

@@ -66,38 +66,38 @@ describe(LeaseBidPriceGuardService.name, () => {
6666

6767
describe("absolute limit", () => {
6868
it("blocks a sole bidder priced above the per-denom ceiling", async () => {
69-
const { service, logger } = setup({ absoluteMaxUakt: 1000, bids: [pricedBid(ACCEPTED, 2000)] });
69+
const { service, logger } = setup({ absoluteMaxUact: 1000, bids: [pricedBid(ACCEPTED, 2000)] });
7070

7171
await expect(service.validateLeaseBidPrices([leaseMessage(ACCEPTED)], createUserWallet())).rejects.toMatchObject({ status: 403 });
7272
expect(logger.error).toHaveBeenCalledWith(expect.objectContaining({ event: "LEASE_BLOCKED_EXCESSIVE_BID_PRICE", reason: "absolute" }));
7373
});
7474

7575
it("allows a sole bidder priced below the per-denom ceiling", async () => {
76-
const { service } = setup({ absoluteMaxUakt: 1000, bids: [pricedBid(ACCEPTED, 500)] });
76+
const { service } = setup({ absoluteMaxUact: 1000, bids: [pricedBid(ACCEPTED, 500)] });
7777

7878
await expect(service.validateLeaseBidPrices([leaseMessage(ACCEPTED)], createUserWallet())).resolves.toBeUndefined();
7979
});
8080

81-
it("allows a sole bidder at any price when no ceiling is configured for the denom", async () => {
82-
const { service } = setup({ absoluteMaxUakt: undefined, bids: [pricedBid(ACCEPTED, 9_519_658)] });
81+
it("allows a sole bidder at any price when no ceiling is configured", async () => {
82+
const { service } = setup({ absoluteMaxUact: undefined, bids: [pricedBid(ACCEPTED, 9_519_658)] });
8383

8484
await expect(service.validateLeaseBidPrices([leaseMessage(ACCEPTED)], createUserWallet())).resolves.toBeUndefined();
8585
});
8686

8787
it("applies the ceiling independently of the relative check when peers exist", async () => {
8888
const { service, logger } = setup({
89-
absoluteMaxUakt: 300,
89+
absoluteMaxUact: 300,
9090
bids: [pricedBid(ACCEPTED, 400), pricedBid({ ...ACCEPTED, provider: "akash1cheap", bseq: 2 }, 100)]
9191
});
9292

9393
await expect(service.validateLeaseBidPrices([leaseMessage(ACCEPTED)], createUserWallet())).rejects.toMatchObject({ status: 403 });
9494
expect(logger.error).toHaveBeenCalledWith(expect.objectContaining({ reason: "absolute" }));
9595
});
9696

97-
it("uses the uact ceiling for uact-denominated bids", async () => {
98-
const { service } = setup({ absoluteMaxUact: 1000, bids: [pricedBid(ACCEPTED, 2000, "uact")] });
97+
it("does not apply the ceiling to a non-uact denom", async () => {
98+
const { service } = setup({ absoluteMaxUact: 1000, bids: [pricedBid(ACCEPTED, 2000, "uakt")] });
9999

100-
await expect(service.validateLeaseBidPrices([leaseMessage(ACCEPTED)], createUserWallet())).rejects.toMatchObject({ status: 403 });
100+
await expect(service.validateLeaseBidPrices([leaseMessage(ACCEPTED)], createUserWallet())).resolves.toBeUndefined();
101101
});
102102
});
103103

@@ -155,7 +155,7 @@ describe(LeaseBidPriceGuardService.name, () => {
155155
expect(logger.error).toHaveBeenCalledWith(expect.objectContaining({ reason: "relative", gseq: 2 }));
156156
});
157157

158-
function pricedBid(ids: { dseq: string; gseq: number; oseq: number; bseq: number; provider: string }, amount: number, denom = "uakt"): Bid {
158+
function pricedBid(ids: { dseq: string; gseq: number; oseq: number; bseq: number; provider: string }, amount: number, denom = "uact"): Bid {
159159
const bid = createBid({ owner: OWNER, ...ids });
160160
bid.bid.price = { denom, amount: amount.toString() };
161161
return bid;
@@ -176,15 +176,13 @@ describe(LeaseBidPriceGuardService.name, () => {
176176
enabled?: boolean;
177177
warnMultiplier?: number;
178178
blockMultiplier?: number;
179-
absoluteMaxUakt?: number;
180179
absoluteMaxUact?: number;
181180
bids?: Bid[];
182181
}) {
183182
const config = mockConfigService<BillingConfigService>({
184183
MANAGED_WALLET_BID_PRICE_GUARD_ENABLED: input.enabled ?? true,
185184
MANAGED_WALLET_BID_PRICE_WARN_MULTIPLIER: input.warnMultiplier ?? 5,
186185
MANAGED_WALLET_BID_PRICE_BLOCK_MULTIPLIER: input.blockMultiplier ?? 10,
187-
MANAGED_WALLET_BID_PRICE_ABSOLUTE_MAX_UAKT: input.absoluteMaxUakt,
188186
MANAGED_WALLET_BID_PRICE_ABSOLUTE_MAX_UACT: input.absoluteMaxUact
189187
});
190188
const bidHttpService = mock<BidHttpService>();

apps/api/src/billing/services/lease-bid-price-guard/lease-bid-price-guard.service.ts

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -133,14 +133,9 @@ export class LeaseBidPriceGuardService {
133133
assert(false, 403, message);
134134
}
135135

136+
// Deployments are uact-denominated; the ceiling only applies to uact bids. Any other denom
137+
// (e.g. a legacy uakt bid) has no absolute cap and is covered by the relative check alone.
136138
#getAbsoluteMax(denom: string): number | undefined {
137-
switch (denom) {
138-
case "uakt":
139-
return this.config.get("MANAGED_WALLET_BID_PRICE_ABSOLUTE_MAX_UAKT");
140-
case "uact":
141-
return this.config.get("MANAGED_WALLET_BID_PRICE_ABSOLUTE_MAX_UACT");
142-
default:
143-
return undefined;
144-
}
139+
return denom === "uact" ? this.config.get("MANAGED_WALLET_BID_PRICE_ABSOLUTE_MAX_UACT") : undefined;
145140
}
146141
}

0 commit comments

Comments
 (0)