Skip to content
This repository was archived by the owner on Nov 10, 2021. It is now read-only.

Commit 442b86e

Browse files
authored
Merge pull request #2 from veqtor/structural_refactor_fixes
Fix 2 structural refactor bugs
2 parents 98a3ecb + c61c164 commit 442b86e

File tree

4 files changed

+36
-15
lines changed

4 files changed

+36
-15
lines changed

README.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,3 +14,10 @@ Built with APIs from @Cryptonomic and @baking-bad.
1414
npm i
1515
npm start
1616
```
17+
18+
```
19+
POST /feed :counter
20+
POST /tz :tz
21+
POST /objkt :objkt_id
22+
POST /hdao :counter
23+
```

src/lib/config.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,9 @@ module.exports = {
1616
curationsPtr: 519,
1717
nftRoyaltiesMap: 522,
1818
daoLedger: 515,
19+
kolibriLedger: 380,
20+
hDaoSwap: "KT1V41fGzkdTJki4d11T1Rp9yPkCmDhB7jph",
21+
kolibriSwap: "KT1CiSKXR68qYSxnbzjwvfeMCRburaSDonT2",
1922
},
2023
serverPort: 3001,
2124
}

src/lib/conseil.js

Lines changed: 24 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ const hDAOFeed = async () => {
2020
conseiljs.ConseilOperator.EQ,
2121
[mainnet.curationsPtr]
2222
)
23-
hDAOQuery = conseiljs.ConseilQueryBuilder.setLimit(hDAOQuery, 30_000)
23+
hDAOQuery = conseiljs.ConseilQueryBuilder.setLimit(hDAOQuery, 300_000)
2424

2525
let hDAOResult = await conseiljs.TezosConseilClient.getTezosEntityData(
2626
{ url: conseilServer, apiKey: conseilApiKey, network: 'mainnet' },
@@ -70,7 +70,7 @@ const getCollectionForAddress = async (address) => {
7070
)
7171
collectionQuery = conseiljs.ConseilQueryBuilder.setLimit(
7272
collectionQuery,
73-
30_000
73+
300_000
7474
)
7575

7676
const collectionResult = await conseiljs.TezosConseilClient.getTezosEntityData(
@@ -553,7 +553,7 @@ const getObjektOwners = async (objekt_id) => {
553553

554554
const getObjektMintingsLastWeek = async () => {
555555
var d = new Date()
556-
d.setDate(d.getDate() - 5)
556+
d.setDate(d.getDate() - 7)
557557
let mintOperationQuery = conseiljs.ConseilQueryBuilder.blankQuery()
558558
mintOperationQuery = conseiljs.ConseilQueryBuilder.addFields(
559559
mintOperationQuery,
@@ -596,7 +596,7 @@ const getObjektMintingsLastWeek = async () => {
596596
)
597597
mintOperationQuery = conseiljs.ConseilQueryBuilder.setLimit(
598598
mintOperationQuery,
599-
900_000
599+
500_000
600600
) // TODO: this is hardwired and will not work for highly productive artists
601601

602602
const mintOperationResult = await conseiljs.TezosConseilClient.getTezosEntityData(
@@ -751,6 +751,7 @@ const getArtisticOutputForAddress = async (address) => {
751751
}
752752

753753
const getArtisticUniverse = async (max_time) => {
754+
max_time = ((typeof max_time !== 'undefined') && max_time != 0) ? max_time : (new Date()).getTime()
754755
var d = new Date()
755756
d.setDate(d.getDate() - 14)
756757
let mintOperationQuery = conseiljs.ConseilQueryBuilder.blankQuery()
@@ -823,7 +824,7 @@ const getArtisticUniverse = async (max_time) => {
823824
)
824825
royaltiesQuery = conseiljs.ConseilQueryBuilder.setLimit(
825826
royaltiesQuery,
826-
30_000
827+
5_000_000
827828
)
828829
const royaltiesResult = await conseiljs.TezosConseilClient.getTezosEntityData(
829830
{ url: conseilServer, apiKey: conseilApiKey, network: 'mainnet' },
@@ -850,7 +851,7 @@ const getArtisticUniverse = async (max_time) => {
850851
conseiljs.ConseilOperator.EQ,
851852
[mainnet.nftSwapMap]
852853
)
853-
swapsQuery = conseiljs.ConseilQueryBuilder.setLimit(swapsQuery, 30_000) // NOTE, limited to 30_000
854+
swapsQuery = conseiljs.ConseilQueryBuilder.setLimit(swapsQuery, 5_000_000) // NOTE, limited to 30_000
854855

855856
const swapsResult = await conseiljs.TezosConseilClient.getTezosEntityData(
856857
{ url: conseilServer, apiKey: conseilApiKey, network: 'mainnet' },
@@ -960,25 +961,34 @@ const getFeaturedArtisticUniverse = async (max_time) => {
960961
artisticUniverse = await getArtisticUniverse(max_time)
961962

962963
hdaoPerTez = await gethDAOPerTez()
964+
kolPerTez = await getKolibriPerTez()
965+
hdaoPerKol = hdaoPerTez / kolPerTez
966+
963967

964968
// Cost to be on feed per objekt last 7 days shouldn't be higher than:
965969
// 0.1tez
966970
// 1 hDAO
971+
// $1
967972
// But not lower than:
968973
// 0.01 hDAO
969974
//
970975
// We should probably add more thresholds like $, € and yen
971976
// It should be cheap but not too cheap and it shouldn't be
972977
// affected by tez or hDAO volatility
973978

974-
thresholdHdao = Math.min(1_000_000, Math.max(100_000 * hdaoPerTez, 10_000))
975-
976-
return artisticUniverse.filter(function (o) {
977-
return (
978-
(hdaoMap[o.minter] || 0) / Math.max(mintsPerCreator[o.minter] || 1, 1) >
979-
thresholdHdao
980-
)
981-
})
979+
let thresholdHdao = Math.floor(
980+
Math.max(10_000,
981+
Math.min(1_000_000,
982+
Math.max(
983+
100_000 * hdaoPerTez,
984+
100_000 * hdaoPerKol)
985+
)
986+
))
987+
//thresholdHdao = 0
988+
989+
return artisticUniverse.filter(o =>
990+
(hdaoMap[o.minter] || 100_000) / Math.max(mintsPerCreator[o.minter] || 1, 1) >
991+
thresholdHdao)
982992
}
983993

984994
const getRecommendedCurateDefault = async () => {

src/lib/router/index.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ router
2424
.route('/feed|/featured')
2525
.all(_processClientCache)
2626
.get((req, res, next) => {
27+
req.body.max_time = req.query.max_time
2728
req.body.counter = req.query.counter
2829

2930
return next()
@@ -39,7 +40,7 @@ router
3940
})
4041
.get((req, res, next) => {
4142
req.body.counter = req.query.counter
42-
43+
req.body.max_time = req.query.max_time
4344
return next()
4445
}, _asyncHandler(readRandomFeed))
4546
.post(_asyncHandler(readRandomFeed))

0 commit comments

Comments
 (0)