Skip to content

Commit 5d733ea

Browse files
authored
Merge pull request #268 from Define101/master
wip frax ETH chain (WIP no merge, still broken)
2 parents 9ed319a + 879fd67 commit 5d733ea

File tree

1 file changed

+16
-17
lines changed

1 file changed

+16
-17
lines changed

src/adapters/peggedAssets/frax/index.ts

Lines changed: 16 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
const sdk = require("@defillama/sdk");
2+
import axios from "axios";
23
import { sumSingleBalance } from "../helper/generalUtil";
34
import {
45
bridgedSupply,
@@ -86,37 +87,35 @@ Frax works differently from other stables, bridged amounts don't matter.
8687
See: https://docs.frax.finance/cross-chain/bridge
8788
*/
8889

89-
async function chainMinted(chain: string, decimals: number) {
90+
91+
async function fraxMinted() {
9092
return async function (
9193
_timestamp: number,
9294
_ethBlock: number,
9395
_chainBlocks: ChainBlocks
9496
) {
9597
let balances = {} as Balances;
96-
for (let issued of chainContracts[chain].issued) {
97-
const totalSupply = (
98-
await sdk.api.abi.call({
99-
abi: "erc20:totalSupply",
100-
target: issued,
101-
block: _chainBlocks?.[chain],
102-
chain: chain,
103-
})
104-
).output;
105-
sumSingleBalance(
106-
balances,
107-
"peggedUSD",
108-
totalSupply / 10 ** decimals,
109-
"issued",
110-
false
98+
try {
99+
const response = await axios.get(
100+
"https://api.frax.finance/v2/frax/balance-sheet/latest"
111101
);
102+
const data = response.data;
103+
104+
// Calculate total supply
105+
const totalSupply = (data.totalLiabilities - data.categorySummaryUsd["asset:owned:frax"]) - data.totalLockedLiquidity
106+
const supply = totalSupply;
107+
sumSingleBalance(balances, "peggedUSD", supply, "issued", false);
108+
return balances;
109+
} catch (error) {
110+
console.error("Error fetching supply data:", error);
112111
}
113112
return balances;
114113
};
115114
}
116115

117116
const adapter: PeggedIssuanceAdapter = {
118117
ethereum: {
119-
minted: chainMinted("ethereum", 18),
118+
minted: fraxMinted(),
120119
unreleased: async () => ({}),
121120
},
122121
bsc: {

0 commit comments

Comments
 (0)