@reyaxyz/common 0.362.1 → 0.364.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (104) hide show
  1. package/README.md +1 -1
  2. package/dist/commands/exposure/command.js +8 -22
  3. package/dist/commands/exposure/command.js.map +1 -1
  4. package/dist/incentives-api-types.js.map +1 -1
  5. package/dist/services/getNativeToken.js +1 -0
  6. package/dist/services/getNativeToken.js.map +1 -1
  7. package/dist/services/getSocketAddresses.js +1 -0
  8. package/dist/services/getSocketAddresses.js.map +1 -1
  9. package/dist/trading-api-types.js.map +1 -1
  10. package/dist/transactions/abis/Errors.json +1638 -34
  11. package/dist/transactions/abis/OrdersGateway.json +729 -123
  12. package/dist/transactions/abis/PassivePerpProxy.json +542 -0
  13. package/dist/transactions/buildMulticallTx.js.map +1 -1
  14. package/dist/transactions/consts.js +1 -2
  15. package/dist/transactions/consts.js.map +1 -1
  16. package/dist/transactions/contractAddresses.js +45 -5
  17. package/dist/transactions/contractAddresses.js.map +1 -1
  18. package/dist/transactions/sign.js +237 -111
  19. package/dist/transactions/sign.js.map +1 -1
  20. package/dist/types/commands/exposure/command.d.ts +8 -7
  21. package/dist/types/commands/exposure/command.d.ts.map +1 -1
  22. package/dist/types/incentives-api-types.d.ts +61 -5
  23. package/dist/types/incentives-api-types.d.ts.map +1 -1
  24. package/dist/types/services/getNativeToken.d.ts.map +1 -1
  25. package/dist/types/services/getSocketAddresses.d.ts.map +1 -1
  26. package/dist/types/trading-api-types.d.ts +200 -32
  27. package/dist/types/trading-api-types.d.ts.map +1 -1
  28. package/dist/types/transactions/buildMulticallTx.d.ts +1 -0
  29. package/dist/types/transactions/buildMulticallTx.d.ts.map +1 -1
  30. package/dist/types/transactions/consts.d.ts +0 -1
  31. package/dist/types/transactions/consts.d.ts.map +1 -1
  32. package/dist/types/transactions/contractAddresses.d.ts +0 -1
  33. package/dist/types/transactions/contractAddresses.d.ts.map +1 -1
  34. package/dist/types/transactions/sign.d.ts +113 -9
  35. package/dist/types/transactions/sign.d.ts.map +1 -1
  36. package/dist/types/types.d.ts +61 -65
  37. package/dist/types/types.d.ts.map +1 -1
  38. package/dist/types/utils/calculate.d.ts.map +1 -1
  39. package/dist/types/utils/consts.d.ts +2 -2
  40. package/dist/types/utils/consts.d.ts.map +1 -1
  41. package/dist/types/utils/error-sanitizer.d.ts +15 -0
  42. package/dist/types/utils/error-sanitizer.d.ts.map +1 -0
  43. package/dist/types/utils/index.d.ts +3 -0
  44. package/dist/types/utils/index.d.ts.map +1 -1
  45. package/dist/types/utils/network.d.ts.map +1 -1
  46. package/dist/types/utils/number.d.ts +5 -0
  47. package/dist/types/utils/number.d.ts.map +1 -1
  48. package/dist/types/utils/realized-balance.d.ts +54 -0
  49. package/dist/types/utils/realized-balance.d.ts.map +1 -0
  50. package/dist/types/utils/throttled-error.d.ts +42 -0
  51. package/dist/types/utils/throttled-error.d.ts.map +1 -0
  52. package/dist/types/utils/token/normalize.d.ts +2 -1
  53. package/dist/types/utils/token/normalize.d.ts.map +1 -1
  54. package/dist/types/utils/token/token-info-getters.d.ts.map +1 -1
  55. package/dist/types/utils/token/token-info.d.ts.map +1 -1
  56. package/dist/types.js +25 -11
  57. package/dist/types.js.map +1 -1
  58. package/dist/utils/calculate.js +18 -9
  59. package/dist/utils/calculate.js.map +1 -1
  60. package/dist/utils/consts.js +2 -7
  61. package/dist/utils/consts.js.map +1 -1
  62. package/dist/utils/error-sanitizer.js +135 -0
  63. package/dist/utils/error-sanitizer.js.map +1 -0
  64. package/dist/utils/index.js +3 -0
  65. package/dist/utils/index.js.map +1 -1
  66. package/dist/utils/network.js +4 -0
  67. package/dist/utils/network.js.map +1 -1
  68. package/dist/utils/number.js +96 -1
  69. package/dist/utils/number.js.map +1 -1
  70. package/dist/utils/realized-balance.js +126 -0
  71. package/dist/utils/realized-balance.js.map +1 -0
  72. package/dist/utils/throttled-error.js +60 -0
  73. package/dist/utils/throttled-error.js.map +1 -0
  74. package/dist/utils/token/normalize.js +2 -2
  75. package/dist/utils/token/normalize.js.map +1 -1
  76. package/dist/utils/token/token-info-getters.js +80 -5
  77. package/dist/utils/token/token-info-getters.js.map +1 -1
  78. package/dist/utils/token/token-info.js +7 -0
  79. package/dist/utils/token/token-info.js.map +1 -1
  80. package/package.json +3 -3
  81. package/src/commands/exposure/command.ts +8 -38
  82. package/src/incentives-api-types.ts +60 -5
  83. package/src/services/getNativeToken.ts +1 -0
  84. package/src/services/getSocketAddresses.ts +1 -0
  85. package/src/trading-api-types.ts +258 -39
  86. package/src/transactions/abis/Errors.json +5478 -3874
  87. package/src/transactions/abis/OrdersGateway.json +730 -124
  88. package/src/transactions/abis/PassivePerpProxy.json +542 -0
  89. package/src/transactions/buildMulticallTx.ts +4 -0
  90. package/src/transactions/consts.ts +0 -1
  91. package/src/transactions/contractAddresses.ts +42 -7
  92. package/src/transactions/sign.ts +306 -150
  93. package/src/types.ts +98 -83
  94. package/src/utils/calculate.ts +21 -8
  95. package/src/utils/consts.ts +4 -16
  96. package/src/utils/error-sanitizer.ts +137 -0
  97. package/src/utils/index.ts +3 -0
  98. package/src/utils/network.ts +4 -0
  99. package/src/utils/number.ts +110 -0
  100. package/src/utils/realized-balance.ts +163 -0
  101. package/src/utils/throttled-error.ts +85 -0
  102. package/src/utils/token/normalize.ts +6 -1
  103. package/src/utils/token/token-info-getters.ts +104 -6
  104. package/src/utils/token/token-info.ts +42 -0
@@ -331,6 +331,548 @@
331
331
  ],
332
332
  "outputs": [],
333
333
  "stateMutability": "nonpayable"
334
+ },
335
+ {
336
+ "type": "event",
337
+ "name": "PassivePerpExecutionV3",
338
+ "inputs": [
339
+ {
340
+ "name": "marketId",
341
+ "type": "uint128",
342
+ "indexed": true,
343
+ "internalType": "uint128"
344
+ },
345
+ {
346
+ "name": "exchangeId",
347
+ "type": "uint128",
348
+ "indexed": false,
349
+ "internalType": "uint128"
350
+ },
351
+ {
352
+ "name": "accountId",
353
+ "type": "uint128",
354
+ "indexed": true,
355
+ "internalType": "uint128"
356
+ },
357
+ {
358
+ "name": "counterpartyAccountId",
359
+ "type": "uint128",
360
+ "indexed": false,
361
+ "internalType": "uint128"
362
+ },
363
+ {
364
+ "name": "eventSequenceNumber",
365
+ "type": "uint128",
366
+ "indexed": true,
367
+ "internalType": "uint128"
368
+ },
369
+ {
370
+ "name": "blockTimestamp",
371
+ "type": "uint256",
372
+ "indexed": false,
373
+ "internalType": "uint256"
374
+ },
375
+ {
376
+ "name": "data",
377
+ "type": "tuple",
378
+ "indexed": false,
379
+ "internalType": "struct PassivePerpExecutionEventDataV3",
380
+ "components": [
381
+ {
382
+ "name": "executedBase",
383
+ "type": "int256",
384
+ "internalType": "SD59x18"
385
+ },
386
+ {
387
+ "name": "perpFillFees",
388
+ "type": "tuple",
389
+ "internalType": "struct PerpFillFees",
390
+ "components": [
391
+ {
392
+ "name": "protocolFeeCredit",
393
+ "type": "uint256",
394
+ "internalType": "uint256"
395
+ },
396
+ {
397
+ "name": "referrerFeeCredit",
398
+ "type": "uint256",
399
+ "internalType": "uint256"
400
+ },
401
+ {
402
+ "name": "takerRebateCredit",
403
+ "type": "uint256",
404
+ "internalType": "uint256"
405
+ },
406
+ {
407
+ "name": "poolFeeCredit",
408
+ "type": "uint256",
409
+ "internalType": "uint256"
410
+ }
411
+ ]
412
+ },
413
+ {
414
+ "name": "executedPrice",
415
+ "type": "uint256",
416
+ "internalType": "UD60x18"
417
+ },
418
+ {
419
+ "name": "referrerAccountId",
420
+ "type": "uint128",
421
+ "internalType": "uint128"
422
+ },
423
+ {
424
+ "name": "executionType",
425
+ "type": "uint8",
426
+ "internalType": "enum ExecutionType"
427
+ },
428
+ {
429
+ "name": "positionData",
430
+ "type": "tuple",
431
+ "internalType": "struct PerpPosition",
432
+ "components": [
433
+ {
434
+ "name": "base",
435
+ "type": "int256",
436
+ "internalType": "SD59x18"
437
+ },
438
+ {
439
+ "name": "realizedPnL",
440
+ "type": "int256",
441
+ "internalType": "SD59x18"
442
+ },
443
+ {
444
+ "name": "lastPriceData",
445
+ "type": "tuple",
446
+ "internalType": "struct PriceData",
447
+ "components": [
448
+ {
449
+ "name": "price",
450
+ "type": "uint256",
451
+ "internalType": "UD60x18"
452
+ },
453
+ {
454
+ "name": "timestamp",
455
+ "type": "uint256",
456
+ "internalType": "uint256"
457
+ }
458
+ ]
459
+ },
460
+ {
461
+ "name": "trackers",
462
+ "type": "tuple",
463
+ "internalType": "struct FundingAndADLTrackers",
464
+ "components": [
465
+ {
466
+ "name": "fundingValue",
467
+ "type": "int256",
468
+ "internalType": "SD59x18"
469
+ },
470
+ {
471
+ "name": "baseMultiplier",
472
+ "type": "uint256",
473
+ "internalType": "UD60x18"
474
+ },
475
+ {
476
+ "name": "adlUnwindPrice",
477
+ "type": "uint256",
478
+ "internalType": "UD60x18"
479
+ }
480
+ ]
481
+ },
482
+ {
483
+ "name": "averageEntryFundingValue",
484
+ "type": "int256",
485
+ "internalType": "SD59x18"
486
+ },
487
+ {
488
+ "name": "session",
489
+ "type": "uint128",
490
+ "internalType": "uint128"
491
+ }
492
+ ]
493
+ },
494
+ {
495
+ "name": "counterpartyPositionData",
496
+ "type": "tuple",
497
+ "internalType": "struct PerpPosition",
498
+ "components": [
499
+ {
500
+ "name": "base",
501
+ "type": "int256",
502
+ "internalType": "SD59x18"
503
+ },
504
+ {
505
+ "name": "realizedPnL",
506
+ "type": "int256",
507
+ "internalType": "SD59x18"
508
+ },
509
+ {
510
+ "name": "lastPriceData",
511
+ "type": "tuple",
512
+ "internalType": "struct PriceData",
513
+ "components": [
514
+ {
515
+ "name": "price",
516
+ "type": "uint256",
517
+ "internalType": "UD60x18"
518
+ },
519
+ {
520
+ "name": "timestamp",
521
+ "type": "uint256",
522
+ "internalType": "uint256"
523
+ }
524
+ ]
525
+ },
526
+ {
527
+ "name": "trackers",
528
+ "type": "tuple",
529
+ "internalType": "struct FundingAndADLTrackers",
530
+ "components": [
531
+ {
532
+ "name": "fundingValue",
533
+ "type": "int256",
534
+ "internalType": "SD59x18"
535
+ },
536
+ {
537
+ "name": "baseMultiplier",
538
+ "type": "uint256",
539
+ "internalType": "UD60x18"
540
+ },
541
+ {
542
+ "name": "adlUnwindPrice",
543
+ "type": "uint256",
544
+ "internalType": "UD60x18"
545
+ }
546
+ ]
547
+ },
548
+ {
549
+ "name": "averageEntryFundingValue",
550
+ "type": "int256",
551
+ "internalType": "SD59x18"
552
+ },
553
+ {
554
+ "name": "session",
555
+ "type": "uint128",
556
+ "internalType": "uint128"
557
+ }
558
+ ]
559
+ },
560
+ {
561
+ "name": "preOrderPositionData",
562
+ "type": "tuple",
563
+ "internalType": "struct PerpPosition",
564
+ "components": [
565
+ {
566
+ "name": "base",
567
+ "type": "int256",
568
+ "internalType": "SD59x18"
569
+ },
570
+ {
571
+ "name": "realizedPnL",
572
+ "type": "int256",
573
+ "internalType": "SD59x18"
574
+ },
575
+ {
576
+ "name": "lastPriceData",
577
+ "type": "tuple",
578
+ "internalType": "struct PriceData",
579
+ "components": [
580
+ {
581
+ "name": "price",
582
+ "type": "uint256",
583
+ "internalType": "UD60x18"
584
+ },
585
+ {
586
+ "name": "timestamp",
587
+ "type": "uint256",
588
+ "internalType": "uint256"
589
+ }
590
+ ]
591
+ },
592
+ {
593
+ "name": "trackers",
594
+ "type": "tuple",
595
+ "internalType": "struct FundingAndADLTrackers",
596
+ "components": [
597
+ {
598
+ "name": "fundingValue",
599
+ "type": "int256",
600
+ "internalType": "SD59x18"
601
+ },
602
+ {
603
+ "name": "baseMultiplier",
604
+ "type": "uint256",
605
+ "internalType": "UD60x18"
606
+ },
607
+ {
608
+ "name": "adlUnwindPrice",
609
+ "type": "uint256",
610
+ "internalType": "UD60x18"
611
+ }
612
+ ]
613
+ },
614
+ {
615
+ "name": "averageEntryFundingValue",
616
+ "type": "int256",
617
+ "internalType": "SD59x18"
618
+ },
619
+ {
620
+ "name": "session",
621
+ "type": "uint128",
622
+ "internalType": "uint128"
623
+ }
624
+ ]
625
+ },
626
+ {
627
+ "name": "preOrderCounterpartyPositionData",
628
+ "type": "tuple",
629
+ "internalType": "struct PerpPosition",
630
+ "components": [
631
+ {
632
+ "name": "base",
633
+ "type": "int256",
634
+ "internalType": "SD59x18"
635
+ },
636
+ {
637
+ "name": "realizedPnL",
638
+ "type": "int256",
639
+ "internalType": "SD59x18"
640
+ },
641
+ {
642
+ "name": "lastPriceData",
643
+ "type": "tuple",
644
+ "internalType": "struct PriceData",
645
+ "components": [
646
+ {
647
+ "name": "price",
648
+ "type": "uint256",
649
+ "internalType": "UD60x18"
650
+ },
651
+ {
652
+ "name": "timestamp",
653
+ "type": "uint256",
654
+ "internalType": "uint256"
655
+ }
656
+ ]
657
+ },
658
+ {
659
+ "name": "trackers",
660
+ "type": "tuple",
661
+ "internalType": "struct FundingAndADLTrackers",
662
+ "components": [
663
+ {
664
+ "name": "fundingValue",
665
+ "type": "int256",
666
+ "internalType": "SD59x18"
667
+ },
668
+ {
669
+ "name": "baseMultiplier",
670
+ "type": "uint256",
671
+ "internalType": "UD60x18"
672
+ },
673
+ {
674
+ "name": "adlUnwindPrice",
675
+ "type": "uint256",
676
+ "internalType": "UD60x18"
677
+ }
678
+ ]
679
+ },
680
+ {
681
+ "name": "averageEntryFundingValue",
682
+ "type": "int256",
683
+ "internalType": "SD59x18"
684
+ },
685
+ {
686
+ "name": "session",
687
+ "type": "uint128",
688
+ "internalType": "uint128"
689
+ }
690
+ ]
691
+ },
692
+ {
693
+ "name": "positionAccountOwner",
694
+ "type": "address",
695
+ "internalType": "address"
696
+ },
697
+ {
698
+ "name": "counterpartyAccountOwner",
699
+ "type": "address",
700
+ "internalType": "address"
701
+ },
702
+ {
703
+ "name": "accountOrderId",
704
+ "type": "uint64",
705
+ "internalType": "uint64"
706
+ },
707
+ {
708
+ "name": "counterpartyOrderId",
709
+ "type": "uint64",
710
+ "internalType": "uint64"
711
+ },
712
+ {
713
+ "name": "counterpartyExchangeId",
714
+ "type": "uint128",
715
+ "internalType": "uint128"
716
+ },
717
+ {
718
+ "name": "meNonce",
719
+ "type": "uint256",
720
+ "internalType": "uint256"
721
+ },
722
+ {
723
+ "name": "metadata",
724
+ "type": "bytes",
725
+ "internalType": "bytes"
726
+ }
727
+ ]
728
+ }
729
+ ],
730
+ "anonymous": false
731
+ },
732
+ {
733
+ "type": "event",
734
+ "name": "FeeTierParametersUpdated",
735
+ "inputs": [
736
+ {
737
+ "name": "tierId",
738
+ "type": "uint256",
739
+ "indexed": true,
740
+ "internalType": "uint256"
741
+ },
742
+ {
743
+ "name": "feeTierParameters",
744
+ "type": "tuple",
745
+ "indexed": false,
746
+ "internalType": "struct FeeTierParameters",
747
+ "components": [
748
+ {
749
+ "name": "takerFee",
750
+ "type": "uint256",
751
+ "internalType": "UD60x18"
752
+ },
753
+ {
754
+ "name": "makerFee",
755
+ "type": "uint256",
756
+ "internalType": "UD60x18"
757
+ },
758
+ {
759
+ "name": "makerRebate",
760
+ "type": "uint256",
761
+ "internalType": "UD60x18"
762
+ }
763
+ ]
764
+ },
765
+ {
766
+ "name": "blockTimestamp",
767
+ "type": "uint256",
768
+ "indexed": false,
769
+ "internalType": "uint256"
770
+ }
771
+ ],
772
+ "anonymous": false
773
+ },
774
+ {
775
+ "type": "event",
776
+ "name": "GlobalFeeParametersUpdated",
777
+ "inputs": [
778
+ {
779
+ "name": "globalFeeParameters",
780
+ "type": "tuple",
781
+ "indexed": false,
782
+ "internalType": "struct GlobalFeeParameters",
783
+ "components": [
784
+ {
785
+ "name": "ogDiscount",
786
+ "type": "uint256",
787
+ "internalType": "UD60x18"
788
+ },
789
+ {
790
+ "name": "refereeDiscount",
791
+ "type": "uint256",
792
+ "internalType": "UD60x18"
793
+ },
794
+ {
795
+ "name": "referrerRebate",
796
+ "type": "uint256",
797
+ "internalType": "UD60x18"
798
+ },
799
+ {
800
+ "name": "affiliateReferrerRebate",
801
+ "type": "uint256",
802
+ "internalType": "UD60x18"
803
+ },
804
+ {
805
+ "name": "vltzDiscount",
806
+ "type": "uint256",
807
+ "internalType": "UD60x18"
808
+ },
809
+ {
810
+ "name": "spreadDiscount",
811
+ "type": "uint256",
812
+ "internalType": "UD60x18"
813
+ }
814
+ ]
815
+ },
816
+ {
817
+ "name": "blockTimestamp",
818
+ "type": "uint256",
819
+ "indexed": false,
820
+ "internalType": "uint256"
821
+ }
822
+ ],
823
+ "anonymous": false
824
+ },
825
+ {
826
+ "type": "event",
827
+ "name": "AccountOwnerFeeConfigurationUpdated",
828
+ "inputs": [
829
+ {
830
+ "name": "accountOwner",
831
+ "type": "address",
832
+ "indexed": true,
833
+ "internalType": "address"
834
+ },
835
+ {
836
+ "name": "accountOwnerFeeConfig",
837
+ "type": "tuple",
838
+ "indexed": false,
839
+ "internalType": "struct AccountOwnerFeeConfig",
840
+ "components": [
841
+ {
842
+ "name": "tierId",
843
+ "type": "uint256",
844
+ "internalType": "uint256"
845
+ },
846
+ {
847
+ "name": "ogStatus",
848
+ "type": "bool",
849
+ "internalType": "bool"
850
+ },
851
+ {
852
+ "name": "affiliateStatus",
853
+ "type": "bool",
854
+ "internalType": "bool"
855
+ },
856
+ {
857
+ "name": "vltzStatus",
858
+ "type": "bool",
859
+ "internalType": "bool"
860
+ },
861
+ {
862
+ "name": "spreadDiscountStatus",
863
+ "type": "bool",
864
+ "internalType": "bool"
865
+ }
866
+ ]
867
+ },
868
+ {
869
+ "name": "blockTimestamp",
870
+ "type": "uint256",
871
+ "indexed": false,
872
+ "internalType": "uint256"
873
+ }
874
+ ],
875
+ "anonymous": false
334
876
  }
335
877
  ]
336
878
  }
@@ -5,6 +5,10 @@ import { abi as MulticallAbi } from './abis/CustomMulticall3.json';
5
5
  export type Call = {
6
6
  target: string;
7
7
  callData: string;
8
+ // Optional gas-limit override used by the off-chain transaction relay.
9
+ // Ignored by on-chain Multicall3 struct encoding (ethers skips unknown
10
+ // fields when matching the Solidity tuple).
11
+ gasLimit?: number;
8
12
  };
9
13
 
10
14
  export const encodeCoreMulticall = (calldatas: string[]): string => {
@@ -3,4 +3,3 @@ export const CORE_DEADLINE_IN_SECONDS = 60; // 1 minute
3
3
  export const ORDERS_GATEWAY_DEADLINE_IN_SECONDS = 60; // 1 minute
4
4
  export const RELAYER_ACCOUNT = '0xb43c317c9c9215d268881d7d6b59c2d3d0247da1'; // @todo update value
5
5
  export const PUBLISHER_ACCOUNT = '0xE32519ca0e751C754c8E1378846B5cd95A1CB66a'; // @todo update value
6
- export const CONDITIONAL_ORDER_SIG_DEADLINE = 10 ** 18; // very big number for timestamp
@@ -4,7 +4,6 @@ export enum ContractType {
4
4
  CORE_PROXY = 'core_proxy',
5
5
  PASSIVE_POOL_PROXY = 'passive_pool_proxy',
6
6
  PERIPHERY_PROXY = 'periphery_proxy',
7
- CONDITIONAL_ORDERS_PROXY = 'conditional_orders_proxy',
8
7
  ORDERS_GATEWAY_PROXY = 'orders_gateway_proxy',
9
8
  PASSIVE_PERP_PROXY = 'passive_perp_proxy',
10
9
  ORACLE_ADAPTERS_PROXY = 'oracle_adapters_proxy',
@@ -13,15 +12,15 @@ export enum ContractType {
13
12
  REYA_TGE_DISTRIBUTION = 'reya_tge_distribution',
14
13
  }
15
14
 
16
- const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
15
+ type RemoteReyaChainId = Exclude<ReyaChainId, ReyaChainId.reyaLocal>;
16
+
17
+ const remoteAddresses = {
17
18
  [ReyaChainId.reyaCronos]: {
18
19
  [ContractType.CORE_PROXY]: '0xc6fb022962e1426f4e0ec9d2f8861c57926e9f72',
19
20
  [ContractType.PASSIVE_POOL_PROXY]:
20
21
  '0x9a3a664987b88790a6fdc1632e3b607813fd94ff',
21
22
  [ContractType.PERIPHERY_PROXY]:
22
23
  '0x94ccae812f1647696754412082dd6684c2366a7f',
23
- [ContractType.CONDITIONAL_ORDERS_PROXY]:
24
- '0x5a0ac2f89e0bdeafc5c549e354842210a3e87ca5',
25
24
  [ContractType.ORDERS_GATEWAY_PROXY]:
26
25
  '0x5a0ac2f89e0bdeafc5c549e354842210a3e87ca5',
27
26
  [ContractType.PASSIVE_PERP_PROXY]:
@@ -39,8 +38,6 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
39
38
  '0xb4b77d6180cc14472a9a7bdff01cc2459368d413',
40
39
  [ContractType.PERIPHERY_PROXY]:
41
40
  '0xcd2869d1eb1bc8991bc55de9e9b779e912faf736',
42
- [ContractType.CONDITIONAL_ORDERS_PROXY]:
43
- '0xfc8c96be87da63cecddbf54abfa7b13ee8044739',
44
41
  [ContractType.ORDERS_GATEWAY_PROXY]:
45
42
  '0xfc8c96be87da63cecddbf54abfa7b13ee8044739',
46
43
  [ContractType.PASSIVE_PERP_PROXY]:
@@ -52,11 +49,49 @@ const addresses: Record<ReyaChainId, Record<ContractType, Address>> = {
52
49
  [ContractType.REYA_TGE_DISTRIBUTION]:
53
50
  '0x0000000000000000000000000000000000000000',
54
51
  },
52
+ } satisfies Record<RemoteReyaChainId, Record<ContractType, Address>>;
53
+
54
+ const addresses: Record<ReyaChainId, Partial<Record<ContractType, Address>>> = {
55
+ ...remoteAddresses,
56
+ [ReyaChainId.reyaLocal]: {},
55
57
  };
58
+ // Map stores the resolved env-var VALUES (not the var names) so that
59
+ // webpack / Next.js `DefinePlugin` can statically inline them into
60
+ // browser bundles.
61
+ //
62
+ // DefinePlugin only inlines literal `process.env.NAME` access — a
63
+ // dynamic `process.env[varName]` lookup is opaque to its source-text
64
+ // pass and stays `undefined` in the browser. Keeping the four
65
+ // `process.env.*` accesses as static literals in this object literal
66
+ // is what makes the override work in both Node (real `process.env` at
67
+ // runtime) and browser (DefinePlugin-substituted constants at build
68
+ // time). See PR #2660 / Daniel's comment for the discovery context.
69
+ //
70
+ // New entries must use the same static-literal pattern; do NOT
71
+ // introduce a dynamic `process.env[someVar]` lookup downstream.
72
+ const CONTRACT_ADDRESS_ENV_OVERRIDES: Partial<Record<ContractType, string>> = {
73
+ [ContractType.CORE_PROXY]: process.env.CORE_PROXY_ADDRESS,
74
+ [ContractType.PASSIVE_PERP_PROXY]: process.env.PASSIVE_PERP_PROXY_ADDRESS,
75
+ [ContractType.ORDERS_GATEWAY_PROXY]: process.env.ORDERS_GATEWAY_PROXY_ADDRESS,
76
+ [ContractType.PERIPHERY_PROXY]: process.env.PERIPHERY_PROXY_ADDRESS,
77
+ [ContractType.ORACLE_ADAPTERS_PROXY]:
78
+ process.env.ORACLE_ADAPTERS_PROXY_ADDRESS,
79
+ [ContractType.PASSIVE_POOL_PROXY]: process.env.PASSIVE_POOL_PROXY_ADDRESS,
80
+ };
81
+
56
82
  export const getAddress = (
57
83
  chainId: number,
58
84
  contractName: ContractType,
59
85
  ): Address => {
86
+ // Normalize env-overridden addresses to lowercase. The hardcoded fallback
87
+ // map below stores lowercased values, and downstream comparisons (e.g.
88
+ // transaction-whitelist.ts uses `convertToAddress(target) === OG_ADDRESS`,
89
+ // which lowercases the runtime target) assume that invariant. Without
90
+ // this, a checksummed env value silently fails every comparison and the
91
+ // OG-aware settlement path gets bypassed.
92
+ const override = CONTRACT_ADDRESS_ENV_OVERRIDES[contractName];
93
+ if (override) return override.toLowerCase() as Address;
94
+
60
95
  const keyChainId = chainId.toString();
61
96
 
62
97
  if (!Object.keys(addresses).includes(keyChainId)) {
@@ -68,5 +103,5 @@ export const getAddress = (
68
103
  throw new Error(`Unspecified address for ${contractName} contract`);
69
104
  }
70
105
 
71
- return networkAddresses[contractName];
106
+ return networkAddresses[contractName]!;
72
107
  };