HyperPaxeer NetworkPaxeer Network

Lending Protocol

Decentralized lending and borrowing protocol with credit scores and dynamic interest rates

Overview

Decentralized lending and borrowing protocol with credit scores and dynamic interest rates on Paxeer Network.

Quick Start

API Base URL: https://lending-api.paxeer.app

curl https://lending-api.paxeer.app/api/pools

Key Features

REST API

Get All Lending Pools

methodstring

GET /api/pools

Retrieves all available lending pools with current statistics.

curl https://lending-api.paxeer.app/api/pools
const response = await fetch('https://lending-api.paxeer.app/api/pools');
const pools = await response.json();
console.log(pools);
import requests

response = requests.get('https://lending-api.paxeer.app/api/pools')
pools = response.json()
print(pools)

Response:

[
  {
    "assetAddress": "0xD0C1a714c46c364DBDd4E0F7b0B6bA5354460dA7",
    "pTokenAddress": "0xE3Df3966007483e8076230e6E7AA381D3bAc52C0",
    "symbol": "WETH",
    "decimals": 18,
    "totalSupplied": "209.119273268701533652",
    "supplyApy": "5.21",
    "borrowApy": "7.85"
  }
]

Get User Lending Positions

methodstring

GET /api/user/:address

Get user-specific data including credit score and borrowing power.

addressstringrequired

User wallet address

curl https://lending-api.paxeer.app/api/user/0x2fccd991Ecc9bEe62Bd10d751A5c5492e2a788C7
const address = '0x2fccd991Ecc9bEe62Bd10d751A5c5492e2a788C7';
const response = await fetch(`https://lending-api.paxeer.app/api/user/${address}`);
const userData = await response.json();

Response:

{
  "address": "0x2fccd991Ecc9bEe62Bd10d751A5c5492e2a788C7",
  "creditScore": 825,
  "borrowingPower": "15000.0",
  "amountBorrowed": "5000.0",
  "availableToBorrow": "10000.0"
}

Smart Contract Functions

deposit()

Deposit assets into the lending pool to earn interest.

function deposit(
  address asset,
  uint256 amount
) external

Requires approve() call first to allow the lending pool to transfer your tokens.

Example:

import { ethers } from 'ethers';

const LENDING_POOL_ADDRESS = '0x...';

async function deposit(assetAddress, amount) {
  const signer = await provider.getSigner();
  
  // 1. Approve token spending
  const token = new ethers.Contract(assetAddress, ERC20_ABI, signer);
  const approveTx = await token.approve(LENDING_POOL_ADDRESS, amount);
  await approveTx.wait();
  
  // 2. Deposit
  const lendingPool = new ethers.Contract(
    LENDING_POOL_ADDRESS,
    LENDING_POOL_ABI,
    signer
  );
  const depositTx = await lendingPool.deposit(assetAddress, amount);
  await depositTx.wait();
}

withdraw()

Withdraw your deposited assets plus earned interest.

function withdraw(
  address asset,
  uint256 amount
) external

Example:

async function withdraw(assetAddress, amount) {
  const signer = await provider.getSigner();
  const lendingPool = new ethers.Contract(
    LENDING_POOL_ADDRESS,
    LENDING_POOL_ABI,
    signer
  );
  
  const withdrawTx = await lendingPool.withdraw(assetAddress, amount);
  await withdrawTx.wait();
}

borrow()

Borrow assets based on your credit score and collateral.

function borrow(
  address asset,
  uint256 amount
) external

Example:

async function borrow(assetAddress, amount) {
  const signer = await provider.getSigner();
  const lendingPool = new ethers.Contract(
    LENDING_POOL_ADDRESS,
    LENDING_POOL_ABI,
    signer
  );
  
  const borrowTx = await lendingPool.borrow(assetAddress, amount);
  await borrowTx.wait();
}

repay()

Repay your borrowed amount to close or reduce your loan.

function repay(
  address asset,
  uint256 amount
) external

Requires approve() call first to allow the lending pool to transfer repayment tokens.

Example:

async function repay(assetAddress, amount) {
  const signer = await provider.getSigner();
  
  // 1. Approve token spending
  const token = new ethers.Contract(assetAddress, ERC20_ABI, signer);
  const approveTx = await token.approve(LENDING_POOL_ADDRESS, amount);
  await approveTx.wait();
  
  // 2. Repay
  const lendingPool = new ethers.Contract(
    LENDING_POOL_ADDRESS,
    LENDING_POOL_ABI,
    signer
  );
  const repayTx = await lendingPool.repay(assetAddress, amount);
  await repayTx.wait();
}

Integration Guide

Fetch Pool Data

Get available pools and their current rates:

const pools = await fetch('https://lending-api.paxeer.app/api/pools')
  .then(res => res.json());

Approve Token Spending

Allow the lending pool to transfer your tokens:

const token = new ethers.Contract(assetAddress, ERC20_ABI, signer);
await token.approve(LENDING_POOL_ADDRESS, amount);

Execute Action

Deposit, borrow, withdraw, or repay:

const lendingPool = new ethers.Contract(
  LENDING_POOL_ADDRESS,
  LENDING_POOL_ABI,
  signer
);

// Deposit
await lendingPool.deposit(assetAddress, amount);

// Or Borrow
await lendingPool.borrow(assetAddress, amount);

Monitor User Data

Track your positions and credit score:

const userData = await fetch(
  `https://lending-api.paxeer.app/api/user/${userAddress}`
).then(res => res.json());

console.log('Credit Score:', userData.creditScore);
console.log('Borrowing Power:', userData.borrowingPower);

Contract ABI

React Hook Example

import { useState, useEffect } from 'react';

export function useLendingPools() {
  const [pools, setPools] = useState([]);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    async function fetchPools() {
      try {
        const response = await fetch('https://lending-api.paxeer.app/api/pools');
        const data = await response.json();
        setPools(data);
      } catch (error) {
        console.error('Error fetching pools:', error);
      } finally {
        setLoading(false);
      }
    }

    fetchPools();
    const interval = setInterval(fetchPools, 30000); // Refresh every 30s

    return () => clearInterval(interval);
  }, []);

  return { pools, loading };
}

export function useUserLending(address: string) {
  const [userData, setUserData] = useState(null);
  const [loading, setLoading] = useState(true);

  useEffect(() => {
    if (!address) return;

    async function fetchUserData() {
      try {
        const response = await fetch(
          `https://lending-api.paxeer.app/api/user/${address}`
        );
        const data = await response.json();
        setUserData(data);
      } catch (error) {
        console.error('Error fetching user data:', error);
      } finally {
        setLoading(false);
      }
    }

    fetchUserData();
    const interval = setInterval(fetchUserData, 30000);

    return () => clearInterval(interval);
  }, [address]);

  return { userData, loading };
}

Understanding Credit Scores

Credit scores in the lending protocol range from 300 to 850 and affect:

Best Practices

Always ensure you:

  • Understand the risks of lending and borrowing
  • Monitor your health factor to avoid liquidation
  • Keep track of accruing interest
  • Maintain sufficient collateral

Tip

Tips for success:

  • Start with small amounts to learn the protocol
  • Monitor APY changes regularly
  • Diversify across multiple assets
  • Set up alerts for health factor changes

Resources

How is this guide?

On this page