Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create liquidity events webhook #1

Closed
wants to merge 29 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
29 commits
Select commit Hold shift + click to select a range
489f9b1
added controller,service and module for events-webhook route
GuticaStefan Aug 21, 2024
e154c97
Work in progress
GuticaStefan Aug 21, 2024
e6c35fa
Work in progress
GuticaStefan Aug 22, 2024
1a82482
Computed liquidity and data formated for addLiquidity/removeLiquidity…
GuticaStefan Aug 22, 2024
de8a197
Add events parsing and liquidity computation
MogageNicolae Aug 23, 2024
fb9c12d
Add prices fetch
MogageNicolae Aug 23, 2024
1bf2bcf
Start even fetching script
MogageNicolae Aug 23, 2024
6bbd85c
Finish script
MogageNicolae Aug 26, 2024
ead0706
Added data service to fetch token price by day and cache it
GuticaStefan Aug 26, 2024
8f3c391
Improvements
GuticaStefan Aug 26, 2024
9236dac
Fetch events script update
GuticaStefan Aug 26, 2024
2545b15
Fix minor bugs
MogageNicolae Aug 27, 2024
a5f058b
Working on dune sender service
GuticaStefan Aug 27, 2024
8833d74
created class manager for and automated creating tables and sending d…
GuticaStefan Aug 28, 2024
5e49432
Add redis cache for records
MogageNicolae Aug 29, 2024
cf2a141
Change records sending to dune logic
MogageNicolae Aug 29, 2024
8089f53
Add OriginLogger
MogageNicolae Aug 29, 2024
196e8d2
Bug fixes
GuticaStefan Aug 30, 2024
905cd3c
WIP
GuticaStefan Aug 30, 2024
c602f54
.
GuticaStefan Aug 30, 2024
7fc5778
WIP
GuticaStefan Aug 30, 2024
3221b91
Parse events fields from hex to base64
GuticaStefan Aug 30, 2024
00066ae
Add default price for tokens if not available on data-api
GuticaStefan Aug 30, 2024
17bb653
Project clean
GuticaStefan Aug 30, 2024
acc98dc
Bug fix
GuticaStefan Aug 30, 2024
f0fb545
Create Dune Mock service WIP
GuticaStefan Aug 30, 2024
c89a083
Add dune-mock app
MogageNicolae Sep 1, 2024
0121394
Fix missing CSV parser for dune-mock
MogageNicolae Sep 1, 2024
9117e54
Add send data logic to local from dune
MogageNicolae Sep 1, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .env.devnet
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
NETWORK=devnet
API_URL=https://devnet-api.multiversx.com
DATA_API_CEX_URL=https://data-api.multiversx.com/v1/quotes/cex
DATA_API_XEXCHANGE_URL=https://data-api.multiversx.com/v1/quotes/xexchange
DUNE_MOCK_URL=http://localhost:3001/dune-mock
DUNE_NAMESPACE=
DUNE_API_KEY=
5 changes: 5 additions & 0 deletions .env.mainnet
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
NETWORK=mainnet
API_URL=https://api.multiversx.com
DATA_API_CEX_URL=https://data-api.multiversx.com/v1/quotes/cex
DATA_API_XEXCHANGE_URL=https://data-api.multiversx.com/v1/quotes/xexchange
DUNE_MOCK_API_URL=http://localhost:3001/dune-mock
DUNE_NAMESPACE=nicolaemogage
DUNE_API_KEY=
5 changes: 5 additions & 0 deletions .env.testnet
Original file line number Diff line number Diff line change
@@ -1,2 +1,7 @@
NETWORK=testnet
API_URL=https://testnet-api.multiversx.com
DATA_API_CEX_URL=https://data-api.multiversx.com/v1/quotes/cex
DATA_API_XEXCHANGE_URL=https://data-api.multiversx.com/v1/quotes/xexchange
DUNE_MOCK_URL=http://localhost:3001/dune-mock
DUNE_NAMESPACE=
DUNE_API_KEY=
22 changes: 3 additions & 19 deletions .eslintrc.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,16 +28,8 @@ module.exports = {
pattern: 'apps/api',
},
{
type: 'apps/cache-warmer',
pattern: 'apps/cache-warmer',
},
{
type: 'apps/queue-worker',
pattern: 'apps/queue-worker',
},
{
type: 'apps/transactions-processor',
pattern: 'apps/transactions-processor',
type: 'apps/dune-mock',
pattern: 'apps/dune-mock',
},
{
type: 'libs/common',
Expand Down Expand Up @@ -82,15 +74,7 @@ module.exports = {
allow: ['libs/common', 'libs/entities', 'libs/services']
},
{
from: 'apps/cache-warmer',
allow: ['libs/common', 'libs/entities', 'libs/services']
},
{
from: 'apps/queue-worker',
allow: ['libs/common', 'libs/entities', 'libs/services']
},
{
from: 'apps/transactions-processor',
from: 'apps/dune-mock',
allow: ['libs/common', 'libs/entities', 'libs/services']
},
{
Expand Down
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -47,3 +47,6 @@ lerna-debug.log*
# Environment
.env
.env.custom
/scripts/insertCsv.ts
scripts/
out_csv/
7 changes: 0 additions & 7 deletions .multiversx/config/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -3,13 +3,6 @@ apps:
port: 3000
privatePort: 4000
useCachingInterceptor: true
cacheWarmer:
port: 4001
queueWorker:
port: 4002
transactionsProcessor:
port: 4003
maxLookBehind: 100
libs:
common:
network: ${NETWORK}
Expand Down
22 changes: 0 additions & 22 deletions TODO

This file was deleted.

28 changes: 28 additions & 0 deletions apps/api/src/config/app-config.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,32 @@ import { Injectable } from "@nestjs/common";
@Injectable()
export class AppConfigService {
readonly config = configuration().apps.api;

getDuneNamespace(): string {
return configuration().libs.common.features.dune.namespace ?? "";
}

getDuneApiKey(): string {
return configuration().libs.common.features.dune.apiKey ?? "";
}

getApiUrl(): string {
return configuration().libs.common.urls.api ?? "";
}

getDataApiCexUrl(): string {
return configuration().libs.common.urls.dataApiCex ?? "";
}

getDataApiXexchangeUrl(): string {
return configuration().libs.common.urls.dataApiXexchange ?? "";
}

getDuneMockApiUrl(): string {
return configuration().libs.common.urls.duneMockApi ?? "";
}

isDuneSendingEnabled(): boolean {
return configuration().libs.common.features.dune.enabled ?? false;
}
}
16 changes: 0 additions & 16 deletions apps/api/src/endpoints/auth/auth.controller.ts

This file was deleted.

13 changes: 0 additions & 13 deletions apps/api/src/endpoints/auth/auth.module.ts

This file was deleted.

10 changes: 2 additions & 8 deletions apps/api/src/endpoints/endpoints.module.ts
Original file line number Diff line number Diff line change
@@ -1,16 +1,10 @@
import { Module } from "@nestjs/common";
import { DynamicModuleUtils } from "@libs/common";
import { AuthModule } from "./auth/auth.module";
import { TokenModule } from "./token/token.module";
import { UserModule } from "./user/user.module";
import { ExampleModule } from "./example/example.module";
import { EventsModule } from "./events/events.module";

@Module({
imports: [
AuthModule,
TokenModule,
UserModule,
ExampleModule,
EventsModule,
],
providers: [
DynamicModuleUtils.getNestJsApiConfigService(),
Expand Down
48 changes: 48 additions & 0 deletions apps/api/src/endpoints/events/entities/event.log.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,48 @@
import { ApiProperty } from "@nestjs/swagger";

export class EventLog {
constructor(init?: Partial<EventLog>) {
Object.assign(this, init);
}
@ApiProperty()
eventId: string = '';

@ApiProperty()
txHash: string = '';

@ApiProperty()
shardId: number = 0;

@ApiProperty()
timestamp: number = 0;

@ApiProperty()
address: string = '';

@ApiProperty()
identifier: string = '';

@ApiProperty()
topics: string[] = [];

@ApiProperty()
data: string = '';

@ApiProperty()
additionalData: string[] = [];

@ApiProperty()
txOrder: number = 0;

@ApiProperty()
eventOrder: number = 0;
}

export class EventsLog {
constructor(init?: Partial<EventsLog>) {
Object.assign(this, init);
}

@ApiProperty({ type: EventLog, isArray: true })
events: EventLog[] = [];
}
1 change: 1 addition & 0 deletions apps/api/src/endpoints/events/entities/index.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
export * from "./event.log";
19 changes: 19 additions & 0 deletions apps/api/src/endpoints/events/events.controller.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Body, Controller, Post } from "@nestjs/common";
import { ApiTags } from "@nestjs/swagger";
import { EventLog } from "./entities/event.log";
import { EventsService } from "@libs/services/events";

@Controller()
@ApiTags('events')
export class EventsController {
constructor(
private readonly eventsService: EventsService,
) { }

@Post("/events-webhook")
async eventsWebhook(
@Body() body: EventLog[],
): Promise<void> {
await this.eventsService.eventsWebhook(body);
}
}
13 changes: 13 additions & 0 deletions apps/api/src/endpoints/events/events.module.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
import { Module } from "@nestjs/common";
import { ServicesModule } from "@libs/services/services.module";
import { EventsController } from "./events.controller";

@Module({
imports: [
ServicesModule,
],
controllers: [
EventsController,
],
})
export class EventsModule { }
16 changes: 0 additions & 16 deletions apps/api/src/endpoints/example/entities/event.log.ts

This file was deleted.

58 changes: 0 additions & 58 deletions apps/api/src/endpoints/example/example.controller.ts

This file was deleted.

13 changes: 0 additions & 13 deletions apps/api/src/endpoints/example/example.module.ts

This file was deleted.

20 changes: 0 additions & 20 deletions apps/api/src/endpoints/token/token.controller.ts

This file was deleted.

Loading
Loading