Conversation
| access(contract) var uniqueID: DeFiActions.UniqueIdentifier? | ||
| /// An unentitled Capability on the Vault to which deposits are distributed | ||
| access(self) let depositVault: Capability<&{FungibleToken.Vault}> | ||
| access(all) let liveDataCap: Capability<&LiveData> |
There was a problem hiding this comment.
My changes were based on the existing VaultSourceHacked struct to keep things consistent. I’m not sure it matters much, though, since this contract is used for testing only.
Co-authored-by: Taras Maliarchuk <maliarchuk@gmail.com>
jordanschalm
left a comment
There was a problem hiding this comment.
Looks good -- just one test that we already cover elsewhere.
cadence/tests/transactions/position-manager/create_position_reentrant_sink.cdc
Outdated
Show resolved
Hide resolved
| // ----------------------------------------------------------------------------- | ||
| /// Swapper returns 10 % less collateral than quoted. | ||
| /// | ||
| /// The protocol validates `seizeAmount < quote.inAmount`, which is checked | ||
| /// before the swap executes, liquidation tx must revert. | ||
| // ----------------------------------------------------------------------------- |
There was a problem hiding this comment.
Since this is using the manual liquidation path, we aren't actually performing a swap. Instead we are using the swapper as a price reference point to decide whether or not to accept the liquidation request from the liquidator.
When we have automated liquidation where we trade against a DEX, I think a test like this will be useful (although we would need to modify the behaviour of the Swapper so that its quote price differs from its swap price). For now, this test is equivalent to the existing liquidation tests (eg. testManualLiquidation_dexOraclePriceDivergence_dexAboveOracle).
I'd suggest marking this test as TODO when automated liquidation is implemented.
There was a problem hiding this comment.
Good point — that makes sense.
I’ve added a TODO and clarified the intent so we can update it once automated liquidation is implemented.
Co-authored-by: Jordan Schalm <jordan.schalm@gmail.com>
Closes: #282
Context
This PR adds the remaining missing tests from the issue, with a primary focus on
reentrancy scenarios in DeFi actions.Notes:
cadence/tests/adversarial_recursive_withdraw_source_test.cdcwas renamed tocadence/tests/adversarial_reentrancy_test.cdcAll other relevant tests already exist or are covered in PR: Rebalancing Failures #290
Flash Loan tests not included as it is a part from
FutureFeatures(https://github.com/onflow/FlowALP/blob/main/FutureFeatures.md#10--flash-loan-support)