-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
19 changed files
with
488 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
2 changes: 1 addition & 1 deletion
2
tests/integration/pools/vessel_manager/apply_pending_rewards/apply_pending_rewards.tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
tests/integration/pools/vessel_manager/check_recovery_mode/check_recovery_mode.tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
test_check_recovery_mode.cairo | ||
├── When TCR is greater or equals than CCR | ||
│ └── it should return false | ||
└── When TCR is lower than CCR | ||
├── it should return true |
112 changes: 112 additions & 0 deletions
112
tests/integration/pools/vessel_manager/check_recovery_mode/test_check_recovery_mode.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,112 @@ | ||
use tests::tests_lib::{deploy_main_contracts}; | ||
use super::super::setup::open_vessel; | ||
use shisui::core::{ | ||
address_provider::{IAddressProviderDispatcher, IAddressProviderDispatcherTrait, AddressesKey}, | ||
admin_contract::{IAdminContractDispatcher, IAdminContractDispatcherTrait}, | ||
fee_collector::{IFeeCollectorDispatcher, IFeeCollectorDispatcherTrait}, | ||
debt_token::{IDebtTokenDispatcher, IDebtTokenDispatcherTrait}, | ||
price_feed::{IPriceFeedDispatcher, IPriceFeedDispatcherTrait}, | ||
}; | ||
use shisui::pools::{ | ||
borrower_operations::{IBorrowerOperationsDispatcher, IBorrowerOperationsDispatcherTrait}, | ||
vessel_manager::{IVesselManagerDispatcher, IVesselManagerDispatcherTrait}, | ||
}; | ||
use snforge_std::{ | ||
start_prank, stop_prank, store, map_entry_address, CheatTarget, spy_events, SpyOn, EventSpy, | ||
EventAssertions, start_mock_call, PrintTrait | ||
}; | ||
use starknet::{ContractAddress, contract_address_const, get_caller_address}; | ||
|
||
|
||
#[test] | ||
fn when_tcr_is_greater_or_equals_than_ccr_should_return_false() { | ||
let ( | ||
borrower_operations, | ||
vessel_manager, | ||
adress_provider, | ||
admin_contract, | ||
fee_collector, | ||
debt_token, | ||
price_feed, | ||
pragma_mock, | ||
active_pool, | ||
default_pool, | ||
asset, | ||
vessel_manager_operations_address | ||
) = | ||
deploy_main_contracts(); | ||
|
||
let mut asset_price: u256 = 1600_000000000000000000; | ||
let deposit_amount: u256 = 1_890000000000000000; | ||
let debt_token_amount: u256 = 2000_000000000000000000; | ||
|
||
let borrower = open_vessel( | ||
asset, | ||
price_feed, | ||
admin_contract, | ||
active_pool, | ||
default_pool, | ||
debt_token, | ||
borrower_operations, | ||
vessel_manager, | ||
pragma_mock, | ||
asset_price, | ||
deposit_amount, | ||
debt_token_amount | ||
); | ||
|
||
start_mock_call(active_pool.contract_address, 'get_asset_balance', 0_u256); | ||
start_mock_call(default_pool.contract_address, 'get_asset_balance', 0_u256); | ||
start_mock_call(active_pool.contract_address, 'get_debt_token_balance', 0_u256); | ||
start_mock_call(default_pool.contract_address, 'get_debt_token_balance', 0_u256); | ||
|
||
let is_recovery = vessel_manager.check_recovery_mode(asset.contract_address, asset_price); | ||
assert(!is_recovery, 'Wrong recovery mode'); | ||
} | ||
|
||
#[test] | ||
fn when_tcr_is_lower_than_ccr_should_return_true() { | ||
let ( | ||
borrower_operations, | ||
vessel_manager, | ||
adress_provider, | ||
admin_contract, | ||
fee_collector, | ||
debt_token, | ||
price_feed, | ||
pragma_mock, | ||
active_pool, | ||
default_pool, | ||
asset, | ||
vessel_manager_operations_address | ||
) = | ||
deploy_main_contracts(); | ||
|
||
let mut asset_price: u256 = 1600_000000000000000000; | ||
let deposit_amount: u256 = 1_890000000000000000; | ||
let debt_token_amount: u256 = 2000_000000000000000000; | ||
|
||
let borrower = open_vessel( | ||
asset, | ||
price_feed, | ||
admin_contract, | ||
active_pool, | ||
default_pool, | ||
debt_token, | ||
borrower_operations, | ||
vessel_manager, | ||
pragma_mock, | ||
asset_price, | ||
deposit_amount, | ||
debt_token_amount | ||
); | ||
|
||
start_mock_call(active_pool.contract_address, 'get_asset_balance', deposit_amount); | ||
start_mock_call(default_pool.contract_address, 'get_asset_balance', 0_u256); | ||
start_mock_call(active_pool.contract_address, 'get_debt_token_balance', debt_token_amount * 2); | ||
start_mock_call(default_pool.contract_address, 'get_debt_token_balance', 0_u256); | ||
|
||
let is_recovery = vessel_manager.check_recovery_mode(asset.contract_address, asset_price); | ||
assert(is_recovery, 'Wrong recovery mode'); | ||
} | ||
|
5 changes: 5 additions & 0 deletions
5
tests/integration/pools/vessel_manager/get_borrowing_fee/get_borrowing_fee.tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
test_get_borrowing_fee.cairo | ||
├── When borrowing fee is defined for asset | ||
│ └── it should return borrowing fee based on debt | ||
└── When borrowing fee is not defined for asset | ||
└── it should return 0 |
69 changes: 69 additions & 0 deletions
69
tests/integration/pools/vessel_manager/get_borrowing_fee/test_get_borrowing_fee.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
use starknet::{ContractAddress, contract_address_const, get_caller_address}; | ||
use super::super::setup::open_vessel; | ||
use shisui::core::{ | ||
address_provider::{IAddressProviderDispatcher, IAddressProviderDispatcherTrait, AddressesKey}, | ||
admin_contract::{IAdminContractDispatcher, IAdminContractDispatcherTrait}, | ||
fee_collector::{IFeeCollectorDispatcher, IFeeCollectorDispatcherTrait}, | ||
debt_token::{IDebtTokenDispatcher, IDebtTokenDispatcherTrait}, | ||
price_feed::{IPriceFeedDispatcher, IPriceFeedDispatcherTrait}, | ||
}; | ||
use shisui::pools::{ | ||
borrower_operations::{IBorrowerOperationsDispatcher, IBorrowerOperationsDispatcherTrait}, | ||
vessel_manager::{IVesselManagerDispatcher, IVesselManagerDispatcherTrait}, | ||
}; | ||
use tests::tests_lib::{deploy_main_contracts}; | ||
use snforge_std::{ | ||
start_prank, stop_prank, CheatTarget, spy_events, SpyOn, EventSpy, EventAssertions, | ||
start_mock_call, PrintTrait | ||
}; | ||
|
||
|
||
#[test] | ||
fn when_borrowing_fee_is_defined_for_asset_should_return_fee_based_on_debt() { | ||
let ( | ||
borrower_operations, | ||
vessel_manager, | ||
adress_provider, | ||
admin_contract, | ||
fee_collector, | ||
debt_token, | ||
price_feed, | ||
pragma_mock, | ||
active_pool, | ||
default_pool, | ||
asset, | ||
vessel_manager_operations_address | ||
) = | ||
deploy_main_contracts(); | ||
|
||
let debt_token_amount: u256 = 2000_000000000000000000; | ||
|
||
admin_contract.add_new_collateral(asset.contract_address, 1000, 18); | ||
|
||
let fee = vessel_manager.get_borrowing_fee(asset.contract_address, debt_token_amount); | ||
assert(fee == 1_0000000000000000000, 'Wrong fee'); | ||
} | ||
|
||
#[test] | ||
fn when_borrowing_fee_is_not_defined_for_asset_should_return_0() { | ||
let ( | ||
borrower_operations, | ||
vessel_manager, | ||
adress_provider, | ||
admin_contract, | ||
fee_collector, | ||
debt_token, | ||
price_feed, | ||
pragma_mock, | ||
active_pool, | ||
default_pool, | ||
asset, | ||
vessel_manager_operations_address | ||
) = | ||
deploy_main_contracts(); | ||
|
||
let debt_token_amount: u256 = 2000_000000000000000000; | ||
|
||
let fee = vessel_manager.get_borrowing_fee(asset.contract_address, debt_token_amount); | ||
assert(fee == 0, 'Wrong fee'); | ||
} |
5 changes: 5 additions & 0 deletions
5
tests/integration/pools/vessel_manager/get_borrowing_rate/get_borrowing_rate.tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
test_get_borrowing_fee.cairo | ||
├── When borrowing fee is defined for asset | ||
│ └── it should return borrowing fee | ||
└── When borrowing fee is not defined for asset | ||
└── it should return 0 |
67 changes: 67 additions & 0 deletions
67
tests/integration/pools/vessel_manager/get_borrowing_rate/test_get_borrowing_rate.cairo
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,67 @@ | ||
use starknet::{ContractAddress, contract_address_const, get_caller_address}; | ||
use super::super::setup::open_vessel; | ||
use shisui::core::{ | ||
address_provider::{IAddressProviderDispatcher, IAddressProviderDispatcherTrait, AddressesKey}, | ||
admin_contract::{IAdminContractDispatcher, IAdminContractDispatcherTrait}, | ||
fee_collector::{IFeeCollectorDispatcher, IFeeCollectorDispatcherTrait}, | ||
debt_token::{IDebtTokenDispatcher, IDebtTokenDispatcherTrait}, | ||
price_feed::{IPriceFeedDispatcher, IPriceFeedDispatcherTrait}, | ||
}; | ||
use shisui::pools::{ | ||
borrower_operations::{IBorrowerOperationsDispatcher, IBorrowerOperationsDispatcherTrait}, | ||
vessel_manager::{IVesselManagerDispatcher, IVesselManagerDispatcherTrait}, | ||
}; | ||
use tests::tests_lib::{deploy_main_contracts}; | ||
use snforge_std::{ | ||
start_prank, stop_prank, CheatTarget, spy_events, SpyOn, EventSpy, EventAssertions, | ||
start_mock_call, PrintTrait | ||
}; | ||
|
||
|
||
#[test] | ||
fn when_borrowing_fee_is_defined_for_asset_should_return_fee_based_on_debt() { | ||
let ( | ||
borrower_operations, | ||
vessel_manager, | ||
adress_provider, | ||
admin_contract, | ||
fee_collector, | ||
debt_token, | ||
price_feed, | ||
pragma_mock, | ||
active_pool, | ||
default_pool, | ||
asset, | ||
vessel_manager_operations_address | ||
) = | ||
deploy_main_contracts(); | ||
|
||
admin_contract.add_new_collateral(asset.contract_address, 1000, 18); | ||
|
||
let rate = vessel_manager.get_borrowing_rate(asset.contract_address); | ||
assert(rate == 5000000000000000, 'Wrong rate'); | ||
} | ||
|
||
#[test] | ||
fn when_borrowing_fee_is_not_defined_for_asset_should_return_0() { | ||
let ( | ||
borrower_operations, | ||
vessel_manager, | ||
adress_provider, | ||
admin_contract, | ||
fee_collector, | ||
debt_token, | ||
price_feed, | ||
pragma_mock, | ||
active_pool, | ||
default_pool, | ||
asset, | ||
vessel_manager_operations_address | ||
) = | ||
deploy_main_contracts(); | ||
|
||
let debt_token_amount: u256 = 2000_000000000000000000; | ||
|
||
let rate = vessel_manager.get_borrowing_rate(asset.contract_address); | ||
assert(rate == 0, 'Wrong fee'); | ||
} |
5 changes: 4 additions & 1 deletion
5
tests/integration/pools/vessel_manager/get_current_icr/get_current_icr.tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
test_get_current_icr.cairo | ||
└── When vessel exist icr is correctly returned | ||
├── When vessel exist | ||
├── it should return icr correctly calculated | ||
├── When vessel not exist | ||
└── it should return max value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 4 additions & 1 deletion
5
tests/integration/pools/vessel_manager/get_nominal_icr/get_nominal_icr.tree
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
test_get_nominal_icr.cairo | ||
└── When vessel exist nominal icr is correctly returned | ||
├── When vessel exist | ||
├── it should return nominal icr correctly calculated | ||
├── When vessel not exist | ||
└── it should return max value |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.