Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🚧 inprogress #25

Open
wants to merge 10 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion abi/oracle_abi/src/main.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library oracle_abi;
library ;

pub struct Price {
asset_id: ContractId,
Expand Down
2 changes: 1 addition & 1 deletion abi/token_abi/src/main.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library token_abi;
library ;

abi Token {
// Initialize contract
Expand Down
92 changes: 46 additions & 46 deletions contracts/market/Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions contracts/market/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ authors = ["Alex Nagorny <[email protected]>"]
license = "Apache-2.0"

[dev-dependencies]
fuels = { version = "0.38.1", features = ["fuel-core-lib"] }
fuels = { version = "0.39", features = ["fuel-core-lib"] }
tokio = { version = "1.12", features = ["rt", "macros"] }

[[test]]
Expand All @@ -17,7 +17,6 @@ path = "tests/harness.rs"

[dependencies]
dotenv = "0.15.0"
fuels-types = "0.38.1"
rand = "0.8.5"
reqwest = "0.11.13"
serde_json = "1.0.91"
4 changes: 2 additions & 2 deletions contracts/market/Forc.lock
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[[package]]
name = 'core'
source = 'path+from-root-894BF76E6DA2FFD3'
source = 'path+from-root-FDF4A5DCC6ECD181'

[[package]]
name = 'market'
Expand All @@ -18,7 +18,7 @@ dependencies = ['std']

[[package]]
name = 'std'
source = 'git+https://github.com/fuellabs/sway?tag=v0.35.3#5d2b10bd83791d2eaff04206dbd45bfdd9cf23ff'
source = 'git+https://github.com/fuellabs/sway?tag=v0.37.0#607ac50176db8bef936f91bacf435d0ea37d041e'
dependencies = ['core']

[[package]]
Expand Down
2 changes: 1 addition & 1 deletion contracts/market/src/i64.sw
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
library i64;
library;

pub struct I64 {
value: u64,
Expand Down
96 changes: 92 additions & 4 deletions contracts/market/src/main.sw
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,12 @@ contract;
* @notice An efficient monolithic money market protocol
* @author SWAY GANG
*/
dep numbers;
dep structs;
dep i64;
mod numbers;
// mod structs;
mod i64;

use i64::I64;
use structs::*;
// use structs::*;
use numbers::*;
use oracle_abi::*;
use token_abi::*;
Expand All @@ -37,6 +37,94 @@ use std::{
u128::U128,
};

//library structs
//------------------------------------------------------------------------

pub struct MarketConfiguration {
governor: Address,
pause_guardian: Address,
base_token: ContractId,
base_token_decimals: u8,
base_token_price_feed: ContractId,
kink: u64, // decimals: 18
supply_per_second_interest_rate_slope_low: u64, // decimals: 18
supply_per_second_interest_rate_slope_high: u64, // decimals: 18
borrow_per_second_interest_rate_slope_low: u64, // decimals: 18
borrow_per_second_interest_rate_slope_high: u64, // decimals: 18
borrow_per_second_interest_rate_base: u64, // decimals: 18
store_front_price_factor: u64, // decimals: 4
base_tracking_supply_speed: u64, // decimals 18
base_tracking_borrow_speed: u64, // decimals 18
base_min_for_rewards: u64, // decimals base_token_decimals
base_borrow_min: u64, // decimals: base_token_decimals
target_reserves: u64, // decimals: base_token_decimals
reward_token: ContractId,
}

pub struct AssetConfig {
asset: ContractId,
price_feed: ContractId,
decimals: u8,
borrow_collateral_factor: u64, // decimals: 4
liquidate_collateral_factor: u64, // decimals: 4
liquidation_penalty: u64, // decimals: 4
supply_cap: u64, // decimals: asset decimals
}

pub struct PauseConfiguration {
supply_paused: bool,
withdraw_paused: bool,
absorb_paused: bool,
buy_pause: bool,
// claim_paused: bool,
}

pub struct UserBasic {
principal: I64, // decimals: base_asset_decimal
base_tracking_index: u64, // decimals: 18
base_tracking_accrued: u64, // decimals: native_asset_decimal
reward_claimed: u64, // decimals: native_asset_decimal
}

impl UserBasic {
pub fn default() -> Self {
UserBasic {
principal: I64::new(),
base_tracking_index: 0,
base_tracking_accrued: 0,
reward_claimed: 0,
}
}
}

pub struct MarketBasics {
base_supply_index: u64,// decimals 18
base_borrow_index: u64,// decimals 18
tracking_supply_index: u64,// decimals 18
tracking_borrow_index: u64,// decimals 18
total_supply_base: u64,// decimals base_asset_decimal
total_borrow_base: u64,// decimals base_asset_decimal
last_accrual_time: u64,
}

pub enum Error {
AlreadyInitialized: (),
Paused: (),
Unauthorized: (),
InsufficientReserves: (),
NotLiquidatable: (),
NotForSale: (),
TooMuchSlippage: (),
SupplyCapExceeded: (),
NotCollateralized: (),
BorrowTooSmall: (),
NotPermitted: (),
InvalidPayment: (),
DebuggingDisabled: (),
}

//------------------------------------------------------------------------

abi Market {
#[storage(read, write)]
fn debug_increment_timestamp();
Expand Down
2 changes: 1 addition & 1 deletion contracts/market/src/numbers.sw
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1
library numbers;
library;
use std::u128::U128;

impl U128 {
Expand Down
4 changes: 2 additions & 2 deletions contracts/market/src/structs.sw
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
// SPDX-License-Identifier: BUSL-1.1
library structs;
dep i64;
library;

mod i64;
use i64::I64;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use fuels_types::Address;
use fuels::types::Address;

use crate::utils::{
local_tests_utils::{
Expand Down
2 changes: 1 addition & 1 deletion contracts/market/tests/local_tests/functions/initialize.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
use fuels_types::Address;
use fuels::types::Address;

use crate::utils::local_tests_utils::market::{self, get_market_config, market_abi_calls};

Expand Down
Loading