@@ -155,3 +155,35 @@ fun test_borrow_supply(duration: u64, borrow: u64, supply: u64) {
155155 test::return_shared (pool);
156156 cleanup_test (registry, admin_cap, maintainer_cap, clock, scenario);
157157}
158+
159+ #[test]
160+ fun test_zero_utilization () {
161+ let (mut scenario, mut clock, admin_cap, maintainer_cap, pool_id) = setup_test ();
162+ scenario.next_tx (test_constants::admin ());
163+ let mut pool = scenario.take_shared_by_id <MarginPool <USDC >>(pool_id);
164+ let registry = scenario.take_shared <MarginRegistry >();
165+
166+ scenario.next_tx (test_constants::user1 ());
167+ let supply = 100 * test_constants::usdc_multiplier ();
168+ let coin = mint_coin <USDC >(supply, scenario.ctx ());
169+ pool.supply (®istry, coin, &clock, scenario.ctx ());
170+
171+ advance_time (&mut clock, margin_constants::year_ms ());
172+
173+ // Withdraw should give back same amount
174+ scenario.next_tx (test_constants::user1 ());
175+ let withdrawn_coin = pool.withdraw (®istry, option::none (), &clock, scenario.ctx ());
176+ assert ! (withdrawn_coin.value () == supply);
177+ destroy (withdrawn_coin);
178+
179+ test::return_shared (pool);
180+ cleanup_test (registry, admin_cap, maintainer_cap, clock, scenario);
181+ }
182+
183+ #[test]
184+ fun test_high_utilization_interest () {
185+ let duration = 1 ;
186+ let borrow = 79 * test_constants::usdc_multiplier (); // Just below optimal utilization
187+ let supply = 100 * test_constants::usdc_multiplier ();
188+ test_borrow_supply (duration, borrow, supply);
189+ }
0 commit comments