# MagpieCelerBridge

`MagpieCelerBridge`, which serves as an intermediary to handle deposits, withdrawals, and refunds of assets between Magpie Aggregator and Celer Network.

**It has two modifiers:**

### onlyMagpieAggregator:

Restricts functions to only be called by the Magpie Aggregator.

### onlyCeler:

Restricts functions to only be called by the Celer Network.

**It contains the following functions:**

### **updateSettings():**

Allows the owner to update the contract settings.

**Input**

<table><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">_settings
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">Settings
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">struct Settings {
        address aggregatorAddress;
        address messageBusAddress;
    }
</code></pre></td></tr></tbody></table>

### **deposit():**

Handles the deposit process by receiving funds, approving tokens, sending them to the liquidity bridge, and notifying the message bus.

**Input**

<table><thead><tr><th></th><th></th><th></th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">depositArgs
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">DepositArgs
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">struct DepositArgs {
        uint32 slippage;
        uint64 chainId;
        uint256 amount;
        address sender;
        address receiver;
        address assetAddress;
        TransferKey transferKey;
    }
</code></pre></td></tr></tbody></table>

### **withdraw():**

Handles withdrawal requests from deposited amounts.

**Input**

<table><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">withdrawArgs
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">WithdrawArgs
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">struct WithdrawArgs {
        address assetAddress;
        TransferKey transferKey;
    }
</code></pre></td></tr></tbody></table>

**Output**

<table><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">amount
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint256
</code></pre></td><td>The withdrawal amount</td></tr></tbody></table>

### **executeMessageWithTransfer():**

Receives transfers and updates the deposited amounts accordingly.

Input

<table><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">address
</code></pre></td><td></td></tr><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">assetAddress
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">address
</code></pre></td><td></td></tr><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">amount
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint256
</code></pre></td><td></td></tr><tr><td></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint64
</code></pre></td><td></td></tr><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">payload
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">bytes
</code></pre></td><td></td></tr><tr><td></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">address
</code></pre></td><td></td></tr></tbody></table>

Output

<table><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">IMessageBus.TxStatus
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">enum TxStatus {
        Null,
        Success,
        Fail,
        Fallback,
        Pending 
    }
</code></pre></td></tr></tbody></table>

### **executeMessageWithTransferRefund():**

Manages refunds to the designated recipient.

**Input**

<table><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">assetAddress
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">address
</code></pre></td><td></td></tr><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">amount
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint256
</code></pre></td><td></td></tr><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">payload
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">bytes
</code></pre></td><td></td></tr><tr><td></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">address
</code></pre></td><td></td></tr></tbody></table>

**Output**

<table><thead><tr><th>Field</th><th>Type</th><th>Description</th></tr></thead><tbody><tr><td></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">IMessageBus.TxStatus
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">enum TxStatus {
        Null,
        Success,
        Fail,
        Fallback,
        Pending 
    }
</code></pre></td></tr></tbody></table>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.fly.trade/flycn/developers/deprecated-magpie-contracts/magpiecelerbridge.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
