Skip to content

Commit 303397b

Browse files
authored
feat(app): add transparent fee calc (#4789)
2 parents b4e0380 + 9664534 commit 303397b

File tree

4 files changed

+184
-92
lines changed

4 files changed

+184
-92
lines changed

app2/src/lib/gasprice/index.ts

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -108,7 +108,9 @@ export class GasPriceMap extends LayerMap.Service<GasPriceMap>()("GasPriceByChai
108108
)
109109
),
110110
Effect.map((a) => ({
111-
value: GasPrice.BaseGasPrice(BigDecimal.make(a, 18)),
111+
value: GasPrice.AtomicGasPrice(BigDecimal.fromBigInt(a)),
112+
minimalDenom: "wei",
113+
denom: viemChain.nativeCurrency.symbol,
112114
additiveFee,
113115
decimals: 18,
114116
})),
@@ -154,13 +156,16 @@ export class GasPriceMap extends LayerMap.Service<GasPriceMap>()("GasPriceByChai
154156
O.map(x => x.average),
155157
)),
156158
O.let("decimals", () => x.coinDecimals),
157-
O.map(({ average, decimals }) =>
159+
O.let("minimalDenom", () => x.coinMinimalDenom),
160+
O.let("denom", () => x.coinDenom),
161+
O.map(({ average, decimals, minimalDenom, denom }) =>
158162
pipe(
159163
BigDecimal.unsafeFromNumber(average),
160-
BigDecimal.multiply(BigDecimal.make(1n, decimals)),
161-
GasPrice.BaseGasPrice,
164+
GasPrice.AtomicGasPrice,
162165
(value) => ({
163166
value,
167+
minimalDenom,
168+
denom,
164169
additiveFee: O.none<GasPrice.AtomicGasPrice>(),
165170
decimals,
166171
}),

app2/src/lib/gasprice/service.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,13 @@ export declare namespace GasPrice {
2929
*/
3030
export interface Service {
3131
readonly of: Effect.Effect<{
32-
value: BaseGasPrice
32+
value: AtomicGasPrice
3333
/**
34-
* e.g. L1 fee on BOB
34+
* e.g. L1 settlement fee on BOB
3535
*/
3636
additiveFee: O.Option<AtomicGasPrice>
37+
minimalDenom: string
38+
denom: string
3739
decimals: number
3840
}, GasPriceError>
3941
}

0 commit comments

Comments
 (0)