union
The trust-minimized, zero-knowledge bridging protocol, designed for censorship resistance, extremely high security, and usage in decentralized finance.
- 74k
- Rust
- Apache-2.0
- 4 mo ago

Flow Yield Vaults. Cadence contracts for automated DeFi vaults in Flow Credit Markets on the Flow network.
Repo onflow/FlowYieldVaults, read from GitHub 5 h ago. onflow has not joined Take My Repo.
onflow/FlowYieldVaults is a public repo on GitHub by onflow. Flow Yield Vaults. Cadence contracts for automated DeFi vaults in Flow Credit Markets on the Flow network. It declares the Unlicense license on GitHub. It is written mainly in Cadence, has 41 stars and last changed on 2026-04-27. Nobody has reviewed it on Take My Repo yet, which says nothing about its quality. Read from GitHub on 2026-11-22.
In the maintainer's words. Shown from GitHub; Take My Repo does not keep a copy.
FlowYieldVaults is a yield farming platform built on the Flow network using Cadence. The platform enables users to deposit tokens to supported DeFi strategies such as collateralized borrowing via FlowALP, a DeFi lending protocol on Flow. FlowYieldVaults aims to support yield-generating strategies, automatically optimizing returns through DeFi Actions components and auto-balancing mechanisms.
git submodule update --init --recursiveflow deps installThe FlowYieldVaults platform consists of several interconnected components:
The main contract that orchestrates the entire yield farming system:
Implements specific yield strategies:
Manages automated rebalancing of positions:
Mock FungibleToken implementations representing:
| Asset Name | Cadence Address | Cadence Contract Name | EVM |
|---|---|---|---|
| FlowActions | 0xd27920b6384e2a78 | DeFiActions | TBD |
| FlowALPv0 | 0xd27920b6384e2a78 | FlowALPv0 | TBD |
| FlowYieldVaults | 0xd27920b6384e2a78 | FlowYieldVaults | 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 |
| FUSDEV (ERC4626) | 0xdfc20aee650fcbdf | EVMVMBridgedToken_61b44d19486ee492449e83c1201581c754e9e1e1 | 0x61b44D19486EE492449E83C1201581C754e9e1E1 |
| Asset Name | Cadence Address | Cadence Contract Name | EVM |
|---|---|---|---|
| FlowActions | 0x6d888f175c158410 | DeFiActions | TBD |
| FlowALPv0 | 0x6b00ff876c299c61 | FlowALPv0 | TBD |
| FlowYieldVaults | 0xb1d63873c3cc9f79 | FlowYieldVaults | 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 |
| WBTC | 0x1e4aa0b87d10b141 | EVMVMBridgedToken_717dae2baf7656be9a9b01dee31d571a9d4c9579 | 0x717DAE2BaF7656BE9a9B01deE31d571a9d4c9579 |
| wETH | 0x1e4aa0b87d10b141 | EVMVMBridgedToken_2f6f07cdcf3588944bf4c42ac74ff24bf56e7590 | 0x2F6F07CDcf3588944Bf4C42aC74ff24bF56e7590 |
| FUSDEV (ERC4626) | 0x1e4aa0b87d10b141 | EVMVMBridgedToken_d069d989e2f44b70c65347d1853c0c67e10a9f8d | 0xd069d989e2F44B70c65347d1853C0c67e10a9F8D |
Below is an overview of the initial prototype Tracer Strategy in the broader context of FlowALP and the FlowYieldVaults platform.
The TracerStrategy demonstrates the power of DeFi Actions composition:
User Deposit (FLOW) → FlowALP Position → MOET Issuance → Swap to YieldToken → AutoBalancer
↑
YieldToken → Swap to FLOW → Recollateralize Position
The system heavily uses DeFi Actions components:
Cadence Scripts are written in Cadence and take advantage of Native Data Availability read and format any public data on the blockchain in the way the developer needs it, without relying on pre-existing view functions in the contract.
scripts/flow-yield-vaults/get_yield_vault_ids.cdc// Returns all YieldVault IDs for a given user address
access(all) fun main(address: Address): [UInt64]?
scripts/tokens/get_balance.cdc// Get token balance for an account
access(all) fun main(account: Address, vaultPath: StoragePath): UFix64
Cadence Transactions are written in Cadence and allow you to compose several function calls to several contracts within a single user approval.
// Setup user account for FlowYieldVaults platform
transaction setup()
// Create a new yield position
transaction create_yield_vault(strategyIdentifier: String, vaultIdentifier: String, amount: UFix64)
// Deposit additional funds to existing YieldVault
transaction deposit_to_yield_vault(id: UInt64, amount: UFix64)
// Withdraw funds from a YieldVault
transaction withdraw_from_yield_vault(id: UInt64, amount: UFix64)
// Close a YieldVault and withdraw all funds
transaction close_yield_vault(id: UInt64)
The local/setup_emulator.sh script provides emulator configuration for local development and testing.
flow.json contains network configurations and contract deployment settings. It is created and managed with the Flow CLI.
The FlowYieldVaults platform implements sophisticated automatic rebalancing and recollateralizing mechanisms to maintain healthy loan positions and optimize yield generation.
Important Distinction: The system has TWO different rebalancing mechanisms:
These work together but serve different purposes and can trigger independently based on market conditions.
Each TracerStrategy includes an AutoBalancer with configured thresholds:
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.
Automated Flow:
YieldToken (excess) → Swap to FLOW → Deposit to FlowALP Position (recollateralization)
Result:
When: YieldToken value < 95% of expected value
Cause: Collateral price dropped or lending position at risk
Action: Position needs more collateral to maintain healthy loan-to-value ratio
Automated Flow:
YieldToken → Swap to FLOW → Add to Position Collateral → Reduce loan risk
Result:
let autoBalancer = FlowYieldVaultsAutoBalancers._initNewAutoBalancer(
oracle: oracle, // Price feeds for value calculations
vaultType: yieldTokenType, // YieldToken holdings monitored
lowerThreshold: 0.95, // Trigger recollateralization at 95%
upperThreshold: 1.05, // Trigger rebalancing at 105%
rebalanceSink: positionSwapSink, // Where excess value goes
rebalanceSource: nil, // Not used in TracerStrategy
uniqueID: uniqueID // Links to specific Strategy
)
The system creates a sophisticated token flow:
Initial Position Opening:
Rebalancing Infrastructure:
abaSwapSink: MOET → YieldToken → AutoBalancerabaSwapSource: YieldToken → MOET (from AutoBalancer)positionSwapSink: YieldToken → FLOW → Position (recollateralizing)Transaction: transactions/flow-yield-vaults/admin/rebalance_auto_balancer_by_id.cdc
// Force rebalancing regardless of thresholds
transaction rebalance_auto_balancer_by_id(id: UInt64, force: Bool)
Parameters:
id: YieldVault ID associated with the AutoBalancerforce: Whether to bypass threshold checksScript: scripts/flow-yield-vaults/get_auto_balancer_balance_by_id.cdc
// Returns current YieldToken balance in AutoBalancer
access(all) fun main(id: UInt64): UFix64?
Users can track their position status by comparing:
The rebalancing system leverages DeFi Actions components:
This creates a fully automated yield farming system that adapts to market conditions while maintaining position safety.
The FlowALP implements a sophisticated interest rate system that governs borrowing costs and lending yields. This system is fundamental to the protocol's economics and affects all lending positions.
Interest rates are determined dynamically based on supply and demand:
The protocol uses InterestCurve implementations to calculate rates:
// Simple example - in production, curves would be more sophisticated
access(all) struct SimpleInterestCurve: InterestCurve {
access(all) fun interestRate(creditBalance: UFix64, debitBalance: UFix64): UFix64 {
// Returns interest rate based on utilization ratio
// Higher utilization = higher rates
let utilizationRatio = debitBalance / creditBalance
return baseRate + (utilizationRatio * rateSlope)
}
}
Interest compounds continuously using per-second calculations:
The protocol uses "scaled balances" for efficiency:
Scaled Balance = True Balance / Interest Index
True Balance = Scaled Balance × Interest Index
Benefits:
// Interest index compounds over time
newIndex = oldIndex × (perSecondRate ^ elapsedSeconds)
(debitIncome - insuranceReserve) / totalCreditBalanceEach supported token has individual interest parameters:
// When adding a new token to the pool
pool.addSupportedToken(
tokenType: Type<@FlowToken.Vault>(),
collateralFactor: 0.8, // 80% of value usable as collateral
borrowFactor: 1.0, // No additional risk adjustment
interestCurve: MyInterestCurve(), // Custom rate calculation
depositRate: 1000000.0, // Rate limiting for deposits
depositCapacityCap: 1000000.0 // Maximum deposit capacity
)
Interest accrual affects position health over time:
Health = Effective Collateral / Effective Debt
// As debt interest accrues:
// - Effective Debt increases
// - Position health decreases
// - May trigger rebalancing or liquidation
The rebalancing system accounts for interest:
Total Credit Balance: 1,000,000 FLOW
Total Debit Balance: 800,000 FLOW
Utilization: 80%
// High utilization leads to:
Debit Interest Rate: 8% APY
Credit Interest Rate: 6.4% APY (after insurance deduction)
Total Credit Balance: 1,000,000 FLOW
Total Debit Balance: 200,000 FLOW
Utilization: 20%
// Low utilization leads to:
Debit Interest Rate: 2% APY
Credit Interest Rate: 0.36% APY (after insurance deduction)
The interest rate system is designed to:
This interest system is what enables the FlowALP to function as a sustainable lending platform while providing the foundation for complex yield farming strategies built on top.
The FlowALP implements a sophisticated loan health system that determines borrowing capacity, monitors position safety, and prevents liquidations. This system is fundamental to how the TracerStrategy calculates how much can be borrowed against a user's initial collateral position.
Before diving into the mechanics, it's important to understand the core terminology used throughout the FlowALP loan system:
The protocol calculates position health using the formula:
Position Health = Effective Collateral / Effective Debt
// From FlowALPv0.cdc
access(all) fun healthComputation(effectiveCollateral: UFix64, effectiveDebt: UFix64): UFix64 {
if effectiveCollateral == 0.0 {
return 0.0
} else if effectiveDebt == 0.0 {
return UFix64.max // Infinite health - no debt
} else {
return effectiveCollateral / effectiveDebt
}
}
For each token type in a position:
Token Value = Token Amount × Oracle Price
Effective Collateral += Token Value × Collateral Factor
For each borrowed token type:
Token Value = Token Amount × Oracle Price
Effective Debt += Token Value ÷ Borrow Factor
getTargetHealth()setTargetHealth(targetHealth: UFix64) (governance only)getMinHealth()setMinHealth(minHealth: UFix64) (governance only)When a user deposits collateral, the protocol calculates maximum borrowing capacity:
// Simplified borrowing capacity calculation
let tokenValue = collateralAmount × oraclePrice
let effectiveCollateral = tokenValue × collateralFactor
let maxBorrowableValue = effectiveCollateral ÷ targetHealth
let maxBorrowableTokens = maxBorrowableValue × borrowFactor ÷ borrowTokenPrice
Token Value = 100 FLOW × $1.00 = $100
Effective Collateral = $100 × 0.8 = $80
Max Borrowable Value = $80 ÷ 1.3 = $61.54
Max MOET Borrowable = $61.54 × 1.0 ÷ $1.00 = 61.54 MOET
The protocol uses scaled balances for efficient interest calculations:
// Convert scaled balance to actual balance
fun scaledBalanceToTrueBalance(scaledBalance: UFix64, interestIndex: UInt64): UFix64 {
let indexMultiplier = UFix64.fromBigEndianBytes(interestIndex.toBigEndianBytes())! / 100000000.0
return scaledBalance * indexMultiplier
}
// Interest compounds continuously
newIndex = oldIndex × (perSecondRate ^ elapsedSeconds)
access(all) struct BalanceSheet {
access(all) let effectiveCollateral: UFix64
access(all) let effectiveDebt: UFix64
access(all) let health: UFix64
}
access(all) fun positionHealth(pid: UInt64): UFix64 {
var effectiveCollateral = 0.0
var effectiveDebt = 0.0
for type in position.balances.keys {
let balance = position.balances[type]!
let tokenState = self.tokenState(type: type)
let tokenPrice = self.priceOracle.price(ofToken: type)!
if balance.direction == BalanceDirection.Credit {
// Collateral calculation
let trueBalance = scaledBalanceToTrueBalance(
scaledBalance: balance.scaledBalance,
interestIndex: tokenState.creditInterestIndex
)
let value = tokenPrice * trueBalance
effectiveCollateral += (value * self.collateralFactor[type]!)
} else {
// Debt calculation
let trueBalance = scaledBalanceToTrueBalance(
scaledBalance: balance.scaledBalance,
interestIndex: tokenState.debitInterestIndex
)
let value = tokenPrice * trueBalance
effectiveDebt += (value / self.borrowFactor[type]!)
}
}
return healthComputation(effectiveCollateral: effectiveCollateral, effectiveDebt: effectiveDebt)
}
The protocol calculates how much can be withdrawn while maintaining target health:
access(all) fun fundsAvailableAboveTargetHealth(pid: UInt64, type: Type, targetHealth: UFix64): UFix64
Logic:
Calculates additional deposits needed to reach target health:
access(all) fun fundsRequiredForTargetHealth(pid: UInt64, type: Type, targetHealth: UFix64): UFix64
access(all) fun healthAfterWithdrawal(pid: UInt64, type: Type, amount: UFix64): UFix64
access(all) fun healthAfterDeposit(pid: UInt64, type: Type, amount: UFix64): UFix64
The protocol continuously monitors position health and triggers rebalancing:
// From rebalancePosition function
let balanceSheet = self.positionBalanceSheet(pid: pid)
if balanceSheet.health < position.targetHealth {
// Under-collateralized: need more collateral or debt payoff
// Trigger top-up from repayment source
} else if balanceSheet.health > position.targetHealth {
// Over-collateralized: can borrow more or withdraw excess
// Trigger draw-down to sink
}
The TracerStrategy leverages this health system:
minHealth (1.1) trigger automatic interventionrepaymentSource before liquidation// Position structure includes automatic top-up capability
access(EImplementation) var topUpSource: {DeFiActions.Source}?
// All health calculations use live oracle prices
let tokenPrice = self.priceOracle.price(ofToken: type)!
let value = tokenPrice * trueBalance
This comprehensive loan health system enables the FlowALP to safely support leveraged yield farming strategies while maintaining strict risk management and protecting user funds from liquidation through automated rebalancing mechanisms.
This section provides a step-by-step guide to test rebalancing functionality in the mock environment by manipulating collateral prices and observing the automatic rebalancing effects.
COLLATERAL PRICE REBALANCING WITH CONTRACT INTERACTIONS


YIELD TOKEN PRICE REBALANCING WITH CONTRACT INTERACTIONS

The AutoBalancer deposits to a Sink, withdrawing YIELD from the nested Vault. The inner Sink is a SwapSink that swaps from YIELD to FLOW and then deposits to a PositionSink. The deposited FLOW makes its way to the Pool and recollateralizes the position, increasing the position's size. The protocol then pushes the surplus value to its drawDownSink. That drawDownSink is also a SwapSink that takes the deposited MOET, swaps it to YIELD and then deposits the swapped tokens to the AutoBalancerSink. That sink then finally deposits the YIELD to the AutoBalancer on which the rebalance was initially called, increasing the valueOfDeposits and closing the loop.
YIELD TOKEN DOWN Scenario not currently supported
create_yield_vault transactionEach scenario below is completely self-contained and can be run independently. You only need to ensure that contracts are already deployed to the Flow emulator. Each scenario handles its own setup, execution, and verification.
Prerequisites: Flow emulator running with all FlowYieldVaults contracts deployed.
What happens: FLOW price increases → Position becomes over-collateralized → AutoBalancer may rebalance if YieldToken holdings exceed threshold
Expected Outcome: If AutoBalancer triggers: fewer YieldTokens (sold for collateral), stronger position health
#!/bin/bash
echo "=== SCENARIO 1: FLOW PRICE INCREASE ==="
echo "Setting up independent test environment..."
# Variables for this scenario
export YOUR_ADDRESS="0xf8d6e0586b0a20c7" # Default test account
export INITIAL_DEPOSIT=100.0
# Step 1: Setup account for FlowYieldVaults platform
echo "Setting up FlowYieldVaults account..."
flow transactions send cadence/transactions/flow-yield-vaults/setup.cdc \
--signer test-account
# Step 2: Setup token vaults
echo "Setting up token vaults..."
flow transactions send cadence/transactions/moet/setup_vault.cdc \
--signer test-account
flow transactions send cadence/transactions/yield-token/setup_vault.cdc \
--signer test-account
# Step 3: Initialize token prices
echo "Setting initial token prices..."
flow transactions send cadence/transactions/mocks/oracle/set_price.cdc \
"A.0ae53cb6e3f42a79.FlowToken.Vault" \
1.0 \
--signer test-account
flow transactions send cadence/transactions/mocks/oracle/set_price.cdc \
"A.045a1763c93006ca.YieldToken.Vault" \
2.0 \
--signer test-account
flow transactions send cadence/transactions/mocks/oracle/set_price.cdc \
"A.045a1763c93006ca.MOET.Vault" \
1.0 \
--signer test-account
# Step 4: Fund MockSwapper with liquidity
echo "Funding MockSwapper with liquidity..."
flow transactions send cadence/transactions/mocks/swapper/set_liquidity_connector.cdc \
"/storage/flowTokenVault" \
--signer test-account
flow transactions send cadence/transactions/mocks/swapper/set_liquidity_connector.cdc \
"/storage/moetTokenVault_0x045a1763c93006ca" \
--signer test-account
flow transactions send cadence/transactions/mocks/swapper/set_liquidity_connector.cdc \
"/storage/yieldTokenVault_0x045a1763c93006ca" \
--signer test-account
# Step 5: Create YieldVault position
echo "Creating YieldVault position with $INITIAL_DEPOSIT FLOW..."
flow transactions send cadence/transactions/flow-yield-vaults/create_yield_vault.cdc \
"A.045a1763c93006ca.MockStrategies.TracerStrategy" \
"A.0ae53cb6e3f42a79.FlowToken.Vault" \
$INITIAL_DEPOSIT \
--signer test-account
# Step 6: Get the YieldVault ID
echo "Getting YieldVault ID..."
YIELD_VAULT_ID=$(flow scripts execute cadence/scripts/flow-yield-vaults/get_yield_vault_ids.cdc \
$YOUR_ADDRESS | grep -o '[0-9]\+' | head -1)
echo "YieldVault ID: $YIELD_VAULT_ID"
# Step 7: Record baseline metrics
echo "=== RECORDING BASELINE METRICS ==="
echo "Initial FLOW Price:"
flow scripts execute cadence/scripts/mocks/oracle/get_price.cdc \
"A.0ae53cb6e3f42a79.FlowToken.Vault"
echo "Initial YieldToken Price:"
flow scripts execute cadence/scripts/mocks/oracle/get_price.cdc \
"A.045a1763c93006ca.YieldToken.Vault"
echo "Initial YieldVault Balance:"
flow scripts execute cadence/scripts/flow-yield-vaults/get_yield_vault_balance.cdc \
$YOUR_ADDRESS $YIELD_VAULT_ID
echo "Initial AutoBalancer Balance:"
flow scripts execute cadence/scripts/flow-yield-vaults/get_auto_balancer_balance_by_id.cdc \
$YIELD_VAULT_ID
# Step 8: Execute the test - Increase FLOW price by 20%
echo "=== EXECUTING TEST: FLOW PRICE INCREASE ==="
echo "Setting FLOW price from $1.00 to $1.20 (+20%)"
flow transactions send cadence/transactions/mocks/oracle/set_price.cdc \
"A.0ae53cb6e3f42a79.FlowToken.Vault" \
1.2 \
--signer test-account
echo "Confirming new FLOW price:"
flow scripts execute cadence/scripts/mocks/oracle/get_price.cdc \
"A.0ae53cb6e3f42a79.FlowToken.Vault"
# Step 9: Trigger rebalancing
echo "Triggering rebalancing..."
flow transactions send cadence/transactions/flow-yield-vaults/admin/rebalance_auto_balancer_by_id.cdc \
$YIELD_VAULT_ID true \
--signer test-account
flow transactions send cadence/transactions/flow-alp/pool-management/rebalance_position.cdc \
$YIELD_VAULT_ID true \
--signer test-account
# Step 10: Verify results
echo "=== VERIFYING RESULTS ==="
echo "New AutoBalancer Balance (should be HIGHER):"
flow scripts execute cadence/scripts/flow-yield-vaults/get_auto_balancer_balance_by_id.cdc \
$YIELD_VAULT_ID
echo "New YieldVault Balance):"
flow scripts execute cadence/scripts/flow-yield-vaults/get_yield_vault_balance.cdc \
$YOUR_ADDRESS $YIELD_VAULT_ID
echo "SCENARIO 1 COMPLETE!"
echo "Expected Results:"
echo "- If AutoBalancer triggers: YieldToken balance may DECREASE (sold for collateral)"
echo "- Position health should IMPROVE from additional collateral"
echo "- FLOW price increase may trigger AutoBalancer rebalanceSink if YieldToken value exceeds threshold"
What You Should See:
What happens: FLOW price decreases → Position becomes under-collateralized → Position may use topUpSource (AutoBalancer) to add collateral
Expected Outcome: Position health stabilized through topUpSource mechanism, may reduce YieldToken holdings
#!/bin/bash
echo "=== SCENARIO 2: FLOW PRICE DECREASE ==="
echo "Setting up independent test environment..."
# Variables for this scenario
export YOUR_ADDRESS="0xf8d6e0586b0a20c7" # Default test account
export INITIAL_DEPOSIT=100.0
# Step 1: Setup account for FlowYieldVaults platform
echo "Setting up FlowYieldVaults account..."
flow transactions send transactions/flow-yield-vaults/setup.cdc \
--signer test-account
# Step 2: Setup token vaults
echo "Setting up token vaults..."
flow transactions send transactions/moet/setup_vault.cdc \
--signer test-account
flow transactions send transactions/yield-token/setup_vault.cdc \
--signer test-account
# Step 3: Initialize token prices
echo "Setting initial token prices..."
flow transactions send transactions/mocks/oracle/set_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault" \
--arg UFix64:1.0 \
--signer test-account
flow transactions send transactions/mocks/oracle/set_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault" \
--arg UFix64:2.0 \
--signer test-account
flow transactions send transactions/mocks/oracle/set_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.MOET.Vault" \
--arg UFix64:1.0 \
--signer test-account
# Step 4: Fund MockSwapper with liquidity
echo "Funding MockSwapper with liquidity..."
flow transactions send transactions/mocks/swapper/set_liquidity_connector.cdc \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault" \
--arg String:"A.0ae53cb6e3f42a79.MOET.Vault" \
--arg UFix64:10000.0 \
--signer test-account
flow transactions send transactions/mocks/swapper/set_liquidity_connector.cdc \
--arg String:"A.0ae53cb6e3f42a79.MOET.Vault" \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault" \
--arg UFix64:10000.0 \
--signer test-account
flow transactions send transactions/mocks/swapper/set_liquidity_connector.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault" \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault" \
--arg UFix64:10000.0 \
--signer test-account
# Step 5: Create YieldVault position
echo "Creating YieldVault position with $INITIAL_DEPOSIT FLOW..."
flow transactions send transactions/flow-yield-vaults/create_yield_vault.cdc \
--arg String:"tracer" \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault" \
--arg UFix64:$INITIAL_DEPOSIT \
--signer test-account
# Step 6: Get the YieldVault ID
echo "Getting YieldVault ID..."
YIELD_VAULT_ID=$(flow scripts execute scripts/flow-yield-vaults/get_yield_vault_ids.cdc \
--arg Address:$YOUR_ADDRESS | grep -o '[0-9]\+' | head -1)
echo "YieldVault ID: $YIELD_VAULT_ID"
# Step 7: Record baseline metrics
echo "=== RECORDING BASELINE METRICS ==="
echo "Initial FLOW Price:"
flow scripts execute scripts/mocks/oracle/get_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault"
echo "Initial YieldToken Price:"
flow scripts execute scripts/mocks/oracle/get_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault"
echo "Initial YieldVault Balance:"
flow scripts execute scripts/flow-yield-vaults/get_yield_vault_balance.cdc \
--arg Address:$YOUR_ADDRESS --arg UInt64:$YIELD_VAULT_ID
echo "Initial AutoBalancer Balance:"
flow scripts execute scripts/flow-yield-vaults/get_auto_balancer_balance_by_id.cdc \
--arg UInt64:$YIELD_VAULT_ID
# Step 8: Execute the test - Decrease FLOW price by 30%
echo "=== EXECUTING TEST: FLOW PRICE DECREASE ==="
echo "Setting FLOW price from $1.00 to $0.70 (-30%)"
flow transactions send transactions/mocks/oracle/set_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault" \
--arg UFix64:0.7 \
--signer test-account
echo "Confirming new FLOW price:"
flow scripts execute scripts/mocks/oracle/get_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault"
# Step 9: Trigger rebalancing
echo "Triggering recollateralization..."
flow transactions send transactions/flow-yield-vaults/admin/rebalance_auto_balancer_by_id.cdc \
--arg UInt64:$YIELD_VAULT_ID \
--arg Bool:true \
--signer test-account
# Step 10: Verify results
echo "=== VERIFYING RESULTS ==="
echo "New AutoBalancer Balance (should be LOWER):"
flow scripts execute scripts/flow-yield-vaults/get_auto_balancer_balance_by_id.cdc \
--arg UInt64:$YIELD_VAULT_ID
echo "New YieldVault Balance (may be lower due to collateral needs):"
flow scripts execute scripts/flow-yield-vaults/get_yield_vault_balance.cdc \
--arg Address:$YOUR_ADDRESS --arg UInt64:$YIELD_VAULT_ID
echo "SCENARIO 2 COMPLETE!"
echo "Expected Results:"
echo "- Position may use topUpSource to add collateral (if configured)"
echo "- AutoBalancer balance may DECREASE if used as topUpSource"
echo "- Position health stabilized through topUpSource mechanism"
What You Should See:
What happens: YieldToken price increases → AutoBalancer portfolio over-valued → Sells excess YieldTokens → Moves gains to position collateral
Expected Outcome: Gains captured and transferred to collateral, AutoBalancer rebalanced, stronger position health
#!/bin/bash
echo "=== SCENARIO 3: YIELD TOKEN PRICE INCREASE ==="
echo "Setting up independent test environment..."
# Variables for this scenario
export YOUR_ADDRESS="0xf8d6e0586b0a20c7" # Default test account
export INITIAL_DEPOSIT=100.0
# Step 1: Setup account for FlowYieldVaults platform
echo "Setting up FlowYieldVaults account..."
flow transactions send transactions/flow-yield-vaults/setup.cdc \
--signer test-account
# Step 2: Setup token vaults
echo "Setting up token vaults..."
flow transactions send transactions/moet/setup_vault.cdc \
--signer test-account
flow transactions send transactions/yield-token/setup_vault.cdc \
--signer test-account
# Step 3: Initialize token prices
echo "Setting initial token prices..."
flow transactions send transactions/mocks/oracle/set_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault" \
--arg UFix64:1.0 \
--signer test-account
flow transactions send transactions/mocks/oracle/set_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault" \
--arg UFix64:2.0 \
--signer test-account
flow transactions send transactions/mocks/oracle/set_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.MOET.Vault" \
--arg UFix64:1.0 \
--signer test-account
# Step 4: Fund MockSwapper with liquidity
echo "Funding MockSwapper with liquidity..."
flow transactions send transactions/mocks/swapper/set_liquidity_connector.cdc \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault" \
--arg String:"A.0ae53cb6e3f42a79.MOET.Vault" \
--arg UFix64:10000.0 \
--signer test-account
flow transactions send transactions/mocks/swapper/set_liquidity_connector.cdc \
--arg String:"A.0ae53cb6e3f42a79.MOET.Vault" \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault" \
--arg UFix64:10000.0 \
--signer test-account
flow transactions send transactions/mocks/swapper/set_liquidity_connector.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault" \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault" \
--arg UFix64:10000.0 \
--signer test-account
# Step 5: Create YieldVault position
echo "Creating YieldVault position with $INITIAL_DEPOSIT FLOW..."
flow transactions send transactions/flow-yield-vaults/create_yield_vault.cdc \
--arg String:"tracer" \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault" \
--arg UFix64:$INITIAL_DEPOSIT \
--signer test-account
# Step 6: Get the YieldVault ID
echo "Getting YieldVault ID..."
YIELD_VAULT_ID=$(flow scripts execute scripts/flow-yield-vaults/get_yield_vault_ids.cdc \
--arg Address:$YOUR_ADDRESS | grep -o '[0-9]\+' | head -1)
echo "YieldVault ID: $YIELD_VAULT_ID"
# Step 7: Record baseline metrics
echo "=== RECORDING BASELINE METRICS ==="
echo "Initial FLOW Price:"
flow scripts execute scripts/mocks/oracle/get_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault"
echo "Initial YieldToken Price:"
flow scripts execute scripts/mocks/oracle/get_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault"
echo "Initial YieldVault Balance:"
flow scripts execute scripts/flow-yield-vaults/get_yield_vault_balance.cdc \
--arg Address:$YOUR_ADDRESS --arg UInt64:$YIELD_VAULT_ID
echo "Initial AutoBalancer Balance:"
flow scripts execute scripts/flow-yield-vaults/get_auto_balancer_balance_by_id.cdc \
--arg UInt64:$YIELD_VAULT_ID
# Step 8: Execute the test - Increase YieldToken price by 15%
echo "=== EXECUTING TEST: YIELD TOKEN PRICE INCREASE ==="
echo "Setting YieldToken price from $2.00 to $2.30 (+15%)"
flow transactions send transactions/mocks/oracle/set_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault" \
--arg UFix64:2.30 \
--signer test-account
echo "Confirming new YieldToken price:"
flow scripts execute scripts/mocks/oracle/get_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault"
# Step 9: Trigger rebalancing
echo "Triggering gain capture..."
flow transactions send transactions/flow-yield-vaults/admin/rebalance_auto_balancer_by_id.cdc \
--arg UInt64:$YIELD_VAULT_ID \
--arg Bool:true \
--signer test-account
# Step 10: Verify results
echo "=== VERIFYING RESULTS ==="
echo "Current YieldToken Price:"
flow scripts execute scripts/mocks/oracle/get_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault"
echo "New AutoBalancer Balance:"
flow scripts execute scripts/flow-yield-vaults/get_auto_balancer_balance_by_id.cdc \
--arg UInt64:$YIELD_VAULT_ID
echo "New YieldVault Balance (should be HIGHER from captured gains):"
flow scripts execute scripts/flow-yield-vaults/get_yield_vault_balance.cdc \
--arg Address:$YOUR_ADDRESS --arg UInt64:$YIELD_VAULT_ID
echo "SCENARIO 3 COMPLETE!"
echo "Expected Results:"
echo "- AutoBalancer should trigger rebalanceSink (excess YieldTokens sold)"
echo "- Gains captured and transferred to position as collateral"
echo "- AutoBalancer rebalanced to target ratio"
What You Should See:
What happens: YieldToken price decreases → AutoBalancer portfolio under-valued → NO automatic rebalancing (rebalanceSource = nil)
Expected Outcome: AutoBalancer cannot self-correct, manual intervention or position-level rebalancing may be needed
#!/bin/bash
echo "=== SCENARIO 4: YIELD TOKEN PRICE DECREASE ==="
echo "Setting up independent test environment..."
# Variables for this scenario
export YOUR_ADDRESS="0xf8d6e0586b0a20c7" # Default test account
export INITIAL_DEPOSIT=100.0
# Step 1: Setup account for FlowYieldVaults platform
echo "Setting up FlowYieldVaults account..."
flow transactions send transactions/flow-yield-vaults/setup.cdc \
--signer test-account
# Step 2: Setup token vaults
echo "Setting up token vaults..."
flow transactions send transactions/moet/setup_vault.cdc \
--signer test-account
flow transactions send transactions/yield-token/setup_vault.cdc \
--signer test-account
# Step 3: Initialize token prices
echo "Setting initial token prices..."
flow transactions send transactions/mocks/oracle/set_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault" \
--arg UFix64:1.0 \
--signer test-account
flow transactions send transactions/mocks/oracle/set_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault" \
--arg UFix64:2.0 \
--signer test-account
flow transactions send transactions/mocks/oracle/set_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.MOET.Vault" \
--arg UFix64:1.0 \
--signer test-account
# Step 4: Fund MockSwapper with liquidity
echo "Funding MockSwapper with liquidity..."
flow transactions send transactions/mocks/swapper/set_liquidity_connector.cdc \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault" \
--arg String:"A.0ae53cb6e3f42a79.MOET.Vault" \
--arg UFix64:10000.0 \
--signer test-account
flow transactions send transactions/mocks/swapper/set_liquidity_connector.cdc \
--arg String:"A.0ae53cb6e3f42a79.MOET.Vault" \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault" \
--arg UFix64:10000.0 \
--signer test-account
flow transactions send transactions/mocks/swapper/set_liquidity_connector.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault" \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault" \
--arg UFix64:10000.0 \
--signer test-account
# Step 5: Create YieldVault position
echo "Creating YieldVault position with $INITIAL_DEPOSIT FLOW..."
flow transactions send transactions/flow-yield-vaults/create_yield_vault.cdc \
--arg String:"tracer" \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault" \
--arg UFix64:$INITIAL_DEPOSIT \
--signer test-account
# Step 6: Get the YieldVault ID
echo "Getting YieldVault ID..."
YIELD_VAULT_ID=$(flow scripts execute scripts/flow-yield-vaults/get_yield_vault_ids.cdc \
--arg Address:$YOUR_ADDRESS | grep -o '[0-9]\+' | head -1)
echo "YieldVault ID: $YIELD_VAULT_ID"
# Step 7: Record baseline metrics
echo "=== RECORDING BASELINE METRICS ==="
echo "Initial FLOW Price:"
flow scripts execute scripts/mocks/oracle/get_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.FlowToken.Vault"
echo "Initial YieldToken Price:"
flow scripts execute scripts/mocks/oracle/get_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault"
echo "Initial YieldVault Balance:"
flow scripts execute scripts/flow-yield-vaults/get_yield_vault_balance.cdc \
--arg Address:$YOUR_ADDRESS --arg UInt64:$YIELD_VAULT_ID
echo "Initial AutoBalancer Balance:"
flow scripts execute scripts/flow-yield-vaults/get_auto_balancer_balance_by_id.cdc \
--arg UInt64:$YIELD_VAULT_ID
# Step 8: Execute the test - Decrease YieldToken price by 15%
echo "=== EXECUTING TEST: YIELD TOKEN PRICE DECREASE ==="
echo "Setting YieldToken price from $2.00 to $1.70 (-15%)"
flow transactions send transactions/mocks/oracle/set_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault" \
--arg UFix64:1.70 \
--signer test-account
echo "Confirming new YieldToken price:"
flow scripts execute scripts/mocks/oracle/get_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault"
# Step 9: Trigger rebalancing
echo "Triggering portfolio restoration..."
flow transactions send transactions/flow-yield-vaults/admin/rebalance_auto_balancer_by_id.cdc \
--arg UInt64:$YIELD_VAULT_ID \
--arg Bool:true \
--signer test-account
# Step 10: Verify results
echo "=== VERIFYING RESULTS ==="
echo "Current YieldToken Price:"
flow scripts execute scripts/mocks/oracle/get_price.cdc \
--arg String:"A.0ae53cb6e3f42a79.YieldToken.Vault"
echo "New AutoBalancer Balance (should be HIGHER in token count):"
flow scripts execute scripts/flow-yield-vaults/get_auto_balancer_balance_by_id.cdc \
--arg UInt64:$YIELD_VAULT_ID
echo "New YieldVault Balance:"
flow scripts execute scripts/flow-yield-vaults/get_yield_vault_balance.cdc \
--arg Address:$YOUR_ADDRESS --arg UInt64:$YIELD_VAULT_ID
echo "SCENARIO 4 COMPLETE!"
echo "Expected Results:"
echo "- AutoBalancer CANNOT rebalance automatically (no rebalanceSource)"
echo "- Portfolio remains under-valued"
echo "- Manual intervention or position-level rebalancing may be needed"
What You Should See:
force: true parameter bypasses threshold checks for testing# Current YieldToken holdings in AutoBalancer
scripts/flow-yield-vaults/get_auto_balancer_balance_by_id.cdc
# Compare against expected value based on deposits
# Ratio should stay between 0.95 - 1.05 for healthy positions
# Overall position health (collateralization ratio)
scripts/flow-alp/position_health.cdc
# Available balance for withdrawal from position
scripts/flow-alp/get_available_balance.cdc
# Total FLOW available for withdrawal from YieldVault
scripts/flow-yield-vaults/get_yield_vault_balance.cdc
# Your account token balances
scripts/tokens/get_balance.cdc
force: true) bypasses thresholdsforce: false# Check if oracle has price set
flow scripts execute scripts/mocks/oracle/get_price.cdc --arg String:"TOKEN_TYPE"
# Check your YieldVault IDs
flow scripts execute scripts/flow-yield-vaults/get_yield_vault_ids.cdc --arg Address:0xYourAddress
# Check supported strategies
flow scripts execute scripts/flow-yield-vaults/get_supported_strategies.cdc
This testing framework allows you to validate that the rebalancing system correctly responds to market conditions while maintaining position safety and optimizing yield generation.
This is a mock implementation for development and testing purposes only. It is not intended for production use.
The contracts include extensive mock components (MockOracle, MockSwapper, etc.) that simulate real DeFi infrastructure. In a production environment, these would be replaced with actual oracle services and DEX integrations.
The platform provides a foundation for sophisticated yield farming strategies while maintaining the security and composability principles of the Cadence programming language.
This repo is part of the Flow network, a Layer 1 blockchain built for consumer applications, AI Agents, and DeFi at scale.
onflow/FlowYieldVaults is a public repo on GitHub by onflow. Flow Yield Vaults. Cadence contracts for automated DeFi vaults in Flow Credit Markets on the Flow network.
It declares the Unlicense license on GitHub.
Its maker has not tagged a system, so it is unknown here. Its README says what it needs.
Open "Take it" on its page: Take My Repo writes an install plan for your machine and hands it to your AI agent (Claude Code, Codex or Cursor), which asks you before each step. Take My Repo has not tested it on any machine.
Its last change on GitHub was on 2026-04-27. Take My Repo does not judge from that whether it is maintained.
Nobody has reviewed it on Take My Repo yet, which says nothing about its quality.
The trust-minimized, zero-knowledge bridging protocol, designed for censorship resistance, extremely high security, and usage in decentralized finance.

A distributed transaction framework, supports workflow, saga, tcc, xa, 2-phase message, outbox patterns, supports many languages.
Open source software that helps you create and deploy high-frequency crypto trading bots
🔥 A well-tested feature-rich modular Firebase implementation for React Native. Supports both iOS & Android platforms for all Firebase services.
Cadence is a distributed, scalable, durable, and highly available orchestration engine to execute asynchronous long-running business logic in a scalable and resilient way.
Reference implementation of the Flow network in Go. Layer 1 proof-of-stake protocol built for consumer apps, AI Agents, and DeFi at scale

Cadence: the resource-oriented smart contract programming language of the Flow network. Capability-based security, type safety, and move semantics
The non-fungible token standard for the Flow network. Resource-oriented NFT contracts in Cadence, with built-in metadata views and royalties
Flow is a Layer 1 proof-of-stake blockchain built for consumer applications, AI Agents, and DeFi at scale. Repo hub for the Flow network

FCL (Flow Client Library) in TypeScript and JavaScript. Connect Flow dApps to wallets, send transactions, and read on-chain data from the browser
Go SDK for the Flow network. Build backend services that send transactions, listen to events, and manage accounts on Flow
Take My Repo has not tested this on your machine. Requirements come from the project's own documentation.