Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions AUTO_BORROWING_GUIDE.md
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
# TidalProtocol Auto-Borrowing Guide
# FlowALP Auto-Borrowing Guide

## Overview

TidalProtocol includes an auto-borrowing feature that automatically optimizes your position's capital efficiency when creating a new position. This guide explains how it works and when to use it.
FlowALP includes an auto-borrowing feature that automatically optimizes your position's capital efficiency when creating a new position. This guide explains how it works and when to use it.

## What is Auto-Borrowing?

When you deposit collateral into TidalProtocol, the system can automatically borrow against that collateral to achieve a target health ratio. This maximizes capital efficiency by ensuring your position is neither too risky nor too conservative.
When you deposit collateral into FlowALP, the system can automatically borrow against that collateral to achieve a target health ratio. This maximizes capital efficiency by ensuring your position is neither too risky nor too conservative.

### Example
- You deposit 1000 Flow tokens as collateral
Expand All @@ -25,7 +25,7 @@ When you deposit collateral into TidalProtocol, the system can automatically bor

### Example:
```cadence
let position = TidalProtocol.openPosition(
let position = FlowALP.openPosition(
collateral: <-myFlowVault,
issuanceSink: mySink,
repaymentSource: mySource,
Expand All @@ -44,7 +44,7 @@ let position = TidalProtocol.openPosition(
### Example:
```cadence
// Use openPosition with pushToDrawDownSink=false to disable auto-borrowing
let position = TidalProtocol.openPosition(
let position = FlowALP.openPosition(
collateral: <-myFlowVault,
issuanceSink: mySink,
repaymentSource: mySource,
Expand Down Expand Up @@ -85,4 +85,4 @@ Auto-borrowing is a powerful feature for capital efficiency, but it's not always
- Market outlook
- Need for immediate liquidity

The protocol provides flexibility to accommodate both aggressive and conservative strategies.
The protocol provides flexibility to accommodate both aggressive and conservative strategies.
4 changes: 2 additions & 2 deletions AUTO_BORROWING_PROPOSAL.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

## Summary of Findings

During testing, we discovered that TidalProtocol implements an **auto-borrowing** feature when positions are created with `pushToDrawDownSink=true`. This behavior is intentional and mathematically correct.
During testing, we discovered that FlowALP implements an **auto-borrowing** feature when positions are created with `pushToDrawDownSink=true`. This behavior is intentional and mathematically correct.

### Example Calculation
When depositing 1000 Flow tokens:
Expand Down Expand Up @@ -84,4 +84,4 @@ access(all) fun openPositionWithoutAutoBorrow(
1. Await reviewer feedback on the proposal
2. Implement approved changes
3. Update documentation and examples
4. Consider adding more granular control over target health ratios per position
4. Consider adding more granular control over target health ratios per position
4 changes: 2 additions & 2 deletions CadenceTestingPatterns.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
## Cadence Testing Patterns & Best Practices

This document distills the patterns, idioms, and general "know-how" exhibited by the experienced Cadence developer who authored the current test-suite for **TidalProtocol**. Use it as a practical checklist and style-guide when writing or reviewing Cadence tests.
This document distills the patterns, idioms, and general "know-how" exhibited by the experienced Cadence developer who authored the current test-suite for **FlowALP**. Use it as a practical checklist and style-guide when writing or reviewing Cadence tests.

### 1. Harness, Organisation & Discovery

Expand Down Expand Up @@ -172,4 +172,4 @@ Use this skeleton as a starting point for any new Cadence test.
6. ❒ All helper code lives in `cadence/tests/test_helpers.cdc` (or sibling).
7. ❒ Imports use relative paths, avoid absolute local paths for portability.

Happy testing! 🚀
Happy testing! 🚀
4 changes: 2 additions & 2 deletions FLOW_TEST_PERSISTENCE_SOLUTION.md
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ The ideal solution would be to refactor the test suite to:
3. Or separate tests that need different contract deployments into different test suites

## Implementation Notes
- The TidalProtocol codebase already uses the snapshot pattern correctly in several test files:
- The FlowALP codebase already uses the snapshot pattern correctly in several test files:
- `platform_integration_test.cdc`
- `position_lifecycle_happy_test.cdc`
- `rebalance_overcollateralised_test.cdc`
Expand All @@ -85,4 +85,4 @@ The ideal solution would be to refactor the test suite to:

## References
- [Cadence Testing Framework Documentation](https://cadence-lang.org/docs/testing-framework)
- [Flow Forum: Major Uplift for Cadence Testing Framework](https://forum.flow.com/t/major-uplift-for-cadence-testing-framework/5232)
- [Flow Forum: Major Uplift for Cadence Testing Framework](https://forum.flow.com/t/major-uplift-for-cadence-testing-framework/5232)
6 changes: 3 additions & 3 deletions TidalProtocol_TestPlan.md → FlowALP_TestPlan.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TidalProtocol – High-Priority Test Plan
# FlowALP – High-Priority Test Plan

This document lists **workflow-centric** test cases that deliver maximum coverage for `TidalProtocol.cdc` and its satellite contracts while fitting comfortably into a single, review-friendly pull-request. Each case follows the conventions captured in `CadenceTestingPatterns.md`.
This document lists **workflow-centric** test cases that deliver maximum coverage for `FlowALP.cdc` and its satellite contracts while fitting comfortably into a single, review-friendly pull-request. Each case follows the conventions captured in `CadenceTestingPatterns.md`.

Legend
* **LOC≈** – rough new lines of test-code (excluding transactions/scripts). Keep total ≈ **300–400 LOC** per PR.
Expand Down Expand Up @@ -90,4 +90,4 @@ Total estimated LOC ≈ **350** spread over 6 test files – aligns with PR size
3. Add position lifecycle + rebalance tests (#3-#5).
4. Conclude with governance reserve withdrawal (#6).

Each commit should introduce ≤2 test files to ease code-review.
Each commit should introduce ≤2 test files to ease code-review.
34 changes: 17 additions & 17 deletions TidalMilestones.md → FlowVaultsMilestones.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Tidal Milestones
# FlowVaults Milestones

## Legend
- ✅ **Must Have** - Critical features required for launch
Expand All @@ -12,19 +12,19 @@
- ✅ Frontend connects to Flow wallet, allows a user to create and view the details of at least one Tide. It will support a single collateral type (a crypto, not a stable), and a single investment type (i.e. yield token).
- 👌 Multiple Tides per account.
- ✅ Frontend provides accurate details about the Tide, compiled using event data. (i.e. a backend). For this milestone, the details can be minimal (i.e. number of trades), just to show that we are tracking on-chain events.
- ✅ Frontend constructs a transaction that "glues together" TidalProtocol with DefiActions to create the Tide. Signed and submitted by Flow Wallet.
- ✅ Frontend constructs a transaction that "glues together" FlowALP with DefiActions to create the Tide. Signed and submitted by Flow Wallet.
- ✅ Frontend adds the initial collateral tokens to the position during setup and triggers a rebalance to kick off the initial purchase of yield tokens.
- 👌 Frontend allows deposit/withdrawal to adjust the size of a Tide.

### Smart Contract Integration
- ✅ The Tide set up by frontend takes tokens pushed out of TidalProtocol (via a sink) and swaps them into a dummy yield bearing token. Uses a dummy Swapper interface that just magically swaps tokens without an AMM.
- ✅ The Tide set up by the frontend provides tokens requested by TidalProtocol (via a source) that are swapped out of the yield bearing token. Same dummy Swapper interface as above.
- ✅ The Tide set up by frontend takes tokens pushed out of FlowALP (via a sink) and swaps them into a dummy yield bearing token. Uses a dummy Swapper interface that just magically swaps tokens without an AMM.
- ✅ The Tide set up by the frontend provides tokens requested by FlowALP (via a source) that are swapped out of the yield bearing token. Same dummy Swapper interface as above.
- ✅ Collateral is a crypto (possibly FLOW), native USDA used as source and sink, investment is a crypto.
- 👌 Use a real AMM deployed in the test environment.

### Price Oracle & Rebalancing
- ✅ A dummy price oracle will provide the price of the collateral and investment tokens. We must be able to easily manipulate the price provided for testing.
- ✅ We will manually increase the price of the collateral, and manually trigger a rebalance in TidalProtocol. Additional yield tokens should be purchased.
- ✅ We will manually increase the price of the collateral, and manually trigger a rebalance in FlowALP. Additional yield tokens should be purchased.
- ✅ We will manually decrease the price of the collateral, and manually trigger a rebalance. Yield tokens should be sold to repay the debt.
- 💛 We will manually increase the price of the yield token, and trigger the autobalancer. Yield tokens should be swapped into collateral tokens and deposited into the position. When we manually trigger a rebalance, the investment position should increase to reflect the extra collateral.

Expand All @@ -34,9 +34,9 @@

### Development & Testing
- ✅ The tracer bullet can run on emulator or testnet, with a soft preference for emulator (to keep eyes off of our secret sauce until we're ready to announce).
- ✅ Automated testing framework for TidalProtocol and DefiActions.
- 💛 Test suite that covers the functionality required for Tidal.
- ✅ Tidal and TidalProtocol code in a private repo.
- ✅ Automated testing framework for FlowALP and DefiActions.
- 💛 Test suite that covers the functionality required for FlowVaults.
- ✅ FlowVaults and FlowALP code in a private repo.
- ✅ DefiActions code in a public repo.

## Limited Beta
Expand Down Expand Up @@ -66,30 +66,30 @@
- 👌 Rebalances/accumulation are triggered manually by a daemon process.

### Access Control
- ✅ Access to TidalProtocol is limited to Tidal users and the TidalProtocol team.
- ✅ Tidal is invite only, but includes a "sign up" with some kind of queuing system so we can allow additional users into the system over time.
- ✅ Tidal enforces a configurable limit on the total collateral value for each user. (Deposits are blocked if the collateral value is above the limit, but natural price growth doesn't cause problems.) The limit can be changed over time.
- ✅ Access to FlowALP is limited to FlowVaults users and the FlowALP team.
- ✅ FlowVaults is invite only, but includes a "sign up" with some kind of queuing system so we can allow additional users into the system over time.
- ✅ FlowVaults enforces a configurable limit on the total collateral value for each user. (Deposits are blocked if the collateral value is above the limit, but natural price growth doesn't cause problems.) The limit can be changed over time.
- 👌 Per user limits to allow controlled testing of larger positions.

### Documentation & Testing
- ✅ First pass documentation of TidalProtocol.
- ✅ First pass documentation of FlowALP.
- ✅ DefiActions available to all devs.
- ✅ First pass documentation of DefiActions.
- 💛 Sample code for DefiActions.
- ✅ Extensive test suite for TidalProtocol, DefiActions, and any Tidal-specific smart contracts.
- ✅ Extensive test suite for FlowALP, DefiActions, and any FlowVaults-specific smart contracts.
- 💛 Test suites should be available, with instructions, for anyone to run locally with minimal effort.
- ✅ All code (including Tidal) in public repos.
- ✅ All code (including FlowVaults) in public repos.

### Marketing Idea
💡 **IDEA**: When you connect during closed beta, if you don't have access, we let you join the queue. We optionally ask for an email address to notify you, but we also post your Cadence account address to the Tidal Twitter feed when you are given access. Imagine a twitter feed of hundreds or thousands of addresses saying "0x39a830 has been unlocked for access to Tidal!" Could be fun!
💡 **IDEA**: When you connect during closed beta, if you don't have access, we let you join the queue. We optionally ask for an email address to notify you, but we also post your Cadence account address to the FlowVaults Twitter feed when you are given access. Imagine a twitter feed of hundreds or thousands of addresses saying "0x39a830 has been unlocked for access to FlowVaults!" Could be fun!

## Open Beta

### Core Requirements
All MUSTs from above, except those related to gated access.

### Access & Availability
- ✅ Open access to Tidal, TidalProtocol, and DefiActions.
- ✅ Open access to FlowVaults, FlowALP, and DefiActions.

### Asset Support
- ✅ Support BTC, ETH as collateral.
Expand All @@ -101,6 +101,6 @@ All MUSTs from above, except those related to gated access.
- 👌 Rebalances/accumulation are triggered manually by a daemon process.

### Documentation
- 💛 Improved documentation for Tidal, TidalProtocol, and DefiActions.
- 💛 Improved documentation for FlowVaults, FlowALP, and DefiActions.
- ✅ Sample code and tutorials for DefiActions.

8 changes: 4 additions & 4 deletions FutureFeatures.md
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
# TidalProtocol Future Features and Tests
# FlowALP Future Features and Tests

This document lists features that are not yet implemented in the TidalProtocol contract, organized by Tidal milestone phases with priority indicators:
This document lists features that are not yet implemented in the FlowALP contract, organized by FlowVaults milestone phases with priority indicators:

- ✅ **Must Have** - Critical features required for launch
- 💛 **Should Have** - Important features that significantly enhance the product
Expand All @@ -9,7 +9,7 @@ This document lists features that are not yet implemented in the TidalProtocol c

## Tracer Bullet Phase Features

### 1. ✅ Functional Sink/Source Hooks (Critical for Tidal Integration)
### 1. ✅ Functional Sink/Source Hooks (Critical for FlowVaults Integration)

**Features to Implement:**
- Real Sink implementation for pushing tokens to yield strategies
Expand Down Expand Up @@ -202,4 +202,4 @@ cadence/tests/
├── governance_test.cdc # Governance tests
├── deposit_queue_test.cdc # Queue tests
└── emergency_test.cdc # Emergency tests
```
```
8 changes: 4 additions & 4 deletions IntensiveTestAnalysis.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# TidalProtocol Intensive Test Analysis
# FlowALP Intensive Test Analysis

## Overview
The intensive test suites (fuzzy testing and attack vectors) reveal several edge cases and limitations in the current implementation. While the basic functionality works correctly, these tests push the boundaries and expose areas for improvement.
Expand Down Expand Up @@ -71,7 +71,7 @@ The intensive test suites (fuzzy testing and attack vectors) reveal several edge

## Action Items

### Immediate (for Tidal integration):
### Immediate (for FlowVaults integration):
1. The contract is safe for normal use cases (all basic tests pass)
2. Edge cases are mostly theoretical and require extreme inputs
3. Cadence's built-in safety features prevent most attack vectors
Expand All @@ -84,7 +84,7 @@ The intensive test suites (fuzzy testing and attack vectors) reveal several edge
5. Add guards against extreme concurrent operations

## Conclusion
The intensive tests reveal that TidalProtocol is robust for normal operations but has some edge cases with extreme values. These edge cases are largely theoretical and protected by Cadence's type system. The contract is ready for integration with Tidal, with the understanding that:
The intensive tests reveal that FlowALP is robust for normal operations but has some edge cases with extreme values. These edge cases are largely theoretical and protected by Cadence's type system. The contract is ready for integration with FlowVaults, with the understanding that:

1. Interest rates are currently fixed at 0%
2. Very small amounts (< 0.00000001) should be avoided
Expand All @@ -95,4 +95,4 @@ The failing intensive tests are primarily due to:
- Extreme edge cases that are unlikely in practice
- The simplified interest curve (0% rates)

These can be addressed in future iterations without blocking the current integration.
These can be addressed in future iterations without blocking the current integration.
6 changes: 3 additions & 3 deletions LIQUIDATION_MECHANISM_DESIGN.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
## Tidal Protocol — Production Liquidation Mechanism (DEX + Keeper + Auto)
## FlowVaults Protocol — Production Liquidation Mechanism (DEX + Keeper + Auto)

### Objectives
- **Safety**: Permissionless, incentive-aligned liquidations that reliably resolve undercollateralized positions.
Expand Down Expand Up @@ -143,8 +143,8 @@
- Reserve/insurance module hookup for bad debt.

## References
- High-level design (Notion): https://www.notion.so/Liquidation-Mechanism-in-Tidal-23a9c94cfb9c8087bee9d8e99045b3d9
- Implementation doc (this branch): https://github.com/onflow/TidalProtocol/blob/feature/liquidation-mechanism/LIQUIDATION_MECHANISM_DESIGN.md
- High-level design (Notion): https://www.notion.so/Liquidation-Mechanism-in-FlowVaults-23a9c94cfb9c8087bee9d8e99045b3d9
- Implementation doc (this branch): https://github.com/onflow/FlowALP/blob/feature/liquidation-mechanism/LIQUIDATION_MECHANISM_DESIGN.md

## Liquidation policy (Phase 1)
- **Target health factor (HF):** `liquidationTargetHF = 1.05e24`.
Expand Down
6 changes: 3 additions & 3 deletions LLM_FILES_MANAGEMENT.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@ The following files contain LLM-generated documentation and context:
- `PROMPT_FOR_TEST_RUNNING.md` - Test running prompts
- `TEST_RUNNING_INSTRUCTIONS.md` - Detailed test execution guide
- `FLOW_TEST_PERSISTENCE_SOLUTION.md` - Flow test persistence solutions
- `TidalProtocol_TestPlan.md` - Overall test planning documentation
- `FlowALP_TestPlan.md` - Overall test planning documentation
- `TestSuiteComparison.md` - Test suite analysis
- `CadenceTestingPatterns.md` - Cadence testing patterns and best practices
- `TestsOverview.md` - High-level test overview
- `TidalMilestones.md` - Project milestones
- `FlowVaultsMilestones.md` - Project milestones
- `PUSH_SUMMARY.md` - Push and PR summaries
- `TestingCompletionSummary.md` - Test completion status
- `IntensiveTestAnalysis.md` - Detailed test analysis
Expand Down Expand Up @@ -56,4 +56,4 @@ You can also use git attributes to exclude these files from releases:
*.md export-ignore
```

This way, the files remain in the repository but are excluded from archive downloads.
This way, the files remain in the repository but are excluded from archive downloads.
12 changes: 6 additions & 6 deletions PROMPT_FOR_TEST_RUNNING.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
# Prompt: Running TidalProtocol Tests with New Approach
# Prompt: Running FlowALP Tests with New Approach

## Background
The TidalProtocol Cadence tests were failing with "cannot overwrite existing contract" errors due to Flow test framework limitations. We've implemented a solution.
The FlowALP Cadence tests were failing with "cannot overwrite existing contract" errors due to Flow test framework limitations. We've implemented a solution.

## Your Task
When asked to run tests for TidalProtocol, follow this new approach:
When asked to run tests for FlowALP, follow this new approach:

### Primary Method: Use Test Runner Script
```bash
Expand Down Expand Up @@ -41,7 +41,7 @@ flow test ./cadence/tests/reserve_withdrawal_test.cdc

## Expected Behavior
- Individual tests should pass when run separately
- Some tests have known issues (MockOracle, MockTidalProtocolConsumer conflicts)
- Some tests have known issues (MockOracle, MockFlowALPConsumer conflicts)
- The test runner script provides the most consistent results

## Example Output
Expand All @@ -54,11 +54,11 @@ When using the test runner script, you'll see:
✅ PASSED: cadence/tests/reserve_withdrawal_test.cdc
```

Please use this approach when working with TidalProtocol tests to ensure consistent and reliable results.
Please use this approach when working with FlowALP tests to ensure consistent and reliable results.

## Verified Status (as of latest changes)
Tests confirmed to PASS individually:
- ✅ `pool_creation_workflow_test.cdc` - PASS: testPoolCreationSucceeds
- ✅ `reserve_withdrawal_test.cdc` - PASS: testReserveWithdrawalGovernanceControlled

These were the two tests we fixed by removing incorrect `Test.reset()` usage.
These were the two tests we fixed by removing incorrect `Test.reset()` usage.
Loading
Loading