Skip to content

Commit

Permalink
Merge pull request #212 from Define101/master
Browse files Browse the repository at this point in the history
add euroe on concordium
  • Loading branch information
Define101 authored Jan 4, 2024
2 parents 0bf0786 + 49a8691 commit 3485aae
Show file tree
Hide file tree
Showing 2 changed files with 36 additions and 3 deletions.
36 changes: 34 additions & 2 deletions src/adapters/peggedAssets/euroe-stablecoin/index.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const sdk = require("@defillama/sdk");
import { sumSingleBalance } from "../helper/generalUtil";
import { bridgedSupply, solanaMintedOrBridged } from "../helper/getSupply";
import fetch from "node-fetch";
import { sumSingleBalance, } from "../helper/generalUtil";
import { solanaMintedOrBridged } from "../helper/getSupply";
import {
ChainBlocks,
PeggedIssuanceAdapter,
Expand Down Expand Up @@ -34,6 +35,33 @@ const chainContracts: ChainContracts = {
},
};

async function concordiumMinted(apiEndpoint: string, decimals: number) {
return async function (
_timestamp: number,
_ethBlock: number,
_chainBlocks: ChainBlocks
) {
let balances = {} as Balances;

try {
const res = await fetch(apiEndpoint);

if (!res.ok) {
throw new Error(`Failed to fetch data from Concordium API. Status: ${res.status}`);
}

const totalSupply = parseFloat(await res.text());
const formattedTotalSupply = Number(totalSupply.toFixed(decimals));
sumSingleBalance(balances, "peggedEUR", formattedTotalSupply, apiEndpoint, true);

} catch (error) {
console.error(`Error fetching data from Concordium API: ${error}`);
}

return balances;
};
}

async function chainMinted(chain: string, decimals: number) {
return async function (
_timestamp: number,
Expand Down Expand Up @@ -87,6 +115,10 @@ const adapter: PeggedIssuanceAdapter = {
minted: chainMinted("optimism", 6),
unreleased: async () => ({}),
},
concordium: {
minted: concordiumMinted("https://www.euroe.com/api/totalsupply/CCD", 6),
unreleased: async () => ({}),
},
};

export default adapter;
3 changes: 2 additions & 1 deletion src/adapters/peggedAssets/helper/chains.json
Original file line number Diff line number Diff line change
Expand Up @@ -135,5 +135,6 @@
"linea",
"mantle",
"agoric",
"emoney"
"emoney",
"concordium"
]

0 comments on commit 3485aae

Please sign in to comment.