Skip to content

Commit

Permalink
chore: add rune market stat
Browse files Browse the repository at this point in the history
  • Loading branch information
mison201 committed Apr 25, 2024
1 parent 5d8a080 commit 2fc10cb
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 1 deletion.
11 changes: 10 additions & 1 deletion service/src/modules/markets/markets.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import {
} from 'src/common/interfaces/rune.interface';
import { BuyerOrderDto } from './dto/buyer-order.dto';
import { ParseRuneIdPipe } from 'src/common/pipes';
import { RuneStat } from '../database/entities/indexer';

@Controller('markets')
@UseInterceptors(CoreTransformInterceptor)
Expand All @@ -47,10 +48,18 @@ export class MarketsController {

// Get market stats
@Get('stats')
async getStats() {
async getStats(): Promise<any> {
return this.marketsService.getStats();
}

// Get market stats by rune id
@Get('stats/:id')
async getStatsById(
@Param('id', ParseRuneIdPipe) id: string,
): Promise<RuneStat> {
return this.marketsService.getStatsById(id);
}

// Generate unsigned listing PSBT
@Post('orders/sell/unsigned-psbt')
@UseGuards(AuthGuard)
Expand Down
8 changes: 8 additions & 0 deletions service/src/modules/markets/markets.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,14 @@ export class MarketsService implements OnModuleInit {
};
}

async getStatsById(id: string): Promise<RuneStat> {
const runeStat = await this.runeStatRepository.findOne({
where: { rune_id: id },
});

return runeStat;
}

async createSellOrder(body: IRuneListingState, user: User): Promise<Order> {
const { seller } = body;
if (!seller) {
Expand Down

0 comments on commit 2fc10cb

Please sign in to comment.