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.