Skip to content
Merged
Show file tree
Hide file tree
Changes from 21 commits
Commits
Show all changes
27 commits
Select commit Hold shift + click to select a range
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
26 changes: 15 additions & 11 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -63,28 +63,32 @@ Mock FungibleToken implementations representing:
| Asset Name | Cadence Address | Cadence Contract Name | EVM |
|---|---|---|---|
| FlowActions | 0xd27920b6384e2a78 | DeFiActions | TBD |
| FlowALP | 0xd27920b6384e2a78 | FlowALP | TBD |
| FlowALPv1 | 0xd27920b6384e2a78 | FlowALPv1 | TBD |
| FlowYieldVaults | 0xd27920b6384e2a78 | FlowYieldVaults | TBD |
| FlowYieldVaultsStrategies | 0xd27920b6384e2a78 | FlowYieldVaultsStrategies | TBD |
| FlowYieldVaultsStrategiesV2 | 0xd27920b6384e2a78 | FlowYieldVaultsStrategiesV2 | TBD |
| PMStrategiesV1 | 0xd27920b6384e2a78 | PMStrategiesV1 | TBD |
| MOET | 0xd27920b6384e2a78 | MOET | 0x51f5cc5f50afb81e8f23c926080fa38c3024b238 |
| USDC | 0xdfc20aee650fcbdf | EVMVMBridgedToken_d431955d55a99ef69beb96ba34718d0f9fbc91b1 | 0xd431955D55a99EF69BEb96BA34718d0f9fBc91b1 |
| PYUSD0 | 0xdfc20aee650fcbdf | EVMVMBridgedToken_d7d43ab7b365f0d0789ae83f4385fa710ffdc98f | 0xd7d43ab7b365f0d0789aE83F4385fA710FfdC98F |
| wBTC | 0xdfc20aee650fcbdf | EVMVMBridgedToken_208d09d2a6dd176e3e95b3f0de172a7471c5b2d6 | 0x208d09d2a6Dd176e3e95b3F0DE172A7471C5B2d6 |
| wETH | 0xdfc20aee650fcbdf | EVMVMBridgedToken_059a77239dafa770977dd9f1e98632c3e4559848 | 0x059A77239daFa770977DD9f1E98632C3E4559848 |
| mUSDC (ERC4626) | 0xdfc20aee650fcbdf | EVMVMBridgedToken_4154d5B0E2931a0A1E5b733f19161aa7D2fc4b95 | 0x4154d5B0E2931a0A1E5b733f19161aa7D2fc4b95 |
| FUSDEV (ERC4626) | 0xdfc20aee650fcbdf | EVMVMBridgedToken_61b44d19486ee492449e83c1201581c754e9e1e1 | 0x61b44D19486EE492449E83C1201581C754e9e1E1 |

#### Mainnet
| Asset Name | Cadence Address | Cadence Contract Name | EVM |
|---|---|---|---|
| FlowActions | 0x6d888f175c158410 | DeFiActions | TBD |
| FlowALP | 0x6b00ff876c299c61 | FlowALP | TBD |
| FlowALPv1 | 0x6b00ff876c299c61 | FlowALPv1 | TBD |
| FlowYieldVaults | 0xb1d63873c3cc9f79 | FlowYieldVaults | TBD |
| FlowYieldVaultsStrategies | 0xb1d63873c3cc9f79 | FlowYieldVaultsStrategies | TBD |
| FlowYieldVaultsStrategiesV2 | 0xb1d63873c3cc9f79 | FlowYieldVaultsStrategiesV2 | TBD |
| PMStrategiesV1 | 0xb1d63873c3cc9f79 | PMStrategiesV1 | TBD |
| MOET | 0x6b00ff876c299c61 | MOET | 0x213979bB8A9A86966999b3AA797C1fcf3B967ae2 |
| USDC | 0x1e4aa0b87d10b141 | EVMVMBridgedToken_f1815bd50389c46847f0bda824ec8da914045d14 | 0xF1815bd50389c46847f0Bda824eC8da914045D14 |
| USDF | 0x1e4aa0b87d10b141 | EVMVMBridgedToken_2aabea2058b5ac2d339b163c6ab6f2b6d53aabed | 0x2aabea2058b5ac2d339b163c6ab6f2b6d53aabed |
| PYUSD0 | 0x1e4aa0b87d10b141 | EVMVMBridgedToken_99af3eea856556646c98c8b9b2548fe815240750 | 0x99aF3EeA856556646C98c8B9b2548Fe815240750 |
| cbBTC | 0x1e4aa0b87d10b141 | EVMVMBridgedToken_a0197b2044d28b08be34d98b23c9312158ea9a18 | 0xA0197b2044D28b08Be34d98b23c9312158Ea9A18 |
| wETH | 0x1e4aa0b87d10b141 | EVMVMBridgedToken_2f6f07cdcf3588944bf4c42ac74ff24bf56e7590 | 0x2F6F07CDcf3588944Bf4C42aC74ff24bF56e7590 |
| tauUSDF (ERC4626) | 0x1e4aa0b87d10b141 | EVMVMBridgedToken_c52E820d2D6207D18667a97e2c6Ac22eB26E803c | 0xc52E820d2D6207D18667a97e2c6Ac22eB26E803c |
| FUSDEV (ERC4626) | 0x1e4aa0b87d10b141 | EVMVMBridgedToken_d069d989e2f44b70c65347d1853c0c67e10a9f8d | 0xd069d989e2F44B70c65347d1853C0c67e10a9F8D |

## How the System Works

Expand All @@ -95,7 +99,7 @@ Below is an overview of the initial prototype Tracer Strategy in the broader con
The TracerStrategy demonstrates the power of DeFi Actions composition:

```
User Deposit (FLOW) → FlowALP Position → MOET Issuance → Swap to YieldToken → AutoBalancer
User Deposit (FLOW) → FlowALPv1 Position → MOET Issuance → Swap to YieldToken → AutoBalancer
YieldToken → Swap to FLOW → Recollateralize Position
```
Expand Down Expand Up @@ -206,12 +210,12 @@ The AutoBalancer continuously monitors the **value ratio** between:

**When:** Current YieldToken value > 105% historical value of deposits
**Cause:** YieldToken price has increased OR position became over-collateralized leading to excess token holdings
**Action:** AutoBalancer deposits excess YieldToken to the rebalanceSink, swapping to FLOW and recollateralizing the FlowALP position.
**Action:** AutoBalancer deposits excess YieldToken to the rebalanceSink, swapping to FLOW and recollateralizing the FlowALPv1 position.

**Automated Flow:**

```
YieldToken (excess) → Swap to FLOW → Deposit to FlowALP Position (recollateralization)
YieldToken (excess) → Swap to FLOW → Deposit to FlowALPv1 Position (recollateralization)
```

**Result:**
Expand Down Expand Up @@ -260,7 +264,7 @@ The system creates a sophisticated token flow:

1. **Initial Position Opening:**

- User deposits FLOW → FlowALP Position
- User deposits FLOW → FlowALPv1 Position
- Position issues MOET → Swaps to YieldToken
- YieldToken held in AutoBalancer

Expand Down Expand Up @@ -573,7 +577,7 @@ Position Health = Effective Collateral / Effective Debt
#### Health Computation Function

```cadence
// From FlowALP.cdc
// From FlowALPv1.cdc
access(all) fun healthComputation(effectiveCollateral: UFix64, effectiveDebt: UFix64): UFix64 {
if effectiveCollateral == 0.0 {
return 0.0
Expand Down
16 changes: 15 additions & 1 deletion cadence/contracts/FlowYieldVaults.cdc
Original file line number Diff line number Diff line change
Expand Up @@ -317,8 +317,22 @@ access(all) contract FlowYieldVaults {
/// Withdraws the requested amount from the Strategy
access(FungibleToken.Withdraw) fun withdraw(amount: UFix64): @{FungibleToken.Vault} {
post {
result.balance == amount:
/// Quoting exact output then swapping exact input can overshoot by 0.00000001 (1 UFix64 quantum).
///
/// UFix64 has 8 decimals; EVM tokens have 18. One UFix64 step = 10^10 wei.
///
/// Example (pool price 1 USDC = 2 FLOW, want 10 FLOW out):
/// 1. Quoter says need 5,000000002000000000 USDC wei
/// 2. Ceil to UFix64: 5,000000010000000000 (overshoot: 8e9 wei)
/// 3. exactInput swaps the ceiled amount; extra 8e9 FLOW wei × 2 = 16e9 FLOW wei extra
/// 4. Actual output: 10,000000016000000000 FLOW wei
/// 5. Floor to UFix64: 10.00000001 FLOW (quoted 10.00000000)
///
/// The overshoot is always non-negative (ceiled input >= what pool needs).
/// It surfaces when the extra output crosses a 10^10 wei quantum boundary.
result.balance >= amount && result.balance <= amount + 0.00000001:
"Invalid Vault balance returned - requested \(amount) but returned \(result.balance)"

self.vaultType == result.getType():
"Invalid Vault returned - expected \(self.vaultType.identifier) but returned \(result.getType().identifier)"
}
Expand Down
Loading