> For the complete documentation index, see [llms.txt](https://docs.canopyhub.xyz/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.canopyhub.xyz/canopys-four-layers/protocol-layer/echelon-integration.md).

# Echelon Integration

## Overview

The `echelon_block::echelon_block` module contains the block implementation for Echelon. Modules in the `blocks` package are modules that contain convenience functions that interface with an underlying protocol(e.g. echelon, moveposition, etc). These block functions are used by concrete strategy implementations to interact with an underlying protocol, instead of interacting with it directly.

## Constants

* **SUPPLY\_MARKET\_TYPE**: `u64 = 200` - Type identifier for supply market operations
* **BORROW\_MARKET\_TYPE**: `u64 = 201` - Type identifier for borrow market operations

## Public Functions

### Market Operations

* `supply<CoinType>(account: &signer, market: Object<Market>, coin: Coin<CoinType>)`: Supplies coins to the specified market.
* `supply_fa(account: &signer, market: Object<Market>, asset: FungibleAsset)`: Supplies fungible assets to the specified market.
* `borrow<CoinType>(account: &signer, market: Object<Market>, amount: u64): Coin<CoinType>`: Borrows coins from the specified market.
* `withdraw<CoinType>(account: &signer, market: Object<Market>, shares: u64): Coin<CoinType>`: Withdraws coins from the specified market based on shares.
* `withdraw_fa(account: &signer, market: Object<Market>, shares: u64): FungibleAsset`: Withdraws fungible assets from the specified market based on shares.

### Account Information

* `account_coins(account: address, market: Object<Market>): u64`: Returns the number of coins an account has in a market.
* `account_shares(account: address, market: Object<Market>): u64`: Returns the number of shares an account has in a market.
* `amount_borrowable<CoinType>(account: address, market: Object<Market>): u64`: Returns the amount of coins an account can borrow from a market.
* `amount_withdrawable<CoinType>(account: address, market: Object<Market>): u64`: Returns the amount of coins an account can withdraw from a market.
* `coins_to_shares(market: Object<Market>, coins: u64): u64`: Converts coin amount to share amount for a given market.

### Reward Operations

* `get_supply_reward<CoinType>(account: address, market: address): u64`: Returns the claimable supply reward amount for a specific coin type.
* `get_supply_reward_fa(account: address, market: address, metadata: Object<Metadata>): u64`: Returns the claimable supply reward amount for a fungible asset.
* `get_borrow_reward<CoinType>(account: address, market: address): u64`: Returns the claimable borrow reward amount for a specific coin type.
* `get_borrow_reward_fa(account: address, market: address, metadata: Object<Metadata>): u64`: Returns the claimable borrow reward amount for a fungible asset.
* `claim_supply_reward<CoinType>(account: &signer, market: address): Coin<CoinType>`: Claims supply rewards for a specific coin type.
* `claim_supply_reward_fa(account: &signer, metadata: Object<Metadata>, market: address): FungibleAsset`: Claims supply rewards for a fungible asset.


---

# Agent Instructions
This documentation is published with GitBook. GitBook is the documentation platform designed so that both humans and AI agents can read, navigate, and reason over technical content effectively. Learn more at gitbook.com.

## 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, and the optional `goal` query parameter:

```
GET https://docs.canopyhub.xyz/canopys-four-layers/protocol-layer/echelon-integration.md?ask=<question>&goal=<endgoal>
```

`ask` is the immediate question: it should be specific, self-contained, and written in natural language.
`goal` is optional and describes the broader end goal you are ultimately trying to accomplish on behalf of the user. GitBook uses it to tailor the answer towards what is most useful for that goal.

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.
