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

Spearbit post-audit fixes #89

Merged
merged 183 commits into from
Apr 3, 2024
Merged
Changes from 1 commit
Commits
Show all changes
183 commits
Select commit Hold shift + click to select a range
95b6928
test for LP token balance delta on allocate
kinrezC Mar 18, 2024
8cff3fc
reproduce audit finding
kinrezC Mar 18, 2024
8c675cc
fix liquidity management order of ops
kinrezC Mar 18, 2024
0557365
fix lptoken allocate test assertions
kinrezC Mar 18, 2024
27381ed
fix: optimize duplicate tokens loop check
clemlak Mar 19, 2024
8040789
fix: DFMM init now returns the totalLiquidity of the pool
clemlak Mar 19, 2024
d30b822
fix: check if token is WETH in _transferFrom
clemlak Mar 19, 2024
43b769a
test: use WETH address in _transferFrom tests
clemlak Mar 19, 2024
e1c4eea
feat: avoid stuck ETH in _transferFrom
clemlak Mar 19, 2024
849cac0
test: add test_DFMM_transferFrom_UsesWETH
clemlak Mar 19, 2024
6594c38
test: add test_DFMM_transferFrom_UsesWETHAndRefunds
clemlak Mar 19, 2024
c62ca0e
feat: add balance zero check before refunding ETH in _transferFrom
clemlak Mar 19, 2024
fe89db1
chore: add commit to OZ clone function link
clemlak Mar 19, 2024
bf1102c
feat: add InvalidReserves error
clemlak Mar 19, 2024
ed37a9b
fix: compare reserves and tokens length in init
clemlak Mar 19, 2024
1fe6809
fix: update controller fees minting in swap
clemlak Mar 19, 2024
6d3eeb9
test: update test_DFMM_swap_MintsLPTokensToFeeCollector
clemlak Mar 19, 2024
051f786
fix: typo in _computeDeallocateDeltasGivenDeltaL NatSpec
clemlak Mar 19, 2024
cfd7ddc
fix: add missing NatSpec to Pool and InitParams structs
clemlak Mar 19, 2024
163d7d3
fix: return controller in ConstantSum getPoolParams
clemlak Mar 19, 2024
21031b5
test: add test_ConstantSum_getPoolParams
clemlak Mar 19, 2024
fa84ff1
test: update ConstantSum getPoolParams test
clemlak Mar 19, 2024
88b596b
fix: add missing controller param in ConstantSum init
clemlak Mar 19, 2024
982765a
fix: ConstantSum computeTradingFunction, computeInitialPoolData
clemlak Mar 20, 2024
746cbc1
fix: compute deltaLiquidity in validateAllocate in ConstantSum
clemlak Mar 20, 2024
3f2bd90
fix: override validateDeallocate in ConstantSum
clemlak Mar 20, 2024
f3698b1
fix: remove incorrect functions in ConstantSumMath
clemlak Mar 20, 2024
5fcbba3
test: update test_ConstantSum_allocate_Works
clemlak Mar 20, 2024
94a304d
test: fix ConstantSum init test
clemlak Mar 21, 2024
bd3c680
test: add test_ConstantSum_init_TransfersTokens
clemlak Mar 21, 2024
b30f8b4
test: update test_ConstantSum_init_InitializesPool
clemlak Mar 21, 2024
f82f84c
test: move ConstantSum init test to dedicated test file
clemlak Mar 22, 2024
4f29be9
test: add test_ConstantSum_init_StoresPoolParams
clemlak Mar 22, 2024
9f6da08
test: move ConstantSum no swap fees tests
clemlak Mar 22, 2024
c63ce0c
test: move ConstantSum validateSwap tests to dedicated test file
clemlak Mar 22, 2024
8fbbc8c
test: move ConstantSum swap tests to dedicated test file
clemlak Mar 22, 2024
a946a7c
test: remove old ConstantSumTest
clemlak Mar 22, 2024
1fe5af1
test: add ConstantSum update tests
clemlak Mar 22, 2024
fb90559
test: add test_ConstantSum_getPoolParams_ReturnsPoolParams
clemlak Mar 22, 2024
8d8f8cb
test: add test_ConstantSum_constructor
clemlak Mar 22, 2024
0903141
fix: add InvalidReservesLength error to PairStrategy
clemlak Mar 22, 2024
af73745
fix: check reserves and tokens array length in ConstantSum
clemlak Mar 22, 2024
ca780dc
fix: add pool reserves length check in G3M
clemlak Mar 22, 2024
3bd1bc3
fix: add reserves and tokens array length check in LogNormal
clemlak Mar 22, 2024
6154ecd
fix: remove reserveX and reserveY in G3M init struct
clemlak Mar 22, 2024
63ed521
fix: use mulDiv to compute G3M deltaLiquidity
clemlak Mar 22, 2024
8ab9767
Merge pull request #73 from primitivefinance/fix/lp-token-tracking
clemlak Mar 25, 2024
fba3699
Merge branch 'fix/spearbit-audit' into fix/duplicate-tokens-loop
clemlak Mar 25, 2024
687a0e3
Merge pull request #74 from primitivefinance/fix/duplicate-tokens-loop
clemlak Mar 25, 2024
dbdbe65
Merge branch 'fix/spearbit-audit' into fix/returned-emitted-init-liqu…
clemlak Mar 25, 2024
923b3a7
Merge pull request #75 from primitivefinance/fix/returned-emitted-ini…
clemlak Mar 25, 2024
674f6aa
Merge branch 'fix/spearbit-audit' into fix/update-clone-commit-link
clemlak Mar 25, 2024
c9e4d9f
Merge pull request #77 from primitivefinance/fix/update-clone-commit-…
clemlak Mar 25, 2024
09fc5ec
Merge branch 'fix/spearbit-audit' into fix/compare-tokens-reserves-le…
clemlak Mar 25, 2024
436d805
Merge branch 'fix/spearbit-audit' into fix/controller-swap-fees
clemlak Mar 25, 2024
8d6fffe
Merge pull request #79 from primitivefinance/fix/compare-tokens-reser…
clemlak Mar 25, 2024
45e6364
Merge branch 'fix/spearbit-audit' into fix/natspec-typo-compute-deall…
clemlak Mar 25, 2024
55abf6c
Merge pull request #81 from primitivefinance/fix/natspec-typo-compute…
clemlak Mar 25, 2024
f8a507a
Merge branch 'fix/spearbit-audit' into fix/idfmm-natspec
clemlak Mar 25, 2024
1f70427
Merge pull request #82 from primitivefinance/fix/idfmm-natspec
clemlak Mar 25, 2024
19b012e
Merge branch 'fix/spearbit-audit' into fix/missing-constant-sum-contr…
clemlak Mar 25, 2024
7e930dc
Merge pull request #83 from primitivefinance/fix/missing-constant-sum…
clemlak Mar 25, 2024
43da6f2
Merge branch 'fix/spearbit-audit' into test/constant-sum-tests
clemlak Mar 25, 2024
22967e4
test: fix test_ConstantSum_getPoolParams_ReturnsPoolParams
clemlak Mar 25, 2024
c2fdd68
Merge pull request #84 from primitivefinance/test/constant-sum-tests
clemlak Mar 25, 2024
e3f07d2
feat: G3M init pool data now expects array of reserves
clemlak Mar 25, 2024
03bf4f4
Merge branch 'fix/spearbit-audit' into fix/reserves-length-check
clemlak Mar 25, 2024
7033738
Merge pull request #85 from primitivefinance/fix/reserves-length-check
clemlak Mar 25, 2024
df79f5a
Merge branch 'fix/spearbit-audit' into fix/g3m-init-struct
clemlak Mar 25, 2024
e6496e6
Merge pull request #86 from primitivefinance/fix/g3m-init-struct
clemlak Mar 25, 2024
5242573
Merge branch 'fix/spearbit-audit' into fix/g3m-compute-delta-liquidity
clemlak Mar 25, 2024
c6fa69b
Merge pull request #87 from primitivefinance/fix/g3m-compute-delta-li…
clemlak Mar 25, 2024
c2f0b5f
Merge branch 'fix/spearbit-audit' into fix/transfer-functions
clemlak Mar 25, 2024
6e84fcf
feat: update _transferFrom to use arrays of token and address
clemlak Mar 26, 2024
3e9497c
test: update _transferFrom tests
clemlak Mar 26, 2024
de6d27b
fix: remove unchecked scope for toUint
clemlak Mar 26, 2024
8aebaae
fix: use mulDiv to compute deltas in LogNormalMath
clemlak Mar 26, 2024
d18948c
fix: max values for width and mean in LogNormal
clemlak Mar 26, 2024
5a37380
feat: add mean and witdth max value check in init and update
clemlak Mar 26, 2024
99b0158
chore: remove mention of tau in LogNormalMath
clemlak Mar 26, 2024
ad69860
chore: rename old K to mean
clemlak Mar 26, 2024
3f94e01
fix: add _computeSwapDeltaLiquidity to PairStrategy
clemlak Mar 27, 2024
dad2ff5
feat: add computeSwapDeltaLiquidity to ConstantSumMath
clemlak Mar 27, 2024
869f482
feat: add _computeSwapDeltaLiquidity to ConstantSum
clemlak Mar 27, 2024
bda4065
feat: update _computeSwapDeltaLiquidity in PairStrategy
clemlak Mar 27, 2024
e591dea
chore: add missing NatSpec to _computeSwapDeltaLiquidity
clemlak Mar 27, 2024
28b310c
feat: add computeSwapDeltaLiquidity to G3MMath
clemlak Mar 27, 2024
c9c6f53
feat: add _computeSwapDeltaLiquidity to G3M
clemlak Mar 27, 2024
b707a67
feat: add computeSwapXForYDeltaLiquidity to LogNormalMath
clemlak Mar 27, 2024
e05bcb8
feat: add computeSwapYForXDeltaLiquidity in LogNormalMath
clemlak Mar 27, 2024
4d4b108
feat: add wip _computeSwapDeltaLiquidity to LogNormal
clemlak Mar 27, 2024
8c8ce08
feat: compute price in LogNormal _computeSwapDeltaLiquidity
clemlak Mar 27, 2024
9562053
feat: add _computeSwapDeltaLiquidity to NTokenStrategy
clemlak Mar 27, 2024
74912bc
feat: add _computeSwapDeltaLiquidity to NTokenGeometricMean
clemlak Mar 27, 2024
6a3c914
feat: add computeSwapDeltaLiquidity to NTokenG3MMath
clemlak Mar 27, 2024
a6a9ae3
feat: remove deltaLiquidity from simulateSwap in LogNormalSolver
clemlak Mar 27, 2024
2bec4ff
feat: use same functions to compute swap deltaLiquidity in LogNormal …
clemlak Mar 27, 2024
166cbaf
feat: fix computeSwapDeltaLiquidity formula in G3MMath
clemlak Mar 27, 2024
a984a6d
feat: remove deltaLiquidity parameter in simulateSwap from ConstantSu…
clemlak Mar 27, 2024
ba12fb2
feat: remove deltaLiquidity parameter in simulateSwap from G3MSolver
clemlak Mar 27, 2024
85a1695
feat: remove deltaLiquidity parameter in simulateSwap from NTokenG3MS…
clemlak Mar 27, 2024
fc63b45
feat: fix computeSwapDeltaLiquidity in ConstantSumMath
clemlak Mar 27, 2024
9bc37f2
Merge branch 'fix/spearbit-audit' into fix/swap-delta-liquidity
clemlak Mar 28, 2024
fdadbbd
fix: ConstantSum computeSwapDeltaLiquidity
clemlak Mar 28, 2024
46c1027
feat: simplify _computeSwapDeltaLiquidity in ConstantSum
clemlak Mar 29, 2024
7699e52
feat: use mulDiv in computeSwapDeltaLiquidity for ConstantSum
clemlak Mar 29, 2024
6f12c05
feat: use computeSwapDeltaLiquidity in ConstantSumSolver
clemlak Mar 29, 2024
8fc862a
Merge pull request #76 from primitivefinance/fix/transfer-functions
clemlak Mar 29, 2024
4052863
Merge branch 'fix/spearbit-audit' into fix/controller-swap-fees
clemlak Mar 29, 2024
f182bac
feat: round up pool controller swap fees in DFMM swap
clemlak Mar 29, 2024
1a2a4b4
feat: check controller fee instead of controller address in DFMM swap
clemlak Mar 29, 2024
95744d2
Merge pull request #90 from primitivefinance/fix/remove-touint-unchecked
clemlak Mar 29, 2024
e70b54e
Merge branch 'fix/spearbit-audit' into fix/log-normal-deltas-rounding
clemlak Mar 29, 2024
740d28d
Merge pull request #91 from primitivefinance/fix/log-normal-deltas-ro…
clemlak Mar 29, 2024
dce5f77
feat: add min bounds for LogNormal width and mean
clemlak Mar 29, 2024
eccb50c
Merge branch 'fix/spearbit-audit' into fix/log-normal-bounded-params
clemlak Mar 29, 2024
78ddd8c
fix: add missing closing bracket in LogNormal
clemlak Mar 29, 2024
a8f02f3
Merge branch 'fix/spearbit-audit' into fix/log-normal-fixed-vars
clemlak Mar 29, 2024
6311ddc
Merge pull request #94 from primitivefinance/fix/log-normal-fixed-vars
clemlak Mar 29, 2024
e7a7867
Merge pull request #95 from primitivefinance/fix/swap-delta-liquidity
clemlak Mar 29, 2024
1317937
Merge pull request #97 from primitivefinance/fix/log-normal-trading-f…
clemlak Mar 29, 2024
744e716
fix: remove useless return in decodeFeeUpdate in ConstantSumUtils
clemlak Mar 29, 2024
da8d520
fix: remove useless library using in ConstantSumMath
clemlak Mar 29, 2024
802491b
fix: remove useless library using in ConstantSumSolver
clemlak Mar 29, 2024
5c52003
fix: remove unused wX parameter in InitState in NTokenG3M
clemlak Mar 29, 2024
28315ce
fix: move test constants in StrategyLib into test files
clemlak Mar 29, 2024
a7cf0aa
fix: add deltas array length check in NTokenStrategy
clemlak Mar 29, 2024
26f2f8c
fix: use mulDiv for most operations in StrategyLib
clemlak Mar 29, 2024
0f5fc6f
Merge branch 'fix/spearbit-audit' into fix/strategy-lib-muldiv
clemlak Mar 29, 2024
80bc05e
fix: change rounding in G3M trading function
clemlak Mar 29, 2024
d5b485d
fix: prevent weightX to be 0
clemlak Mar 29, 2024
d4b6fd2
fix: add weightX check in G3M update
clemlak Mar 29, 2024
6d2faab
fix: add missing onlyDFMM modifier in NTokenG3M
clemlak Mar 29, 2024
9605b1f
fix: add remainder to dynamic parameter calculation
clemlak Mar 29, 2024
3c3b1ae
fix: remove totalLiquidity from init in ConstantSum
clemlak Mar 29, 2024
7b8df07
Merge branch 'fix/spearbit-audit' into fix/total-liquidity-init
clemlak Mar 29, 2024
6001c4e
feat: remove L from ConstantSum init pool data
clemlak Mar 29, 2024
276ceb3
feat: reintroduce EPSILON
clemlak Mar 29, 2024
3333eaf
feat: use EPSILON to check invariant in ConstantSum ini
clemlak Mar 29, 2024
e5db5ac
feat: use EPSILON to check invariant in G3M init
clemlak Mar 29, 2024
5a7b2bc
feat: use EPSILON to check invariant in LogNormal init
clemlak Mar 29, 2024
6ecc8e7
feat: use EPSILON to check invariant in NTokenG3M init
clemlak Mar 29, 2024
d9f23f8
Merge branch 'fix/spearbit-audit' into fix/controller-swap-fees
clemlak Mar 29, 2024
c6209b8
fix: fix `SetsValue*` tests to account for instantaneous `lastCompute…
kinrezC Mar 29, 2024
86b6b0b
Merge pull request #80 from primitivefinance/fix/controller-swap-fees
clemlak Apr 1, 2024
af6ac26
Merge branch 'fix/spearbit-audit' into fix/minor-issues
clemlak Apr 1, 2024
62eeb36
Merge pull request #98 from primitivefinance/fix/minor-issues
clemlak Apr 1, 2024
fa3af60
Merge branch 'fix/spearbit-audit' into fix/g3m-weight-check
clemlak Apr 1, 2024
c38bb61
Merge pull request #102 from primitivefinance/fix/g3m-weight-check
clemlak Apr 1, 2024
8cb531c
Merge branch 'fix/spearbit-audit' into fix/g3m-trading-function-rounding
clemlak Apr 1, 2024
274696a
Merge pull request #101 from primitivefinance/fix/g3m-trading-functio…
clemlak Apr 1, 2024
22313f9
Merge branch 'fix/spearbit-audit' into fix/missing-modifier-ntokeng3m
clemlak Apr 1, 2024
7406c0e
Merge pull request #103 from primitivefinance/fix/missing-modifier-nt…
clemlak Apr 1, 2024
49a20c7
Merge pull request #99 from primitivefinance/fix/ntoken-deltas-array-…
clemlak Apr 1, 2024
0f0ce53
fix: remove computeLGivenY in G3MMath
clemlak Apr 1, 2024
2069ef1
Merge branch 'fix/spearbit-audit' into fix/g3m-math
clemlak Apr 1, 2024
8a6788f
fix: remove computeYGivenL
clemlak Apr 1, 2024
8a7fa28
fix: use mulDivUp in computeLGivenX
clemlak Apr 1, 2024
03ea755
fix: delete unused imports in G3MSolver
clemlak Apr 1, 2024
11861e8
fix: remove computeXGivenL in G3MMath
clemlak Apr 1, 2024
1316bc2
fix: remove computeX in G3MMath
clemlak Apr 1, 2024
74719d5
Merge pull request #111 from primitivefinance/fix/ntoken-g3m-rounding
clemlak Apr 1, 2024
f332e3d
Merge branch 'fix/spearbit-audit' into fix/log-normal-bounded-params
clemlak Apr 1, 2024
a6ed4ed
Merge pull request #93 from primitivefinance/fix/log-normal-bounded-p…
clemlak Apr 1, 2024
cda904a
fix: use computeDeltaLiquidity in ConstantSum init
clemlak Apr 1, 2024
cebcdca
Merge branch 'fix/spearbit-audit' into fix/total-liquidity-init
clemlak Apr 1, 2024
8bff684
Merge pull request #107 from primitivefinance/fix/total-liquidity-init
clemlak Apr 1, 2024
1972c1c
Merge branch 'fix/spearbit-audit' into fix/strategy-lib-muldiv
clemlak Apr 1, 2024
aa9e127
test: increase default X reserve for LogNormal pools
clemlak Apr 1, 2024
32a5572
Merge pull request #100 from primitivefinance/fix/strategy-lib-muldiv
clemlak Apr 1, 2024
f597df3
Fix/unused imports ntokeng3m utils (#109)
clemlak Apr 1, 2024
79c7b22
Merge branch 'fix/spearbit-audit' into fix/g3m-math
clemlak Apr 2, 2024
4fd811a
Merge branch 'fix/spearbit-audit' into fix/dynamic-library-rounding
clemlak Apr 2, 2024
bf3c7bf
Merge pull request #106 from primitivefinance/fix/dynamic-library-rou…
clemlak Apr 2, 2024
1b9e6ed
Merge branch 'fix/spearbit-audit' into fix/g3m-math
clemlak Apr 2, 2024
a2f111e
Merge pull request #108 from primitivefinance/fix/g3m-math
clemlak Apr 2, 2024
b0c9f6f
Fix/ntoken accumulator (#105)
clemlak Apr 2, 2024
1b7a4dd
fix: optimize token decimals check in DFMM init (#112)
clemlak Apr 2, 2024
7868687
fix: computeNextLiquidity in G3MMath (#114)
clemlak Apr 2, 2024
af5c660
fix: NatSpec in computeLGivenX in LogNormalMath (#113)
clemlak Apr 2, 2024
89e1a96
fix: rounding direction in computeTradingFunction in LogNormalMath
clemlak Apr 3, 2024
32f9862
Merge pull request #117 from primitivefinance/fix/log-normal-trading-…
clemlak Apr 3, 2024
1a3d7b1
Merge branch 'main' into fix/spearbit-audit
clemlak Apr 3, 2024
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
Prev Previous commit
Next Next commit
fix: remove reserveX and reserveY in G3M init struct
  • Loading branch information
clemlak committed Mar 22, 2024
commit 6154ecd000914d061514402b3a24397d25c04d01
2 changes: 0 additions & 2 deletions src/GeometricMean/GeometricMean.sol
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,6 @@ contract GeometricMean is PairStrategy {
struct InitState {
bool valid;
int256 invariant;
uint256 reserveX;
uint256 reserveY;
address controller;
uint256 swapFee;
uint256 wX;
Expand Down
Loading