LLM Notice: This documentation site supports content negotiation for AI agents. Request any page with Accept: text/markdown or Accept: text/plain header to receive Markdown instead of HTML. Alternatively, append ?format=md to any URL. All markdown files are available at /md/ prefix paths. For all content in one file, visit /llms-full.txt
Skip to main content

MOET System Integration

This document explains how MOET connects and enables seamless interactions between ALP, FYV, and the broader FCM ecosystem.

Overview of Integration Architecture

MOET serves as the integration layer that binds together FCM's components, enabling automated capital flows and coordinated risk management:


_44
graph TB
_44
subgraph FCM[Flow Credit Market Ecosystem]
_44
subgraph ALP[ALP - Lending Engine]
_44
Pool[Pool Contract]
_44
Position[Position Resource]
_44
Oracle[Price Oracle]
_44
end
_44
_44
subgraph MOET[MOET - Integration Layer]
_44
Mint[Minting System]
_44
Burn[Burning System]
_44
Balance[Balance Tracking]
_44
end
_44
_44
subgraph FYV[FYV - Yield Layer]
_44
Vault[Yield Vault]
_44
Strategy[Tracer Strategy]
_44
Balancer[Auto Balancer]
_44
end
_44
_44
subgraph Actions[DeFi Actions - Flow Control]
_44
Sink[DrawDownSink]
_44
Source[TopUpSource]
_44
Swap[SwapConnector]
_44
end
_44
_44
Pool -->|Mints| Mint
_44
Position -->|Burns| Burn
_44
Oracle -->|Prices in MOET| Balance
_44
_44
Mint -->|Flows via| Sink
_44
Sink -->|Deploys to| Strategy
_44
Strategy -->|Holds in| Balancer
_44
_44
Balancer -->|Converts via| Swap
_44
Swap -->|Provides via| Source
_44
Source -->|Repays to| Position
_44
Position -->|Burns| Burn
_44
end
_44
_44
style ALP fill:#6699ff,stroke:#333,stroke-width:2px
_44
style MOET fill:#ff6666,stroke:#333,stroke-width:2px
_44
style FYV fill:#66cc66,stroke:#333,stroke-width:2px
_44
style Actions fill:#ffcc66,stroke:#333,stroke-width:2px

MOET in ALP (Automated Lending Platform)

Primary Borrowed Asset

MOET is the default and primary borrowed asset in ALP, with all lending operations centered around it.

Pool Configuration:


_10
// ALP Pool initialization (simplified)
_10
init() {
_10
self.defaultToken = Type<@MOET.Vault>
_10
self.supportedTokens = {
_10
Type<@MOET.Vault>: TokenState,
_10
Type<@FlowToken.Vault>: TokenState,
_10
// ... other collateral types
_10
}
_10
}

Why MOET as Default:

  1. Unified Denomination: Simplifies multi-collateral accounting
  2. Capital Efficiency: Borrowed MOET immediately deployable to yield
  3. Composability: Standard FungibleToken interface enables DeFi integration
  4. Liquidation Simplicity: Single debt token reduces liquidation complexity

Borrowing Flow

Step-by-Step Integration:


_37
User Action: Deposit 1000 FLOW Collateral
_37
_37
Step 1: Collateral Locked
_37
├── User calls: Pool.deposit(collateral: <-flowVault, pushToDrawDownSink: true)
_37
├── Pool receives: 1000 FLOW tokens
_37
├── Position created: positionID = 123
_37
└── Collateral stored in: Pool reserves
_37
_37
Step 2: Borrow Capacity Calculated
_37
├── Oracle fetches: FLOW/MOET price = 1.0
_37
├── Collateral value: 1000 × 1.0 = 1000 MOET
_37
├── Collateral factor: 0.8
_37
├── Effective collateral: 1000 × 0.8 = 800 MOET
_37
├── Target health: 1.3
_37
└── Max borrow: 800 / 1.3 = 615.38 MOET
_37
_37
Step 3: MOET Minted
_37
├── Pool calls: MOETMinter.mintTokens(615.38)
_37
├── Minter creates: 615.38 new MOET
_37
├── Vault returned to: Pool
_37
├── Total supply: Increased by 615.38
_37
└── Event emitted: TokensMinted(amount: 615.38, positionID: 123)
_37
_37
Step 4: Debt Recorded
_37
├── Position.debt.scaledBalance: 615.38
_37
├── Position.debt.index: Current interest index (I₀)
_37
├── Position.health: 1.30
_37
└── Position state: {collateral: 1000 FLOW, debt: 615.38 MOET}
_37
_37
Step 5: MOET Distribution
_37
├── If pushToDrawDownSink = true:
_37
│ ├── Pool deposits: <-moetVault into DrawDownSink
_37
│ ├── Sink forwards to: FYV strategy
_37
│ └── Automatic yield deployment
_37
└── If pushToDrawDownSink = false:
_37
├── Pool sends: <-moetVault to user's wallet
_37
└── User manually deploys MOET

Unit of Account in Pricing

All collateral assets are priced in MOET terms through the oracle system.

Oracle Interface:


_10
access(all) resource interface PriceOracle {
_10
// Returns price of token denominated in MOET
_10
access(all) fun getPrice(token: Type): UFix64
_10
}

Price Examples:


_10
Oracle Price Feeds (in MOET):
_10
├── FLOW/MOET: 1.0 (1 FLOW = 1 MOET)
_10
├── stFLOW/MOET: 1.05 (liquid staking premium)
_10
├── USDC/MOET: 1.0 (stablecoin parity)
_10
├── wBTC/MOET: 65,000.0 (Bitcoin price)
_10
└── wETH/MOET: 3,500.0 (Ethereum price)
_10
_10
Assumption: 1 MOET = 1 USD

Health Factor Calculation Using MOET Prices:


_22
Multi-Collateral Position:
_22
├── Collateral 1: 500 FLOW @ 1.0 MOET each
_22
│ ├── Value: 500 MOET
_22
│ ├── CF: 0.8
_22
│ └── Effective: 400 MOET
_22
├── Collateral 2: 100 stFLOW @ 1.05 MOET each
_22
│ ├── Value: 105 MOET
_22
│ ├── CF: 0.85
_22
│ └── Effective: 89.25 MOET
_22
├── Collateral 3: 1000 USDC @ 1.0 MOET each
_22
│ ├── Value: 1000 MOET
_22
│ ├── CF: 0.9
_22
│ └── Effective: 900 MOET
_22
├── Total Effective Collateral: 1,389.25 MOET
_22
├── Total Debt: 1,068.65 MOET
_22
└── Health Factor: 1,389.25 / 1,068.65 = 1.30 ✓
_22
_22
Benefits:
_22
├── All values in common denomination
_22
├── No currency conversion needed
_22
├── Efficient on-chain computation
_22
└── Real-time health monitoring simplified

Liquidation Process

MOET integration enables efficient liquidation through standardized debt repayment.

Liquidation Flow:


_37
Underwater Position Detected:
_37
├── Position 123: HF = 0.85 < 1.0
_37
├── Collateral: 1000 FLOW @ $0.70 = $700 (MOET terms)
_37
├── Effective collateral: $700 × 0.8 = $560 MOET
_37
├── Debt: 700 MOET
_37
└── Liquidatable: Yes
_37
_37
Liquidator Action:
_37
Step 1: Liquidator Prepares
_37
├── Liquidator has: 300 MOET in wallet
_37
├── Calls: Pool.liquidate(positionID: 123, repayAmount: 300 MOET)
_37
└── Goal: Seize collateral at profit
_37
_37
Step 2: Debt Repayment
_37
├── Pool receives: 300 MOET from liquidator
_37
├── Position debt reduced: 700 → 400 MOET
_37
├── Pool burns: 300 MOET (automatic on vault destruction)
_37
└── Supply reduced: 300 MOET
_37
_37
Step 3: Collateral Seizure
_37
├── Formula: CollateralSeized = (DebtRepaid × (1 + Bonus)) / PriceCollateral
_37
├── Calculation: (300 × 1.05) / 0.70 = 450 FLOW
_37
├── Transfer: 450 FLOW to liquidator
_37
└── Remaining collateral: 1000 - 450 = 550 FLOW
_37
_37
Step 4: Position Update
_37
├── New collateral: 550 FLOW @ $0.70 = $385
_37
├── New effective collateral: $385 × 0.8 = $308
_37
├── New debt: 400 MOET
_37
├── New HF: $308 / $400 = 0.77 (still liquidatable)
_37
└── Further liquidations possible
_37
_37
Liquidator Profit:
_37
├── Paid: 300 MOET ($300)
_37
├── Received: 450 FLOW worth $315
_37
├── Profit: $315 - $300 = $15 (5%)
_37
└── Incentivizes holding MOET for liquidations

Automated Rebalancing

MOET enables automatic position adjustments through health factor monitoring.

Over-Collateralized Rebalancing (HF > 1.5):


_30
Initial State:
_30
├── Collateral: 1000 FLOW @ $1.00 = $1,000
_30
├── Effective collateral: $800 MOET
_30
├── Debt: 615.38 MOET
_30
├── HF: 1.30
_30
└── Status: Optimal
_30
_30
Price Increase Event:
_30
├── FLOW price: $1.00 → $1.50 (+50%)
_30
├── New collateral value: $1,500
_30
├── New effective collateral: $1,500 × 0.8 = $1,200 MOET
_30
├── Debt unchanged: 615.38 MOET
_30
├── New HF: $1,200 / 615.38 = 1.95 > 1.5 ⚠️
_30
└── Trigger: Auto-borrow more
_30
_30
Automated Response:
_30
├── Target HF: 1.3
_30
├── Target debt: $1,200 / 1.3 = $923.08 MOET
_30
├── Additional borrow: $923.08 - 615.38 = $307.70 MOET
_30
├── Pool mints: 307.70 MOET
_30
├── MOET flows via DrawDownSink to: FYV
_30
├── Debt updated: 615.38 → 923.08 MOET
_30
├── HF restored: $1,200 / 923.08 = 1.30 ✓
_30
└── Extra capital deployed: 307.70 MOET earning yield
_30
_30
Benefits:
_30
├── Maximizes capital efficiency automatically
_30
├── No user intervention required
_30
├── More MOET generating yield
_30
└── Higher overall returns

Under-Collateralized Rebalancing (HF < 1.1):


_30
Initial State:
_30
├── Collateral: 1000 FLOW @ $1.00 = $1,000
_30
├── Effective collateral: $800 MOET
_30
├── Debt: 615.38 MOET
_30
├── HF: 1.30
_30
└── Status: Optimal
_30
_30
Price Decrease Event:
_30
├── FLOW price: $1.00 → $0.85 (-15%)
_30
├── New collateral value: $850
_30
├── New effective collateral: $850 × 0.8 = $680 MOET
_30
├── Debt unchanged: 615.38 MOET
_30
├── New HF: $680 / 615.38 = 1.11 < 1.1 ⚠️
_30
└── Trigger: Auto-repay debt
_30
_30
Automated Response:
_30
├── Target HF: 1.3
_30
├── Target debt: $680 / 1.3 = $523.08 MOET
_30
├── Must repay: 615.38 - $523.08 = $92.30 MOET
_30
├── Pool pulls from TopUpSource: 92.30 MOET (from FYV)
_30
├── Pool burns: 92.30 MOET
_30
├── Debt updated: 615.38 → 523.08 MOET
_30
├── HF restored: $680 / 523.08 = 1.30 ✓
_30
└── Position protected from liquidation
_30
_30
Benefits:
_30
├── Prevents liquidation automatically
_30
├── Utilizes yield earned in FYV
_30
├── No user intervention required
_30
└── Maintains position health

MOET in FYV (Flow Yield Vaults)

Yield Deployment Medium

MOET serves as the capital source for FYV yield strategies, enabling leveraged yield farming.

TracerStrategy Integration:


_24
Capital Flow: ALP → MOET → FYV → Yield Assets
_24
_24
Step 1: Receive MOET
_24
├── FYV receives: 615.38 MOET from ALP (via DrawDownSink)
_24
├── Strategy: TracerStrategy
_24
└── Goal: Generate yield > borrowing cost
_24
_24
Step 2: Convert to Yield Assets
_24
├── SwapConnector activated
_24
├── Swap: 615.38 MOET → 615.38 LP tokens
_24
├── LP tokens: e.g., FLOW/USDC liquidity pair
_24
└── Yield sources: Trading fees + liquidity rewards
_24
_24
Step 3: Hold in AutoBalancer
_24
├── AutoBalancer receives: 615.38 LP tokens
_24
├── Target value ratio: 100% (1.0)
_24
├── Acceptable range: 95%-105%
_24
└── Continuously monitors value growth
_24
_24
Step 4: Yield Accumulation
_24
├── LP tokens earn: Trading fees
_24
├── After 30 days: 615.38 LP → 640 LP
_24
├── Value growth: +4% (monthly yield)
_24
└── Yield ready for: Rebalancing or withdrawal

Value Ratio Monitoring

FYV tracks the ratio of yield assets to borrowed MOET for rebalancing decisions.

Value Ratio Formula:


_10
ValueRatio = Current LP Value (in MOET) / Initial MOET Borrowed
_10
_10
Example:
_10
├── Initial borrow: 615.38 MOET
_10
├── Current LP value: 640 MOET (after yield)
_10
├── Value ratio: 640 / 615.38 = 1.04 (104%)
_10
└── Status: Within acceptable range (95%-105%)

Rebalancing Thresholds:


_19
Value Ratio Conditions:
_19
_19
Case 1: Ratio < 95% (Deficit - Price Drop or Loss)
_19
├── Current value: 584.61 MOET (95% × 615.38)
_19
├── Problem: Insufficient value to cover debt
_19
├── Action: System alerts, may need external capital
_19
└── Risk: Position may become liquidatable
_19
_19
Case 2: Ratio 95%-105% (Optimal - Balanced)
_19
├── Current value: 584.61 - 646.15 MOET
_19
├── Status: Healthy range
_19
├── Action: No rebalancing needed
_19
└── Continue: Generating yield
_19
_19
Case 3: Ratio > 105% (Surplus - Excess Yield)
_19
├── Current value: 646.15+ MOET (>105% × 615.38)
_19
├── Profit: Excess beyond debt coverage
_19
├── Action: Harvest profit, reinvest or compound
_19
└── Opportunity: Increase leverage or take profit

Liquidation Prevention

FYV provides MOET back to ALP through TopUpSource when positions need protection.

TopUpSource Flow:


_32
Trigger: ALP Position HF Drops Below 1.1
_32
_32
Step 1: ALP Requests Liquidity
_32
├── ALP detects: HF = 1.05 < 1.1
_32
├── Required MOET: 92.30 to restore HF to 1.3
_32
├── ALP calls: TopUpSource.withdraw(92.30, Type<@MOET.Vault>)
_32
└── TopUpSource connected to: FYV strategy
_32
_32
Step 2: FYV Prepares MOET
_32
├── FYV checks: LP balance = 640 tokens
_32
├── Required conversion: 92.30 MOET
_32
├── Calculate LP needed: 92.30 LP (assuming 1:1 ratio)
_32
└── FYV has sufficient: 640 > 92.30 ✓
_32
_32
Step 3: Convert Yield to MOET
_32
├── FYV calls: SwapConnector.swap(92.30 LP → MOET)
_32
├── LP tokens sold: 92.30
_32
├── MOET received: 92.30
_32
└── Remaining LP: 640 - 92.30 = 547.7
_32
_32
Step 4: Provide to ALP
_32
├── FYV transfers: 92.30 MOET via TopUpSource
_32
├── ALP receives: 92.30 MOET
_32
├── ALP repays position debt: 615.38 → 523.08 MOET
_32
├── Pool burns: 92.30 MOET
_32
└── HF restored: 1.30 ✓
_32
_32
Result:
_32
├── Position saved from liquidation
_32
├── FYV still has: 547.7 LP generating yield
_32
├── System maintains: Health and composability
_32
└── User retains: All collateral

Yield Compounding

FYV can reinvest excess yield back into strategies using MOET as the medium.

Compounding Scenario:


_26
Initial Strategy:
_26
├── Borrowed: 615.38 MOET
_26
├── LP tokens: 615.38
_26
├── After 3 months yield: 688 LP (+11.8%)
_26
├── Value ratio: 688 / 615.38 = 1.118 (111.8%)
_26
└── Excess: 72.62 LP above 105% threshold
_26
_26
Compounding Decision:
_26
Option 1: Harvest Profit
_26
├── Convert excess: 72.62 LP → 72.62 MOET
_26
├── Repay debt: Reduce from 615.38 to 542.76 MOET
_26
├── Improve HF: From 1.30 to higher
_26
└── Lower risk: Less leverage
_26
_26
Option 2: Compound (Increase Leverage)
_26
├── Keep excess: 72.62 LP in strategy
_26
├── Borrow more: Request ALP to increase leverage
_26
├── Additional MOET: Based on new LP value
_26
├── Higher exposure: More LP, more yield
_26
└── Higher risk: Increased leverage
_26
_26
Option 3: Take Profit
_26
├── Convert excess: 72.62 LP → 72.62 MOET
_26
├── Withdraw to wallet: 72.62 MOET
_26
├── Realize gains: Lock in profit
_26
└── Maintain position: Continue with base amount

DeFi Actions: Connecting ALP and FYV

DrawDownSink (ALP → FYV)

DrawDownSink channels borrowed MOET from ALP positions into FYV strategies.

Interface:


_10
access(all) resource interface Sink {
_10
access(all) fun deposit(vault: @{FungibleToken.Vault})
_10
}

Implementation in FYV:


_16
// TracerStrategy implements Sink
_16
access(all) resource TracerStrategy: Sink {
_16
access(all) fun deposit(vault: @{FungibleToken.Vault}) {
_16
// Receive MOET from ALP
_16
let moet <- vault as! @MOET.Vault
_16
_16
// Convert to yield asset
_16
let lpTokens <- self.swapConnector.swap(from: <-moet, to: Type<@LPToken.Vault>)
_16
_16
// Deposit into AutoBalancer
_16
self.autoBalancer.deposit(<-lpTokens)
_16
_16
// Update tracking
_16
self.totalBorrowed = self.totalBorrowed + moet.balance
_16
}
_16
}

Usage Flow:


_11
ALP Position Configuration:
_11
├── User sets: position.drawDownSink = TracerStrategy capability
_11
├── On borrow: ALP calls drawDownSink.deposit(<-moetVault)
_11
└── MOET flows: ALP → TracerStrategy automatically
_11
_11
Example:
_11
├── Position borrows: 615.38 MOET
_11
├── DrawDownSink receives: 615.38 MOET
_11
├── TracerStrategy swaps: MOET → LP tokens
_11
├── AutoBalancer holds: 615.38 LP
_11
└── Yield generation: Begins immediately

TopUpSource (FYV → ALP)

TopUpSource provides MOET from FYV back to ALP for debt repayment and liquidation prevention.

Interface:


_10
access(all) resource interface Source {
_10
access(all) fun withdraw(amount: UFix64, type: Type): @{FungibleToken.Vault}
_10
}

Implementation in FYV:


_22
// TracerStrategy implements Source
_22
access(all) resource TracerStrategy: Source {
_22
access(all) fun withdraw(amount: UFix64, type: Type): @{FungibleToken.Vault} {
_22
// Verify type is MOET
_22
assert(type == Type<@MOET.Vault>(), message: "Only MOET withdrawals supported")
_22
_22
// Calculate LP tokens needed
_22
let lpNeeded = amount // Assuming 1:1 ratio for simplicity
_22
_22
// Withdraw from AutoBalancer
_22
let lpTokens <- self.autoBalancer.withdraw(lpNeeded)
_22
_22
// Convert to MOET
_22
let moet <- self.swapConnector.swap(from: <-lpTokens, to: Type<@MOET.Vault>)
_22
_22
// Update tracking
_22
self.totalWithdrawn = self.totalWithdrawn + amount
_22
_22
// Return MOET to ALP
_22
return <- (moet as! @{FungibleToken.Vault})
_22
}
_22
}

Usage Flow:


_12
ALP Position Configuration:
_12
├── User sets: position.topUpSource = TracerStrategy capability
_12
├── On low HF: ALP calls topUpSource.withdraw(amount, type)
_12
└── MOET flows: TracerStrategy → ALP automatically
_12
_12
Example:
_12
├── HF drops to: 1.05
_12
├── Required MOET: 92.30
_12
├── TopUpSource provides: 92.30 MOET (converted from LP)
_12
├── ALP repays: 92.30 MOET debt
_12
├── HF restored: 1.30
_12
└── Liquidation prevented

SwapConnector (Token Conversion)

SwapConnector enables MOET ↔ Yield Asset conversions within FYV strategies.

Interface:


_10
access(all) resource interface SwapConnector {
_10
access(all) fun swap(
_10
from: @{FungibleToken.Vault},
_10
to: Type
_10
): @{FungibleToken.Vault}
_10
}

Bidirectional Swaps:


_13
MOET → Yield Asset (Deployment):
_13
├── Input: 615.38 MOET vault
_13
├── Target: LP token (e.g., FLOW/USDC pair)
_13
├── Swap via: DEX (e.g., IncrementFi)
_13
├── Output: 615.38 LP tokens
_13
└── Use: Deployed to yield vault
_13
_13
Yield Asset → MOET (Withdrawal):
_13
├── Input: 92.30 LP tokens
_13
├── Target: MOET
_13
├── Swap via: DEX
_13
├── Output: 92.30 MOET
_13
└── Use: Debt repayment to ALP

Implementation Example:


_18
// DEX-based SwapConnector
_18
access(all) resource DEXSwapConnector: SwapConnector {
_18
access(all) fun swap(from: @{FungibleToken.Vault}, to: Type): @{FungibleToken.Vault} {
_18
// Route to appropriate DEX pool
_18
let pool = self.getPool(fromType: from.getType(), toType: to)
_18
_18
// Execute swap
_18
let output <- pool.swap(input: <-from, minOutput: self.calculateSlippage())
_18
_18
// Return swapped tokens
_18
return <-output
_18
}
_18
_18
access(self) fun getPool(fromType: Type, toType: Type): &Pool {
_18
// Find optimal pool for this pair
_18
return &self.pools[fromType]![toType]! as &Pool
_18
}
_18
}

Complete Integration Example

End-to-End User Journey


_60
Day 1: Position Creation
_60
├── User deposits: 1000 FLOW
_60
├── ALP mints: 615.38 MOET
_60
├── MOET flows via DrawDownSink to: FYV
_60
├── FYV swaps: MOET → 615.38 LP tokens
_60
├── LP held in: AutoBalancer
_60
└── Position state: 1000 FLOW collateral, 615.38 MOET debt, HF = 1.30
_60
_60
Days 2-30: Yield Generation
_60
├── LP tokens earn: Trading fees + rewards
_60
├── LP value grows: 615.38 → 640 LP (+4%)
_60
├── MOET debt accrues interest: 615.38 → 620.51 (+0.83% monthly)
_60
├── Net position value: 640 - 620.51 = 19.49 MOET profit
_60
└── Value ratio: 640 / 620.51 = 1.031 (103.1%, healthy)
_60
_60
Day 15: Price Drop Event
_60
├── FLOW price drops: $1.00 → $0.88 (-12%)
_60
├── Collateral value: $880
_60
├── Effective collateral: $880 × 0.8 = $704 MOET
_60
├── Debt: 617.50 MOET (with partial interest)
_60
├── HF: 704 / 617.50 = 1.14 > 1.1 ✓
_60
└── No action: Still above minimum threshold
_60
_60
Day 20: Further Price Drop
_60
├── FLOW price drops: $0.88 → $0.82 (-7% more, -18% total)
_60
├── Collateral value: $820
_60
├── Effective collateral: $820 × 0.8 = $656 MOET
_60
├── Debt: 618.50 MOET
_60
├── HF: 656 / 618.50 = 1.06 < 1.1 ⚠️
_60
└── Trigger: Auto-rebalancing
_60
_60
Auto-Rebalancing:
_60
├── Target HF: 1.3
_60
├── Target debt: 656 / 1.3 = 504.62 MOET
_60
├── Repay amount: 618.50 - 504.62 = 113.88 MOET
_60
├── FYV provides via TopUpSource: 113.88 MOET
_60
│ ├── Convert LP: 113.88 LP → 113.88 MOET
_60
│ └── Remaining LP: 640 - 113.88 = 526.12 LP
_60
├── ALP burns: 113.88 MOET
_60
├── New debt: 504.62 MOET
_60
├── New HF: 656 / 504.62 = 1.30 ✓
_60
└── Position protected!
_60
_60
Days 21-30: Recovery
_60
├── FLOW price recovers: $0.82 → $0.95 (+16%)
_60
├── Collateral value: $950
_60
├── Effective collateral: $950 × 0.8 = $760 MOET
_60
├── Debt: 507.50 MOET (with interest)
_60
├── HF: 760 / 507.50 = 1.50 (at threshold)
_60
└── No auto-borrow: Exactly at 1.5
_60
_60
Day 30: Position Closure
_60
├── LP value: 526.12 LP worth $547.35
_60
├── Convert all LP: 526.12 LP → 547.35 MOET
_60
├── Total debt: 507.50 MOET
_60
├── Repay: 507.50 MOET to ALP
_60
├── ALP burns: 507.50 MOET
_60
├── Excess MOET: 547.35 - 507.50 = 39.85 MOET
_60
├── Withdraw collateral: 1000 FLOW
_60
└── Final profit: 39.85 MOET ($39.85 on $1,000 = 3.98% monthly ROI)

Integration Benefits

For Users:

  1. Seamless Capital Flow: MOET moves automatically between components
  2. Automated Protection: Yield protects positions without manual intervention
  3. Maximized Returns: Borrowed capital immediately deployed to yield
  4. Simplified UX: Single deposit action triggers entire flow

For Protocol:

  1. Capital Efficiency: No idle MOET sitting in wallets
  2. Reduced Liquidations: Auto-rebalancing prevents most liquidations
  3. Composability: MOET enables third-party integrations
  4. Scalability: Standardized interfaces support multiple strategies

For Ecosystem:

  1. Unified Liquidity: MOET creates common liquidity layer
  2. DeFi Composability: Standard token enables broader integrations
  3. Innovation: Developers can build new strategies using MOET
  4. Network Effects: More users → more liquidity → better yields

Technical Implementation Details

Contract Interactions

Key Contract Calls:


_41
// ALP borrows MOET for user
_41
pub fun borrow(amount: UFix64): @MOET.Vault {
_41
// Mint MOET
_41
let moet <- MOETMinter.mintTokens(amount: amount)
_41
_41
// Update position debt
_41
self.debt.scaledBalance = self.debt.scaledBalance + amount
_41
_41
// Push to DrawDownSink if configured
_41
if let sink = self.drawDownSink {
_41
sink.deposit(vault: <-moet)
_41
return <- MOET.createEmptyVault() // Return empty vault
_41
}
_41
_41
// Otherwise return MOET to user
_41
return <- moet
_41
}
_41
_41
// ALP repays MOET debt
_41
pub fun repay(vault: @MOET.Vault) {
_41
// Record repaid amount
_41
let repaidAmount = vault.balance
_41
_41
// Update position debt
_41
self.debt.scaledBalance = self.debt.scaledBalance - repaidAmount
_41
_41
// Burn MOET (automatic on destroy)
_41
destroy vault // Triggers burnCallback()
_41
}
_41
_41
// FYV provides MOET for debt repayment
_41
pub fun provideForRepayment(): @MOET.Vault {
_41
// Calculate needed amount
_41
let neededAmount = self.calculateRepaymentAmount()
_41
_41
// Withdraw from strategy
_41
let moet <- self.strategy.withdraw(amount: neededAmount, type: Type<@MOET.Vault>())
_41
_41
// Return MOET for ALP repayment
_41
return <- (moet as! @MOET.Vault)
_41
}

Event Emissions

Tracking MOET Flows:


_14
// Emitted when MOET is minted
_14
pub event TokensMinted(amount: UFix64, positionID: UInt64, mintedBy: Address)
_14
_14
// Emitted when MOET is burned
_14
pub event TokensBurned(amount: UFix64, burnedFrom: UInt64)
_14
_14
// Emitted when MOET flows to DrawDownSink
_14
pub event MOETDeployed(amount: UFix64, from: UInt64, to: Address, strategy: String)
_14
_14
// Emitted when MOET provided via TopUpSource
_14
pub event MOETWithdrawn(amount: UFix64, from: Address, to: UInt64, reason: String)
_14
_14
// Emitted when MOET swapped
_14
pub event MOETSwapped(amount: UFix64, direction: String, pool: Address)

Analytics Use Cases:


_17
Monitor Total Supply:
_17
├── Track: TokensMinted events
_17
├── Track: TokensBurned events
_17
├── Calculate: Supply = Mints - Burns
_17
└── Analyze: Supply growth trends
_17
_17
Monitor Capital Flows:
_17
├── Track: MOETDeployed events (ALP → FYV)
_17
├── Track: MOETWithdrawn events (FYV → ALP)
_17
├── Calculate: Net flow = Deployed - Withdrawn
_17
└── Analyze: Capital efficiency metrics
_17
_17
Monitor Liquidation Activity:
_17
├── Track: TokensBurned with reason = "liquidation"
_17
├── Calculate: Liquidation volume
_17
├── Analyze: System health indicators
_17
└── Alert: Liquidation cascades

Next Steps