@lemmaoracle/x402 0.1.1 → 0.1.2

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 (146) hide show
  1. package/dist/advanced/index.d.ts +14 -0
  2. package/dist/advanced/index.d.ts.map +1 -0
  3. package/dist/advanced/index.js +14 -0
  4. package/dist/advanced/index.js.map +1 -0
  5. package/dist/index.d.ts +25 -42
  6. package/dist/index.d.ts.map +1 -1
  7. package/dist/index.js +25 -77
  8. package/dist/index.js.map +1 -1
  9. package/dist/lemma-config.d.ts +41 -0
  10. package/dist/lemma-config.d.ts.map +1 -0
  11. package/dist/lemma-config.js +12 -0
  12. package/dist/lemma-config.js.map +1 -0
  13. package/dist/lemma-discovery.d.ts +37 -0
  14. package/dist/lemma-discovery.d.ts.map +1 -0
  15. package/dist/lemma-discovery.js +104 -0
  16. package/dist/lemma-discovery.js.map +1 -0
  17. package/dist/lemma-server.d.ts +30 -0
  18. package/dist/lemma-server.d.ts.map +1 -0
  19. package/dist/lemma-server.js +120 -0
  20. package/dist/lemma-server.js.map +1 -0
  21. package/dist/lemma-submission.d.ts +41 -0
  22. package/dist/lemma-submission.d.ts.map +1 -0
  23. package/dist/lemma-submission.js +80 -0
  24. package/dist/lemma-submission.js.map +1 -0
  25. package/package.json +13 -13
  26. package/broadcast/DeployPaymentVerifier.s.sol/10143/run-1775996174982.json +0 -34
  27. package/broadcast/DeployPaymentVerifier.s.sol/10143/run-1775996423983.json +0 -51
  28. package/broadcast/DeployPaymentVerifier.s.sol/10143/run-1775996907850.json +0 -51
  29. package/broadcast/DeployPaymentVerifier.s.sol/10143/run-latest.json +0 -51
  30. package/cache/DeployPaymentVerifier.s.sol/10143/run-1775996174982.json +0 -7
  31. package/cache/DeployPaymentVerifier.s.sol/10143/run-1775996423983.json +0 -7
  32. package/cache/DeployPaymentVerifier.s.sol/10143/run-1775996907850.json +0 -7
  33. package/cache/DeployPaymentVerifier.s.sol/10143/run-latest.json +0 -7
  34. package/cache/solidity-files-cache.json +0 -1
  35. package/circuits/README.md +0 -78
  36. package/circuits/payment-comprehensive.test.mjs +0 -272
  37. package/circuits/payment.circom +0 -89
  38. package/circuits/payment.test.mjs +0 -173
  39. package/dist/proof-generator.d.ts +0 -26
  40. package/dist/proof-generator.d.ts.map +0 -1
  41. package/dist/proof-generator.js +0 -154
  42. package/dist/proof-generator.js.map +0 -1
  43. package/dist/proof-generator.test.d.ts +0 -7
  44. package/dist/proof-generator.test.d.ts.map +0 -1
  45. package/dist/proof-generator.test.js +0 -121
  46. package/dist/proof-generator.test.js.map +0 -1
  47. package/dist/transaction-watcher.d.ts +0 -42
  48. package/dist/transaction-watcher.d.ts.map +0 -1
  49. package/dist/transaction-watcher.js +0 -88
  50. package/dist/transaction-watcher.js.map +0 -1
  51. package/dist/transaction-watcher.test.d.ts +0 -7
  52. package/dist/transaction-watcher.test.d.ts.map +0 -1
  53. package/dist/transaction-watcher.test.js +0 -111
  54. package/dist/transaction-watcher.test.js.map +0 -1
  55. package/dist/types.d.ts +0 -76
  56. package/dist/types.d.ts.map +0 -1
  57. package/dist/types.js +0 -2
  58. package/dist/types.js.map +0 -1
  59. package/foundry.lock +0 -11
  60. package/foundry.toml +0 -16
  61. package/lib/forge-std/.gitattributes +0 -1
  62. package/lib/forge-std/.github/CODEOWNERS +0 -1
  63. package/lib/forge-std/.github/dependabot.yml +0 -6
  64. package/lib/forge-std/.github/workflows/ci.yml +0 -161
  65. package/lib/forge-std/.github/workflows/sync.yml +0 -36
  66. package/lib/forge-std/CONTRIBUTING.md +0 -193
  67. package/lib/forge-std/LICENSE-APACHE +0 -203
  68. package/lib/forge-std/LICENSE-MIT +0 -25
  69. package/lib/forge-std/README.md +0 -314
  70. package/lib/forge-std/RELEASE_CHECKLIST.md +0 -12
  71. package/lib/forge-std/foundry.toml +0 -18
  72. package/lib/forge-std/package.json +0 -16
  73. package/lib/forge-std/scripts/vm.py +0 -636
  74. package/lib/forge-std/src/Base.sol +0 -48
  75. package/lib/forge-std/src/Config.sol +0 -60
  76. package/lib/forge-std/src/LibVariable.sol +0 -477
  77. package/lib/forge-std/src/Script.sol +0 -28
  78. package/lib/forge-std/src/StdAssertions.sol +0 -1300
  79. package/lib/forge-std/src/StdChains.sol +0 -303
  80. package/lib/forge-std/src/StdCheats.sol +0 -825
  81. package/lib/forge-std/src/StdConfig.sol +0 -632
  82. package/lib/forge-std/src/StdConstants.sol +0 -30
  83. package/lib/forge-std/src/StdError.sol +0 -15
  84. package/lib/forge-std/src/StdInvariant.sol +0 -161
  85. package/lib/forge-std/src/StdJson.sol +0 -275
  86. package/lib/forge-std/src/StdMath.sol +0 -47
  87. package/lib/forge-std/src/StdStorage.sol +0 -476
  88. package/lib/forge-std/src/StdStyle.sol +0 -333
  89. package/lib/forge-std/src/StdToml.sol +0 -275
  90. package/lib/forge-std/src/StdUtils.sol +0 -200
  91. package/lib/forge-std/src/Test.sol +0 -32
  92. package/lib/forge-std/src/Vm.sol +0 -2533
  93. package/lib/forge-std/src/console.sol +0 -1551
  94. package/lib/forge-std/src/console2.sol +0 -4
  95. package/lib/forge-std/src/interfaces/IERC1155.sol +0 -105
  96. package/lib/forge-std/src/interfaces/IERC165.sol +0 -12
  97. package/lib/forge-std/src/interfaces/IERC20.sol +0 -43
  98. package/lib/forge-std/src/interfaces/IERC4626.sol +0 -190
  99. package/lib/forge-std/src/interfaces/IERC6909.sol +0 -72
  100. package/lib/forge-std/src/interfaces/IERC721.sol +0 -164
  101. package/lib/forge-std/src/interfaces/IERC7540.sol +0 -145
  102. package/lib/forge-std/src/interfaces/IERC7575.sol +0 -241
  103. package/lib/forge-std/src/interfaces/IMulticall3.sol +0 -68
  104. package/lib/forge-std/src/safeconsole.sol +0 -13248
  105. package/lib/forge-std/test/CommonBase.t.sol +0 -44
  106. package/lib/forge-std/test/Config.t.sol +0 -381
  107. package/lib/forge-std/test/LibVariable.t.sol +0 -452
  108. package/lib/forge-std/test/StdAssertions.t.sol +0 -141
  109. package/lib/forge-std/test/StdChains.t.sol +0 -227
  110. package/lib/forge-std/test/StdCheats.t.sol +0 -638
  111. package/lib/forge-std/test/StdConstants.t.sol +0 -38
  112. package/lib/forge-std/test/StdError.t.sol +0 -119
  113. package/lib/forge-std/test/StdJson.t.sol +0 -49
  114. package/lib/forge-std/test/StdMath.t.sol +0 -202
  115. package/lib/forge-std/test/StdStorage.t.sol +0 -532
  116. package/lib/forge-std/test/StdStyle.t.sol +0 -110
  117. package/lib/forge-std/test/StdToml.t.sol +0 -49
  118. package/lib/forge-std/test/StdUtils.t.sol +0 -342
  119. package/lib/forge-std/test/Vm.t.sol +0 -18
  120. package/lib/forge-std/test/compilation/CompilationScript.sol +0 -8
  121. package/lib/forge-std/test/compilation/CompilationScriptBase.sol +0 -8
  122. package/lib/forge-std/test/compilation/CompilationTest.sol +0 -8
  123. package/lib/forge-std/test/compilation/CompilationTestBase.sol +0 -8
  124. package/lib/forge-std/test/fixtures/broadcast.log.json +0 -187
  125. package/lib/forge-std/test/fixtures/config.toml +0 -81
  126. package/lib/forge-std/test/fixtures/test.json +0 -8
  127. package/lib/forge-std/test/fixtures/test.toml +0 -6
  128. package/package.json.backup +0 -55
  129. package/scripts/DeployPaymentVerifier.s.sol +0 -18
  130. package/scripts/build.sh +0 -61
  131. package/scripts/deploy.sh +0 -65
  132. package/scripts/fix-verifier.mjs +0 -64
  133. package/scripts/register-circuit.ts +0 -213
  134. package/scripts/test-with-circuit.mjs +0 -88
  135. package/src/index.ts +0 -115
  136. package/src/proof-generator.test.ts +0 -139
  137. package/src/proof-generator.ts +0 -220
  138. package/src/transaction-watcher.test.ts +0 -153
  139. package/src/transaction-watcher.ts +0 -154
  140. package/src/types.ts +0 -110
  141. package/tsconfig.json +0 -14
  142. package/tsconfig.tsbuildinfo +0 -1
  143. package/vitest.config.ts +0 -18
  144. package/workers/x402-facilitator/src/index.ts +0 -582
  145. package/workers/x402-facilitator/src/x402-env.d.ts +0 -25
  146. package/workers/x402-facilitator/wrangler.toml +0 -19
@@ -1,119 +0,0 @@
1
- // SPDX-License-Identifier: MIT OR Apache-2.0
2
- pragma solidity >=0.8.13 <0.9.0;
3
-
4
- import {stdError} from "../src/StdError.sol";
5
- import {Test} from "../src/Test.sol";
6
-
7
- contract StdErrorsTest is Test {
8
- ErrorsTest test;
9
-
10
- function setUp() public {
11
- test = new ErrorsTest();
12
- }
13
-
14
- function test_RevertIf_AssertionError() public {
15
- vm.expectRevert(stdError.assertionError);
16
- test.assertionError();
17
- }
18
-
19
- function test_RevertIf_ArithmeticError() public {
20
- vm.expectRevert(stdError.arithmeticError);
21
- test.arithmeticError(10);
22
- }
23
-
24
- function test_RevertIf_DivisionError() public {
25
- vm.expectRevert(stdError.divisionError);
26
- test.divError(0);
27
- }
28
-
29
- function test_RevertIf_ModError() public {
30
- vm.expectRevert(stdError.divisionError);
31
- test.modError(0);
32
- }
33
-
34
- function test_RevertIf_EnumConversionError() public {
35
- vm.expectRevert(stdError.enumConversionError);
36
- test.enumConversion(1);
37
- }
38
-
39
- function test_RevertIf_EncodeStgError() public {
40
- vm.expectRevert(stdError.encodeStorageError);
41
- test.encodeStgError();
42
- }
43
-
44
- function test_RevertIf_PopError() public {
45
- vm.expectRevert(stdError.popError);
46
- test.pop();
47
- }
48
-
49
- function test_RevertIf_IndexOOBError() public {
50
- vm.expectRevert(stdError.indexOOBError);
51
- test.indexOOBError(1);
52
- }
53
-
54
- function test_RevertIf_MemOverflowError() public {
55
- vm.expectRevert(stdError.memOverflowError);
56
- test.mem();
57
- }
58
-
59
- function test_RevertIf_InternError() public {
60
- vm.expectRevert(stdError.zeroVarError);
61
- test.intern();
62
- }
63
- }
64
-
65
- contract ErrorsTest {
66
- enum T {
67
- T1
68
- }
69
-
70
- uint256[] public someArr;
71
- bytes someBytes;
72
-
73
- function assertionError() public pure {
74
- assert(false);
75
- }
76
-
77
- function arithmeticError(uint256 a) public pure {
78
- a -= 100;
79
- }
80
-
81
- function divError(uint256 a) public pure {
82
- 100 / a;
83
- }
84
-
85
- function modError(uint256 a) public pure {
86
- 100 % a;
87
- }
88
-
89
- function enumConversion(uint256 a) public pure {
90
- T(a);
91
- }
92
-
93
- function encodeStgError() public {
94
- assembly ("memory-safe") {
95
- sstore(someBytes.slot, 1)
96
- }
97
- keccak256(someBytes);
98
- }
99
-
100
- function pop() public {
101
- someArr.pop();
102
- }
103
-
104
- function indexOOBError(uint256 a) public pure {
105
- uint256[] memory t = new uint256[](0);
106
- t[a];
107
- }
108
-
109
- function mem() public pure {
110
- uint256 l = 2 ** 256 / 32;
111
- new uint256[](l);
112
- }
113
-
114
- function intern() public returns (uint256) {
115
- function(uint256) internal returns (uint256) x;
116
- x(2);
117
- return 7;
118
- }
119
- }
@@ -1,49 +0,0 @@
1
- // SPDX-License-Identifier: MIT OR Apache-2.0
2
- pragma solidity >=0.8.13 <0.9.0;
3
-
4
- import {Test, stdJson} from "../src/Test.sol";
5
-
6
- contract StdJsonTest is Test {
7
- using stdJson for string;
8
-
9
- string root;
10
- string path;
11
-
12
- function setUp() public {
13
- root = vm.projectRoot();
14
- path = string.concat(root, "/test/fixtures/test.json");
15
- }
16
-
17
- struct SimpleJson {
18
- uint256 a;
19
- string b;
20
- }
21
-
22
- struct NestedJson {
23
- uint256 a;
24
- string b;
25
- SimpleJson c;
26
- }
27
-
28
- function test_readJson() public view {
29
- string memory json = vm.readFile(path);
30
- assertEq(json.readUint(".a"), 123);
31
- }
32
-
33
- function test_writeJson() public {
34
- string memory json = "json";
35
- json.serialize("a", uint256(123));
36
- string memory semiFinal = json.serialize("b", string("test"));
37
- string memory finalJson = json.serialize("c", semiFinal);
38
- finalJson.write(path);
39
-
40
- string memory json_ = vm.readFile(path);
41
- bytes memory data = json_.parseRaw("$");
42
- NestedJson memory decodedData = abi.decode(data, (NestedJson));
43
-
44
- assertEq(decodedData.a, 123);
45
- assertEq(decodedData.b, "test");
46
- assertEq(decodedData.c.a, 123);
47
- assertEq(decodedData.c.b, "test");
48
- }
49
- }
@@ -1,202 +0,0 @@
1
- // SPDX-License-Identifier: MIT OR Apache-2.0
2
- pragma solidity >=0.8.13 <0.9.0;
3
-
4
- import {stdMath} from "../src/StdMath.sol";
5
- import {Test, stdError} from "../src/Test.sol";
6
-
7
- contract StdMathMock is Test {
8
- function exposedPercentDelta(uint256 a, uint256 b) public pure returns (uint256) {
9
- return stdMath.percentDelta(a, b);
10
- }
11
-
12
- function exposedPercentDelta(int256 a, int256 b) public pure returns (uint256) {
13
- return stdMath.percentDelta(a, b);
14
- }
15
- }
16
-
17
- contract StdMathTest is Test {
18
- function test_GetAbs() external pure {
19
- assertEq(stdMath.abs(-50), 50);
20
- assertEq(stdMath.abs(50), 50);
21
- assertEq(stdMath.abs(-1337), 1337);
22
- assertEq(stdMath.abs(0), 0);
23
-
24
- assertEq(stdMath.abs(type(int256).min), (type(uint256).max >> 1) + 1);
25
- assertEq(stdMath.abs(type(int256).max), (type(uint256).max >> 1));
26
- }
27
-
28
- function testFuzz_GetAbs(int256 a) external pure {
29
- uint256 manualAbs = getAbs(a);
30
-
31
- uint256 abs = stdMath.abs(a);
32
-
33
- assertEq(abs, manualAbs);
34
- }
35
-
36
- function test_GetDelta_Uint() external pure {
37
- assertEq(stdMath.delta(uint256(0), uint256(0)), 0);
38
- assertEq(stdMath.delta(uint256(0), uint256(1337)), 1337);
39
- assertEq(stdMath.delta(uint256(0), type(uint64).max), type(uint64).max);
40
- assertEq(stdMath.delta(uint256(0), type(uint128).max), type(uint128).max);
41
- assertEq(stdMath.delta(uint256(0), type(uint256).max), type(uint256).max);
42
-
43
- assertEq(stdMath.delta(0, uint256(0)), 0);
44
- assertEq(stdMath.delta(1337, uint256(0)), 1337);
45
- assertEq(stdMath.delta(type(uint64).max, uint256(0)), type(uint64).max);
46
- assertEq(stdMath.delta(type(uint128).max, uint256(0)), type(uint128).max);
47
- assertEq(stdMath.delta(type(uint256).max, uint256(0)), type(uint256).max);
48
-
49
- assertEq(stdMath.delta(1337, uint256(1337)), 0);
50
- assertEq(stdMath.delta(type(uint256).max, type(uint256).max), 0);
51
- assertEq(stdMath.delta(5000, uint256(1250)), 3750);
52
- }
53
-
54
- function testFuzz_GetDelta_Uint(uint256 a, uint256 b) external pure {
55
- uint256 manualDelta = a > b ? a - b : b - a;
56
-
57
- uint256 delta = stdMath.delta(a, b);
58
-
59
- assertEq(delta, manualDelta);
60
- }
61
-
62
- function test_GetDelta_Int() external pure {
63
- assertEq(stdMath.delta(int256(0), int256(0)), 0);
64
- assertEq(stdMath.delta(int256(0), int256(1337)), 1337);
65
- assertEq(stdMath.delta(int256(0), type(int64).max), type(uint64).max >> 1);
66
- assertEq(stdMath.delta(int256(0), type(int128).max), type(uint128).max >> 1);
67
- assertEq(stdMath.delta(int256(0), type(int256).max), type(uint256).max >> 1);
68
-
69
- assertEq(stdMath.delta(0, int256(0)), 0);
70
- assertEq(stdMath.delta(1337, int256(0)), 1337);
71
- assertEq(stdMath.delta(type(int64).max, int256(0)), type(uint64).max >> 1);
72
- assertEq(stdMath.delta(type(int128).max, int256(0)), type(uint128).max >> 1);
73
- assertEq(stdMath.delta(type(int256).max, int256(0)), type(uint256).max >> 1);
74
-
75
- assertEq(stdMath.delta(-0, int256(0)), 0);
76
- assertEq(stdMath.delta(-1337, int256(0)), 1337);
77
- assertEq(stdMath.delta(type(int64).min, int256(0)), (type(uint64).max >> 1) + 1);
78
- assertEq(stdMath.delta(type(int128).min, int256(0)), (type(uint128).max >> 1) + 1);
79
- assertEq(stdMath.delta(type(int256).min, int256(0)), (type(uint256).max >> 1) + 1);
80
-
81
- assertEq(stdMath.delta(int256(0), -0), 0);
82
- assertEq(stdMath.delta(int256(0), -1337), 1337);
83
- assertEq(stdMath.delta(int256(0), type(int64).min), (type(uint64).max >> 1) + 1);
84
- assertEq(stdMath.delta(int256(0), type(int128).min), (type(uint128).max >> 1) + 1);
85
- assertEq(stdMath.delta(int256(0), type(int256).min), (type(uint256).max >> 1) + 1);
86
-
87
- assertEq(stdMath.delta(1337, int256(1337)), 0);
88
- assertEq(stdMath.delta(type(int256).max, type(int256).max), 0);
89
- assertEq(stdMath.delta(type(int256).min, type(int256).min), 0);
90
- assertEq(stdMath.delta(type(int256).min, type(int256).max), type(uint256).max);
91
- assertEq(stdMath.delta(5000, int256(1250)), 3750);
92
- }
93
-
94
- function testFuzz_GetDelta_Int(int256 a, int256 b) external pure {
95
- uint256 absA = getAbs(a);
96
- uint256 absB = getAbs(b);
97
- uint256 absDelta = absA > absB ? absA - absB : absB - absA;
98
-
99
- uint256 manualDelta;
100
- if ((a >= 0 && b >= 0) || (a < 0 && b < 0)) {
101
- manualDelta = absDelta;
102
- }
103
- // (a < 0 && b >= 0) || (a >= 0 && b < 0)
104
- else {
105
- manualDelta = absA + absB;
106
- }
107
-
108
- uint256 delta = stdMath.delta(a, b);
109
-
110
- assertEq(delta, manualDelta);
111
- }
112
-
113
- function test_GetPercentDelta_Uint() external {
114
- StdMathMock stdMathMock = new StdMathMock();
115
-
116
- assertEq(stdMath.percentDelta(uint256(0), uint256(1337)), 1e18);
117
- assertEq(stdMath.percentDelta(uint256(0), type(uint64).max), 1e18);
118
- assertEq(stdMath.percentDelta(uint256(0), type(uint128).max), 1e18);
119
- assertEq(stdMath.percentDelta(uint256(0), type(uint192).max), 1e18);
120
-
121
- assertEq(stdMath.percentDelta(1337, uint256(1337)), 0);
122
- assertEq(stdMath.percentDelta(type(uint192).max, type(uint192).max), 0);
123
- assertEq(stdMath.percentDelta(0, uint256(2500)), 1e18);
124
- assertEq(stdMath.percentDelta(2500, uint256(2500)), 0);
125
- assertEq(stdMath.percentDelta(5000, uint256(2500)), 1e18);
126
- assertEq(stdMath.percentDelta(7500, uint256(2500)), 2e18);
127
-
128
- vm.expectRevert("stdMath percentDelta(uint256,uint256): Divisor is zero");
129
- stdMathMock.exposedPercentDelta(uint256(1), 0);
130
- }
131
-
132
- function testFuzz_GetPercentDelta_Uint(uint192 a, uint192 b) external pure {
133
- vm.assume(b != 0);
134
- uint256 manualDelta = a > b ? a - b : b - a;
135
-
136
- uint256 manualPercentDelta = manualDelta * 1e18 / b;
137
- uint256 percentDelta = stdMath.percentDelta(a, b);
138
-
139
- assertEq(percentDelta, manualPercentDelta);
140
- }
141
-
142
- function test_GetPercentDelta_Int() external {
143
- // We deploy a mock version so we can properly test the revert.
144
- StdMathMock stdMathMock = new StdMathMock();
145
-
146
- assertEq(stdMath.percentDelta(int256(0), int256(1337)), 1e18);
147
- assertEq(stdMath.percentDelta(int256(0), -1337), 1e18);
148
- assertEq(stdMath.percentDelta(int256(0), type(int64).min), 1e18);
149
- assertEq(stdMath.percentDelta(int256(0), type(int128).min), 1e18);
150
- assertEq(stdMath.percentDelta(int256(0), type(int192).min), 1e18);
151
- assertEq(stdMath.percentDelta(int256(0), type(int64).max), 1e18);
152
- assertEq(stdMath.percentDelta(int256(0), type(int128).max), 1e18);
153
- assertEq(stdMath.percentDelta(int256(0), type(int192).max), 1e18);
154
-
155
- assertEq(stdMath.percentDelta(1337, int256(1337)), 0);
156
- assertEq(stdMath.percentDelta(type(int192).max, type(int192).max), 0);
157
- assertEq(stdMath.percentDelta(type(int192).min, type(int192).min), 0);
158
-
159
- assertEq(stdMath.percentDelta(type(int192).min, type(int192).max), 2e18); // rounds the 1 wei diff down
160
- assertEq(stdMath.percentDelta(type(int192).max, type(int192).min), 2e18 - 1); // rounds the 1 wei diff down
161
- assertEq(stdMath.percentDelta(0, int256(2500)), 1e18);
162
- assertEq(stdMath.percentDelta(2500, int256(2500)), 0);
163
- assertEq(stdMath.percentDelta(5000, int256(2500)), 1e18);
164
- assertEq(stdMath.percentDelta(7500, int256(2500)), 2e18);
165
-
166
- vm.expectRevert("stdMath percentDelta(int256,int256): Divisor is zero");
167
- stdMathMock.exposedPercentDelta(int256(1), 0);
168
- }
169
-
170
- function testFuzz_GetPercentDelta_Int(int192 a, int192 b) external pure {
171
- vm.assume(b != 0);
172
- uint256 absA = getAbs(a);
173
- uint256 absB = getAbs(b);
174
- uint256 absDelta = absA > absB ? absA - absB : absB - absA;
175
-
176
- uint256 manualDelta;
177
- if ((a >= 0 && b >= 0) || (a < 0 && b < 0)) {
178
- manualDelta = absDelta;
179
- }
180
- // (a < 0 && b >= 0) || (a >= 0 && b < 0)
181
- else {
182
- manualDelta = absA + absB;
183
- }
184
-
185
- uint256 manualPercentDelta = manualDelta * 1e18 / absB;
186
- uint256 percentDelta = stdMath.percentDelta(a, b);
187
-
188
- assertEq(percentDelta, manualPercentDelta);
189
- }
190
-
191
- /*//////////////////////////////////////////////////////////////////////////
192
- HELPERS
193
- //////////////////////////////////////////////////////////////////////////*/
194
-
195
- function getAbs(int256 a) private pure returns (uint256) {
196
- if (a < 0) {
197
- return a == type(int256).min ? uint256(type(int256).max) + 1 : uint256(-a);
198
- }
199
-
200
- return uint256(a);
201
- }
202
- }