@@ -22,15 +22,6 @@ import "test_helpers.cdc"
2222// Published via the FIXED publish_beta_cap.cdc.
2323// Cap stored at FlowALPv0.PoolCapStoragePath.
2424//
25- // ePositionUser — Capability<auth(EPosition) &Pool>
26- // EPosition-only capability; can perform pool-level position
27- // ops on any position by ID. No EParticipant.
28- // Cap stored at FlowALPv0.PoolCapStoragePath.
29- //
30- // eParticipantPositionUser — Capability<auth(EParticipant, EPosition) &Pool> over-grant
31- // Current (unfixed) beta cap — grants EPosition unnecessarily.
32- // Cap stored at FlowALPv0.PoolCapStoragePath.
33- //
3425// eRebalanceUser — Capability<auth(ERebalance) &Pool>
3526// Narrowly-scoped cap for rebalancer contracts.
3627// Cap stored at FlowALPv0.PoolCapStoragePath.
@@ -52,7 +43,7 @@ import "test_helpers.cdc"
5243// =============================================================================
5344
5445
55- // Position created for PROTOCOL_ACCOUNT in setup — used as target for EPosition tests.
46+ // Position created for PROTOCOL_ACCOUNT in setup — used as target for ERebalance tests.
5647access (all ) var setupPid : UInt64 = 0
5748access (all ) var ePositionAdminPid : UInt64 = 0
5849
@@ -61,8 +52,6 @@ access(all) var snapshot: UInt64 = 0
6152// Role accounts
6253access (all ) var userWithoutCap = Test .createAccount ()
6354access (all ) var eParticipantUser = Test .createAccount ()
64- access (all ) var ePositionUser = Test .createAccount ()
65- access (all ) var eParticipantPositionUser = Test .createAccount ()
6655access (all ) var eRebalanceUser = Test .createAccount ()
6756access (all ) var ePositionAdminUser = Test .createAccount ()
6857access (all ) var eGovernanceUser = Test .createAccount ()
@@ -71,7 +60,7 @@ access(all) var eGovernanceUser = Test.createAccount()
7160/// Used in negative tests to verify governance methods are inaccessible to them.
7261access (all )
7362fun getNonGovernanceUsers (): [Test .TestAccount ] {
74- return [eParticipantUser , ePositionUser , eParticipantPositionUser , eRebalanceUser , ePositionAdminUser ]
63+ return [eParticipantUser , eRebalanceUser , ePositionAdminUser ]
7564}
7665
7766access (all )
@@ -150,28 +139,6 @@ fun setup() {
150139 Test .beSucceeded ()
151140 )
152141
153- // ─────────────────────────────────────────────────────────────────────────
154- // EPosition user — EPosition-ONLY capability (no EParticipant)
155- // ─────────────────────────────────────────────────────────────────────────
156- setupMoetVault (ePositionUser , beFailed : false )
157- mintMoet (signer : PROTOCOL_ACCOUNT , to : ePositionUser .address , amount : 100.0 , beFailed : false )
158- Test .expect (
159- _execute2Signers (
160- " ../tests/transactions/flow-alp/setup/grant_eposition_cap.cdc" ,
161- [],
162- PROTOCOL_ACCOUNT ,
163- ePositionUser
164- ),
165- Test .beSucceeded ()
166- )
167-
168- // ─────────────────────────────────────────────────────────────────────────
169- // EParticipantPosition user — EParticipant+EPosition capability (current over-grant)
170- // ─────────────────────────────────────────────────────────────────────────
171- setupMoetVault (eParticipantPositionUser , beFailed : false )
172- mintMoet (signer : PROTOCOL_ACCOUNT , to : eParticipantPositionUser .address , amount : 100.0 , beFailed : false )
173- grantBetaPoolParticipantAccess (PROTOCOL_ACCOUNT , eParticipantPositionUser )
174-
175142 // ─────────────────────────────────────────────────────────────────────────
176143 // ERebalance user — ERebalance-only capability (rebalancer simulation)
177144 // ─────────────────────────────────────────────────────────────────────────
@@ -277,222 +244,6 @@ fun testEParticipant_CreateAndDeposit() {
277244 Test .assertEqual (6.0 , creditBalance )
278245}
279246
280- // =============================================================================
281- // EParticipant+EPosition — over-grant (current beta cap via publish_beta_cap.cdc)
282- // =============================================================================
283- //
284- // Actor: eParticipantPositionUser — Capability<auth(EParticipant, EPosition) &Pool>
285- // Issued by publish_beta_cap.cdc and stored at FlowALPv0.PoolCapStoragePath.
286- // This is the CURRENT (unfixed) beta cap. EPosition is NOT needed for normal
287- // user actions; its presence lets this actor perform pool-level position ops
288- // on ANY position, including positions owned by other accounts.
289- //
290- // Matrix rows: createPosition (EParticipant), depositToPosition (EParticipant),
291- // withdraw [OVERGRANT], withdrawAndPull [OVERGRANT], depositAndPush [OVERGRANT],
292- // lockPosition [OVERGRANT], unlockPosition [OVERGRANT], rebalancePosition [OVERGRANT],
293- // rebalance (Position) [OVERGRANT — same entry point as rebalancePosition]
294- //
295- // The [OVERGRANT] rows confirm the security issue: a normal beta user can operate on
296- // positions they do not own (setupPid is owned by PROTOCOL_ACCOUNT).
297-
298- /// Over-granted beta cap still allows EParticipant operations (createPosition, depositToPosition).
299- access (all )
300- fun testEParticipantPosition_CreateAndDeposit () {
301- safeReset ()
302-
303- let result = _executeTransaction (
304- " ../tests/transactions/flow-alp/eparticipant/create_and_deposit_via_cap.cdc" ,
305- [],
306- eParticipantPositionUser
307- )
308- Test .expect (result , Test .beSucceeded ())
309-
310- // Verify position was created and funded: create_and_deposit_via_cap.cdc deposits
311- // 5.0 MOET (createPosition) + 1.0 MOET (depositToPosition) = 6.0 MOET credit.
312- let newPid = getLastPositionId ()
313- let creditBalance = getCreditBalanceForType (
314- details : getPositionDetails (pid : newPid , beFailed : false ),
315- vaultType : Type <@MOET.Vault >()
316- )
317- Test .assertEqual (6.0 , creditBalance )
318- }
319-
320- /// Over-granted beta cap allows Pool.withdraw on ANY position — including
321- /// setupPid owned by PROTOCOL_ACCOUNT.
322- access (all )
323- fun testEParticipantPosition_WithdrawAnyPosition () {
324- safeReset ()
325-
326- let balanceBefore = getBalance (address : eParticipantPositionUser .address , vaultPublicPath : MOET .VaultPublicPath )!
327- let result = _executeTransaction (
328- " ../tests/transactions/flow-alp/eposition/withdraw_any.cdc" ,
329- [setupPid , 1.0 ],
330- eParticipantPositionUser
331- )
332- Test .expect (result , Test .beSucceeded ())
333- let balanceAfter = getBalance (address : eParticipantPositionUser .address , vaultPublicPath : MOET .VaultPublicPath )!
334- Test .assertEqual (balanceAfter , balanceBefore + 1.0 )
335- }
336-
337- /// Over-granted beta cap allows Pool.withdrawAndPull on ANY position — including
338- /// positions owned by other accounts.
339- access (all )
340- fun testEParticipantPosition_WithdrawAndPullAnyPosition () {
341- safeReset ()
342-
343- let balanceBefore = getBalance (address : eParticipantPositionUser .address , vaultPublicPath : MOET .VaultPublicPath )!
344- let result = _executeTransaction (
345- " ../tests/transactions/flow-alp/eposition/withdraw_and_pull_any.cdc" ,
346- [setupPid , 1.0 ],
347- eParticipantPositionUser
348- )
349- Test .expect (result , Test .beSucceeded ())
350- let balanceAfter = getBalance (address : eParticipantPositionUser .address , vaultPublicPath : MOET .VaultPublicPath )!
351- Test .assertEqual (balanceAfter , balanceBefore + 1.0 )
352- }
353-
354- /// Over-granted beta cap allows Pool.depositAndPush on ANY position — including
355- /// positions owned by other accounts.
356- access (all )
357- fun testEParticipantPosition_DepositAndPushAnyPosition () {
358- safeReset ()
359-
360- let creditBefore = getCreditBalanceForType (
361- details : getPositionDetails (pid : setupPid , beFailed : false ),
362- vaultType : Type <@MOET.Vault >()
363- )
364- let result = _executeTransaction (
365- " ../tests/transactions/flow-alp/eposition/deposit_and_push_any.cdc" ,
366- [setupPid , 1.0 ],
367- eParticipantPositionUser
368- )
369- Test .expect (result , Test .beSucceeded ())
370- let creditAfter = getCreditBalanceForType (
371- details : getPositionDetails (pid : setupPid , beFailed : false ),
372- vaultType : Type <@MOET.Vault >()
373- )
374- Test .assertEqual (creditBefore + 1.0 , creditAfter )
375- }
376-
377- /// Over-granted beta cap allows Pool.lockPosition and Pool.unlockPosition on ANY position —
378- /// including positions owned by other accounts.
379- access (all )
380- fun testEParticipantPosition_LockUnlockAnyPosition () {
381- safeReset ()
382-
383- let result = _executeTransaction (
384- " ../tests/transactions/flow-alp/eposition/lock_any.cdc" ,
385- [setupPid ],
386- eParticipantPositionUser
387- )
388- Test .expect (result , Test .beSucceeded ())
389- }
390-
391- /// Over-granted beta cap allows Pool.rebalancePosition on any position.
392- access (all )
393- fun testEParticipantPosition_RebalancePosition () {
394- safeReset ()
395-
396- let result = _executeTransaction (
397- " ../tests/transactions/flow-alp/eposition/rebalance_position_via_cap.cdc" ,
398- [setupPid , true ],
399- eParticipantPositionUser
400- )
401- Test .expect (result , Test .beSucceeded ())
402- }
403-
404- // =============================================================================
405- // EPosition — narrowly-scoped EPosition-only Pool capability
406- // =============================================================================
407- //
408- // Actor: ePositionUser — Capability<auth(EPosition) &Pool>
409- // Matrix rows: withdraw, withdrawAndPull, depositAndPush, lockPosition, unlockPosition,
410- // rebalancePosition
411-
412- /// EPosition cap allows Pool.withdraw on ANY position by ID — including
413- /// setupPid owned by PROTOCOL_ACCOUNT.
414- access (all )
415- fun testEPosition_WithdrawAnyPosition () {
416- safeReset ()
417-
418- let balanceBefore = getBalance (address : ePositionUser .address , vaultPublicPath : MOET .VaultPublicPath )!
419- let result = _executeTransaction (
420- " ../tests/transactions/flow-alp/eposition/withdraw_any.cdc" ,
421- [setupPid , 1.0 ],
422- ePositionUser
423- )
424- Test .expect (result , Test .beSucceeded ())
425- let balanceAfter = getBalance (address : ePositionUser .address , vaultPublicPath : MOET .VaultPublicPath )!
426- Test .assertEqual (balanceAfter , balanceBefore + 1.0 )
427- }
428-
429- /// EPosition cap allows Pool.withdrawAndPull on ANY position — including positions
430- /// owned by other accounts.
431- access (all )
432- fun testEPosition_WithdrawAndPullAnyPosition () {
433- safeReset ()
434-
435- let balanceBefore = getBalance (address : ePositionUser .address , vaultPublicPath : MOET .VaultPublicPath )!
436- let result = _executeTransaction (
437- " ../tests/transactions/flow-alp/eposition/withdraw_and_pull_any.cdc" ,
438- [setupPid , 1.0 ],
439- ePositionUser
440- )
441- Test .expect (result , Test .beSucceeded ())
442- let balanceAfter = getBalance (address : ePositionUser .address , vaultPublicPath : MOET .VaultPublicPath )!
443- Test .assertEqual (balanceAfter , balanceBefore + 1.0 )
444- }
445-
446- /// EPosition cap allows Pool.depositAndPush on ANY position — including positions
447- /// owned by other accounts.
448- access (all )
449- fun testEPosition_DepositAndPushAnyPosition () {
450- safeReset ()
451-
452- let creditBefore = getCreditBalanceForType (
453- details : getPositionDetails (pid : setupPid , beFailed : false ),
454- vaultType : Type <@MOET.Vault >()
455- )
456- let result = _executeTransaction (
457- " ../tests/transactions/flow-alp/eposition/deposit_and_push_any.cdc" ,
458- [setupPid , 1.0 ],
459- ePositionUser
460- )
461- Test .expect (result , Test .beSucceeded ())
462- let creditAfter = getCreditBalanceForType (
463- details : getPositionDetails (pid : setupPid , beFailed : false ),
464- vaultType : Type <@MOET.Vault >()
465- )
466- Test .assertEqual (creditBefore + 1.0 , creditAfter )
467- }
468-
469- /// EPosition cap allows Pool.lockPosition and Pool.unlockPosition on ANY position —
470- /// including positions owned by other accounts.
471- access (all )
472- fun testEPosition_LockUnlockAnyPosition () {
473- safeReset ()
474-
475- let result = _executeTransaction (
476- " ../tests/transactions/flow-alp/eposition/lock_any.cdc" ,
477- [setupPid ],
478- ePositionUser
479- )
480- Test .expect (result , Test .beSucceeded ())
481- }
482-
483- /// EPosition cap allows Pool.rebalancePosition.
484- access (all )
485- fun testEPosition_RebalancePosition () {
486- safeReset ()
487-
488- let result = _executeTransaction (
489- " ../tests/transactions/flow-alp/eposition/rebalance_position_via_cap.cdc" ,
490- [setupPid , true ],
491- ePositionUser
492- )
493- Test .expect (result , Test .beSucceeded ())
494- }
495-
496247// =============================================================================
497248// ERebalance — narrowly-scoped rebalancer capability
498249// =============================================================================
0 commit comments