# LibCeler

These functions manage the configuration, addition, and execution of Celer bridge transactions. They handle the interaction with the Celer bridge and logs events related to their actions. Additionally, they decode payload data and perform the necessary transaction actions for both inbound and outbound asset transfers between Celer networks and other networks. The functions include validations to ensure the Celer bridge is active and functional before executing these transactions.

### updateSetting():

Updates the Celer bridge settings in the application storage.

**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">celerBridgeSettings
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">CelerBridgeSettings
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">struct CelerBridgeSettings {
    address messageBusAddress;
}
</code></pre></td></tr></tbody></table>

### addCelerChainIds():

Adds Celer chain IDs to the application storage.

**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">networkIds
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint16[]
</code></pre></td><td>An array containing identifiers for networks.</td></tr><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">chainIds
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint64[]
</code></pre></td><td>An array containing chain identifiers corresponding to the networks in <code>networkIds</code>.</td></tr></tbody></table>

### addMagpieCelerBridgeAddresses():

Adds Magpie Celer bridge addresses to the application storage.

**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">networkIds
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">uint16[] 
</code></pre></td><td>An array containing identifiers for networks.</td></tr><tr><td><p></p><pre class="language-solidity"><code class="lang-solidity">magpieCelerBridgeAddresses
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">bytes32[]
</code></pre></td><td>An array containing chain identifiers corresponding to the networks in <code>networkIds</code>.</td></tr></tbody></table>

### decodeBridgeInPayload():

Decodes the payload used in a Celer bridge transaction.

**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">bridgeInPayload
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">bytes
</code></pre></td><td><p></p><p>A bytes array that represents the input payload.</p></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">bridgeInData
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">CelerBridgeInData
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">struct CelerBridgeInData {
    uint32 slippage;
    uint256 fee;
}
</code></pre></td></tr></tbody></table>

### bridgeIn():

Executes the bridge in operation for a Celer bridge, facilitating the transfer from one network to another.

**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">bridgeInArgs
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">BridgeInArgs
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">struct BridgeInArgs {
    uint16 recipientNetworkId;
    BridgeArgs bridgeArgs;
    uint256 amount;
    address toAssetAddress;
    TransferKey transferKey;
}
</code></pre></td></tr></tbody></table>

### bridgeOut():

Performs the bridge out operation, transferring assets from the Celer network back to the original network.

**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">bridgeOutArgs
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">BridgeOutArgs
</code></pre></td><td><p></p><pre class="language-solidity"><code class="lang-solidity">struct BridgeOutArgs {
    BridgeArgs bridgeArgs;
    Transaction transaction;
    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 amount received after the bridgining</td></tr></tbody></table>

### Events:

```solidity
event UpdateCelerBridgeSettings(address indexed sender, CelerBridgeSettings celerBridgeSettings);
```

```solidity
event AddCelerChainIds(address indexed sender, uint16[] networkIds, uint64[] chainIds);
```

```solidity
event AddMagpieCelerBridgeAddresses(
        address indexed sender,
        uint16[] networkIds,
        bytes32[] magpieCelerBridgeAddresses
    );
```


---

# 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/magpieaggregator-diamond-proxy/bridge/libceler.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.
