# 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>
