mvx_flash_loan_patterns

Implement atomic lend-execute-verify flash loan patterns on MultiversX.

12|5|Updated Jan 28, 2026
One-click install
npx skills add https://github.com/multiversx/mx-ai-skills --skill mvx-flash-loan-patterns
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: mvx_flash_loan_patterns
Source: https://github.com/multiversx/mx-ai-skills/tree/main/antigravity/skills/mvx_flash_loan_patterns
Command: npx skills add https://github.com/multiversx/mx-ai-skills --skill mvx-flash-loan-patterns

SYSTEM DOCUMENTATION & REQUIREMENTS

What problem does it solve?

This Skill provides a robust pattern for implementing atomic operations involving lending and borrowing assets within a single transaction, ensuring that all steps, from lending to repayment, are completed successfully or rolled back entirely.

Core Features & Use Cases

  • Atomic Transactions: Guarantees that lending, execution of a callback, and repayment occur as a single, indivisible operation.
  • Reentrancy Protection: Includes a guard to prevent recursive calls within the same operation.
  • Shard Validation: Ensures operations are confined to the same blockchain shard to maintain atomicity.
  • Endpoint Validation: Verifies that the callback endpoint is not a built-in function, preventing bypass of repayment logic.
  • Repayment Verification: Confirms that the contract balance is sufficient for repayment after the callback.
  • Use Case: Ideal for implementing flash loans, atomic swaps, or temporary asset grants where immediate repayment is critical.

Quick Start

Implement the atomic lend-execute-verify pattern using the provided Rust code snippet.

Frequently Asked Questions about mvx_flash_loan_patterns

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I implement a secure flash loan on MultiversX?

A flash loan requires an atomic lend-execute-verify pattern on MultiversX, enforcing reentrancy guards and same-shard validation to ensure operations complete entirely or roll back, verifying repayment by checking contract balances post-callback.

What is the atomic lend-execute-verify pattern for smart contracts?

The atomic lend-execute-verify pattern executes lending, callback processing, and repayment as a single indivisible transaction, ensuring that all steps succeed or the entire operation rolls back entirely to maintain state consistency.

How do reentrancy guards protect DeFi atomic operations?

Reentrancy guards protect DeFi atomic operations by preventing recursive smart contract calls within the same transaction, blocking attempts to bypass repayment logic and ensuring the lend-execute-verify sequence completes safely.

Why does a flash loan callback require same-shard validation on MultiversX?

Same-shard validation is required for flash loan callbacks on MultiversX because cross-shard execution breaks atomicity, preventing the smart contract from guaranteeing that lending and repayment occur successfully within a single transaction.

How does endpoint validation prevent flash loan repayment bypass?

Endpoint validation prevents repayment bypass by verifying the callback endpoint is not a built-in function, ensuring custom logic executes so the contract can check post-callback balances and confirm sufficient repayment before completing the atomic operation.

Can I use atomic operations for temporary asset grants in DeFi?

Yes, atomic operations support temporary asset grants in DeFi by applying the lend-execute-verify pattern, ensuring that temporary asset grants are either repaid within the same transaction or rolled back entirely to prevent loss.