Skip to content

Commit e5fabcc

Browse files
Merge branch 'main' into UlianaAndrukhiv/280-rebalancing-failures
2 parents 4ddca00 + b9d0051 commit e5fabcc

83 files changed

Lines changed: 2875 additions & 197 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -179,7 +179,7 @@ FlowALP/
179179

180180
- `FungibleToken.Vault`: Standard token operations
181181
- `DeFiActions.Sink/Source`: DeFi protocol composability
182-
- Entitlements: `FlowALPv0.EParticipant`, `FlowALPv0.EPosition`, `FlowALPv0.EGovernance`, `FlowALPv0.ERebalance`
182+
- Entitlements: `FlowALPModels.EParticipant`, `FlowALPModels.EPosition`, `FlowALPModels.EGovernance`, `FlowALPModels.ERebalance`
183183

184184
## 🛠️ Development
185185

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import "FlowALPv0"
2+
import "FlowALPPositionResources"
3+
4+
/// Returns the maximum health for the given position.
5+
///
6+
/// @param positionOwner: The account address that holds the PositionManager
7+
/// @param pid: The position ID
8+
access(all)
9+
fun main(positionOwner: Address, pid: UInt64): UFix64 {
10+
let manager = getAccount(positionOwner).capabilities
11+
.borrow<&FlowALPPositionResources.PositionManager>(FlowALPv0.PositionPublicPath)
12+
?? panic("Could not borrow PositionManager from \(positionOwner) at \(FlowALPv0.PositionPublicPath)")
13+
return manager.borrowPosition(pid: pid).getMaxHealth()
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import "FlowALPv0"
2+
import "FlowALPPositionResources"
3+
4+
/// Returns the minimum health for the given position.
5+
///
6+
/// @param positionOwner: The account address that holds the PositionManager
7+
/// @param pid: The position ID
8+
access(all)
9+
fun main(positionOwner: Address, pid: UInt64): UFix64 {
10+
let manager = getAccount(positionOwner).capabilities
11+
.borrow<&FlowALPPositionResources.PositionManager>(FlowALPv0.PositionPublicPath)
12+
?? panic("Could not borrow PositionManager from \(positionOwner) at \(FlowALPv0.PositionPublicPath)")
13+
return manager.borrowPosition(pid: pid).getMinHealth()
14+
}
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
import "FlowALPv0"
2+
import "FlowALPPositionResources"
3+
4+
/// Returns the target health for the given position.
5+
///
6+
/// @param positionOwner: The account address that holds the PositionManager
7+
/// @param pid: The position ID
8+
access(all)
9+
fun main(positionOwner: Address, pid: UInt64): UFix64 {
10+
let manager = getAccount(positionOwner).capabilities
11+
.borrow<&FlowALPPositionResources.PositionManager>(FlowALPv0.PositionPublicPath)
12+
?? panic("Could not borrow PositionManager from \(positionOwner) at \(FlowALPv0.PositionPublicPath)")
13+
return manager.borrowPosition(pid: pid).getTargetHealth()
14+
}

cadence/tests/adversarial_recursive_withdraw_source_test.cdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -120,7 +120,7 @@ fun testRecursiveWithdrawSource() {
120120
// In this test, the topUpSource behavior is adversarial: it attempts to re-enter
121121
// the pool during the pull/deposit flow. We expect the transaction to fail.
122122
let withdrawRes = executeTransaction(
123-
"./transactions/flow-alp/pool-management/withdraw_from_position.cdc",
123+
"./transactions/flow-alp/epositionadmin/withdraw_from_position.cdc",
124124
[positionID, flowTokenIdentifier, 1500.0, true], // pullFromTopUpSource: true
125125
userAccount
126126
)

cadence/tests/adversarial_type_spoofing_test.cdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ fun testMaliciousSource() {
5959

6060
// withdraw 1337 Flow from the position
6161
let withdrawRes = executeTransaction(
62-
"./transactions/flow-alp/pool-management/withdraw_from_position.cdc",
62+
"./transactions/flow-alp/epositionadmin/withdraw_from_position.cdc",
6363
[1 as UInt64, flowTokenIdentifier, 1337.0, true],
6464
hackerAccount
6565
)

cadence/tests/async_update_position_test.cdc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ fun testUpdatePosition() {
4141
depositToPosition(signer: user, positionID: 0, amount: 600.0, vaultStoragePath: FLOW_VAULT_STORAGE_PATH, pushToDrawDownSink: false)
4242

4343
let updatePositionRes = _executeTransaction(
44-
"./transactions/flow-alp/pool-management/async_update_position.cdc",
44+
"./transactions/flow-alp/eimplementation/async_update_position.cdc",
4545
[ 0 as UInt64 ],
4646
PROTOCOL_ACCOUNT
4747
)

cadence/tests/cap_test.cdc

Lines changed: 1163 additions & 32 deletions
Large diffs are not rendered by default.

cadence/tests/insurance_swapper_test.cdc

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,7 @@ access(all)
182182
fun test_setInsuranceSwapper_wrongOutputType_fails() {
183183
// try to set a swapper that doesn't output MOET (outputs FLOW_TOKEN_IDENTIFIER instead)
184184
let res = _executeTransaction(
185-
"./transactions/flow-alp/pool-governance/set_insurance_swapper_mock.cdc",
185+
"./transactions/flow-alp/egovernance/set_insurance_swapper_mock.cdc",
186186
[MOET_TOKEN_IDENTIFIER, 1.0, MOET_TOKEN_IDENTIFIER, FLOW_TOKEN_IDENTIFIER],
187187
PROTOCOL_ACCOUNT
188188
)
@@ -199,7 +199,7 @@ access(all)
199199
fun test_setInsuranceSwapper_wrongInputType_fails() {
200200
// try to set a swapper with wrong input type (FLOW_TOKEN_IDENTIFIER instead of MOET_TOKEN_IDENTIFIER)
201201
let res = _executeTransaction(
202-
"./transactions/flow-alp/pool-governance/set_insurance_swapper_mock.cdc",
202+
"./transactions/flow-alp/egovernance/set_insurance_swapper_mock.cdc",
203203
[MOET_TOKEN_IDENTIFIER, 1.0, FLOW_TOKEN_IDENTIFIER, MOET_TOKEN_IDENTIFIER],
204204
PROTOCOL_ACCOUNT
205205
)

cadence/tests/liquidation_phase1_test.cdc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -640,7 +640,7 @@ fun testManualLiquidation_repaymentVaultCollateralType() {
640640
let repayAmount = debtBalance + 0.001
641641
let seizeAmount = (repayAmount / newPrice) * 0.99
642642
let liqRes = _executeTransaction(
643-
"../tests/transactions/flow-alp/pool-management/manual_liquidation_chosen_vault.cdc",
643+
"../tests/transactions/flow-alp/helpers/manual_liquidation_chosen_vault.cdc",
644644
[pid, Type<@MOET.Vault>().identifier, FLOW_TOKEN_IDENTIFIER, FLOW_TOKEN_IDENTIFIER, seizeAmount, repayAmount],
645645
liquidator
646646
)
@@ -696,7 +696,7 @@ fun testManualLiquidation_repaymentVaultTypeMismatch() {
696696
let repayAmount = debtBalance + 0.001
697697
let seizeAmount = (repayAmount / newPrice) * 0.99
698698
let liqRes = _executeTransaction(
699-
"../tests/transactions/flow-alp/pool-management/manual_liquidation_chosen_vault.cdc",
699+
"../tests/transactions/flow-alp/helpers/manual_liquidation_chosen_vault.cdc",
700700
[pid, Type<@MOET.Vault>().identifier, MOCK_YIELD_TOKEN_IDENTIFIER, FLOW_TOKEN_IDENTIFIER, seizeAmount, repayAmount],
701701
liquidator
702702
)
@@ -751,7 +751,7 @@ fun testManualLiquidation_unsupportedDebtType() {
751751
let repayAmount = debtBalance + 0.001
752752
let seizeAmount = (repayAmount / newPrice) * 0.99
753753
let liqRes = _executeTransaction(
754-
"../tests/transactions/flow-alp/pool-management/manual_liquidation_chosen_vault.cdc",
754+
"../tests/transactions/flow-alp/helpers/manual_liquidation_chosen_vault.cdc",
755755
[pid, MOCK_YIELD_TOKEN_IDENTIFIER, MOCK_YIELD_TOKEN_IDENTIFIER, FLOW_TOKEN_IDENTIFIER, seizeAmount, repayAmount],
756756
liquidator
757757
)

0 commit comments

Comments
 (0)