@@ -218,11 +218,17 @@ func TestDepositMultipleDeposits(t *testing.T) {
218218 // ASSERT: Bob's balance is correct
219219 assert .Equal (t , math .NewInt (50 * ONE_V2 ), bank .Balances [bob .Address ].AmountOf ("uusdn" ))
220220
221- // ASSERT: User position accumulated correctly
222- position , found , err := k .GetVaultsV2UserPosition (ctx , bob .Bytes , 1 )
221+ // ASSERT: First position has 30 USDN (first deposit)
222+ position1 , found , err := k .GetVaultsV2UserPosition (ctx , bob .Bytes , 1 )
223223 require .NoError (t , err )
224224 require .True (t , found )
225- assert .Equal (t , math .NewInt (50 * ONE_V2 ), position .DepositAmount )
225+ assert .Equal (t , math .NewInt (30 * ONE_V2 ), position1 .DepositAmount )
226+
227+ // ASSERT: Second position has 20 USDN (second deposit)
228+ position2 , found , err := k .GetVaultsV2UserPosition (ctx , bob .Bytes , 2 )
229+ require .NoError (t , err )
230+ require .True (t , found )
231+ assert .Equal (t , math .NewInt (20 * ONE_V2 ), position2 .DepositAmount )
226232
227233 // ASSERT: Position tracking works correctly (no longer using shares)
228234
@@ -293,8 +299,9 @@ func TestRequestWithdrawalBasic(t *testing.T) {
293299
294300 // ACT: Request withdrawal of 50 USDN
295301 resp , err := vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
296- Requester : bob .Address ,
297- Amount : math .NewInt (50 * ONE_V2 ),
302+ Requester : bob .Address ,
303+ Amount : math .NewInt (50 * ONE_V2 ),
304+ PositionId : 1 , // Use position 1 (created by deposit)
298305 })
299306
300307 // ASSERT: Request succeeds
@@ -344,8 +351,9 @@ func TestRequestWithdrawalInvalidAmount(t *testing.T) {
344351
345352 // ACT: Request withdrawal with zero amount
346353 _ , err = vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
347- Requester : bob .Address ,
348- Amount : math .ZeroInt (),
354+ Requester : bob .Address ,
355+ Amount : math .ZeroInt (),
356+ PositionId : 1 ,
349357 })
350358
351359 // ASSERT: Error returned
@@ -367,8 +375,9 @@ func TestRequestWithdrawalInsufficientBalance(t *testing.T) {
367375
368376 // ACT: Request withdrawal of more than deposited
369377 _ , err = vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
370- Requester : bob .Address ,
371- Amount : math .NewInt (100 * ONE_V2 ),
378+ Requester : bob .Address ,
379+ Amount : math .NewInt (100 * ONE_V2 ),
380+ PositionId : 1 ,
372381 })
373382
374383 // ASSERT: Error returned
@@ -379,15 +388,16 @@ func TestRequestWithdrawalInsufficientBalance(t *testing.T) {
379388func TestRequestWithdrawalNoPosition (t * testing.T ) {
380389 _ , vaultsV2Server , _ , ctx , bob := setupV2Test (t )
381390
382- // ACT: Request withdrawal without any position
391+ // ACT: Request withdrawal without any position
383392 _ , err := vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
384- Requester : bob .Address ,
385- Amount : math .NewInt (50 * ONE_V2 ),
393+ Requester : bob .Address ,
394+ Amount : math .NewInt (50 * ONE_V2 ),
395+ PositionId : 1 , // Try to access non-existent position
386396 })
387397
388- // ASSERT: Error returned
398+ // ASSERT: Error returned
389399 require .Error (t , err )
390- assert .Contains (t , err .Error (), "no position found" )
400+ assert .Contains (t , err .Error (), "position 1 not found" )
391401}
392402
393403func TestRequestWithdrawalMultipleRequests (t * testing.T ) {
@@ -404,15 +414,17 @@ func TestRequestWithdrawalMultipleRequests(t *testing.T) {
404414
405415 // ACT: First withdrawal request for 30 USDN
406416 resp1 , err := vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
407- Requester : bob .Address ,
408- Amount : math .NewInt (30 * ONE_V2 ),
417+ Requester : bob .Address ,
418+ Amount : math .NewInt (30 * ONE_V2 ),
419+ PositionId : 1 ,
409420 })
410421 require .NoError (t , err )
411422
412423 // ACT: Second withdrawal request for 20 USDN
413424 resp2 , err := vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
414- Requester : bob .Address ,
415- Amount : math .NewInt (20 * ONE_V2 ),
425+ Requester : bob .Address ,
426+ Amount : math .NewInt (20 * ONE_V2 ),
427+ PositionId : 1 ,
416428 })
417429 require .NoError (t , err )
418430
@@ -443,8 +455,9 @@ func TestProcessWithdrawalQueueBasic(t *testing.T) {
443455 require .NoError (t , err )
444456
445457 resp , err := vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
446- Requester : bob .Address ,
447- Amount : math .NewInt (50 * ONE_V2 ),
458+ Requester : bob .Address ,
459+ Amount : math .NewInt (50 * ONE_V2 ),
460+ PositionId : 1 , // Use position 1 (created by deposit)
448461 })
449462 require .NoError (t , err )
450463
@@ -513,8 +526,9 @@ func TestProcessWithdrawalQueueNotUnlocked(t *testing.T) {
513526 require .NoError (t , err )
514527
515528 resp , err := vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
516- Requester : bob .Address ,
517- Amount : math .NewInt (50 * ONE_V2 ),
529+ Requester : bob .Address ,
530+ Amount : math .NewInt (50 * ONE_V2 ),
531+ PositionId : 1 , // Use position 1 (created by deposit)
518532 })
519533 require .NoError (t , err )
520534
@@ -565,8 +579,9 @@ func TestProcessWithdrawalQueueWithLimit(t *testing.T) {
565579 })
566580 require .NoError (t , err )
567581 _ , err = vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
568- Requester : alice .Address ,
569- Amount : math .NewInt (30 * ONE_V2 ),
582+ Requester : alice .Address ,
583+ Amount : math .NewInt (30 * ONE_V2 ),
584+ PositionId : 1 , // Alice's first position
570585 })
571586 require .NoError (t , err )
572587
@@ -598,8 +613,9 @@ func TestClaimWithdrawalBasic(t *testing.T) {
598613 require .NoError (t , err )
599614
600615 resp , err := vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
601- Requester : bob .Address ,
602- Amount : math .NewInt (50 * ONE_V2 ),
616+ Requester : bob .Address ,
617+ Amount : math .NewInt (50 * ONE_V2 ),
618+ PositionId : 1 , // Use position 1 (created by deposit)
603619 })
604620 require .NoError (t , err )
605621
@@ -655,8 +671,9 @@ func TestClaimWithdrawalNotReady(t *testing.T) {
655671 require .NoError (t , err )
656672
657673 resp , err := vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
658- Requester : bob .Address ,
659- Amount : math .NewInt (50 * ONE_V2 ),
674+ Requester : bob .Address ,
675+ Amount : math .NewInt (50 * ONE_V2 ),
676+ PositionId : 1 , // Use position 1 (created by deposit)
660677 })
661678 require .NoError (t , err )
662679
@@ -685,8 +702,9 @@ func TestClaimWithdrawalWrongClaimer(t *testing.T) {
685702 require .NoError (t , err )
686703
687704 resp , err := vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
688- Requester : bob .Address ,
689- Amount : math .NewInt (50 * ONE_V2 ),
705+ Requester : bob .Address ,
706+ Amount : math .NewInt (50 * ONE_V2 ),
707+ PositionId : 1 , // Use position 1 (created by deposit)
690708 })
691709 require .NoError (t , err )
692710
@@ -741,8 +759,9 @@ func TestFullDepositWithdrawalCycle(t *testing.T) {
741759
742760 // ACT: Bob requests withdrawal of 60 USDN
743761 resp , err := vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
744- Requester : bob .Address ,
745- Amount : math .NewInt (60 * ONE_V2 ),
762+ Requester : bob .Address ,
763+ Amount : math .NewInt (60 * ONE_V2 ),
764+ PositionId : 1 ,
746765 })
747766 require .NoError (t , err )
748767
@@ -811,15 +830,17 @@ func TestMultiUserDepositWithdrawal(t *testing.T) {
811830
812831 // ACT: Bob requests withdrawal of 50 USDN
813832 bobResp , err := vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
814- Requester : bob .Address ,
815- Amount : math .NewInt (50 * ONE_V2 ),
833+ Requester : bob .Address ,
834+ Amount : math .NewInt (50 * ONE_V2 ),
835+ PositionId : 1 ,
816836 })
817837 require .NoError (t , err )
818838
819839 // ACT: Alice requests withdrawal of 100 USDN
820840 aliceResp , err := vaultsV2Server .RequestWithdrawal (ctx , & vaultsv2.MsgRequestWithdrawal {
821- Requester : alice .Address ,
822- Amount : math .NewInt (100 * ONE_V2 ),
841+ Requester : alice .Address ,
842+ Amount : math .NewInt (100 * ONE_V2 ),
843+ PositionId : 1 , // Alice's first position
823844 })
824845 require .NoError (t , err )
825846
@@ -1006,6 +1027,7 @@ func TestSetYieldPreferenceUpdatesPosition(t *testing.T) {
10061027 resp , err := vaultsV2Server .SetYieldPreference (ctx , & vaultsv2.MsgSetYieldPreference {
10071028 User : bob .Address ,
10081029 ReceiveYield : false ,
1030+ PositionId : 1 , // Bob's first position
10091031 })
10101032 require .NoError (t , err )
10111033 require .True (t , resp .PreviousPreference )
0 commit comments