File tree 1 file changed +71
-0
lines changed
1 file changed +71
-0
lines changed Original file line number Diff line number Diff line change
1
+ const utils = require ( '../utils' ) ;
2
+ const { Address } = require ( '@ton/core' ) ;
3
+
4
+ const MIN_TVL_USD = 100000 ;
5
+
6
+ const GRAPHQL_ENDPOINT = 'https://indexer.tonco.io/' ;
7
+ const POOLS_QUERY = `
8
+ query Pools {
9
+ pools {
10
+ address
11
+ apr
12
+ name
13
+ totalValueLockedUsd
14
+ jetton0 {
15
+ address
16
+ }
17
+ jetton1 {
18
+ address
19
+ }
20
+ }
21
+ }
22
+ ` ;
23
+
24
+ const getApy = async ( ) => {
25
+ console . log ( "Requesting pools list" )
26
+ const poolsList = ( await utils . getData ( GRAPHQL_ENDPOINT , {
27
+ query : POOLS_QUERY
28
+ } ) ) . data . pools ;
29
+
30
+ const poolsInfo = { } ;
31
+ for ( const pool of poolsList ) {
32
+ const address = pool . address ;
33
+
34
+ const tvl = pool . totalValueLockedUsd ;
35
+ if ( tvl < MIN_TVL_USD ) {
36
+ continue
37
+ }
38
+
39
+
40
+ poolsInfo [ pool . address ] = {
41
+ symbol : pool . name ,
42
+ tvl : tvl ,
43
+ apyBase : pool . apr ,
44
+ underlyingTokens : [ Address . parse ( pool . jetton0 . address ) . toString ( ) , Address . parse ( pool . jetton1 . address ) . toString ( ) ]
45
+ }
46
+ }
47
+ console . log ( `Inited ${ Object . keys ( poolsInfo ) . length } pools` ) ;
48
+
49
+
50
+ const pools = Object . keys ( poolsInfo )
51
+ . map ( ( pool_address ) => {
52
+ const pool = poolsInfo [ pool_address ] ;
53
+ return {
54
+ pool : `${ pool_address } -ton` . toLowerCase ( ) ,
55
+ chain : 'Ton' ,
56
+ project : 'tonco' ,
57
+ symbol : pool . symbol ,
58
+ tvlUsd : pool . tvl ,
59
+ apyBase : pool . apyBase ,
60
+ underlyingTokens : pool . underlyingTokens ,
61
+ url : `https://app.tonco.io/#/pool/${ pool_address } `
62
+ } ;
63
+ } ) ;
64
+ return pools ;
65
+ } ;
66
+
67
+ module . exports = {
68
+ timetravel : false ,
69
+ apy : getApy ,
70
+ url : 'https://tonco.io/' ,
71
+ } ;
You can’t perform that action at this time.
0 commit comments