Magpie Protocol
  • Magpie Protocol
    • What is Magpie solving?
      • What is DeFi?
    • Magpies Key Features
      • Use Cases
    • FLY
      • xFLY & FLY33
  • 📶Supported Networks
  • Guides
    • 📖Glossary of DeFi Terms
    • 👜Connect Wallet
    • 🔄On-Chain Swap
    • 🔀Cross-Chain Swap
    • 🔂Swap configuration
    • 🥚Magpie Boosts
    • 📒Transaction History
    • 💲Portfolio
  • Media Kit
  • 👩‍💻Developers
    • Magpie Contracts
      • MagpieCCTPBridge
      • MagpieCelerBridgeV2
      • MagpieRouterV3
      • MagpieStargateBridgeV3
      • LibAsset
      • LibBridge
      • LibRouter
    • Smart Contracts Audit
    • Deployments
    • API Reference
      • On chain swap
      • Cross chain swap
      • Requesting and Using API Key
Powered by GitBook
On this page
  • enforcePreGuard():
  • enforcePostGuard():
  • enforceDelegatedCallPreGuard():
  • enforceDelegatedCall():
  • enforceDelegatedCallPostGaurd():
  • enforceDelegatedCallGuard():
  1. Developers
  2. Deprecated Magpie Contracts
  3. MagpieAggregator Diamond Proxy
  4. Libraries

LibGuard

These functions are intended to prevent reentrancy attacks by ensuring that reentrant calls are not executed when the guarded flag is set. The guarded flag is controlled by these functions to enable or disable the reentrancy guard as needed.

enforcePreGuard():

This function is used to enforce a pre-reentrancy guard. It retrieves the AppStorage instance using LibMagpieAggregator.getStorage() and checks if the guarded flag is set. If the flag is already set, indicating an ongoing reentrant call, it reverts the transaction with a ReentrantCall error. Otherwise, it sets the guarded flag to true.

enforcePostGuard():

This function is used to enforce a post-reentrancy guard. It retrieves the AppStorage instance using LibMagpieAggregator.getStorage() and sets the guarded flag to false.

enforceDelegatedCallPreGuard():

Accesses the contract storage to determine if a specific type of delegated call is already in progress. If a call of that type is already in progress, it reverts the transaction to prevent reentrancy. If no such call is in progress, it sets the delegated call state to true for that call type.

Input:

Field
Type
Description

enforceDelegatedCall():

Accesses the contract storage to confirm whether a particular type of delegated call is currently in progress. If the expected call is not in progress, it reverts the transaction, indicating an invalid delegated call.

enforceDelegatedCallPostGaurd():

Accesses the contract storage and sets the delegated call state back to false for the specified type of delegated call.

Input:

Field
Type

enforceDelegatedCallGuard():

Accesses the contract storage to confirm whether a particular type of delegated call is currently in progress. If the expected call is not in progress, it reverts the transaction, indicating an invalid delegated call.

Input:

Field
Type
Description

Last updated 1 year ago

👩‍💻
delegatedCallType
DelegatedCallType
enum DelegatedCallType {
    BridgeIn,
    BridgeOut,
    DataTransferIn,
    DataTransferOut
}
delegatedCallType
DelegatedCallType
enum DelegatedCallType {
    BridgeIn,
    BridgeOut,
    DataTransferIn,
    DataTransferOut
}
delegatedCallType
DelegatedCallType
enum DelegatedCallType {
    BridgeIn,
    BridgeOut,
    DataTransferIn,
    DataTransferOut
}