Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
44 commits
Select commit Hold shift + click to select a range
e311bab
chore(submodule): update TidalProtocol to feature/liquidation-mechani…
kgrgpg Sep 9, 2025
fc397ca
chore(submodule): bump DeFiActions to origin/main f83f08d for SwapSta…
kgrgpg Sep 9, 2025
a6ae442
chore: align DeFiActions connectors to SwapStack; update helpers and …
kgrgpg Sep 15, 2025
8f4b67d
merge: resolve conflicts with origin/main (use main's helpers/flow.js…
kgrgpg Sep 15, 2025
2eb0e65
tests(liquidation): align root tests with TidalProtocol liquidation m…
kgrgpg Sep 16, 2025
4d2e42d
chore: remove archives/ (generated test artifacts)
kgrgpg Sep 16, 2025
090e190
chore(submodule): add MORE-Vaults-Core under lib/
kgrgpg Sep 25, 2025
44c028c
docs(flow-evm): guide + script to deploy MORE vault and set up USDC–S…
kgrgpg Sep 25, 2025
0e2a1f7
Mirror sim integration (phase 1): add mirror tests, swap helper, and …
kgrgpg Oct 21, 2025
4d57511
Merge origin/main into branch: resolve test_helpers conflict; update …
kgrgpg Oct 21, 2025
6bb6c09
chore(submodules): update all submodules to latest origin main/master
kgrgpg Oct 21, 2025
78ccf7a
fix: align TidalYieldStrategies to current TidalProtocol openPosition…
kgrgpg Oct 21, 2025
c96a3e6
chore(submodules): add simulation repo as submodule (lib/tidal-protoc…
kgrgpg Oct 21, 2025
a896e67
ci: scope Cadence tests to mirror tests only (phase 1)
kgrgpg Oct 21, 2025
3f80537
ci(incrementfi): update submodules to latest main before deploy to re…
kgrgpg Oct 21, 2025
f8f3c96
Mirror: add MIRROR logs, comparator + report, runner; isolated flow.t…
kgrgpg Oct 21, 2025
5a858fb
Merge mirror-ci-and-report into unit-zero-sim-integration-1st-phase: …
kgrgpg Oct 21, 2025
a81d825
Complete simulation validation with comprehensive gap analysis
kgrgpg Oct 27, 2025
7292445
Add multi-agent mirror tests and complete simulation validation audit
kgrgpg Oct 27, 2025
8a7792b
Complete mirror validation analysis with multi-agent test designs
kgrgpg Oct 27, 2025
9f10061
Solve MOET depeg mystery and validate MockV3 correctness
kgrgpg Oct 27, 2025
c4035b1
Add honest reassessment of MockV3 and MOET depeg validation
kgrgpg Oct 27, 2025
e71cbbc
Add comprehensive handoff document for fresh context
kgrgpg Oct 28, 2025
dfa18de
Add START HERE executive summary for fresh model context
kgrgpg Oct 28, 2025
726b327
Add PunchSwap V3 integration plan for real Uniswap V3 validation
kgrgpg Oct 28, 2025
c0df4ad
Add complete summary and PunchSwap V3 integration plan
kgrgpg Oct 28, 2025
89be854
Add EVM integration discovery - built-in EVM support in Flow CLI
kgrgpg Oct 28, 2025
d4935d5
Add final summary for fresh model context
kgrgpg Oct 28, 2025
7c3482f
Add basic EVM/COA tests - 4/5 passing!
kgrgpg Oct 28, 2025
8910dbf
Add EVM/PunchSwap V3 integration progress summary
kgrgpg Oct 28, 2025
44127ef
Fix EVM deployment - ALL 5 BASIC TESTS PASSING! ✅
kgrgpg Oct 28, 2025
da61a67
Add PunchSwap V3 deployment test structure and workflow documentation
kgrgpg Oct 28, 2025
315bf92
Add PunchSwap V3 status and integration roadmap
kgrgpg Oct 28, 2025
6baa11f
Add complete journey summary and decision point
kgrgpg Oct 28, 2025
ae3226a
Confirm PunchSwap V3 repository matches official Kitty-Punch repo
kgrgpg Oct 28, 2025
9c008cf
PunchSwap V3 ready to deploy - Factory and SwapRouter compiled
kgrgpg Oct 28, 2025
036593a
Begin PunchSwap V3 deployment - Option 1 selected
kgrgpg Oct 28, 2025
09e0599
Master handoff: PunchSwap V3 deployment ready to execute
kgrgpg Oct 28, 2025
dab4686
Add PunchSwap deployment test framework and final status
kgrgpg Oct 28, 2025
729788c
Add mock token deployment tests - 2/3 passing on emulator
kgrgpg Oct 28, 2025
84233e5
Session complete handoff - PunchSwap V3 deployment in progress
kgrgpg Oct 28, 2025
e6ec158
CRITICAL CORRECTION: Pool should be MOET/YT not MOET/FLOW
kgrgpg Oct 28, 2025
1fad36a
Update architecture: Correct MOET/YT pool configuration
kgrgpg Oct 28, 2025
4c990ad
Final handoff with correct MOET/YT architecture
kgrgpg Oct 28, 2025
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
6 changes: 6 additions & 0 deletions .env.flow-evm.secret
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
[
{
"address": "0xd3dF49C036DE9E9264Fd7e9516B0e1d56f604EB0",
"private_key": "0x695317baa091f524b63f7d4ca62f272568243e7ab5c3a15861634ea334e76f28"
}
]
2 changes: 2 additions & 0 deletions .github/workflows/incrementfi_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,8 @@ jobs:
with:
token: ${{ secrets.GH_PAT }}
submodules: recursive
- name: Update submodules to latest main
run: git submodule update --init --remote --recursive
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)" -- v2.2.17
- name: Flow CLI Version
Expand Down
64 changes: 64 additions & 0 deletions .github/workflows/mirror_mirrors.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,64 @@
name: Mirror Tests

on:
push:
branches:
- main
pull_request:
branches:
- main

jobs:
mirror-tests:
name: Tidal Mirror Tests
runs-on: ubuntu-latest
env:
CI: "true"
TERM: "dumb"
steps:
- uses: actions/checkout@v4
with:
token: ${{ secrets.GH_PAT }}
submodules: recursive
- name: Set up Go
uses: actions/setup-go@v3
with:
go-version: "1.23.x"
- uses: actions/cache@v4
with:
path: ~/go/pkg/mod
key: ${{ runner.os }}-go-${{ hashFiles('**/go.sum') }}
restore-keys: |
${{ runner.os }}-go-
- name: Install Flow CLI
run: sh -ci "$(curl -fsSL https://raw.githubusercontent.com/onflow/flow-cli/master/install.sh)"
- name: Flow CLI Version
run: flow version
- name: Update PATH
run: echo "/root/.local/bin" >> $GITHUB_PATH
- name: Install Flow dependencies
run: flow deps install --skip-alias --skip-deployments
- name: Run Emulator
run: ./local/run_emulator.sh
- name: Setup Emulator
run: ./local/setup_emulator.sh
- name: Setup Wallets
run: ./local/setup_wallets.sh
- name: Ensure runner is executable
run: chmod +x scripts/run_mirrors_and_compare.sh
- name: Run mirror tests and generate report
run: |
bash scripts/run_mirrors_and_compare.sh
python3 scripts/save_mirror_markdown.py
- name: Upload mirror artifacts
uses: actions/upload-artifact@v4
with:
name: mirror-results
path: |
docs/mirror_report.md
docs/mirror_run.md
local/mirror_flow.log
local/mirror_moet.log
local/mirror_rebalance.log


6 changes: 6 additions & 0 deletions .gitmodules
Original file line number Diff line number Diff line change
Expand Up @@ -11,3 +11,9 @@
[submodule "solidity/lib/forge-std"]
path = solidity/lib/forge-std
url = https://github.com/foundry-rs/forge-std
[submodule "lib/MORE-Vaults-Core"]
path = lib/MORE-Vaults-Core
url = https://github.com/MORE-Vaults/MORE-Vaults-Core
[submodule "lib/tidal-protocol-research"]
path = lib/tidal-protocol-research
url = https://github.com/unit-zero-labs/tidal-protocol-research.git
242 changes: 242 additions & 0 deletions ARCHITECTURE_CORRECTION_SUMMARY.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,242 @@
# Architecture Correction: MOET/YT is Correct!

**Date**: October 27, 2025
**User's Correction**: Pool should be MOET/YT, not MOET/FLOW!

---

## ✅ User is 100% CORRECT

### What User Said:
1. **MOET minted in Tidal Protocol** → ✅ Confirmed (`cadence/contracts/MOET.cdc`)
2. **MOET bridged to EVM** → ✅ Found `FlowEVMBridge` + `EVMTokenConnectors.cdc`
3. **FLOW already on EVM** → ✅ Native token, auto-available
4. **Need YieldToken ERC20** → ✅ `cadence/contracts/mocks/YieldToken.cdc` exists
5. **Pool: MOET/YT not MOET/FLOW** → ✅ **CONFIRMED by simulation config!**

---

## 🔍 Evidence: Simulation Configuration

**From** `lib/tidal-protocol-research/sim_tests/flash_crash_simulation.py` **lines 119-126**:

```python
self.moet_yt_pool_config = {
"size": 500_000, # $500K pool
"concentration": 0.95, # 95% concentration at 1:1 peg
"token0_ratio": 0.75, # 75% MOET, 25% YT
"fee_tier": 0.0005, # 0.05% fee tier (stable/yield)
"tick_spacing": 10,
"pool_name": "MOET:Yield_Token" # ← MOET/YT!!!
}
```

**The simulation models MOET/YT pool, NOT MOET/FLOW!**

**User understood the architecture perfectly!** 🎯

---

## 🔧 Correct Deployment Architecture

### Bridge Infrastructure (EXISTS!)

**FlowEVMBridge** (`flow.json` line 164-180):
```json
"EVM": {
"source": "mainnet://e467b9dd11fa00df.EVM",
"aliases": {"emulator": "f8d6e0586b0a20c7"}
},
"FlowEVMBridgeHandlerInterfaces": {
"source": "mainnet://1e4aa0b87d10b141.FlowEVMBridgeHandlerInterfaces",
"aliases": {"emulator": "f8d6e0586b0a20c7"}
}
```

**EVMTokenConnectors** (`lib/TidalProtocol/DeFiActions/cadence/contracts/connectors/evm/EVMTokenConnectors.cdc`):
- Lines 135-140: `FlowEVMBridge.bridgeTokensToEVM(vault, to, feeProvider)`
- Bridges Cadence FTs to EVM automatically
- Creates ERC20 wrapper on EVM side

**Onboarding Transaction** (`lib/TidalProtocol/DeFiActions/cadence/tests/transactions/bridge/onboard_by_type_identifier.cdc`):
- Onboards Cadence token to bridge
- Creates ERC20 representation on EVM
- Maintains linkage between VMs

---

## 🎯 Corrected Deployment Plan

### Phase 1: Bridge MOET to EVM (NOT Deploy!)

**Step 1a: Onboard MOET to Bridge**:
```cadence
// Use onboard_by_type_identifier.cdc
// Identifier: Type<@MOET.Vault>().identifier
// This creates MOET ERC20 wrapper on EVM automatically
```

**Step 1b: Get MOET EVM Address**:
```cadence
// Use FlowEVMBridgeConfig.getEVMAddressAssociated(with: Type<@MOET.Vault>())
// Returns EVM address of bridged MOET
```

### Phase 2: Deploy or Bridge YieldToken

**Option A: Bridge YieldToken** (if bridge supports mock contracts):
```cadence
// Onboard YieldToken to bridge
// Creates YT ERC20 wrapper on EVM
```

**Option B: Deploy Simple YT ERC20** (for emulator testing):
```solidity
// MockYieldToken.sol - simple ERC20 for testing
// Just for emulator validation
```

### Phase 3: Deploy PunchSwap V3

**Deploy Factory + SwapRouter** (same as before)

### Phase 4: Create MOET/YT Pool (CORRECTED!)

**Correct Configuration**:
```cadence
factory.createPool(
moet_evm_address, // From bridge
yt_evm_address, // From bridge or deployment
500 // 0.05% fee (NOT 3000!)
)

pool.initialize(
sqrtPriceX96 // 1:1 peg
)
```

### Phase 5: Add Tight Liquidity (95% Concentrated!)

**Match Simulation**:
```cadence
// 95% concentration = VERY tight range
tickLower = -30 // ~0.3% below peg
tickUpper = 90 // ~0.9% above peg

// Add liquidity:
// 75% MOET ($375k)
// 25% YT ($125k)
// Total: $500k pool
```

### Phase 6: Test MOET→YT Swap

**Correct Test**:
```cadence
// Swap MOET → YieldToken (not FLOW!)
amountIn = 10000 MOET
// In tight 95% range, price impact should be minimal
// Expected slippage: ~0.0025% (very low!)
```

**Compare to Simulation**: MOET:YT pool data (NOT MOET:BTC!)

---

## 💡 Why This Matters

### Wrong Approach (What I Was Planning):
```
Deploy: MockMOET ERC20
Deploy: MockFLOW ERC20
Pool: MOET/FLOW at 0.3% fee
Wide range liquidity

Matches: Nothing (wrong pair!)
```

### Correct Approach (User's Architecture):
```
Bridge: MOET from Cadence
Deploy/Bridge: YieldToken
Pool: MOET/YT at 0.05% fee
95% concentration (tight!)

Matches: Simulation + TidalYield strategy ✓
```

---

## 🎓 Evidence from TidalYieldStrategies

**Lines 151-162** show the actual swaps:
```cadence
// MOET -> YieldToken swapper
let moetToYieldSwapper = MockSwapper.Swapper(
inVault: moetTokenType,
outVault: yieldTokenType,
uniqueID: uniqueID
)

// YieldToken -> MOET swapper
let yieldToMoetSwapper = MockSwapper.Swapper(
inVault: yieldTokenType,
outVault: moetTokenType,
uniqueID: uniqueID
)
```

**The protocol swaps MOET ↔ YieldToken!** Not MOET ↔ FLOW.

FLOW is just collateral. The yield strategy is about MOET/YT pair.

---

## 🚀 Corrected Next Steps

### Immediate:

**1. Check if FlowEVMBridge is set up on emulator**:
```bash
flow scripts execute check_bridge_setup.cdc --network emulator
```

**2. Onboard MOET to bridge**:
```bash
flow transactions send \
lib/TidalProtocol/DeFiActions/cadence/tests/transactions/bridge/onboard_by_type_identifier.cdc \
"A.f8d6e0586b0a20c7.MOET.Vault" \
--network emulator
```

**3. Deploy or bridge YieldToken**

**4. Get EVM addresses**:
```cadence
// moet_evm = FlowEVMBridgeConfig.getEVMAddressAssociated(with: Type<@MOET.Vault>())
// yt_evm = ... (from bridge or deployment)
```

**5. Create MOET/YT pool at 0.05% fee**

**6. Add 95% concentrated liquidity**

**7. Test swaps and validate!**

---

## 📊 Updated TODOs

1. ✅ Identify correct architecture (DONE - thanks to user!)
2. ⏳ Bridge MOET to EVM
3. ⏳ Deploy/bridge YieldToken
4. ⏳ Deploy Factory
5. ⏳ Deploy Router
6. ⏳ Create MOET/YT pool (0.05% fee)
7. ⏳ Add 95% liquidity
8. ⏳ Test swaps

---

**User caught a critical architectural error! Proceeding with CORRECT MOET/YT configuration matching simulation.** 🙏✅

Loading
Loading