Skip to content

Commit 360dd7e

Browse files
authored
Merge pull request #247 from Define101/master
add adapter for ULTRA (prisma)
2 parents 5e9603f + 847c059 commit 360dd7e

File tree

2 files changed

+60
-2
lines changed

2 files changed

+60
-2
lines changed

src/adapters/peggedAssets/index.ts

+4-2
Original file line numberDiff line numberDiff line change
@@ -159,7 +159,8 @@ import vchf from "./vnx-swiss-franc";
159159
import usdrif from "./usd-rif";
160160
import dllr from "./sovryn-dollar"
161161
import eurd from "./quantoz-eurd";
162-
import xusd from "./xusd"
162+
import xusd from "./xusd";
163+
import ultra from "./ultra"
163164

164165
export default {
165166
tether,
@@ -323,5 +324,6 @@ export default {
323324
"rif-us-dollar": usdrif,
324325
"sovryn-dollar": dllr,
325326
"quantoz-eurd": eurd,
326-
"xusd-fake": xusd
327+
"xusd-fake": xusd,
328+
"ultra": ultra
327329
};
+56
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
1+
const sdk = require("@defillama/sdk");
2+
import { sumSingleBalance } from "../helper/generalUtil";
3+
import {
4+
ChainBlocks,
5+
PeggedIssuanceAdapter,
6+
Balances,
7+
} from "../peggedAsset.type";
8+
9+
type ChainContracts = {
10+
[chain: string]: {
11+
[contract: string]: string[];
12+
};
13+
};
14+
15+
const chainContracts: ChainContracts = {
16+
ethereum: {
17+
issued: ["0x35282d87011f87508D457F08252Bc5bFa52E10A0"],
18+
}
19+
};
20+
21+
async function chainMinted(chain: string, decimals: number) {
22+
return async function (
23+
_timestamp: number,
24+
_ethBlock: number,
25+
_chainBlocks: ChainBlocks
26+
) {
27+
let balances = {} as Balances;
28+
for (let issued of chainContracts[chain].issued) {
29+
const totalSupply = (
30+
await sdk.api.abi.call({
31+
abi: "erc20:totalSupply",
32+
target: issued,
33+
block: _chainBlocks?.[chain],
34+
chain: chain,
35+
})
36+
).output;
37+
sumSingleBalance(
38+
balances,
39+
"peggedUSD",
40+
totalSupply / 10 ** decimals,
41+
"issued",
42+
false
43+
);
44+
}
45+
return balances;
46+
};
47+
}
48+
49+
const adapter: PeggedIssuanceAdapter = {
50+
ethereum: {
51+
minted: chainMinted("ethereum", 18),
52+
unreleased: async () => ({}),
53+
}
54+
};
55+
56+
export default adapter;

0 commit comments

Comments
 (0)