Skip to content
This repository was archived by the owner on Jul 30, 2025. It is now read-only.

Commit a92a411

Browse files
authored
Relay fee details: pocket money in fee token (#292)
1 parent ab109b6 commit a92a411

File tree

4 files changed

+21
-1
lines changed

4 files changed

+21
-1
lines changed

crates/shielder-relayer/src/fee.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,17 @@ pub struct FeeDetails {
2525
/// but excluding the commission.
2626
#[schema(value_type = String)]
2727
pub relayer_cost_native: U256,
28+
/// The actual on-chain cost of the relay in fee token, including gas and pocket money,
29+
/// but excluding the commission.
30+
#[schema(value_type = String)]
31+
pub relayer_cost_fee_token: U256,
32+
33+
/// The cost of pocket money in native.
34+
#[schema(value_type = String)]
35+
pub pocket_money_native: U256,
36+
/// The cost of pocket money in fee token.
37+
#[schema(value_type = String)]
38+
pub pocket_money_fee_token: U256,
2839

2940
/// Gas cost for relay call (in native token).
3041
#[schema(value_type = String)]
@@ -85,6 +96,9 @@ pub fn compute_fee(
8596
total_cost_native,
8697
total_cost_fee_token: scale_u256(total_cost_native, native_to_fee_ratio)?,
8798
relayer_cost_native,
99+
relayer_cost_fee_token: scale_u256(relayer_cost_native, native_to_fee_ratio)?,
100+
pocket_money_native: pocket_money,
101+
pocket_money_fee_token: scale_u256(pocket_money, native_to_fee_ratio)?,
88102
gas_cost_native,
89103
gas_cost_fee_token: scale_u256(gas_cost_native, native_to_fee_ratio)?,
90104
commission_native,

ts/shielder-sdk/__tests/client/actions.test.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -302,6 +302,8 @@ describe("ShielderActions", () => {
302302
gas_cost_native: 0n,
303303
gas_cost_fee_token: 0n,
304304
relayer_cost_native: 0n,
305+
pocket_money_native: 0n,
306+
pocket_money_fee_token: 0n,
305307
commission_native: 0n,
306308
commission_fee_token: 0n
307309
},

ts/shielder-sdk/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@cardinal-cryptography/shielder-sdk",
3-
"version": "0.3.0-rc.1",
3+
"version": "0.3.0-rc.2",
44
"description": "A web package for interacting with Shielder, a part of zkOS privacy engine.",
55
"license": "Apache-2.0",
66
"keywords": [

ts/shielder-sdk/src/chain/relayer.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@ const quoteFeesResponseSchema = z.object({
1717
gas_cost_native: z.coerce.bigint(),
1818
gas_cost_fee_token: z.coerce.bigint(),
1919
relayer_cost_native: z.coerce.bigint(),
20+
pocket_money_native: z.coerce.bigint(),
21+
pocket_money_fee_token: z.coerce.bigint(),
2022
commission_native: z.coerce.bigint(),
2123
commission_fee_token: z.coerce.bigint()
2224
}),
@@ -42,6 +44,8 @@ export const quotedFeesFromExpectedTokenFee = (totalCostFeeToken: bigint) => {
4244
gas_cost_native: 0n,
4345
gas_cost_fee_token: 0n,
4446
relayer_cost_native: 0n,
47+
pocket_money_native: 0n,
48+
pocket_money_fee_token: 0n,
4549
commission_native: 0n,
4650
commission_fee_token: 0n
4751
},

0 commit comments

Comments
 (0)