---
# System prepended metadata

title: Deploy Isle Finance to Hedera

---

# Deploy Isle Finance to Hedera

## Project Overview
### Contract Description
![isle](https://hackmd.io/_uploads/HJymEU2bee.png)
[Isle Finance documentation](https://docs.isle.finance/contract-documentation/diagrams)


## Development Environment
### Main Tools
- [Foundry](https://book.getfoundry.sh/)
### Hedera Related Tools
- [Hedera SDKs](https://github.com/hiero-ledger/hiero-sdk-js)
- [hedera-forking](https://github.com/hashgraph/hedera-forking)
- [hedera-the-graph](https://github.com/hashgraph/hedera-the-graph/tree/main/subgraphs/starter-example)


## Prerequisites
### 1. Setting up EVM address Alias on Hedera mainnet
To use our existing EVM address, we first need to set an alias using the Hedera SDK.
Using the example code provided in the documentation, we can then obtain the corresponding account ID on the Hedera Mainnet.

```typescript=
const tx = new AccountCreateTransaction()
    .setKeyWithAlias(evmPublicKey)
    .setInitialBalance(new Hbar(1));
const submitTx = await tx.execute(client);
const receipt = await submitTx.getReceipt(client);
const accountId = receipt.accountId;
```

### 2. Integrating hedera-forking into Foundry Script
To interact with HTS in a Foundry script, we need to rely on the `hedera-forking` library.
Therefore, we’ve included this library in the necessary deployment scripts.

```solidity=
function run(
    address asset_,
    address globals_,
    address receivable_
)
    public
    virtual
    returns (
        PoolAddressesProvider poolAddressesProvider_,
        address poolConfigurator_,
        address loanManager_,
        address withdrawalManager_
    )
{
    Hsc.htsSetup(); // Setup HTS

    oolAddressesProvider_ = deployPoolAddressesProvider(IsleGlobals(globals_));

    initGlobals({ globals_: IsleGlobals(globals_), asset_: asset_, receivable_: receivable_ });

    poolConfigurator_ = deployPoolConfigurator(poolAddressesProvider_, asset_);
    loanManager_ = deployLoanManager(poolAddressesProvider_, asset_);
    withdrawalManager_ = deployWithdrawalManager(poolAddressesProvider_);
}
```

### 3. Adjusting Pool contract to adapt to the Hedera system
There are two compatibility issues between Isle’s Pool and HTS:
- The Isle Pool interacts with HTS directly within its constructor, which means there’s no opportunity to `associate` with HTS beforehand.
- HTS only supports `int64` as the maximum value for approve, whereas we use `uint256` for `approve` during initialization.

Due to these issues, the Hedera Dev Team suggested modifying the Pool's constructor.
Here is the updated code
```solidity=
constructor(
    address configurator_,
    address asset_,
    string memory name_,
    string memory symbol_
)
    ERC20Permit(name_)
    ERC20(name_, symbol_)
{
    if (asset_ == address(0)) revert Errors.Pool_ZeroAsset();
    if ((configurator = configurator_) == address(0)) revert Errors.Pool_ZeroConfigurator();
    // if (!IERC20(asset_).approve(configurator_, type(uint256).max)) revert Errors.Pool_FailedApprove();

    IHRC719(asset_).associate();
    if (!IERC20(asset_).approve(configurator_, uint256(int256(type(int64).max)))) revert Errors.Pool_FailedApprove();

    _underlyingDecimals = ERC20(asset_).decimals();
    _asset = ERC20Permit(asset_);
}
```


## Deployment Process
### Deployment commands and steps
#### 1. Deploy and verify Globals contract
Hedera Configs
- RPC_URL: https://mainnet.hashio.io/api
- VERIFIER_URL: https://server-verify.hashscan.io
```shell
forge script scripts/DeployGlobals.s.sol \
  --sig "run()" \
  --broadcast \
  --rpc-url $RPC_URL \
  --verify --verifier sourcify --verifier-url $VERIFIER_URL \
  --legacy --skip-simulation -vvvvv
```
After execution, will obtain Globals contract address.

#### 2. Deploy and verify Receivable contract
```shell
forge script scripts/DeployReceivable.s.sol \
  --sig "run(address)" $GLOBAL \
  --broadcast \
  --rpc-url $RPC_URL \
  --verify --verifier sourcify --verifier-url $VERIFIER_URL \
  --legacy --skip-simulation -vvvvv
```
After execution, will obtain Receivable contract address.

#### 3. Deploy and verify Pools contract
In this step, we will deploy the following contracts.
- PoolAddressesProvider
- PoolConfigurator
- Pool
- LoanManager
- WithdrawalManager

Hedera Configs
- ASSET: 0x000000000000000000000000000000000006f89a 
USDC HTS mainnet address

**Note: This step will interact with `hedera-forking`, and according to the doc, the `--ffi` flag must be used.**

```shell
forge script scripts/DeployPool.s.sol \
  --sig "run(address,address,address)" $ASSET $GLOBAL $RECEIVABLE \
  --broadcast \
  --rpc-url $RPC_URL \
  --verify --verifier sourcify --verifier-url $VERIFIER_URL \
  --legacy --skip-simulation --ffi -vvvvv
```

#### 4. Verify contracts
Since deploying pools involves a series of steps to deploy multiple contracts, including both proxy and implementation contracts. It’s common to miss some during the verification process. Therefore, manual verification is required.
```shell
# chain id
# Mainnet is 295
# Testnet is 296
# Previewnet is 297

forge verify-contract \
  --chain-id 295 \
  --verifier sourcify --verifier-url $VERIFIER_URL  \
  --skip-is-verified-check \
  --watch \
  <address> \
  <contract_file>:<contract_name>
```

### At this point, we have completed the deployment of all contracts.


## Check on the explore
### IsleGlobals
Proxy
- address: [0x0b2BdD04D12f4Fc7d4a45100cE3dC10605b44B00](https://hashscan.io/mainnet/contract/0.0.9200837)
- id: [0.0.9200837](https://hashscan.io/mainnet/contract/0.0.9200837)

Implementation:
- address: [0x731194479c488ffd3f5bde9ee5c098d84e9c39b7](https://hashscan.io/mainnet/contract/0.0.9200836)
- id: [0.0.9200836](https://hashscan.io/mainnet/contract/0.0.9200836)

### Receivable

Proxy
- address: [0x536ad6c51716db79713eafc1c30948f0759ff12e](https://hashscan.io/mainnet/contract/0.0.9200848)
- id: [0.0.9200848](https://hashscan.io/mainnet/contract/0.0.9200848)

Implementation
- address: [0x0e7349cbcba4d5394e51ae8b227a0f7d5ae3333c](https://hashscan.io/mainnet/contract/0.0.9200847?ps=1&pa=1&pr=1&pf=1)
- id: [0.0.9200847](https://hashscan.io/mainnet/contract/0.0.9200847?ps=1&pa=1&pr=1&pf=1)

### PoolAddressesProvider
- address: [0xb51d6cd9edb262ec18f2940936afb205456aa60a](https://hashscan.io/mainnet/contract/0.0.9215399?pr=1&pa=1&ps=1&pf=1)
- id: [0.0.9215399](https://hashscan.io/mainnet/contract/0.0.9215399?pr=1&pa=1&ps=1&pf=1)

### PoolConfigurator
Proxy
- address: [0xda7c7ca4438c099dfa4d224c6ed75d050b5ee911](https://hashscan.io/mainnet/contract/0.0.9215405?ps=1&pa=1&pr=1&pf=1&kf=0.0.456858)
- id: [0.0.9215405](https://hashscan.io/mainnet/contract/0.0.9215405?ps=1&pa=1&pr=1&pf=1&kf=0.0.456858)

Implementation
- address: [0xa31672D3E1139eE44F5603926f0CFd22F568A77F](https://hashscan.io/mainnet/contract/0.0.9215404?pa=1&pr=1&ps=1&pf=1)
- id: [0.0.9215404](https://hashscan.io/mainnet/contract/0.0.9215404?pa=1&pr=1&ps=1&pf=1)

### Pool
- address: [0xb463faC356b2d7913D8c4Daa79cC5B895d3f84C9](https://hashscan.io/mainnet/contract/0.0.9215406?pr=1&pa=1&ps=1&pf=1&kf=0.0.456858)
- id: [0.0.9215406](https://hashscan.io/mainnet/contract/0.0.9215406?pr=1&pa=1&ps=1&pf=1&kf=0.0.456858)

### LoanManager
Proxy

- address: [0x0d2006e890535e0fc8b6ab6197146d23c7c71264](https://hashscan.io/mainnet/contract/0.0.9215411?pa=1&pr=1&pf=1&kf=0.0.456858&ps=1)
- id: [0.0.9215411](https://hashscan.io/mainnet/contract/0.0.9215411?pa=1&pr=1&pf=1&kf=0.0.456858&ps=1)

Implementation
- address: [0x9186C635B4907f9d0FA759afeA7a4dBDa786eF54](https://hashscan.io/mainnet/contract/0.0.9215410?pr=1&pa=1&ps=1&pf=1)
- id: [0.0.9215410](https://hashscan.io/mainnet/contract/0.0.9215410?pr=1&pa=1&ps=1&pf=1)

### WithdrawalManager

Proxy
- address: [0x1c744bd01a1773d218a13955ebd8927155491a35](https://hashscan.io/mainnet/contract/0.0.9215417?ps=1&pa=1&pr=1&pf=1)
- id: [0.0.9215417](https://hashscan.io/mainnet/contract/0.0.9215417?ps=1&pa=1&pr=1&pf=1)

Implementation
- address: [0x1131a7894e7f1b2c07a367b759ec5b7d117dcd84](https://hashscan.io/mainnet/contract/0.0.9215415?pa=1&pr=1&ps=1&pf=1)
- id: [0.0.9215415](https://hashscan.io/mainnet/contract/0.0.9215415?pa=1&pr=1&ps=1&pf=1)


### USDC
- address: [0x000000000000000000000000000000000006f89a](https://hashscan.io/mainnet/token/0.0.456858)
- id: [0.0.456858](https://hashscan.io/mainnet/token/0.0.456858)


## Subgraph
### hedera-the-graph
The Hedera dev team recommends using [hedera-the-graph](https://github.com/hashgraph/hedera-the-graph/tree/main/subgraphs/starter-example) as the indexer. However, we’ve encountered some issues after deployment, and Hedera’s developer are currently working on resolving them.

### Goldsky
So for now, we’ve deployed to the Goldsky mainnet instead. 


## Common Issues and Troubleshooting
### Solidity version compatable issue
The Isle Finance contracts use Solidity version `0.8.19`, while the `hedera-forking only` supported `0.8.21` and above.
However, this has already been fixed in the following [PR](https://github.com/hashgraph/hedera-forking/pull/285).

### forge-std version compatable issue
We were originally using an earlier version of `forge-std`, so we didn’t realize there could be a version compatibility issue here as well.
However, this prerequisite has since been added to the documentation, as noted in the [PR](https://github.com/hashgraph/hedera-forking/pull/290).

### HTS associate issue
In the previous of `hedera-forking`, an error would occur during HTS association when the provided address did not belong to an existing Hedera account.
This issue has since been resolved in this [PR](https://github.com/hashgraph/hedera-forking/pull/291).


## References
- [Hedera documentation](https://docs.hedera.com/hedera)
- [hedera-forking](https://github.com/hashgraph/hedera-forking)
- [hedera-the-graph](https://github.com/hashgraph/hedera-the-graph/tree/main/subgraphs/starter-example)