@@ -9,7 +9,7 @@ conseiljs.registerFetch(fetch)
99const conseilServer = 'https://conseil-prod.cryptonomic-infra.tech'
1010const conseilApiKey = 'aa73fa8a-8626-4f43-a605-ff63130f37b1' // signup at nautilus.cloud
1111const tezosNode = ''
12-
12+ const quipuSwapContract = "KT1V41fGzkdTJki4d11T1Rp9yPkCmDhB7jph"
1313const mainnet = require ( './config' ) . networkConfig
1414
1515
@@ -101,6 +101,37 @@ const gethDaoBalanceForAddress = async (address) => {
101101 return balance
102102}
103103
104+
105+ const getTezBalanceForAddress = async ( address ) => {
106+ let accountQuery = conseiljs . ConseilQueryBuilder . blankQuery ( ) ;
107+ accountQuery = conseiljs . ConseilQueryBuilder . addFields ( accountQuery , 'balance' ) ;
108+ accountQuery = conseiljs . ConseilQueryBuilder . addPredicate ( accountQuery , 'account_id' , conseiljs . ConseilOperator . EQ , [ address ] , false ) ;
109+ accountQuery = conseiljs . ConseilQueryBuilder . setLimit ( accountQuery , 1 ) ;
110+
111+ try {
112+ const balanceResult = await conseiljs . TezosConseilClient . getTezosEntityData ( { url : conseilServer , apiKey : conseilApiKey , network : 'mainnet' } , 'mainnet' , 'accounts' , accountQuery ) ;
113+ balance = balanceResult [ 0 ] [ 'balance' ] // TODO: consider bigNumber here, for the moment there is no reason for it
114+ } catch ( error ) {
115+ console . log ( `getTezBalanceForAddress failed for ${ JSON . stringify ( accountQuery ) } with ${ error } ` )
116+ }
117+
118+ return balance
119+ }
120+
121+
122+ const gethDAOPerTez = async ( ) => {
123+ const tezBalance = await ( getTezBalanceForAddress ( quipuSwapContract ) )
124+ const hdaoBalance = await ( gethDaoBalanceForAddress ( quipuSwapContract ) )
125+ return hdaoBalance / tezBalance
126+ }
127+
128+ const getTezPerhDAO = async ( ) => {
129+ hDAOpTez = await gethDAOPerTez ( )
130+ return 1 / hDAOpTez
131+ }
132+
133+
134+
104135const gethDaoBalances = async ( ) => {
105136 let hDaoBalanceQuery = conseiljs . ConseilQueryBuilder . blankQuery ( ) ;
106137 hDaoBalanceQuery = conseiljs . ConseilQueryBuilder . addFields ( hDaoBalanceQuery , 'key' , 'value' ) ;
@@ -309,8 +340,22 @@ const getFeaturedArtisticUniverse = async(max_time) => {
309340
310341 artisticUniverse = await getArtisticUniverse ( max_time )
311342
343+ hdaoPerTez = await gethDAOPerTez ( )
344+
345+ // Cost to be on feed per objekt last 7 days shouldn't be higher than:
346+ // 0.1tez
347+ // 1 hDAO
348+ // But not lower than:
349+ // 0.01 hDAO
350+ //
351+ // We should probably add more thresholds like $, € and yen
352+ // It should be cheap but not too cheap and it shouldn't be
353+ // affected by tez or hDAO volatility
354+
355+ thresholdHdao = Math . min ( 1_000_000 , Math . max ( 100_000 * hdaoPerTez , 10_000 ) )
356+
312357 return artisticUniverse . filter ( function ( o ) {
313- return ( ( hdaoMap [ o . minter ] || 0 ) / Math . max ( mintsPerCreator [ o . minter ] || 1 , 1 ) ) > 1000000
358+ return ( ( hdaoMap [ o . minter ] || 0 ) / Math . max ( mintsPerCreator [ o . minter ] || 1 , 1 ) ) > thresholdHdao
314359 } )
315360}
316361
0 commit comments