Skip to content

Commit

Permalink
add project jpow-ai (#13709)
Browse files Browse the repository at this point in the history
  • Loading branch information
dganhnhnh authored Mar 3, 2025
1 parent e142306 commit 9a4b724
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions projects/jpow/index.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
const { PublicKey } = require("@solana/web3.js");
const { sumTokens2 } = require('../helper/solana');

const JPOW_PROGRAM_ID = new PublicKey('3APJcbC2iHEFGv4y6a8Fi5nQ5u75ML85TQreSr7cpRDs');

const DEPOSITORY_SEED = "DEPOSITORY";

// get collateral tokens supported by JPOW lending protocol
async function fetchCollateralTokens() {
const response = await fetch('https://api.jpow.ai/lending/metrics');
const data = await response.json();
return data.assets.map(asset => new PublicKey(asset.contractAddress));
}

async function tvl() {
const tokensAndOwners = [];
const collaterals = await fetchCollateralTokens();

// get depository of each collateral
for (let i = 0; i < collaterals.length; i++) {
const [depositoryPda] = PublicKey.findProgramAddressSync(
[Buffer.from(DEPOSITORY_SEED), collaterals[i].toBuffer()],
JPOW_PROGRAM_ID
);

tokensAndOwners.push([
collaterals[i],
depositoryPda
]);
}
return sumTokens2({ tokensAndOwners });
}


module.exports = {
timetravel: false,
solana: {
tvl,
}
};

0 comments on commit 9a4b724

Please sign in to comment.