Skip to content

Commit

Permalink
Merge pull request #53 from zkLinkProtocol/feat-lppufpoint
Browse files Browse the repository at this point in the history
fixed display lp puffer points.
  • Loading branch information
zkcarter authored May 17, 2024
2 parents af07620 + e48f3cf commit fae976c
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/entities/blockAddressPointOfLp.entity.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ import { bigIntNumberTransformer } from "../transformers/bigIntNumber.transforme
import { hexTransformer } from "../transformers/hex.transformer";

@Entity({ name: "blockAddressPointOfLp" })
export class BlockAddressPointOfLp extends BaseEntity {
export class BlockAddressPointOfLp {
@PrimaryColumn({ type: "bigint", transformer: bigIntNumberTransformer })
public readonly blockNumber: number;

Expand Down
8 changes: 5 additions & 3 deletions src/nova/nova.controller.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,11 +186,13 @@ export class NovaController {
return NOT_FOUND_EXCEPTION;
}
// Get real puffer points in layerbank.
let points: number;
let points: number = 0;
try {
const tokenData =
await this.pufferPointsSercie.getPointsData(tokenAddress);
points = tokenData.items[0]?.realPoints ?? 0;
this.pufferPointsSercie.getPoolPufferPoints(tokenAddress);
if (tokenData) {
points = tokenData.realPoints ?? 0;
}
} catch (err) {
this.logger.error(
"Get puffer real points in layerbank failed",
Expand Down
1 change: 0 additions & 1 deletion src/nova/nova.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,6 @@ export class NovaService {
addresses,
project,
);

if (Array.isArray(points) && totalPoints) {
return this.getPointData(points, totalPoints);
} else {
Expand Down
8 changes: 8 additions & 0 deletions src/puffer/puffPoints.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,14 @@ export class PuffPointsService extends Worker {
return await this.projectGraphService.getPoints(this.projectName, address);
}

public getPoolPufferPoints(poolAddress: string): PufferPointItem {
const _poolAddress = poolAddress.toLowerCase();
const result = this.localPoints.filter(
(item) => item.address === _poolAddress,
);
return result[0];
}

// return real totalPoints
public async getRealPointsData(): Promise<number> {
const realData = await fetch(
Expand Down

0 comments on commit fae976c

Please sign in to comment.