diff --git a/drivers/asteroidprotocol.js b/drivers/asteroidprotocol.js new file mode 100644 index 00000000..933fb1a0 --- /dev/null +++ b/drivers/asteroidprotocol.js @@ -0,0 +1,47 @@ +const Driver = require('../models/driver'); +const request = require('../lib/request'); +const Ticker = require('../models/ticker'); +const { parseToFloat } = require('../lib/utils'); + +/** + * @memberof Driver + * @augments Driver + */ +class Asteroidprotocol extends Driver { + /** + * @augments Driver.fetchTickers + * @returns {Promise.Array} Returns a promise of an array with tickers. + */ + async fetchTickers() { + const result = await request({ + method: 'POST', + url: 'https://api.asteroidprotocol.io/v1/graphql', + json: { + query: ` + query { + token(offset: 0, limit: 100, order_by: [{ volume_24_base: desc }], where: { volume_24_base: { _gt: 1000000 }}) { + transaction { + hash + } + name + ticker + last_price_base + volume_24_base + } + } + `, + }, + }); + + return result.data.token.map((ticker) => new Ticker(({ + base: ticker.ticker, + baseName: ticker.name, + baseReference: ticker.transaction.hash, + quote: 'ATOM', + quoteVolume: parseToFloat(ticker.volume_24_base) / 1000000, + close: parseToFloat(ticker.last_price_base) / 1000000, + }))); + } +} + +module.exports = Asteroidprotocol; diff --git a/drivers/index.js b/drivers/index.js index 96bae00d..04bbcc1a 100644 --- a/drivers/index.js +++ b/drivers/index.js @@ -3,6 +3,7 @@ exports.Aex = require('./aex'); exports.Altcointrader = require('./altcointrader'); exports.Apeswappolygon = require('./apeswappolygon'); exports.Ascendex = require('./ascendex'); +exports.Asteroidprotocol = require('./asteroidprotocol'); exports.Balancer = require('./balancer'); exports.Balancerpolygon = require('./balancerpolygon'); exports.Bamboo = require('./bamboo'); diff --git a/tests/fixtures/asteroidprotocol.json b/tests/fixtures/asteroidprotocol.json new file mode 100644 index 00000000..67a8baff --- /dev/null +++ b/tests/fixtures/asteroidprotocol.json @@ -0,0 +1,440 @@ +[ + { + "scope": "https://api.asteroidprotocol.io:443", + "method": "POST", + "path": "/v1/graphql", + "body": { + "query": "\n query {\n token(offset: 0, limit: 100, order_by: [{ volume_24_base: desc }], where: { volume_24_base: { _gt: 1000000 }}) {\n transaction {\n hash\n }\n name\n ticker\n last_price_base\n volume_24_base\n }\n }\n " + }, + "status": 200, + "response": { + "data": { + "token": [ + { + "transaction": { + "hash": "FB87E737DEEA418E7E4236DBD7B751679009454BDC2D1A48B0A202AB060B9126" + }, + "name": "Asteroids", + "ticker": "ROIDS", + "last_price_base": 5785, + "volume_24_base": 1640742530 + }, + { + "transaction": { + "hash": "FA127E8A1ADD425EA8E164F8BD4113F5CBEFA5E71CCF755B52ADE556341B657F" + }, + "name": "Jake Won", + "ticker": "JKWON", + "last_price_base": 100000000, + "volume_24_base": 100000000 + }, + { + "transaction": { + "hash": "AD2D2A1442CCEE7F8DF56E7E084FB6648D949791E16ECD09D29DC9988E2C5218" + }, + "name": "Panda", + "ticker": "PND", + "last_price_base": 114, + "volume_24_base": 87526531 + }, + { + "transaction": { + "hash": "B1A851F4874F6475FBB53BFF04885E71A27AF7FC85AD0F7C611F8C33D6950D30" + }, + "name": "AstroDickButt Token", + "ticker": "ADB", + "last_price_base": 399956, + "volume_24_base": 75000000 + }, + { + "transaction": { + "hash": "D7D6E6CB257737774EBBD5C7BDD472FEDD36B245C4C327AC9AED3AC1B6A399B7" + }, + "name": "BlackGlovesMatter", + "ticker": "BGM", + "last_price_base": 3425000, + "volume_24_base": 47100000 + }, + { + "transaction": { + "hash": "69579C8774A61914B2C55F1B5A0F4DFE9E0DDC65296D37F6FC7EE332359702E2" + }, + "name": "reece", + "ticker": "REECE", + "last_price_base": 0, + "volume_24_base": 25000000 + }, + { + "transaction": { + "hash": "0D629D0B5306CE4EA7BF6BE0FCE2F06C37B67A413FB2F2EA83CDB8A2B769DF06" + }, + "name": "Atomic Swap Protocol", + "ticker": "ASP", + "last_price_base": 1000000, + "volume_24_base": 21100000 + }, + { + "transaction": { + "hash": "71536591E0EAC01C5E06CA37BDF45986110D6098EE2681E379B41A143BF4835D" + }, + "name": "Good Game", + "ticker": "GGM", + "last_price_base": 0, + "volume_24_base": 20970000 + }, + { + "transaction": { + "hash": "8C54611BC9A3736B946625B93837FDCBD334933B86FCFBE9686B50FAD4C06EAA" + }, + "name": "NBACON", + "ticker": "NBACON", + "last_price_base": 100000, + "volume_24_base": 20000000 + }, + { + "transaction": { + "hash": "DF9A8E96D26C2E9E22419E1A9F79E72F0F9067D655030BFB5A97BEED9C820972" + }, + "name": "Bubbly", + "ticker": "BBLY", + "last_price_base": 10, + "volume_24_base": 18600000 + }, + { + "transaction": { + "hash": "ADBF244740B5BE4321F8E0A984F01249EA574426894C158A83DE810CDD1E8A21" + }, + "name": "Veggs Token", + "ticker": "VEGGS", + "last_price_base": 16, + "volume_24_base": 13642240 + }, + { + "transaction": { + "hash": "8E5F2DA52B3CCAA65EDB43BEDDAC831082A30F2A127EC81500D05044577C35C6" + }, + "name": "StakecitoWifHat", + "ticker": "STAKE", + "last_price_base": 100, + "volume_24_base": 11819841 + }, + { + "transaction": { + "hash": "A4E42E94ABF8218B1850D04F66B73281AB0B3C8978C5501A1E2A6C9C98BA0047" + }, + "name": "Memecoin", + "ticker": "MEMECOIN", + "last_price_base": 0, + "volume_24_base": 11000006 + }, + { + "transaction": { + "hash": "271ED1E29493D15C76AEB4E231FEF61B82E6ACE7703451F2CC1688E119BD459E" + }, + "name": "IBC Gangsters", + "ticker": "IBCG", + "last_price_base": 250, + "volume_24_base": 10800000 + }, + { + "transaction": { + "hash": "3CDD5B406347300F32F8863F9581610567FEC45C233233C643A3461A4FDE523B" + }, + "name": "Goon Has A Hat", + "ticker": "LFGOON", + "last_price_base": 14, + "volume_24_base": 9720528 + }, + { + "transaction": { + "hash": "A221D3553EB045AC1F9262C10D0505BF3256185A6976EF3D02D95B8635CDE5DC" + }, + "name": "Lucy Dog", + "ticker": "LUCY99", + "last_price_base": 1500000, + "volume_24_base": 7680000 + }, + { + "transaction": { + "hash": "9573EAB9817304F706A71234502AA9A5A0C1693F57927FB776139D88389A8794" + }, + "name": "Cosmox", + "ticker": "CSMX", + "last_price_base": 30, + "volume_24_base": 6903000 + }, + { + "transaction": { + "hash": "E62C8D7E7F2B4101C466DD4D544F91AD7058E79DAEA9F54779E576C1B027E6D2" + }, + "name": "ASTRO BOY", + "ticker": "ASTROBOY", + "last_price_base": 284, + "volume_24_base": 5260000 + }, + { + "transaction": { + "hash": "D863EDCF0C9A3A401F3552441DCC324978228D1C12A1565FC0CE7CD7E489EC7E" + }, + "name": "CryptoWizard", + "ticker": "WIZARD", + "last_price_base": 1000000, + "volume_24_base": 5000000 + }, + { + "transaction": { + "hash": "ABF9C9BDD0CBF39FA2BD9E2C76CA6ABA15A50C15A52EB3B025FBC0DEEA8D6CD0" + }, + "name": "BONK", + "ticker": "BONK", + "last_price_base": 2, + "volume_24_base": 3800000 + }, + { + "transaction": { + "hash": "ED131D69656BF341016B90445E07C7D10DE459CD0B7EB16D898E72E119D9D1F7" + }, + "name": "FritesDAO", + "ticker": "FRITES", + "last_price_base": 1772636, + "volume_24_base": 3750000 + }, + { + "transaction": { + "hash": "C822CB1C921FAB1BD59D4D8CB49FD7A6A1824484580724C5452A1A464834D203" + }, + "name": "Asteroid Protocol", + "ticker": "ASPR", + "last_price_base": 11, + "volume_24_base": 3591000 + }, + { + "transaction": { + "hash": "16F0516185E772ADF0140CA12FCEE2CD56999D1ED49DE7B0B73DD20B1A0F800A" + }, + "name": "cosmos", + "ticker": "ATOM", + "last_price_base": 370, + "volume_24_base": 3500000 + }, + { + "transaction": { + "hash": "32A1B8A32847AE80E95EFDEDD2D1B1648E6F263F64A39FEB06606D8078CD5B7D" + }, + "name": "SunnyProp16JunoWhaleInu", + "ticker": "COSMOS", + "last_price_base": 1200000, + "volume_24_base": 3400000 + }, + { + "transaction": { + "hash": "D1059E907BFBDDC554893415D133B02C0CD93B0FA67BD5DB47E1E5351D692C96" + }, + "name": "iCosmosDAO", + "ticker": "ICOSMOSDAO", + "last_price_base": 2000, + "volume_24_base": 3200000 + }, + { + "transaction": { + "hash": "C992F9849A980D4D769D7C0F89A2EDCBE5F68B0E48E6D0E475C1CE515BEFFD8E" + }, + "name": "NOTIONAL", + "ticker": "KITTEH", + "last_price_base": 10000, + "volume_24_base": 2750000 + }, + { + "transaction": { + "hash": "A9CFA7301A848D75F21F9E38BE59B497034E03BCBE8AC36A557C9292E567692A" + }, + "name": "SIR", + "ticker": "SIR", + "last_price_base": 397, + "volume_24_base": 2700000 + }, + { + "transaction": { + "hash": "87DABF19ABA616B656AF09C0297C2BC23EA5146394BF59743293D7307F847E78" + }, + "name": "MEETING", + "ticker": "MEETING", + "last_price_base": 81833, + "volume_24_base": 2688000 + }, + { + "transaction": { + "hash": "28337D8E4ED25CAEA3E04946CC49BC9F09AC31D07EC9285B7B7EF12A1CF6A0A2" + }, + "name": "Elder Futhark", + "ticker": "RUNES", + "last_price_base": 303, + "volume_24_base": 2662052 + }, + { + "transaction": { + "hash": "F681C0709FE954AC397831A9ABF39D33E6233FDF07FA0CD94F52F558DE6EFF43" + }, + "name": "CURSED CAT", + "ticker": "CURSE", + "last_price_base": 2, + "volume_24_base": 2640000 + }, + { + "transaction": { + "hash": "111758828CC37123CB49247151DAE5C97014CBBD8C75950667F1D96BA077EB59" + }, + "name": "PEPE", + "ticker": "PEPE", + "last_price_base": 66742, + "volume_24_base": 2472800 + }, + { + "transaction": { + "hash": "87B4EAD0CCB583ADFA7718DC8E957266DC90AD9B9935B126E7BBF54EAB65AA1E" + }, + "name": "UpsideDownTiger", + "ticker": "USDT", + "last_price_base": 2, + "volume_24_base": 2000000 + }, + { + "transaction": { + "hash": "6B68C55CFF63540DBD37B2AF1EBA3373373DF95654B31A654219CA47812D7F41" + }, + "name": "Woven Aegis", + "ticker": "WOV", + "last_price_base": 0, + "volume_24_base": 2000000 + }, + { + "transaction": { + "hash": "F8AFD90CECCB30E86E6603C01BFE4C4DB2F61E54C2B862E12A15A6EDC47249C2" + }, + "name": "AstroDoge", + "ticker": "ASTRODOGE", + "last_price_base": 1000, + "volume_24_base": 2000000 + }, + { + "transaction": { + "hash": "642933493B28D2023DCB052F6D5B2C1FC6CF24EA90407EDFB1E6432EE0EB47C6" + }, + "name": "Celestia", + "ticker": "TIA", + "last_price_base": 500, + "volume_24_base": 2000000 + }, + { + "transaction": { + "hash": "43F898F88EB001DFA98151A5BB2C29E4527E0A72D8DCB8B4F03B449102F165BB" + }, + "name": "Cookie", + "ticker": "COOKIE", + "last_price_base": 2, + "volume_24_base": 2000000 + }, + { + "transaction": { + "hash": "560EC571F78B65B27A2837934B71990A480820663A5406C6600C88A8DE069E90" + }, + "name": "Glue", + "ticker": "GLUE", + "last_price_base": 1420690, + "volume_24_base": 1420690 + }, + { + "transaction": { + "hash": "965962CCFFA2ADAFB4A3FA3B34BC94722CC589A0AD0ECF6F31B00DC509970256" + }, + "name": "Bad Coin", + "ticker": "BAD", + "last_price_base": 44000, + "volume_24_base": 1416000 + }, + { + "transaction": { + "hash": "87EE61536538F50447AC84D095990E8FC1232CD7DA145D279CCBE6B44A2CEB13" + }, + "name": "Cosmowave", + "ticker": "COSMOWAVE", + "last_price_base": 100, + "volume_24_base": 1400000 + }, + { + "transaction": { + "hash": "4109251BEF0740BA662187393EFCBDE3563C28DFB3C56E90C826B0994A1EB979" + }, + "name": "DogWifHat", + "ticker": "WIF", + "last_price_base": 300, + "volume_24_base": 1320000 + }, + { + "transaction": { + "hash": "506285D72F7EBFDA8F31E5B834E11CCCFC41C1FB6D1DC4081ECA449266F64DA7" + }, + "name": "ForTheCulture", + "ticker": "FTC", + "last_price_base": 0, + "volume_24_base": 1300000 + }, + { + "transaction": { + "hash": "AB24504BBF98DCD2E9977708869D46141128491C2711D0EE08DEADBAF3A41F38" + }, + "name": "Have fun staying poor", + "ticker": "STAYPOOR", + "last_price_base": 133700000, + "volume_24_base": 1247070 + }, + { + "transaction": { + "hash": "BCCD0FABA8FB0CFD60FCEC32A5465E20CF6B2D2E917A471149A195A922FC2932" + }, + "name": "SNOWY", + "ticker": "SNOWY", + "last_price_base": 1000000, + "volume_24_base": 1100000 + }, + { + "transaction": { + "hash": "45C51646D221E9F6AAFCD5EE2AE5770E740EB908AE15DB2445442CD937156998" + }, + "name": "Atom to da moon", + "ticker": "ABOY", + "last_price_base": 1808, + "volume_24_base": 1026000 + } + ] + } + }, + "rawHeaders": [ + "Date", + "Mon, 05 Feb 2024 04:00:05 GMT", + "Content-Type", + "application/json; charset=utf-8", + "Transfer-Encoding", + "chunked", + "Connection", + "keep-alive", + "x-request-id", + "7fc115a7-dce7-4362-a080-b9b20f72789a", + "x-do-app-origin", + "1be01f58-6550-40e1-acb7-c993049e1a1e", + "cache-control", + "private", + "x-do-orig-status", + "200", + "CF-Cache-Status", + "DYNAMIC", + "Report-To", + "{\"endpoints\":[{\"url\":\"https:\\/\\/a.nel.cloudflare.com\\/report\\/v3?s=7N3Mo8ZgxpA4RSeMH%2Bj7fumNMQ%2Ftk4l7f92Yt%2Bs65GzXiMkD73pLGzYnVuXjO2aownSix4ORrni%2BHiPL1GZl9Kjxs0Dfvusiy%2FOQQolBy7Z21Hbv0GPJsGPgz56o5Mgb7Rrip3XEqYml\"}],\"group\":\"cf-nel\",\"max_age\":604800}", + "NEL", + "{\"success_fraction\":0,\"report_to\":\"cf-nel\",\"max_age\":604800}", + "Server", + "cloudflare" + ], + "responseIsBinary": false + } +] \ No newline at end of file