Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion bridge/bridge.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { StablecoinEnum } from './bridge.enum';

@Injectable()
export class BridgeService {
async getBridgedStables(stablecoin: StablecoinEnum, timestamp: Date): Promise<StablecoinBridgeQuery[]> {
async getBridgedStables(stablecoin: StablecoinEnum, timestamp: Date, minAmount: bigint): Promise<StablecoinBridgeQuery[]> {
const checkTimestamp = Math.trunc(timestamp.getTime() / 1000);

const bridgeFetched = await PONDER_CLIENT.query({
Expand All @@ -18,6 +18,7 @@ export class BridgeService {
orderBy: "timestamp", orderDirection: "desc"
where: {
timestamp_gt: "${checkTimestamp}"
amount_gte: "${minAmount}"
isMint: true
}
) {
Expand Down
13 changes: 8 additions & 5 deletions frontendcode/frontendcode.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -29,16 +29,19 @@ export class FrontendCodeService {
return frontendCodeFetched?.data?.frontendCodeRegistereds?.items ?? [];
}

async getSavingsSaveds(timestamp: Date): Promise<FrontendCodeSavingsQuery[]> {
async getSavingsSaveds(timestamp: Date, minAmount: bigint): Promise<FrontendCodeSavingsQuery[]> {
const checkTimestamp = Math.trunc(timestamp.getTime() / 1000);

const savedFetched = await PONDER_CLIENT.query({
fetchPolicy: 'no-cache',
query: gql`
query GetFrontendCodeSavingsSaved {
savingsSaveds(
orderBy: "created", orderDirection: "desc"
where: { created_gt: "${checkTimestamp}" }
query GetFrontendCodeSavingsSaved {
savingsSaveds(
orderBy: "created", orderDirection: "desc"
where: {
created_gt: "${checkTimestamp}"
amount_gte: "${minAmount}"
}
) {
items {
txHash
Expand Down
9 changes: 7 additions & 2 deletions socialmedia/socialmedia.service.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ export interface SocialMediaFct {
doSendBridgeUpdates(bridge: StablecoinBridgeQuery, stablecoin: string): Promise<void>;
}

const MIN_SAVING_AMOUNT = 1000;
const MIN_BRIDGE_AMOUNT = 5000;

@Injectable()
export class SocialMediaService {
private readonly logger = new Logger(this.constructor.name);
Expand Down Expand Up @@ -71,7 +74,8 @@ export class SocialMediaService {
private async sendSavingUpdates(): Promise<void> {
try {
const checkDate = new Date(this.socialMediaState.savingUpdates);
const requestedSavingsSaveds = await this.frontendCode.getSavingsSaveds(checkDate);
const minAmount = BigInt(MIN_SAVING_AMOUNT * 10 ** 18);
const requestedSavingsSaveds = await this.frontendCode.getSavingsSaveds(checkDate, minAmount);

if (requestedSavingsSaveds.length > 0) {
this.socialMediaState.savingUpdates = Date.now();
Expand Down Expand Up @@ -133,9 +137,10 @@ export class SocialMediaService {
private async sendBridgeUpdates(): Promise<void> {
try {
const checkDate = new Date(this.socialMediaState.bridgeUpdates);
const minAmount = BigInt(MIN_BRIDGE_AMOUNT * 10 ** 18);

for (const stablecoin of Object.values(StablecoinEnum)) {
const requestedBridged = await this.bridges.getBridgedStables(stablecoin, checkDate);
const requestedBridged = await this.bridges.getBridgedStables(stablecoin, checkDate, minAmount);

if (requestedBridged.length > 0) {
this.socialMediaState.bridgeUpdates = Date.now();
Expand Down