> For the complete documentation index, see [llms.txt](https://docs.nondollar.life/autonomint/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.nondollar.life/autonomint/blockchain-docs/core-contracts/globalvariables.md).

# GlobalVariables

## Write Functions

### send

```solidity
function send(
    FunctionToDo functionToDo,
    IBorrowing.AssetName assetName,
    MessagingFee memory fee,
    bytes memory options,
    address refundAddress
) external payable
```

```solidity
enum FunctionToDo {
    DUMMY,
    UPDATE_GLOBAL,
    UPDATE_INDIVIDUAL,
    TOKEN_TRANSFER,
    COLLATERAL_TRANSFER,
    BOTH_TRANSFER
}

struct MessagingFee {
    uint256 nativeFee;
    uint256 lzTokenFee;
}
```

| Param Name    | Param Type                                                                              | Description                                            |
| ------------- | --------------------------------------------------------------------------------------- | ------------------------------------------------------ |
| functionToDo  | enum FunctionToDo                                                                       | What function needs to be done in destination chain.   |
| assetName     | enum [AssetName](/autonomint/blockchain-docs/core-contracts/borrowing.md#deposittokens) | Collateral type to update the amount of collaterals.   |
| fee           | struct MessagingFee                                                                     | Native fee needs to pay for LZ transaction.            |
| options       | bytes                                                                                   | Gas limit.                                             |
| refundAddress | address                                                                                 | Address where the remaining native fee should be sent. |
| msg.value     | uint256                                                                                 | Native fee.                                            |

Send the LZ transaction to do the specified function in the destination chain.

### sendForLiquidation

```solidity
function sendForLiquidation(
    FunctionToDo functionToDo,
    uint128 liqIndex,
    CDSInterface.LiquidationInfo memory liquidationInfo,
    IBorrowing.AssetName assetName,
    MessagingFee memory fee,
    bytes memory options,
    address refundAddress
) external payable
```

| Param Name     | Param Type      | Description                                            |
| -------------- | --------------- | ------------------------------------------------------ |
| functionToDo   | FunctionToDo    | What function needs to be done in destination chain.   |
| liqIndex       | uint128         | Liquidation index to map to the data.                  |
| liquidtionInfo | LiquidationInfo | Liquidation Info to store.                             |
| assetName      | AssetName       | Liquidated asset.                                      |
| fee            | MessagingFee    | Native fee for lz send.                                |
| options        | bytes           | Gas limit.                                             |
| refundAddress  | address         | Address where the remaining native fee should be sent. |
| msg.value      | uint256         | Native fee.                                            |

Send the LZ transaction to do the specified function in the destination chain.

### oftOrCollateralReceiveFromOtherChains

```solidity
function oftOrCollateralReceiveFromOtherChains(
    FunctionToDo functionToDo,
    USDaOftTransferData memory oftTransferData,
    CollateralTokenTransferData memory collateralTokenTransferData,
    CallingFunction callingFunction,
    address refundAddress
) external payable
```

<table><thead><tr><th width="256">Param Name</th><th width="243">Param Type</th><th>Description</th></tr></thead><tbody><tr><td>functionToDo</td><td>FunctionToDo</td><td>What function needs to be done in destination chain.</td></tr><tr><td>oftTransferData</td><td>USDaOftTransferData</td><td>Details contains receiver address and amount of USDa to get.</td></tr><tr><td>collateralTokenTransferData</td><td>CollateralTokenTransferData</td><td>Details contains receiver address and amount of Collateral to get.</td></tr><tr><td>callingFunction</td><td>CallingFunction</td><td>Which function is calling this function.</td></tr><tr><td>refundAddress</td><td>address</td><td>Address where the remaining native fee should be sent.</td></tr></tbody></table>

Gets the required USDa or Collateral from destination chain.

### \_lzReceive

```solidity
function _lzReceive(
    Origin calldata /*_origin*/,
    bytes32 /*_guid*/,
    bytes calldata payload,
    address /*_executor*/,
    bytes calldata /*_extraData*/
) internal override {
```

| Param Name | Param Type     | Description                             |
| ---------- | -------------- | --------------------------------------- |
| payload    | bytes calldata | payload data received from source chain |

Performs the function mentioned in payload.

## Setter Functions

### setDstEid

```solidity
function setDstEid(uint32 eid)
```

Sets the destination endpoint id for the contract.

### setTreasury

```solidity
function setTreasury(address _treasury)
```

Sets the treasury contract interface.

### setOmniChainData

```solidity
function setOmniChainData(OmniChainData memory _omniChainData)
```

Updates the omnichain data to be stored in other chain.

### setBorrowing

```solidity
function setBorrowing(address _borrow)
```

Sets the borrowing contract instance.

### setBorrowLiq

```solidity
function setBorrowLiq(address _borrowLiq)
```

Sets the borrow liquidation contract address.

### setDstGlobalVariablesAddress

```solidity
function setDstGlobalVariablesAddress(
    address _globalVariables
)
```

Sets the destination chain global variables contract address.

## Read Functions

## quote

```solidity
function quote(
    FunctionToDo functionToDo,
    IBorrowing.AssetName assetName,
    bytes memory options,
    bool payInLzToken
)
```

| Param Name   | Param Type   | Description                                          |
| ------------ | ------------ | ---------------------------------------------------- |
| functionToDo | FunctionToDo | What function needs to be done in destination chain. |
| assetName    | AssetName    | Collateral type to update the amount of collaterals. |
| options      | bytes        | Gas value                                            |
| payInLzToken | bool         | Whether the fee is paying in lzToken                 |

Returns the native fee needs to be pay for the lz send transaction.
