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