File tree 1 file changed +56
-0
lines changed
src/adapters/peggedAssets/sovryn-dollar
1 file changed +56
-0
lines changed Original file line number Diff line number Diff line change
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
+ rsk : {
17
+ issued : [ "0xc1411567d2670e24d9c4daaa7cda95686e1250aa" ] ,
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
+ rsk : {
51
+ minted : chainMinted ( "rsk" , 18 ) ,
52
+ unreleased : async ( ) => ( { } ) ,
53
+ }
54
+ } ;
55
+
56
+ export default adapter ;
You can’t perform that action at this time.
0 commit comments