• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

hicommonwealth / commonwealth / 14472509949

15 Apr 2025 02:51PM UTC coverage: 46.275% (+0.1%) from 46.172%
14472509949

push

github

web-flow
Merge pull request #11712 from hicommonwealth/ka.launchpadFix

Launchpad Fix

1621 of 3864 branches covered (41.95%)

Branch coverage included in aggregate %.

17 of 30 new or added lines in 3 files covered. (56.67%)

1 existing line in 1 file now uncovered.

2976 of 6070 relevant lines covered (49.03%)

39.56 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

14.29
/libs/model/src/aggregates/token/ProjectLaunchpadTrade.command.ts
1
import { Command } from '@hicommonwealth/core';
2
import { events } from '@hicommonwealth/schemas';
3
import { z } from 'zod';
4
import { models } from '../../database';
5
import { chainNodeMustExist } from '../../policies/utils/utils';
6
import { handleCapReached } from './utils'; // TODO: place in utils
7

8
const schema = {
32✔
9
  input: events.LaunchpadTokenTraded,
10
  output: z.object({}),
11
};
12

13
export function ProjectLaunchpadTrade(): Command<typeof schema> {
14
  return {
×
15
    ...schema,
16
    auth: [],
17
    body: async ({ payload }) => {
18
      const {
19
        block_timestamp,
20
        transaction_hash,
21
        token_address: token_address_unformatted,
22
        trader_address,
23
        is_buy,
24
        eth_chain_id,
25
        eth_amount,
26
        community_token_amount,
27
        floating_supply,
28
      } = payload;
×
29

NEW
30
      const token_address = token_address_unformatted.toLowerCase();
×
31

32
      const chainNode = await chainNodeMustExist(eth_chain_id);
×
33

34
      await models.LaunchpadTrade.findOrCreate({
×
35
        where: { eth_chain_id, transaction_hash },
36
        defaults: {
37
          eth_chain_id,
38
          transaction_hash,
39
          token_address,
40
          trader_address,
41
          is_buy,
42
          community_token_amount,
43
          price:
44
            Number((eth_amount * BigInt(1e18)) / community_token_amount) / 1e18,
45
          floating_supply,
46
          timestamp: Number(block_timestamp),
47
        },
48
      });
49

50
      // If cap reached, transfer to uniswap
NEW
51
      await handleCapReached(
×
52
        token_address,
53
        floating_supply,
54
        eth_chain_id,
55
        chainNode.private_url!,
56
      );
57
    },
58
  };
59
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2026 Coveralls, Inc