Cross-Chain Lending

Lending Demo

Explore RHEA lending via createNoirCrossChainLendingBridge and read-only SDK APIs loaded on demand.

Connect Noir Wallet to use Bridge write actions and Identity/MCA queries. Market read-only APIs work without a wallet.

Zcash MCA Bridge

Covers all createNoirCrossChainLendingBridge methods. Deposit targets must be transparent t1/t3 addresses.

Usage example
import { NoirZcashWalletAdapter } from '@rhea-finance/zcash-wallet-adapter';
import { createNoirCrossChainLendingBridge } from '@rhea-finance/zcash-wallet-adapter/lending';

const noir = new NoirZcashWalletAdapter({ network: 'mainnet' });
await noir.connect();

const lending = createNoirCrossChainLendingBridge(noir, {
  fundingSource: 'shielded',
  signingMode: 'derived',
});

isTransparentZcashLendingAddress

Usage example
import { isTransparentZcashLendingAddress } from '@rhea-finance/zcash-wallet-adapter/lending';

const valid = isTransparentZcashLendingAddress('t1...', 'zcash:mainnet');

loadSdk

Usage example
// Lazy-load the full RHEA cross-chain SDK
const sdk = await lending.loadSdk();

getIdentityKey

Usage example
// Derived public key used as Zcash MCA identity
const identityKey = await lending.getIdentityKey();

getMcaByWallet

Usage example
// Look up MCA bound to the connected Noir wallet
const mcaId = await lending.getMcaByWallet();
// null when no MCA exists yet

getCreateMcaDepositAddress

Usage example
// Request a transparent deposit address for MCA creation
const depositAddress = await lending.getCreateMcaDepositAddress('multica.near');

getZcashDepositStatus

Usage example
// Poll deposit status by transparent address
const status = await lending.getZcashDepositStatus(depositAddress);
// status?.mca_id, status?.status

sendDeposit

Usage example
// Send ZEC from shielded balance to a RHEA deposit address
const result = await lending.sendDeposit({
  depositAddress: 't1...',
  amount: '0.01', // decimal string
});
// result.txHash

createMcaDeposit

Usage example
// Get deposit address + send in one flow
const result = await lending.createMcaDeposit({
  accountManagerId: 'multica.near',
  amount: '0.01',
});
// result.txHash, result.depositAddress

Market & Config

getAssetsDetail

Usage example
const sdk = await lending.loadSdk();
const assets = await sdk.getAssetsDetail();

getAssetDetailsView

Usage example
const sdk = await lending.loadSdk();
const assetsView = await sdk.getAssetDetailsView();

getAllFarms

Usage example
const sdk = await lending.loadSdk();
const farms = await sdk.getAllFarms();

getMultichainLendingConfig

Usage example
const sdk = await lending.loadSdk();
const config = await sdk.getMultichainLendingConfig();

getCreateMcaFeePaged

Usage example
const sdk = await lending.loadSdk();
const fees = await sdk.getCreateMcaFeePaged();

getNearValuesPaged

Usage example
const sdk = await lending.loadSdk();
const values = await sdk.getNearValuesPaged();

get_all_tokens_metadata

Usage example
const sdk = await lending.loadSdk();
const metadata = await sdk.get_all_tokens_metadata();

getBurrowAsset

Usage example
const sdk = await lending.loadSdk();
const asset = await sdk.getBurrowAsset();

getLsdMetadata

Usage example
const sdk = await lending.loadSdk();
const lsdMeta = await sdk.getLsdMetadata();

getLsdTotalSupply

Usage example
const sdk = await lending.loadSdk();
const supply = await sdk.getLsdTotalSupply();

fetchIntentsTokens

Usage example
const sdk = await lending.loadSdk();
const tokens = await sdk.fetchIntentsTokens();

Account Views

batchViews

Requires MCA ID

Usage example
const sdk = await lending.loadSdk();
const views = await sdk.batchViews(mcaId);

batchViewsData

Requires MCA ID

Usage example
const sdk = await lending.loadSdk();
const data = await sdk.batchViewsData(mcaId);

getAccountAllPositions

Requires MCA ID

Usage example
const sdk = await lending.loadSdk();
const positions = await sdk.getAccountAllPositions(mcaId);

getAccountAllPositionsView

Requires MCA ID

Usage example
const sdk = await lending.loadSdk();
const portfolio = await sdk.getAccountAllPositionsView(mcaId);

getListWalletsByMca

Requires MCA ID

Usage example
const sdk = await lending.loadSdk();
const wallets = await sdk.getListWalletsByMca(mcaId);

getMultichainLendingHistory

Requires MCA ID

Usage example
const sdk = await lending.loadSdk();
const history = await sdk.getMultichainLendingHistory({
  mca_id: mcaId,
  page_number: 1,
  page_size: 10,
});

get_records

Requires MCA ID

Usage example
const sdk = await lending.loadSdk();
const records = await sdk.get_records(mcaId, 1, 10);

get_liquidations

Requires MCA ID

Usage example
const sdk = await lending.loadSdk();
const liquidations = await sdk.get_liquidations(mcaId, 1, 10);

getLsdBalances

Usage example
const sdk = await lending.loadSdk();
const balances = await sdk.getLsdBalances({ accountAddress: mcaId });

Quote / Dry-run

format_wallet (zcash)

Requires Identity Key

Usage example
const sdk = await lending.loadSdk();
const wallet = sdk.format_wallet({
  chain: 'zcash',
  identityKey,
});

fetchIntentsQuotation

Usage example
const sdk = await lending.loadSdk();
const quote = await sdk.fetchIntentsQuotation({
  originAsset: 'nep141:zec.omft.near',
  destinationAsset: 'nep141:eth-0xdac17f958d2ee523a2206206994597c13d831ec7.omft.near',
  amount: '10000000',
  refundTo: 'u1...', // origin chain (Zcash)
  recipient: '0x...', // destination chain (EVM for eth-* assets)
  dry: true,
  slippageTolerance: 100,
});

quoteLsdSupplyByIntents

Usage example
const sdk = await lending.loadSdk();
const quote = await sdk.quoteLsdSupplyByIntents({
  accountAddress: mcaId,
  amount: '10',
  dry: true,
});

quoteLsdWithdrawByIntents

Usage example
const sdk = await lending.loadSdk();
const quote = await sdk.quoteLsdWithdrawByIntents({
  accountAddress: mcaId,
  amount: '10',
  dry: true,
});

findPath

Usage example
const sdk = await lending.loadSdk();
const path = await sdk.findPath({
  tokenIn: 'USDT',
  tokenOut: 'USDC',
  amountIn: '1000000',
  slippage: 50,
});

Zcash SDK Helpers

getZcashCreateMcaDepositAddress

Usage example
const sdk = await lending.loadSdk();
const depositAddress = await sdk.getZcashCreateMcaDepositAddress('multica.near');

getZcashResponseDataByAddress

Usage example
const sdk = await lending.loadSdk();
const status = await sdk.getZcashResponseDataByAddress('t1...');