@@ -672,24 +672,24 @@ impl<T: Config> Pallet<T> {
672
672
}
673
673
674
674
/// Calculate the `min_target_amount` for `SerpUp` operation.
675
- fn calculate_min_target_amount ( market_price : u64 , dinar_price : u64 , expand_by : Balance ) -> Balance {
676
- type Fix = FixedU128 < U128 > ;
677
- let expand_by_amount = Fix :: from_num ( 1 ) . saturating_mul_int ( expand_by as u128 ) ;
678
- let relative_price = Fix :: from_num ( market_price) / Fix :: from_num ( dinar_price) ;
679
- let min_target_amount_full = Fix :: from_num ( expand_by_amount) / Fix :: from_num ( relative_price) ;
680
- let min_target_fraction = Fix :: from_num ( min_target_amount_full) / Fix :: from_num ( 100 ) ;
681
- min_target_fraction. saturating_mul_int ( 94 as u128 ) . to_num :: < u128 > ( )
682
- }
675
+ // fn calculate_min_target_amount(market_price: u64, dinar_price: u64, expand_by: Balance) -> Balance {
676
+ // type Fix = FixedU128<U128>;
677
+ // let expand_by_amount = Fix::from_num(1).saturating_mul_int(expand_by as u128);
678
+ // let relative_price = Fix::from_num(market_price) / Fix::from_num(dinar_price);
679
+ // let min_target_amount_full = Fix::from_num(expand_by_amount) / Fix::from_num(relative_price);
680
+ // let min_target_fraction = Fix::from_num(min_target_amount_full) / Fix::from_num(100);
681
+ // min_target_fraction.saturating_mul_int(94 as u128).to_num::<u128>()
682
+ // }
683
683
684
684
/// Calculate the `max_supply_amount` for `SerpUp` operation.
685
- fn calculate_max_supply_amount ( market_price : u64 , dinar_price : u64 , contract_by : Balance ) -> Balance {
686
- type Fix = FixedU128 < U128 > ;
687
- let contract_by_amount = Fix :: from_num ( 1 ) . saturating_mul_int ( contract_by as u128 ) ;
688
- let relative_price = Fix :: from_num ( market_price) / Fix :: from_num ( dinar_price) ;
689
- let max_supply_amount_full = Fix :: from_num ( contract_by_amount) / Fix :: from_num ( relative_price) ;
690
- let max_supply_fraction = Fix :: from_num ( max_supply_amount_full) / Fix :: from_num ( 100 ) ;
691
- max_supply_fraction. saturating_mul_int ( 106 as u128 ) . to_num :: < u128 > ( )
692
- }
685
+ // fn calculate_max_supply_amount(market_price: u64, dinar_price: u64, contract_by: Balance) -> Balance {
686
+ // type Fix = FixedU128<U128>;
687
+ // let contract_by_amount = Fix::from_num(1).saturating_mul_int(contract_by as u128);
688
+ // let relative_price = Fix::from_num(market_price) / Fix::from_num(dinar_price);
689
+ // let max_supply_amount_full = Fix::from_num(contract_by_amount) / Fix::from_num(relative_price);
690
+ // let max_supply_fraction = Fix::from_num(max_supply_amount_full) / Fix::from_num(100);
691
+ // max_supply_fraction.saturating_mul_int(106 as u128).to_num::<u128>()
692
+ // }
693
693
694
694
/// FETCH SETCURRENCIES COIN PRICES
695
695
///
@@ -944,19 +944,13 @@ impl<T: Config> Pallet<T> {
944
944
// safe from underflow because `peg_price` is checked to be less than `market_price`
945
945
let expand_by = Self :: calculate_supply_change ( market_price, peg_price, total_supply) ;
946
946
947
- // `min_target_amount` for `SerpUp` operation
948
- let min_target_amount = Self :: calculate_min_target_amount ( market_price, dinar_price, expand_by) ;
949
-
950
- T :: SerpTreasury :: on_serpup ( T :: SetterCurrencyId :: get ( ) , expand_by, min_target_amount) . unwrap ( ) ;
947
+ T :: SerpTreasury :: on_serpup ( T :: SetterCurrencyId :: get ( ) , expand_by) . unwrap ( ) ;
951
948
}
952
949
market_price if market_price < peg_price => {
953
950
// safe from underflow because `peg_price` is checked to be greater than `market_price`
954
951
let contract_by = Self :: calculate_supply_change ( peg_price, market_price, total_supply) ;
955
952
956
- // `max_supply_amount` for `SerpDown` operation
957
- let max_supply_amount = Self :: calculate_max_supply_amount ( market_price, dinar_price, contract_by) ;
958
-
959
- T :: SerpTreasury :: on_serpdown ( T :: SetterCurrencyId :: get ( ) , contract_by, max_supply_amount) . unwrap ( ) ;
953
+ T :: SerpTreasury :: on_serpdown ( T :: SetterCurrencyId :: get ( ) , contract_by) . unwrap ( ) ;
960
954
}
961
955
_ => { }
962
956
}
@@ -1073,19 +1067,13 @@ impl<T: Config> Pallet<T> {
1073
1067
// safe from underflow because `peg_price` is checked to be less than `market_price`
1074
1068
let expand_by = Self :: calculate_supply_change ( market_price, peg_price, total_supply) ;
1075
1069
1076
- // `min_target_amount` for `SerpUp` operation
1077
- let min_target_amount = Self :: calculate_min_target_amount ( market_price, dinar_price, expand_by) ;
1078
-
1079
- T :: SerpTreasury :: on_serpup ( T :: GetSetUSDCurrencyId :: get ( ) , expand_by, min_target_amount) . unwrap ( ) ;
1070
+ T :: SerpTreasury :: on_serpup ( T :: GetSetUSDCurrencyId :: get ( ) , expand_by) . unwrap ( ) ;
1080
1071
}
1081
1072
market_price if market_price < peg_price => {
1082
1073
// safe from underflow because `peg_price` is checked to be greater than `market_price`
1083
1074
let contract_by = Self :: calculate_supply_change ( peg_price, market_price, total_supply) ;
1084
1075
1085
- // `max_supply_amount` for `SerpDown` operation
1086
- let max_supply_amount = Self :: calculate_max_supply_amount ( market_price, setter_price, contract_by) ;
1087
-
1088
- T :: SerpTreasury :: on_serpdown ( T :: GetSetUSDCurrencyId :: get ( ) , contract_by, max_supply_amount) . unwrap ( ) ;
1076
+ T :: SerpTreasury :: on_serpdown ( T :: GetSetUSDCurrencyId :: get ( ) , contract_by) . unwrap ( ) ;
1089
1077
}
1090
1078
_ => { }
1091
1079
}
@@ -1202,19 +1190,13 @@ impl<T: Config> Pallet<T> {
1202
1190
// safe from underflow because `peg_price` is checked to be less than `market_price`
1203
1191
let expand_by = Self :: calculate_supply_change ( market_price, peg_price, total_supply) ;
1204
1192
1205
- // `min_target_amount` for `SerpUp` operation
1206
- let min_target_amount = Self :: calculate_min_target_amount ( market_price, dinar_price, expand_by) ;
1207
-
1208
- T :: SerpTreasury :: on_serpup ( T :: GetSetEURCurrencyId :: get ( ) , expand_by, min_target_amount) . unwrap ( ) ;
1193
+ T :: SerpTreasury :: on_serpup ( T :: GetSetEURCurrencyId :: get ( ) , expand_by) . unwrap ( ) ;
1209
1194
}
1210
1195
market_price if market_price < peg_price => {
1211
1196
// safe from underflow because `peg_price` is checked to be greater than `market_price`
1212
1197
let contract_by = Self :: calculate_supply_change ( peg_price, market_price, total_supply) ;
1213
1198
1214
- // `max_supply_amount` for `SerpDown` operation
1215
- let max_supply_amount = Self :: calculate_max_supply_amount ( market_price, setter_price, contract_by) ;
1216
-
1217
- T :: SerpTreasury :: on_serpdown ( T :: GetSetEURCurrencyId :: get ( ) , contract_by, max_supply_amount) . unwrap ( ) ;
1199
+ T :: SerpTreasury :: on_serpdown ( T :: GetSetEURCurrencyId :: get ( ) , contract_by) . unwrap ( ) ;
1218
1200
}
1219
1201
_ => { }
1220
1202
}
@@ -1331,19 +1313,13 @@ impl<T: Config> Pallet<T> {
1331
1313
// safe from underflow because `peg_price` is checked to be less than `market_price`
1332
1314
let expand_by = Self :: calculate_supply_change ( market_price, peg_price, total_supply) ;
1333
1315
1334
- // `min_target_amount` for `SerpUp` operation
1335
- let min_target_amount = Self :: calculate_min_target_amount ( market_price, dinar_price, expand_by) ;
1336
-
1337
- T :: SerpTreasury :: on_serpup ( T :: GetSetGBPCurrencyId :: get ( ) , expand_by, min_target_amount) . unwrap ( ) ;
1316
+ T :: SerpTreasury :: on_serpup ( T :: GetSetGBPCurrencyId :: get ( ) , expand_by) . unwrap ( ) ;
1338
1317
}
1339
1318
market_price if market_price < peg_price => {
1340
1319
// safe from underflow because `peg_price` is checked to be greater than `market_price`
1341
1320
let contract_by = Self :: calculate_supply_change ( peg_price, market_price, total_supply) ;
1342
1321
1343
- // `max_supply_amount` for `SerpDown` operation
1344
- let max_supply_amount = Self :: calculate_max_supply_amount ( market_price, setter_price, contract_by) ;
1345
-
1346
- T :: SerpTreasury :: on_serpdown ( T :: GetSetGBPCurrencyId :: get ( ) , contract_by, max_supply_amount) . unwrap ( ) ;
1322
+ T :: SerpTreasury :: on_serpdown ( T :: GetSetGBPCurrencyId :: get ( ) , contract_by) . unwrap ( ) ;
1347
1323
}
1348
1324
_ => { }
1349
1325
}
@@ -1460,19 +1436,13 @@ impl<T: Config> Pallet<T> {
1460
1436
// safe from underflow because `peg_price` is checked to be less than `market_price`
1461
1437
let expand_by = Self :: calculate_supply_change ( market_price, peg_price, total_supply) ;
1462
1438
1463
- // `min_target_amount` for `SerpUp` operation
1464
- let min_target_amount = Self :: calculate_min_target_amount ( market_price, dinar_price, expand_by) ;
1465
-
1466
- T :: SerpTreasury :: on_serpup ( T :: GetSetCHFCurrencyId :: get ( ) , expand_by, min_target_amount) . unwrap ( ) ;
1439
+ T :: SerpTreasury :: on_serpup ( T :: GetSetCHFCurrencyId :: get ( ) , expand_by) . unwrap ( ) ;
1467
1440
}
1468
1441
market_price if market_price < peg_price => {
1469
1442
// safe from underflow because `peg_price` is checked to be greater than `market_price`
1470
1443
let contract_by = Self :: calculate_supply_change ( peg_price, market_price, total_supply) ;
1471
1444
1472
- // `max_supply_amount` for `SerpDown` operation
1473
- let max_supply_amount = Self :: calculate_max_supply_amount ( market_price, setter_price, contract_by) ;
1474
-
1475
- T :: SerpTreasury :: on_serpdown ( T :: GetSetCHFCurrencyId :: get ( ) , contract_by, max_supply_amount) . unwrap ( ) ;
1445
+ T :: SerpTreasury :: on_serpdown ( T :: GetSetCHFCurrencyId :: get ( ) , contract_by) . unwrap ( ) ;
1476
1446
}
1477
1447
_ => { }
1478
1448
}
@@ -1589,19 +1559,13 @@ impl<T: Config> Pallet<T> {
1589
1559
// safe from underflow because `peg_price` is checked to be less than `market_price`
1590
1560
let expand_by = Self :: calculate_supply_change ( market_price, peg_price, total_supply) ;
1591
1561
1592
- // `min_target_amount` for `SerpUp` operation
1593
- let min_target_amount = Self :: calculate_min_target_amount ( market_price, dinar_price, expand_by) ;
1594
-
1595
- T :: SerpTreasury :: on_serpup ( T :: GetSetSARCurrencyId :: get ( ) , expand_by, min_target_amount) . unwrap ( ) ;
1562
+ T :: SerpTreasury :: on_serpup ( T :: GetSetSARCurrencyId :: get ( ) , expand_by) . unwrap ( ) ;
1596
1563
}
1597
1564
market_price if market_price < peg_price => {
1598
1565
// safe from underflow because `peg_price` is checked to be greater than `market_price`
1599
1566
let contract_by = Self :: calculate_supply_change ( peg_price, market_price, total_supply) ;
1600
1567
1601
- // `max_supply_amount` for `SerpDown` operation
1602
- let max_supply_amount = Self :: calculate_max_supply_amount ( market_price, setter_price, contract_by) ;
1603
-
1604
- T :: SerpTreasury :: on_serpdown ( T :: GetSetSARCurrencyId :: get ( ) , contract_by, max_supply_amount) . unwrap ( ) ;
1568
+ T :: SerpTreasury :: on_serpdown ( T :: GetSetSARCurrencyId :: get ( ) , contract_by) . unwrap ( ) ;
1605
1569
}
1606
1570
_ => { }
1607
1571
}
0 commit comments