forked from MettaChain/PropChain-contract
-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathlib.rs
More file actions
704 lines (653 loc) · 26.3 KB
/
Copy pathlib.rs
File metadata and controls
704 lines (653 loc) · 26.3 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
#![allow(clippy::clone_on_copy)] // fires inside ink! generated storage code
#![cfg_attr(not(feature = "std"), no_std)]
#![allow(unexpected_cfgs)]
use ink::prelude::string::String;
use ink::prelude::vec::Vec;
use ink::storage::Mapping;
use propchain_traits::{DynamicFeeProvider, FeeOperation};
/// Dynamic Fee and Market Mechanism contract for PropChain.
/// Implements congestion-based fees, premium listing auctions, validator incentives,
/// and fee transparency for network participants.
#[ink::contract]
// `errors.rs` is `include!()`d before `strategies.rs`, so its in-file
// `#[cfg(test)] mod tests` lands before the strategies items in the module
// body. `clippy::items_after_test_module` flags that ordering, but moving
// every test after every include isn't worth the structural churn, so
// suppress the lint here.
#[allow(clippy::items_after_test_module)]
mod propchain_fees {
use super::*;
/// Basis points denominator (10000 = 100%)
const BASIS_POINTS: u128 = BasisPoints::DENOM as u128;
/// Default congestion window: number of recent operations to consider
const CONGESTION_WINDOW: u32 = 100;
/// Max fee multiplier from congestion (e.g. 3x base)
const MAX_CONGESTION_MULTIPLIER: u32 = 300; // 300% of base
include!("types.rs");
include!("errors.rs");
include!("strategies.rs");
#[ink(storage)]
pub struct FeeManager {
admin: AccountId,
/// Fee config per operation type (optional override; else use default)
operation_config: Mapping<FeeOperation, FeeConfig>,
/// Default fee config
default_config: FeeConfig,
/// Recent operation timestamps for congestion (ring buffer style: count per slot)
recent_ops_count: u32,
last_congestion_reset: u64,
/// Premium listing auctions: auction_id -> PremiumAuction
auctions: Mapping<u64, PremiumAuction>,
auction_bids: Mapping<(u64, AccountId), AuctionBid>,
auction_count: u64,
/// Accumulated fees (to be distributed)
fee_treasury: u128,
/// Validator/participant rewards: account -> pending amount
pending_rewards: Mapping<AccountId, u128>,
/// Reward history (for reporting)
reward_records: Mapping<u64, RewardRecord>,
reward_record_count: u64,
/// Total fees collected (all time)
total_fees_collected: u128,
/// Total distributed to validators/participants
total_distributed: u128,
/// Authorized validators (receive incentive share)
validators: Mapping<AccountId, bool>,
/// List of validator accounts for distribution (enumerable)
validator_list: Vec<AccountId>,
/// Distribution rate for validators (basis points of collected fees)
validator_share_bp: BasisPoints,
/// Distribution rate for treasury (rest)
treasury_share_bp: BasisPoints,
/// Dynamic fee configuration based on pool utilisation / market congestion
dynamic_fee_config: DynamicFeeConfig,
}
#[ink(event)]
pub struct FeeConfigUpdated {
#[ink(topic)]
by: AccountId,
operation: Option<FeeOperation>,
base_fee: u128,
timestamp: u64,
}
#[ink(event)]
pub struct PremiumAuctionCreated {
#[ink(topic)]
auction_id: u64,
#[ink(topic)]
property_id: u64,
#[ink(topic)]
seller: AccountId,
min_bid: u128,
end_time: u64,
fee_paid: u128,
}
#[ink(event)]
pub struct PremiumAuctionBid {
#[ink(topic)]
auction_id: u64,
#[ink(topic)]
bidder: AccountId,
amount: u128,
outbid_previous: u128,
}
#[ink(event)]
pub struct PremiumAuctionSettled {
#[ink(topic)]
auction_id: u64,
#[ink(topic)]
property_id: u64,
#[ink(topic)]
winner: AccountId,
amount: u128,
timestamp: u64,
}
#[ink(event)]
pub struct RewardsDistributed {
#[ink(topic)]
recipient: AccountId,
amount: u128,
reason: RewardReason,
timestamp: u64,
}
/// Emitted whenever the dynamic fee rate changes due to a config update
/// or a shift in pool utilisation tracked via `set_dynamic_fee_config`.
#[ink(event)]
pub struct FeeRateUpdated {
#[ink(topic)]
by: AccountId,
/// Previous effective fee rate in basis points
old_rate_bps: BasisPoints,
/// New effective fee rate in basis points
new_rate_bps: BasisPoints,
timestamp: u64,
}
impl FeeManager {
#[ink(constructor)]
pub fn new(base_fee: u128, min_fee: u128, max_fee: u128) -> Self {
let caller = Self::env().caller();
let timestamp = Self::env().block_timestamp();
let default_config = FeeConfig {
base_fee,
min_fee,
max_fee,
congestion_sensitivity: 80,
demand_factor_bp: BasisPoints::new(500),
calculation_method: FeeCalculationMethod::Dynamic,
last_updated: timestamp,
};
Self {
admin: caller,
operation_config: Mapping::default(),
default_config,
recent_ops_count: 0,
last_congestion_reset: timestamp,
auctions: Mapping::default(),
auction_bids: Mapping::default(),
auction_count: 0,
fee_treasury: 0,
pending_rewards: Mapping::default(),
reward_records: Mapping::default(),
reward_record_count: 0,
total_fees_collected: 0,
total_distributed: 0,
validators: Mapping::default(),
validator_list: Vec::new(),
validator_share_bp: BasisPoints::new(5000), // 50% to validators
treasury_share_bp: BasisPoints::new(5000), // 50% to treasury
dynamic_fee_config: DynamicFeeConfig {
base_fee_bps: BasisPoints::new(30), // 0.30 % base
congestion_multiplier: 300, // up to 3× at full utilisation
max_fee_bps: BasisPoints::new(200), // hard cap at 2.00 %
},
}
}
fn ensure_admin(&self) -> Result<(), FeeError> {
if self.env().caller() != self.admin {
return Err(FeeError::Unauthorized);
}
Ok(())
}
/// Get config for operation (operation-specific or default)
fn get_config(&self, op: FeeOperation) -> FeeConfig {
self.operation_config
.get(op)
.unwrap_or(self.default_config.clone())
}
/// Compute current congestion index (0-100) from recent activity
fn congestion_index(&self) -> u32 {
let now = self.env().block_timestamp();
let window_secs = 3600u64; // 1 hour window
if now.saturating_sub(self.last_congestion_reset) > window_secs {
return 0; // Reset after window
}
let count = self.recent_ops_count;
// Normalize to 0-100: CONGESTION_WINDOW ops = 100
(count.saturating_mul(100).saturating_div(CONGESTION_WINDOW)).min(100)
}
/// Demand factor in basis points (from recent volume)
fn demand_factor_bp(&self) -> BasisPoints {
let ci = self.congestion_index();
let demand_factor = self.default_config.demand_factor_bp.get();
let new_demand_factor = demand_factor.saturating_mul(ci).saturating_div(100);
BasisPoints::new(new_demand_factor)
}
// ========== Dynamic fee calculation ==========
/// Calculate fee for an operation using configured strategy
#[ink(message)]
pub fn calculate_fee(&self, operation: FeeOperation) -> u128 {
let config = self.get_config(operation);
let context = FeeContext {
congestion_index: self.congestion_index(),
demand_factor_bp: self.demand_factor_bp(),
operation,
};
FeeCalculator::calculate(&config, &context)
}
/// Record that a fee was collected (called by registry or self after charging)
#[ink(message)]
pub fn record_fee_collected(
&mut self,
_operation: FeeOperation,
amount: u128,
from: AccountId,
) -> Result<(), FeeError> {
let _ = from;
self.recent_ops_count = self
.recent_ops_count
.saturating_add(1)
.min(CONGESTION_WINDOW);
let now = self.env().block_timestamp();
if now.saturating_sub(self.last_congestion_reset) > 3600 {
self.last_congestion_reset = now;
self.recent_ops_count = 1;
}
self.fee_treasury = self.fee_treasury.saturating_add(amount);
self.total_fees_collected = self.total_fees_collected.saturating_add(amount);
Ok(())
}
// ========== Automated fee adjustment ==========
/// Automated fee adjustment based on recent utilization vs target
#[ink(message)]
pub fn update_fee_params(&mut self) -> Result<(), FeeError> {
self.ensure_admin()?;
let now = self.env().block_timestamp();
let congestion = self.congestion_index();
let mut config = self.default_config.clone();
if congestion > 70 {
config.base_fee = config
.base_fee
.saturating_mul(105)
.saturating_div(100)
.min(config.max_fee);
} else if congestion < 30 {
config.base_fee = config
.base_fee
.saturating_mul(95)
.saturating_div(100)
.max(config.min_fee);
}
config.last_updated = now;
self.default_config = config.clone();
self.env().emit_event(FeeConfigUpdated {
by: self.env().caller(),
operation: None,
base_fee: config.base_fee,
timestamp: now,
});
Ok(())
}
/// Set fee config for an operation (admin)
#[ink(message)]
pub fn set_operation_config(
&mut self,
operation: FeeOperation,
config: FeeConfig,
) -> Result<(), FeeError> {
self.ensure_admin()?;
if config.min_fee > config.max_fee || config.base_fee < config.min_fee {
return Err(FeeError::InvalidConfig);
}
self.operation_config.insert(operation, &config);
self.env().emit_event(FeeConfigUpdated {
by: self.env().caller(),
operation: Some(operation),
base_fee: config.base_fee,
timestamp: self.env().block_timestamp(),
});
Ok(())
}
// ========== Auction mechanism for premium listings ==========
/// Create premium listing auction (pay fee; fee goes to treasury)
#[ink(message)]
pub fn create_premium_auction(
&mut self,
property_id: u64,
min_bid: u128,
duration_seconds: u64,
) -> Result<u64, FeeError> {
let caller = self.env().caller();
let now = self.env().block_timestamp();
let fee = self.calculate_fee(FeeOperation::PremiumListingBid);
if fee > 0 {
self.fee_treasury = self.fee_treasury.saturating_add(fee);
self.total_fees_collected = self.total_fees_collected.saturating_add(fee);
}
self.auction_count += 1;
let auction_id = self.auction_count;
let auction = PremiumAuction {
property_id,
seller: caller,
min_bid,
current_bid: 0,
current_bidder: None,
end_time: now.saturating_add(duration_seconds),
settled: false,
fee_paid: fee,
};
self.auctions.insert(auction_id, &auction);
self.env().emit_event(PremiumAuctionCreated {
auction_id,
property_id,
seller: caller,
min_bid,
end_time: auction.end_time,
fee_paid: fee,
});
Ok(auction_id)
}
/// Place or increase bid (bid must be > current_bid and >= min_bid)
#[ink(message)]
pub fn place_bid(&mut self, auction_id: u64, amount: u128) -> Result<(), FeeError> {
let caller = self.env().caller();
let now = self.env().block_timestamp();
let mut auction = self
.auctions
.get(auction_id)
.ok_or(FeeError::AuctionNotFound)?;
if auction.settled {
return Err(FeeError::AlreadySettled);
}
if now >= auction.end_time {
return Err(FeeError::AuctionEnded);
}
if amount < auction.min_bid {
return Err(FeeError::BidTooLow);
}
if amount <= auction.current_bid {
return Err(FeeError::BidTooLow);
}
let outbid = auction.current_bid;
auction.current_bid = amount;
auction.current_bidder = Some(caller);
self.auctions.insert(auction_id, &auction);
self.auction_bids.insert(
(auction_id, caller),
&AuctionBid {
bidder: caller,
amount,
timestamp: now,
},
);
self.env().emit_event(PremiumAuctionBid {
auction_id,
bidder: caller,
amount,
outbid_previous: outbid,
});
Ok(())
}
/// Settle auction after end_time; winner is current_bidder
#[ink(message)]
pub fn settle_auction(&mut self, auction_id: u64) -> Result<(), FeeError> {
let now = self.env().block_timestamp();
let mut auction = self
.auctions
.get(auction_id)
.ok_or(FeeError::AuctionNotFound)?;
if auction.settled {
return Err(FeeError::AlreadySettled);
}
if now < auction.end_time {
return Err(FeeError::AuctionNotEnded);
}
let winner = auction.current_bidder.ok_or(FeeError::AuctionNotFound)?;
let amount = auction.current_bid;
auction.settled = true;
self.auctions.insert(auction_id, &auction);
// fee_paid was already added to fee_treasury at auction creation
self.env().emit_event(PremiumAuctionSettled {
auction_id,
property_id: auction.property_id,
winner,
amount,
timestamp: now,
});
Ok(())
}
#[ink(message)]
pub fn get_auction(&self, auction_id: u64) -> Option<PremiumAuction> {
self.auctions.get(auction_id)
}
#[ink(message)]
pub fn get_auction_count(&self) -> u64 {
self.auction_count
}
// ========== Incentives and distribution ==========
#[ink(message)]
pub fn add_validator(&mut self, account: AccountId) -> Result<(), FeeError> {
self.ensure_admin()?;
if self.validators.get(account).unwrap_or(false) {
return Ok(());
}
self.validators.insert(account, &true);
self.validator_list.push(account);
Ok(())
}
#[ink(message)]
pub fn remove_validator(&mut self, account: AccountId) -> Result<(), FeeError> {
self.ensure_admin()?;
self.validators.remove(account);
self.validator_list.retain(|&a| a != account);
Ok(())
}
#[ink(message)]
pub fn set_distribution_rates(
&mut self,
validator_share_bp: BasisPoints,
treasury_share_bp: BasisPoints,
) -> Result<(), FeeError> {
self.ensure_admin()?;
if validator_share_bp
.get()
.saturating_add(treasury_share_bp.get())
> BasisPoints::DENOM
{
return Err(FeeError::InvalidConfig);
}
self.validator_share_bp = validator_share_bp;
self.treasury_share_bp = treasury_share_bp;
Ok(())
}
/// Distribute accumulated fees: validator share to validators, rest to treasury
#[ink(message)]
pub fn distribute_fees(&mut self) -> Result<(), FeeError> {
self.ensure_admin()?;
let amount = self.fee_treasury;
if amount == 0 {
return Ok(());
}
let validator_total = self.validator_share_bp.mul_floor(amount);
let validator_list = self.validator_list.clone();
let validator_count = validator_list.len() as u32;
if validator_count > 0 && validator_total > 0 {
let per_validator = validator_total.saturating_div(validator_count as u128);
for acc in validator_list {
let current = self.pending_rewards.get(acc).unwrap_or(0);
self.pending_rewards
.insert(acc, ¤t.saturating_add(per_validator));
self.record_reward(acc, per_validator, RewardReason::ValidatorReward);
self.total_distributed = self.total_distributed.saturating_add(per_validator);
self.env().emit_event(RewardsDistributed {
recipient: acc,
amount: per_validator,
reason: RewardReason::ValidatorReward,
timestamp: self.env().block_timestamp(),
});
}
}
self.fee_treasury = 0;
Ok(())
}
fn record_reward(&mut self, account: AccountId, amount: u128, reason: RewardReason) {
self.reward_record_count += 1;
self.reward_records.insert(
self.reward_record_count,
&RewardRecord {
account,
amount,
reason,
timestamp: self.env().block_timestamp(),
},
);
}
/// Claim pending rewards for a participant
#[ink(message)]
pub fn claim_rewards(&mut self) -> Result<u128, FeeError> {
let caller = self.env().caller();
let amount = self.pending_rewards.get(caller).unwrap_or(0);
if amount == 0 {
return Ok(0);
}
self.pending_rewards.remove(caller);
self.env().emit_event(RewardsDistributed {
recipient: caller,
amount,
reason: RewardReason::ValidatorReward,
timestamp: self.env().block_timestamp(),
});
Ok(amount)
}
#[ink(message)]
pub fn pending_reward(&self, account: AccountId) -> u128 {
self.pending_rewards.get(account).unwrap_or(0)
}
// ========== Market-based price discovery & transparency ==========
/// Recommended fee for an operation (market-based price discovery)
#[ink(message)]
pub fn get_recommended_fee(&self, operation: FeeOperation) -> u128 {
self.calculate_fee(operation)
}
/// Fee estimate with optimization recommendation
#[ink(message)]
pub fn get_fee_estimate(&self, operation: FeeOperation) -> FeeEstimate {
let config = self.get_config(operation);
let congestion = self.congestion_index();
let demand_bp = self.demand_factor_bp();
let context = FeeContext {
congestion_index: congestion,
demand_factor_bp: demand_bp,
operation,
};
let estimated = FeeCalculator::calculate(&config, &context);
let congestion_level = if congestion < 33 {
"low"
} else if congestion < 66 {
"medium"
} else {
"high"
};
let recommendation = if congestion >= 70 {
"Consider batching operations or submitting during off-peak."
} else if congestion < 30 {
"Good time to submit; fees are below average."
} else {
"Fees are at typical levels."
};
FeeEstimate {
operation,
estimated_fee: estimated,
min_fee: config.min_fee,
max_fee: config.max_fee,
congestion_level: congestion_level.into(),
recommendation: recommendation.into(),
}
}
/// Full fee report for transparency and dashboard
#[ink(message)]
pub fn get_fee_report(&self) -> FeeReport {
let now = self.env().block_timestamp();
let recommended = self.calculate_fee(FeeOperation::RegisterProperty);
let mut active_auctions = 0u32;
for id in 1..=self.auction_count {
if let Some(a) = self.auctions.get(id) {
if !a.settled && now < a.end_time {
active_auctions += 1;
}
}
}
FeeReport {
config: self.default_config.clone(),
congestion_index: self.congestion_index(),
recommended_fee: recommended,
total_fees_collected: self.total_fees_collected,
total_distributed: self.total_distributed,
operation_count_24h: self.recent_ops_count as u64,
premium_auctions_active: active_auctions,
timestamp: now,
}
}
/// Fee optimization recommendations for users
#[ink(message)]
pub fn get_fee_recommendations(&self) -> Vec<String> {
let mut rec = Vec::new();
let c = self.congestion_index();
if c >= 70 {
rec.push("High congestion: use batch operations to reduce total fee.".into());
rec.push("Consider submitting during off-peak hours.".into());
} else if c < 30 {
rec.push("Low congestion: current fees are favorable.".into());
}
rec.push("Premium listings: use auctions for better price discovery.".into());
rec.push("Check get_fee_estimate before each operation type.".into());
rec
}
#[ink(message)]
pub fn admin(&self) -> AccountId {
self.admin
}
#[ink(message)]
pub fn default_config(&self) -> FeeConfig {
self.default_config.clone()
}
#[ink(message)]
pub fn fee_treasury(&self) -> u128 {
self.fee_treasury
}
// ========== Dynamic fee model (Issue #508) ==========
/// Return the current effective fee rate in basis points, computed
/// from the stored `DynamicFeeConfig` and the live utilisation index.
///
/// Formula:
/// utilisation = congestion_index() (0 – 100)
/// multiplier = 100 + utilisation × (congestion_multiplier − 100) / 100
/// effective = base_fee_bps × multiplier / 100
/// effective = min(effective, max_fee_bps)
#[ink(message)]
pub fn get_current_fee_rate(&self) -> u32 {
Self::compute_fee_rate(&self.dynamic_fee_config, self.congestion_index())
}
/// Update the dynamic fee configuration (admin only).
/// Emits `FeeRateUpdated` with the old and new effective rates.
#[ink(message)]
pub fn set_dynamic_fee_config(&mut self, config: DynamicFeeConfig) -> Result<(), FeeError> {
self.ensure_admin()?;
if config.base_fee_bps > config.max_fee_bps {
return Err(FeeError::InvalidConfig);
}
if config.congestion_multiplier < 100 {
// Multiplier below 100 % would make fees decrease with load —
// not a valid congestion model.
return Err(FeeError::InvalidConfig);
}
let utilisation = self.congestion_index();
let old_rate = Self::compute_fee_rate(&self.dynamic_fee_config, utilisation);
let new_rate = Self::compute_fee_rate(&config, utilisation);
self.dynamic_fee_config = config;
let now = self.env().block_timestamp();
self.env().emit_event(FeeRateUpdated {
by: self.env().caller(),
old_rate_bps: BasisPoints::new(old_rate),
new_rate_bps: BasisPoints::new(new_rate),
timestamp: now,
});
Ok(())
}
/// Return a copy of the current `DynamicFeeConfig`.
#[ink(message)]
pub fn dynamic_fee_config(&self) -> DynamicFeeConfig {
self.dynamic_fee_config.clone()
}
/// Pure helper: compute effective fee rate (bps) for a given config
/// and utilisation index (0-100).
fn compute_fee_rate(config: &DynamicFeeConfig, utilisation: u32) -> u32 {
// multiplier_pct is 100 at 0 % util and congestion_multiplier at 100 % util.
let util = utilisation.min(100) as u64;
let base = config.base_fee_bps.get() as u64;
let cm = config.congestion_multiplier as u64;
// effective = base * (100 + util * (cm - 100) / 100) / 100
let multiplier_pct = 100u64.saturating_add(
util.saturating_mul(cm.saturating_sub(100))
.saturating_div(100),
);
let effective = base.saturating_mul(multiplier_pct).saturating_div(100);
(effective as u32).min(config.max_fee_bps.get())
}
}
impl DynamicFeeProvider for FeeManager {
#[ink(message)]
fn get_recommended_fee(&self, operation: FeeOperation) -> u128 {
self.calculate_fee(operation)
}
}
}