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
  • updateWeth()
  • updateMagpieRouterAddress()
  • updateNetworkId()
  • addMagpieAggregatorAddresses()
  • swapIn()
  • swapOut()
  • getDeposit()
  • withdraw()
  • getDepositByUser()
  • isTransferKeyUsed()
  1. Developers
  2. Deprecated Magpie Contracts
  3. MagpieAggregator Diamond Proxy
  4. Aggregator

AggregatorFacet

The AggregatorFacet contract serves as the implementation of the IAggregator interface. It provides functions for updating settings, performing swaps, managing deposits, retrieving payloads, and checking transfer key usage. The functions enforce necessary checks and interact with the underlying LibAggregator library to execute the operations.

updateWeth()

The purpose of this function is to allow the contract owner to update the address of the WETH token used in the aggregator contract.

Input

Field
Type
Description

Address of wrapped native address (WETH for Ethereum, WMATIC for Polygon etc.)

updateMagpieRouterAddress()

the updateMagpieRouterAddress function is a straightforward administrative function that allows the contract owner to update a critical component of the system, in this case, the address of the Magpie Router.

Input

Field
Type
Description

This new address is the updated address for the Magpie Router within the contract.

updateNetworkId()

The purpose of this function is to allow the contract owner to update the network ID used in the aggregator contract.

Input

Field
Type
Description

networkId of the current chain in Magpie protocol, it is different from the actual networkId ethereum: 1 polygon: 2 bsc: 3 avalanche: 4 arbitrum: 5 optimism: 6

addMagpieAggregatorAddresses()

The purpose of this function is to allow the contract owner to add Magpie aggregator addresses for multiple network IDs in the aggregator contract.

Input

Field
Type
Description

networkIds of the networks we want to add

Address of MagpieAggregator contracts on the specified chains/networks

swapIn()

this function is responsible for executing a swap-in operation. It enforces various checks such as the deadline, pausing status, and custom guards.

Input

Field
Type
Description

Output

Field
Type
Description

amountOut that you will receive after swapping tokens

swapOut()

this function is responsible for executing a swap-out operation. It enforces various checks such as the deadline, pausing status, and custom guards.

Input

Field
Type
Description

Output

Field
Type
Description

amountOut that you will receive after swapping tokens

getDeposit()

The purpose of this function is to allow external callers to retrieve the deposit amount for a specific asset in the aggregator contract.

Input

Field
Type
Description

Address of the token for which you want to query deposit

Output

Field
Type
Description

It returns the amount of deposited assets

withdraw()

The purpose of this function is to allow external callers to initiate the withdrawal of funds from the aggregator contract for a specific asset.

Input

Field
Type
Description

Address of the token which will be withdrawn

getDepositByUser()

The purpose of this function is to allow external callers to retrieve the deposit amount for a specific asset deposited by a specific user in the aggregator contract.

Input

Field
Type
Description

the address of the asset whose deposited amount needs to be retrieved

the address of the user who has deposited the asset

Output

Field
Type
Description

amount

the deposited amount

isTransferKeyUsed()

The purpose of this function is to allow external callers to check if a specific transfer key has been used in the aggregator contract.

Input

Field
Type
Description

the source network identifier provided by the magpie team for each bloackchain

the address of the user

the sequence stored in our data base

Output

Field
Type
Description

True if the key has been used false if not

Last updated 1 year ago

SwapInArgs is a struct, its explained

SwapOutArgs is a struct, its explained

👩‍💻
weth
address
magpieRouterAddress
address
networkId
uint16
networkIds
uint16[]
magpieAggregatorAddresses
bytes32[]
swapInArgs
SwapInArgs
amountOut
uint256
swapOutArgs
SwapOutArgs
amountOut
uint256
assetAddress
address
uint256
assetAddress
address
assetAddress
address
senderAddress
address
uint256
networkId
uint16
senderAddress
bytes32
coreSequence
uint64
bool
here
here