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

Map TWAP (createWithContext call) orders #1669

Merged
merged 3 commits into from
Jun 19, 2024
Merged

Map TWAP (createWithContext call) orders #1669

merged 3 commits into from
Jun 19, 2024

Conversation

iamacook
Copy link
Member

Summary

We currently display TWAP (createWithContext) calls as a "standard" transaction and do not decode the data as we do with swaps. This implements TWAP-specific decoding behind a feature flag.

Official TWAP-based orders are now decoded and the txInfo is mapped as follows:

type TwapOrderInfo = {
  type: 'TwapOrder'
  orderStatus: OrderStatus;
  kind: 'sell';
  class: 'limit';
  validUntil: number;
  sellAmount: string;
  buyAmount: string;
  executedSellAmount: string;
  executedBuyAmount: string;
  sellToken: {
      address: `0x${string}`,
      decimals: number,
      logoUri: string,
      name: string,
      symbol: string,
      trusted: boolean,
  };
  buyToken: {
      address: `0x${string}`,
      decimals: number,
      logoUri: string,
      name: string,
      symbol: string,
      trusted: boolean,
  };
  receiver: `0x${string}`;
  owner: `0x${string}`;
  numberOfParts: number;
  partSellAmount: string;
  minPartLimit: string;
  timeBetweenParts: string;
  durationOfPart:
    | { durationType: 'AUTO' }
    | { durationType: 'LIMIT_DURATION'; duration: number };
  startTime: 
    | { startType: 'AT_MINING_TIME }
    | { startType: 'AT_EPOCH'; epoch: number };
}

Changes

  • Add features.twapsDecoding feature flag
  • Extract re-used values from Order entity to relative enums
  • Add TwapOrderInfo entity
  • Add TransactionInfoType.TwapOrder type
  • Add test-covered GPv2OrderHelper for decoding order UIDs (based on CoW Protocol/SDK - linked in code)
  • Add test-covered TwapOrderHelper for finding/generating parts of TWAP orders (based on CoW Swap app - linked in code)
  • Add test-covered TwapOrderMapper for mapping TWAP orders

@iamacook iamacook self-assigned this Jun 18, 2024
@iamacook iamacook requested a review from a team as a code owner June 18, 2024 13:36
@coveralls
Copy link

coveralls commented Jun 18, 2024

Pull Request Test Coverage Report for Build 9566099283

Details

  • 91 of 172 (52.91%) changed or added relevant lines in 9 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 49.295%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/routes/transactions/helpers/swap-order.helper.ts 3 4 75.0%
src/routes/transactions/helpers/gp-v2-order.helper.ts 8 11 72.73%
src/routes/transactions/helpers/twap-order.helper.ts 10 23 43.48%
src/routes/transactions/mappers/common/transaction-info.mapper.ts 5 18 27.78%
src/routes/transactions/entities/swaps/twap-order-info.entity.ts 31 51 60.78%
src/routes/transactions/mappers/common/twap-order.mapper.ts 18 49 36.73%
Totals Coverage Status
Change from base Build 9563691273: -0.1%
Covered Lines: 4068
Relevant Lines: 6656

💛 - Coveralls

@iamacook iamacook linked an issue Jun 18, 2024 that may be closed by this pull request
@coveralls
Copy link

coveralls commented Jun 18, 2024

Pull Request Test Coverage Report for Build 9568377389

Details

  • 91 of 174 (52.3%) changed or added relevant lines in 10 files are covered.
  • No unchanged relevant lines lost coverage.
  • Overall coverage decreased (-0.1%) to 49.274%

Changes Missing Coverage Covered Lines Changed/Added Lines %
src/routes/transactions/helpers/swap-order.helper.ts 3 4 75.0%
src/domain/swaps/contracts/decoders/composable-cow-decoder.helper.ts 0 2 0.0%
src/routes/transactions/helpers/gp-v2-order.helper.ts 8 11 72.73%
src/routes/transactions/helpers/twap-order.helper.ts 10 23 43.48%
src/routes/transactions/mappers/common/transaction-info.mapper.ts 5 18 27.78%
src/routes/transactions/entities/swaps/twap-order-info.entity.ts 31 51 60.78%
src/routes/transactions/mappers/common/twap-order.mapper.ts 18 49 36.73%
Totals Coverage Status
Change from base Build 9563691273: -0.1%
Covered Lines: 4068
Relevant Lines: 6658

💛 - Coveralls

@iamacook iamacook merged commit 5a04f38 into main Jun 19, 2024
16 checks passed
@iamacook iamacook deleted the twap-mapping branch June 19, 2024 08:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add decoding for TWAP orders
3 participants