From d38760c312413e4590ba7b8ed95f1c89b306e9c3 Mon Sep 17 00:00:00 2001 From: Vid Kersic <38610409+Vid201@users.noreply.github.com> Date: Mon, 12 Aug 2024 14:22:20 +0200 Subject: [PATCH] fix: decimals info (#6) --- abis/market_abi/src/structs.sw | 12 ++++++------ contracts/market/src/main.sw | 4 ++-- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/abis/market_abi/src/structs.sw b/abis/market_abi/src/structs.sw index 1c1d2327..92f705b5 100644 --- a/abis/market_abi/src/structs.sw +++ b/abis/market_abi/src/structs.sw @@ -33,9 +33,9 @@ pub struct MarketConfiguration { pub borrow_per_second_interest_rate_slope_high: u256, // decimals: 18 pub borrow_per_second_interest_rate_base: u256, // decimals: 18 pub store_front_price_factor: u256, // decimals: 18 - pub base_tracking_index_scale: u256, // decimals: 18 - pub base_tracking_supply_speed: u256, // decimals: 18 - pub base_tracking_borrow_speed: u256, // decimals: 18 + pub base_tracking_index_scale: u256, // decimals: 15 + pub base_tracking_supply_speed: u256, // decimals: 15 + pub base_tracking_borrow_speed: u256, // decimals: 15 pub base_min_for_rewards: u256, // decimals: base_token_decimals pub base_borrow_min: u256, // decimals: base_token_decimals pub target_reserves: u256, // decimals: base_token_decimals @@ -88,7 +88,7 @@ impl PauseConfiguration { pub struct UserBasic { pub principal: I256, // decimals: base_asset_decimal - pub base_tracking_index: u256, // decimals: 18 + pub base_tracking_index: u256, // decimals: 15 pub base_tracking_accrued: u256, // decimals: base_accrual_scale } @@ -105,8 +105,8 @@ impl UserBasic { pub struct MarketBasics { pub base_supply_index: u256, // decimals: 15 pub base_borrow_index: u256, // decimals: 15 - pub tracking_supply_index: u256, // decimals: 18 - pub tracking_borrow_index: u256, // decimals: 18 + pub tracking_supply_index: u256, // decimals: 15 + pub tracking_borrow_index: u256, // decimals: 15 pub total_supply_base: u256, // decimals: base_asset_decimal pub total_borrow_base: u256, // decimals: base_asset_decimal pub last_accrual_time: u256, diff --git a/contracts/market/src/main.sw b/contracts/market/src/main.sw index ce55af9b..58aaa0c9 100644 --- a/contracts/market/src/main.sw +++ b/contracts/market/src/main.sw @@ -1174,10 +1174,10 @@ fn accrue_internal() { // Calculate rewards and update tracking indices if market_basic.total_supply_base >= storage.market_configuration.read().base_min_for_rewards { - market_basic.tracking_supply_index += storage.market_configuration.read().base_tracking_supply_speed * time_elapsed * base_scale / market_basic.total_supply_base; // decimals: 18 + market_basic.tracking_supply_index += storage.market_configuration.read().base_tracking_supply_speed * time_elapsed * base_scale / market_basic.total_supply_base; // decimals: 15 } if market_basic.total_borrow_base >= storage.market_configuration.read().base_min_for_rewards { - market_basic.tracking_borrow_index += storage.market_configuration.read().base_tracking_borrow_speed * time_elapsed * base_scale / market_basic.total_borrow_base; // decimals: 18 + market_basic.tracking_borrow_index += storage.market_configuration.read().base_tracking_borrow_speed * time_elapsed * base_scale / market_basic.total_borrow_base; // decimals: 15 } // Update last_accrual_time