forked from DefiLlama/DefiLlama-Adapters
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
add FranklinTempleton RWA adapter (DefiLlama#10918)
* add FranklinTempleton RWA adapter * use toUSDTBalances() helper --------- Co-authored-by: 0xpeluche <0xpeluche@protonmail.com>
- Loading branch information
Showing
1 changed file
with
28 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
const { toUSDTBalances } = require('../helper/balances'); | ||
|
||
const BENJI_STELLAR = {ticker: "BENJI", address: 'GBHNGLLIE3KWGKCHIKMHJ5HVZHYIK7WTBE4QF5PLAKL4CJGSEU7HZIW5'} | ||
const BENJI_POLYGON = '0x408a634b8a8f0de729b48574a3a7ec3fe820b00a' | ||
|
||
const stellarTvl = async (api) => { | ||
const stellarApi = `https://api.stellar.expert/explorer/public/asset/${BENJI_STELLAR.ticker}-${BENJI_STELLAR.address}` | ||
const response = await fetch(stellarApi) | ||
const {supply, toml_info} = await response.json() | ||
const adjustedSupply = toUSDTBalances((supply / Math.pow(10, toml_info.decimals))) | ||
const [[tokenAddress, tokenBalance]] = Object.entries(adjustedSupply); | ||
return api.add(tokenAddress, tokenBalance, { skipChain: true }) | ||
} | ||
|
||
const polygonTvl = async (api) => { | ||
const [decimals, totalSupply] = await Promise.all([ | ||
api.call({target: BENJI_POLYGON, abi:'erc20:decimals'}), | ||
api.call({target: BENJI_POLYGON, abi:'erc20:totalSupply'}) | ||
]) | ||
const adjustedSupply = toUSDTBalances((totalSupply / Math.pow(10, decimals))) | ||
const [[tokenAddress, tokenBalance]] = Object.entries(adjustedSupply); | ||
api.add(tokenAddress, tokenBalance, {skipChain: true} ) | ||
} | ||
|
||
module.exports = { | ||
stellar: {tvl: stellarTvl}, | ||
polygon: {tvl: polygonTvl}, | ||
} |