Skip to content

Commit

Permalink
add diffusion dex assetcollector and scraper.
Browse files Browse the repository at this point in the history
  • Loading branch information
jppade committed May 4, 2022
1 parent 7343fe5 commit bd18512
Show file tree
Hide file tree
Showing 14 changed files with 54 additions and 8 deletions.
2 changes: 1 addition & 1 deletion cmd/assetCollectionService/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/diadata-org/diadata/assetCollectionService
go 1.14

require (
github.com/diadata-org/diadata v1.4.1-rc-138
github.com/diadata-org/diadata v1.4.1-rc-157
github.com/sirupsen/logrus v1.8.1
)
2 changes: 2 additions & 0 deletions cmd/assetCollectionService/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,8 @@ func NewAssetScraper(exchange string, secret string) source.AssetSource {
return source.NewUniswapAssetSource(exchanges[dia.HermesExchange])
case dia.OmniDexExchange:
return source.NewUniswapAssetSource(exchanges[dia.OmniDexExchange])
case dia.DiffusionExchange:
return source.NewUniswapAssetSource(exchanges[dia.DiffusionExchange])
case "assetlists":
return source.NewJSONReader(exchange, secret)
default:
Expand Down
1 change: 1 addition & 0 deletions cmd/exchange-scrapers/collector/collector.go
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,7 @@ var (
swapTradesOnExchange = []string{
dia.CurveFIExchange,
dia.OmniDexExchange,
dia.DiffusionExchange,
}
)

Expand Down
2 changes: 1 addition & 1 deletion cmd/exchange-scrapers/collector/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/diadata-org/diadata/exchange-scrapers/collector
go 1.14

require (
github.com/diadata-org/diadata v1.4.1-rc-142
github.com/diadata-org/diadata v1.4.1-rc-157
github.com/segmentio/kafka-go v0.3.7
github.com/sirupsen/logrus v1.8.1
)
2 changes: 1 addition & 1 deletion cmd/services/blockchainservice/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module github.com/diadata-org/diadata/cmd/services/blockchainservice
go 1.14

require (
github.com/diadata-org/diadata v1.4.1-rc-51
github.com/diadata-org/diadata v1.4.1-rc-157
github.com/sirupsen/logrus v1.8.1
)
2 changes: 1 addition & 1 deletion cmd/services/tradesBlockService/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ module github.com/diadata-org/diadata/services/tradesBlockService
go 1.14

require (
github.com/diadata-org/diadata v1.4.1-rc-141
github.com/diadata-org/diadata v1.4.1-rc-157
github.com/segmentio/kafka-go v0.4.16
github.com/sirupsen/logrus v1.8.1
)
10 changes: 10 additions & 0 deletions config/Diffusion.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
{
"Coins": [
{
"Symbol": "SOLAR",
"ForeignName": "SOLAR-MOVR",
"Exchange": "Diffusion",
"Ignore": false
}
]
}
9 changes: 9 additions & 0 deletions config/blockchains/blockchains.json
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,15 @@
"VerificationMechanism": "pos",
"ChainID": "Ethereum1285"
},
{
"Name": "Evmos",
"GenesisDate": 1651151824,
"NativeToken": {
"Address": "0x0000000000000000000000000000000000000000"
},
"VerificationMechanism": "pos",
"ChainID": "Ethereum9001"
},
{
"Name": "Arbitrum",
"GenesisDate": 0,
Expand Down
15 changes: 11 additions & 4 deletions internal/pkg/tradesBlockService/tradesBlockService.go
Original file line number Diff line number Diff line change
Expand Up @@ -135,28 +135,35 @@ func (s *TradesBlockService) process(t dia.Trade) {
basetoken = dia.Asset{
Symbol: "USDC",
Address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
Blockchain: "Ethereum",
Blockchain: dia.ETHEREUM,
}
}
if basetoken.Blockchain == dia.METIS && (t.Source == dia.NetswapExchange || t.Source == dia.TethysExchange || t.Source == dia.HermesExchange) && basetoken.Address == "0xEA32A96608495e54156Ae48931A7c20f0dcc1a21" {
basetoken = dia.Asset{
Symbol: "USDC",
Address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
Blockchain: "Ethereum",
Blockchain: dia.ETHEREUM,
}
}
if basetoken.Blockchain == dia.FANTOM && (t.Source == dia.SpookyswapExchange || t.Source == dia.SpiritswapExchange || t.Source == dia.BeetsExchange) && basetoken.Address == "0x21be370D5312f44cB42ce377BC9b8a0cEF1A4C83" {
basetoken = dia.Asset{
Symbol: "FTM",
Address: "0x0000000000000000000000000000000000000000",
Blockchain: "Fantom",
Blockchain: dia.FANTOM,
}
}
if basetoken.Blockchain == dia.TELOS && (t.Source == dia.OmniDexExchange) && basetoken.Address == common.HexToAddress("0xd102ce6a4db07d247fcc28f366a623df0938ca9e").Hex() {
basetoken = dia.Asset{
Symbol: "TLOS",
Address: "0x0000000000000000000000000000000000000000",
Blockchain: "Telos",
Blockchain: dia.TELOS,
}
}
if basetoken.Blockchain == dia.EVMOS && t.Source == dia.DiffusionExchange && basetoken.Address == common.HexToAddress("0x51e44FfaD5C2B122C8b635671FCC8139dc636E82").Hex() {
basetoken = dia.Asset{
Symbol: "USDC",
Address: "0xA0b86991c6218b36c1d19D4a2e9Eb0cE3606eB48",
Blockchain: dia.ETHEREUM,
}
}

Expand Down
1 change: 1 addition & 0 deletions pkg/dia/Config.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ import (
)

const (
DiffusionExchange = "Diffusion"
OmniDexExchange = "OmniDex"
NetswapExchange = "Netswap"
TethysExchange = "Tethys"
Expand Down
1 change: 1 addition & 0 deletions pkg/dia/Messages.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ const (
FETCH = "Fetch"
FUSE = "Fuse"
TELOS = "Telos"
EVMOS = "Evmos"
FIAT = "Fiat"
)

Expand Down
4 changes: 4 additions & 0 deletions pkg/dia/scraper/exchange-scrapers/APIScraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,7 @@ func init() {
blockchains[dia.FETCH] = dia.BlockChain{Name: dia.FETCH, NativeToken: dia.Asset{Symbol: "FET"}, VerificationMechanism: dia.PROOF_OF_STAKE}
blockchains[dia.FUSE] = dia.BlockChain{Name: dia.FUSE, NativeToken: dia.Asset{Symbol: "FUSE"}, VerificationMechanism: dia.PROOF_OF_STAKE}
blockchains[dia.TELOS] = dia.BlockChain{Name: dia.TELOS, NativeToken: dia.Asset{Symbol: "TLOS"}, VerificationMechanism: dia.PROOF_OF_STAKE}
blockchains[dia.EVMOS] = dia.BlockChain{Name: dia.EVMOS, NativeToken: dia.Asset{Symbol: "EVMOS"}, VerificationMechanism: dia.PROOF_OF_STAKE}
blockchains[dia.FIAT] = dia.BlockChain{Name: dia.FIAT}

Exchanges = make(map[string]dia.Exchange)
Expand Down Expand Up @@ -105,6 +106,7 @@ func init() {
Exchanges[dia.TethysExchange] = dia.Exchange{Name: dia.TethysExchange, Centralized: false, BlockChain: blockchains[dia.METIS], Contract: common.HexToAddress("0x2CdFB20205701FF01689461610C9F321D1d00F80"), WatchdogDelay: watchdogDelayLong}
Exchanges[dia.HermesExchange] = dia.Exchange{Name: dia.HermesExchange, Centralized: false, BlockChain: blockchains[dia.METIS], Contract: common.HexToAddress("0x633a093C9e94f64500FC8fCBB48e90dd52F6668F"), WatchdogDelay: watchdogDelayLong}
Exchanges[dia.OmniDexExchange] = dia.Exchange{Name: dia.OmniDexExchange, Centralized: false, BlockChain: blockchains[dia.TELOS], Contract: common.HexToAddress("0x7a2A35706f5d1CeE2faa8A254dd6F6D7d7Becc25"), WatchdogDelay: watchdogDelayLong}
Exchanges[dia.DiffusionExchange] = dia.Exchange{Name: dia.DiffusionExchange, Centralized: false, BlockChain: blockchains[dia.EVMOS], Contract: common.HexToAddress("0x6aBdDa34Fb225be4610a2d153845e09429523Cd2"), WatchdogDelay: watchdogDelayLong}
Exchanges[dia.BitMexExchange] = dia.Exchange{Name: dia.BitMexExchange, Centralized: true, WatchdogDelay: watchdogDelay}

Exchanges[dia.SushiSwapExchangePolygon] = dia.Exchange{Name: dia.SushiSwapExchangePolygon, Centralized: false, BlockChain: blockchains[dia.POLYGON], Contract: common.HexToAddress("0xc35dadb65012ec5796536bd9864ed8773abc74c4"), WatchdogDelay: watchdogDelay}
Expand Down Expand Up @@ -269,6 +271,8 @@ func NewAPIScraper(exchange string, scrape bool, key string, secret string, relD
return NewUniswapScraper(Exchanges[dia.HermesExchange], scrape)
case dia.OmniDexExchange:
return NewUniswapScraper(Exchanges[dia.OmniDexExchange], scrape)
case dia.DiffusionExchange:
return NewUniswapScraper(Exchanges[dia.DiffusionExchange], scrape)
// case dia.FinageForex:
// return NewFinageForexScraper(Exchanges[dia.FinageForex], scrape, relDB, key, secret)

Expand Down
7 changes: 7 additions & 0 deletions pkg/dia/scraper/exchange-scrapers/UniswapV2Scraper.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,9 @@ const (
restDialTelos = ""
wsDialTelos = ""

restDialEvmos = ""
wsDialEvmos = ""

uniswapWaitMilliseconds = "25"
sushiswapWaitMilliseconds = "100"
pancakeswapWaitMilliseconds = "200"
Expand All @@ -76,6 +79,7 @@ const (
moonriverWaitMilliseconds = "500"
avalancheWaitMilliseconds = "200"
telosWaitMilliseconds = "400"
evmosWaitMilliseconds = "400"
)

type UniswapToken struct {
Expand Down Expand Up @@ -189,6 +193,9 @@ func NewUniswapScraper(exchange dia.Exchange, scrape bool) *UniswapScraper {
case dia.OmniDexExchange:
listenByAddress = false
s = makeUniswapScraper(exchange, listenByAddress, restDialTelos, wsDialTelos, telosWaitMilliseconds)
case dia.DiffusionExchange:
listenByAddress = false
s = makeUniswapScraper(exchange, listenByAddress, restDialEvmos, wsDialEvmos, evmosWaitMilliseconds)
}

if scrape {
Expand Down
4 changes: 4 additions & 0 deletions pkg/dia/service/assetservice/source/uniswap.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ const (
restDialMetis = ""
restDialAvalanche = ""
restDialTelos = ""
restDialEvmos = ""

uniswapWaitMilliseconds = "25"
sushiswapWaitMilliseconds = "100"
Expand All @@ -47,6 +48,7 @@ const (
moonriverWaitMilliseconds = "500"
avalancheWaitMilliseconds = "200"
telosWaitMilliseconds = "400"
evmosWaitMilliseconds = "400"
)

type UniswapAssetSource struct {
Expand Down Expand Up @@ -96,6 +98,8 @@ func NewUniswapAssetSource(exchange dia.Exchange) (uas *UniswapAssetSource) {
uas = makeUniswapAssetSource(exchange, restDialMetis, metisWaitMilliseconds)
case dia.OmniDexExchange:
uas = makeUniswapAssetSource(exchange, restDialTelos, telosWaitMilliseconds)
case dia.DiffusionExchange:
uas = makeUniswapAssetSource(exchange, restDialEvmos, evmosWaitMilliseconds)
}

exchangeFactoryContractAddress = exchange.Contract.Hex()
Expand Down

0 comments on commit bd18512

Please sign in to comment.