Skip to content

Commit

Permalink
Increase base fee multiplier from 1.5 to 1.65 (#3917)
Browse files Browse the repository at this point in the history
  • Loading branch information
p0mvn authored Oct 28, 2024
1 parent c8a2972 commit c483069
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 24 deletions.
29 changes: 11 additions & 18 deletions packages/tx/src/__tests__/gas.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import { ApiClientError } from "@osmosis-labs/utils";
import type { Any } from "cosmjs-types/google/protobuf/any";

import {
defaultBaseFeeMultiplier,
getDefaultGasPrice,
getGasFeeAmount,
getGasPriceByFeeDenom,
Expand Down Expand Up @@ -322,7 +323,7 @@ describe("getGasFeeAmount", () => {
})
)[0];

const expectedGasAmount = new Dec(baseFee * gasMultiplier)
const expectedGasAmount = new Dec(baseFee * defaultBaseFeeMultiplier)
.quo(new Dec(spotPrice))
.mul(new Dec(1.01))
.mul(new Dec(gasLimit))
Expand Down Expand Up @@ -419,7 +420,7 @@ describe("getGasFeeAmount", () => {
})
)[0];

const expectedGasAmount = new Dec(baseFee * gasMultiplier)
const expectedGasAmount = new Dec(baseFee * defaultBaseFeeMultiplier)
.quo(new Dec(spotPrice))
.mul(new Dec(1.01))
.mul(new Dec(gasLimit))
Expand Down Expand Up @@ -506,7 +507,7 @@ describe("getGasFeeAmount", () => {
})
)[0];

const expectedGasAmount = new Dec(baseFee * gasMultiplier)
const expectedGasAmount = new Dec(baseFee * defaultBaseFeeMultiplier)
.quo(new Dec(spotPrice))
.mul(new Dec(1.01))
.mul(new Dec(gasLimit))
Expand Down Expand Up @@ -592,7 +593,7 @@ describe("getGasFeeAmount", () => {
})
)[0];

const expectedGasAmount = new Dec(baseFee * gasMultiplier)
const expectedGasAmount = new Dec(baseFee * defaultBaseFeeMultiplier)
.quo(new Dec(spotPrice))
.mul(new Dec(1.01))
.mul(new Dec(gasLimit))
Expand Down Expand Up @@ -679,7 +680,7 @@ describe("getGasFeeAmount", () => {
})
)[0];

const expectedGasAmount = new Dec(baseFee * gasMultiplier)
const expectedGasAmount = new Dec(baseFee * defaultBaseFeeMultiplier)
.quo(new Dec(spotPrice))
.mul(new Dec(1.01))
.mul(new Dec(gasLimit))
Expand Down Expand Up @@ -795,7 +796,7 @@ describe("getGasFeeAmount", () => {
)[0];

const expectedGasAmount = new Dec(baseFee)
.mul(new Dec(gasMultiplier))
.mul(new Dec(defaultBaseFeeMultiplier))
.quo(new Dec(lowEnoughSpotPrice))
.mul(new Dec(1.01))
.mul(new Dec(gasLimit))
Expand Down Expand Up @@ -1053,7 +1054,6 @@ describe("getGasPriceByFeeDenom", () => {
const chainId = "osmosis-1";
const chainList = MockChains;
const feeDenom = "uion";
const gasMultiplier = 1.5;

it("should return the correct gas price with fee market module", async () => {
const baseFee = 0.01;
Expand All @@ -1070,13 +1070,12 @@ describe("getGasPriceByFeeDenom", () => {
chainId,
chainList,
feeDenom,
gasMultiplier,
});

const expectedGasPrice = new Dec(baseFee)
.quo(new Dec(spotPrice))
.mul(new Dec(1.01))
.mul(new Dec(gasMultiplier));
.mul(new Dec(defaultBaseFeeMultiplier));

expect(result.gasPrice.toString()).toBe(expectedGasPrice.toString());

Expand All @@ -1103,7 +1102,6 @@ describe("getGasPriceByFeeDenom", () => {
chainId,
chainList: chainListWithoutFeeMarket,
feeDenom: "uosmo",
gasMultiplier,
});

expect(result.gasPrice.toString()).toBe(defaultGasPrice.toString());
Expand All @@ -1125,7 +1123,6 @@ describe("getGasPriceByFeeDenom", () => {
chainId,
chainList: chainListWithoutFeeMarket,
feeDenom,
gasMultiplier,
});

expect(result.gasPrice.toString()).toBe(new Dec(0.004).toString());
Expand All @@ -1145,7 +1142,6 @@ describe("getGasPriceByFeeDenom", () => {
chainId,
chainList: chainListWithoutFeeMarket,
feeDenom,
gasMultiplier,
})
).rejects.toThrow("Fee token not found: uion");

Expand All @@ -1159,7 +1155,6 @@ describe("getGasPriceByFeeDenom", () => {
chainId: "non-existent-chain",
chainList,
feeDenom,
gasMultiplier,
})
).rejects.toThrow("Chain not found: non-existent-chain");

Expand All @@ -1182,7 +1177,6 @@ describe("getGasPriceByFeeDenom", () => {
chainId,
chainList,
feeDenom,
gasMultiplier,
})
).rejects.toThrow(`Failed to fetch spot price for fee token ${feeDenom}.`);

Expand All @@ -1207,7 +1201,6 @@ describe("getGasPriceByFeeDenom", () => {
chainId,
chainList,
feeDenom,
gasMultiplier,
})
).rejects.toThrow("Invalid base fee: invalid");
});
Expand Down Expand Up @@ -1243,15 +1236,15 @@ describe("getDefaultGasPrice", () => {
base_fee: baseFee.toString(),
} as Awaited<ReturnType<typeof queryFeesBaseGasPrice>>);

const gasMultiplier = 1.5;
const baseFeeMultiplier = 1.65;
const result = await getDefaultGasPrice({
chainId,
chainList,
gasMultiplier,
baseFeeMultiplier: baseFeeMultiplier,
});

expect(result.gasPrice.toString()).toBe(
new Dec(baseFee * gasMultiplier).toString()
new Dec(baseFee * baseFeeMultiplier).toString()
);
expect(result.feeDenom).toBe("uosmo");

Expand Down
16 changes: 10 additions & 6 deletions packages/tx/src/gas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,11 @@ export type QuoteStdFee = {
}[];
};

// We have experienced instabilities with the base fee query. To avoid debugging its stability
// for the sake of time, we have opted in to increase the base fee multiplier to 1.65 from the original
// value of 1.5 which was equal to the gas multiplier. The update was applied on 2024-10-27.
export const defaultBaseFeeMultiplier = 1.65;

/** Tx body portions relevant for simulation */
export type SimBody = Partial<
Pick<
Expand Down Expand Up @@ -114,7 +119,7 @@ export async function estimateGasFee({
const { feeDenom, gasPrice } = await getDefaultGasPrice({
chainId,
chainList,
gasMultiplier,
baseFeeMultiplier: defaultBaseFeeMultiplier,
});
return {
gas: gasLimit,
Expand Down Expand Up @@ -493,7 +498,6 @@ export async function getGasPriceByFeeDenom({
chainId,
chainList,
feeDenom,
gasMultiplier = 1.5,
defaultGasPrice = 0.025,
}: {
chainId: string;
Expand All @@ -513,7 +517,7 @@ export async function getGasPriceByFeeDenom({
const defaultFee = await getDefaultGasPrice({
chainId,
chainList,
gasMultiplier,
baseFeeMultiplier: defaultBaseFeeMultiplier,
});

if (defaultFee.feeDenom === feeDenom) {
Expand Down Expand Up @@ -557,13 +561,13 @@ export async function getGasPriceByFeeDenom({
export async function getDefaultGasPrice({
chainId,
chainList,
gasMultiplier = 1.5,
baseFeeMultiplier = defaultBaseFeeMultiplier,
defaultGasPrice = 0.025,
}: {
chainId: string;
chainList: ChainWithFeatures[];
gasMultiplier?: number;
defaultGasPrice?: number;
baseFeeMultiplier?: number;
}) {
const chain = chainList.find(({ chain_id }) => chain_id === chainId);
if (!chain) throw new Error("Chain not found: " + chainId);
Expand All @@ -586,7 +590,7 @@ export async function getDefaultGasPrice({

feeDenom = baseDenom;
// Add slippage multiplier to account for shifting gas prices in gas market
gasPrice = baseFeePrice.mul(new Dec(gasMultiplier));
gasPrice = baseFeePrice.mul(new Dec(baseFeeMultiplier));
} else {
// registry

Expand Down

0 comments on commit c483069

Please sign in to comment.