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

Feat/new solver #139

Merged
merged 78 commits into from
Apr 26, 2024
Merged
Changes from 1 commit
Commits
Show all changes
78 commits
Select commit Hold shift + click to select a range
f0b5ebc
feat: LogNormalSolver
0xJepsen Apr 2, 2024
a19b93c
wip: save constant sum
0xJepsen Apr 2, 2024
34249eb
feat: constant sum
0xJepsen Apr 2, 2024
3d98aa4
Add `PairSolver` abstract contract to avoid custom allo/deallo delta …
kinrezC Apr 2, 2024
2a8ceec
Merge branch 'fix/spearbit-audit' into solvers
clemlak Apr 3, 2024
46cbea6
chore: natspec
0xJepsen Apr 3, 2024
793697c
Merge branch 'main' into solvers
0xJepsen Apr 3, 2024
16abc1f
chore: bindings
0xJepsen Apr 3, 2024
0f84472
feat: constant sum pool type
0xJepsen Apr 3, 2024
d6f5df7
feat: geometric mean pool type
0xJepsen Apr 3, 2024
d61cb51
feat: log normal pool type
0xJepsen Apr 3, 2024
e36f731
feat: n token geometric mean
0xJepsen Apr 3, 2024
2710bbc
feat: n token geometric mean
0xJepsen Apr 3, 2024
0db5c15
fmt
0xJepsen Apr 3, 2024
d47157f
return abi encoded allo/deallo data
kinrezC Apr 4, 2024
0056bad
feat: n-token bindings + pool types + tests
0xJepsen Apr 4, 2024
c002d1e
feat: n-token pooltype
0xJepsen Apr 4, 2024
b8c246f
feat: deploy n token geometric mean
0xJepsen Apr 4, 2024
9d051f2
feat: generic allocate and deallocate and update
0xJepsen Apr 5, 2024
6692071
feat: token admin
0xJepsen Apr 8, 2024
02a1117
feat: mint request
0xJepsen Apr 8, 2024
4e207a7
Merge pull request #119 from primitivefinance/fix/post-review
clemlak Apr 11, 2024
469e524
Merge branch 'main' into tokenAdmin
clemlak Apr 11, 2024
e93f4c6
feat: add wip ISolver
clemlak Apr 12, 2024
82ac894
chore: amount is now called delta in allocate and deallocate
clemlak Apr 15, 2024
8424e9b
feat: G3MSolver is now using the ISolver interface
clemlak Apr 15, 2024
11c5bc7
test: update G3M deallocate tests
clemlak Apr 15, 2024
4efe611
test: update G3M allocate tests
clemlak Apr 15, 2024
576d171
test: update G3M swap tests
clemlak Apr 15, 2024
13d14c3
test: fix prepare allocation and deallocation params order for G3M tests
clemlak Apr 15, 2024
c8b4e48
feat: add InvalidTokenIndex error to ISolver
clemlak Apr 15, 2024
b1cf6fe
feat: implement ISolver in ConstantSumSolver
clemlak Apr 15, 2024
5f2177d
chore: remove unused Reserves struct in ConstantSumSolver
clemlak Apr 15, 2024
3a1cb57
test: update tests using ConstantSumSolver
clemlak Apr 15, 2024
ffae452
feat: implement ISolver in LogNormalSolver
clemlak Apr 15, 2024
0d6fa61
test: update LogNormal tests
clemlak Apr 15, 2024
f696cc3
feat: implement ISolver in NTokenG3MSolver
clemlak Apr 15, 2024
7b14363
test: update NTokenG3M tests
clemlak Apr 15, 2024
b9decb5
feat: update ISolver getPrice function
clemlak Apr 15, 2024
134fac7
feat: update getPrice in ConstantSumSolver
clemlak Apr 15, 2024
afff6d7
feat: update G3M getPrice function
clemlak Apr 15, 2024
5589b86
feat: update ISolver interface
clemlak Apr 24, 2024
ff4c0b4
feat: update GeometricMeanSolver
clemlak Apr 24, 2024
9483ccc
chore: add NatSpec to ISolver
clemlak Apr 25, 2024
c3a66ad
chore: add prepareInit and getPoolParams mentions in ISolver
clemlak Apr 25, 2024
a85c1b8
feat: update LogNormalSolver with new ISolver
clemlak Apr 25, 2024
93d74c1
feat: update ConstantSumSolver with new ISolver changes
clemlak Apr 25, 2024
507d0ac
feat: update G3MSolver with new ISolver changes
clemlak Apr 25, 2024
f5eb6b3
feat: use IStrategy interface for startegy getter in ISolver
clemlak Apr 25, 2024
30b2b2a
test: update LogNormal getPrice tests
clemlak Apr 25, 2024
7a5f853
feat: import errors from ISolver
clemlak Apr 26, 2024
a46b6f0
feat: add InvalidDeltasLength error to ISolver
clemlak Apr 26, 2024
0644fee
feat: import errors from ISolver in LogNormalSolver
clemlak Apr 26, 2024
5ddbbcd
feat: rework NTokenG3MSolver to fit with new ISolver
clemlak Apr 26, 2024
74275a2
test: update ConstantSum setup
clemlak Apr 26, 2024
6b9e08c
test: use prepareInit for ConstantSumSolver
clemlak Apr 26, 2024
e2993d7
test: use prepareInit for ConstantSumSolver
clemlak Apr 26, 2024
8239eea
test: import NotEnoughLiquidity from ConstantSumSolver file
clemlak Apr 26, 2024
065ac93
test: cast G3M strategy as IStrategy in G3M test setup
clemlak Apr 26, 2024
88930c2
test: update G3M allocate tests with new solver
clemlak Apr 26, 2024
f5dbe25
test: update G3M deallocate tests with new solver
clemlak Apr 26, 2024
890735e
test: use IStrategy type to init G3MSolver
clemlak Apr 26, 2024
1745f77
test: use prepareInit for LogNormal tests
clemlak Apr 26, 2024
5a2d554
test: use getEstimatedPrice in LogNormal allocate tests
clemlak Apr 26, 2024
85f4c2d
test: use IStrategy type to init LogNormal solver
clemlak Apr 26, 2024
8fdd9de
test: update NTokenG3M tests to new solver updates
clemlak Apr 26, 2024
45b2cb1
feat: use ISolver errors in G3MSolver
clemlak Apr 26, 2024
b7b827d
chore: add NatSpec to ConstantSumSolver
clemlak Apr 26, 2024
16b0e1d
chore: update NatSpec, remove unused imports in ConstantSumSolver
clemlak Apr 26, 2024
fb9b7da
chore: move G3M and NTokenG3M READMEs around
clemlak Apr 26, 2024
a504c53
chore: add NatSpec, remove unused imports in G3MSolver
clemlak Apr 26, 2024
df0e589
feat: add token index check in G3M prepareSwap
clemlak Apr 26, 2024
7bbff79
feat: add NatSpec, remove unused functions, add token index checks
clemlak Apr 26, 2024
30882d3
chore: add NatSpec to NTokenG3MSolver
clemlak Apr 26, 2024
1d86f3b
test: update tests with solver changes
clemlak Apr 26, 2024
a9cd91d
test: fix G3M transfer tokens test
clemlak Apr 26, 2024
60146fa
feat: change rounding direction in NTokenG3MSolver
clemlak Apr 26, 2024
58cae0e
Merge branch 'feat/v0.3.0' into feat/new-solver
clemlak Apr 26, 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
feat: constant sum
  • Loading branch information
0xJepsen committed Apr 2, 2024
commit 34249ebeacc9766ced5ad21aae1132f2ccac53b3
36 changes: 13 additions & 23 deletions src/ConstantSum/ConstantSumSolver.sol
Original file line number Diff line number Diff line change
@@ -142,31 +142,21 @@ contract ConstantSumSolver {
);
}

function getPrice(
uint256 poolId,
uint256 rx,
uint256 L
) public view returns (uint256 price) {
ConstantSumParams memory poolParams = getPoolParams(poolId);
return poolParams.price;
}

function prepareAllocateGivenDeltaX(
// These are same for allocation and deallocation
// delta y is 0
function PrepareAllocationDeltaGivenDeltaX(
uint256 poolId,
uint256 deltaX
) public view returns (bytes memory) {
(uint256[] memory reserves, uint256 liquidity) =
getReservesAndLiquidity(poolId);
(uint256 adjustedReserveX, uint256 adjustedLiquidity) =
computeAllocationGivenX(true, deltaX, reserves[0], liquidity);
uint256 approximatedPrice =
getPrice(poolId, adjustedReserveX, adjustedLiquidity);
// todo
uint256 adjustedReserveY = getNextReserveY(
poolId, adjustedReserveX, adjustedLiquidity, approximatedPrice
);
uint256 deltaY = adjustedReserveY - reserves[1];
uint256 deltaLiquidity = adjustedLiquidity - liquidity;
return abi.encode(deltaY, deltaLiquidity);
ConstantSumParams memory params = getPoolParams(poolId);
uint256 deltaL = deltaX.mulWadDown(params.price);
return abi.encode(deltaX, 0, deltaL);
}

function PrepareAllocationDeltaGivenDeltaY(
// uint256 poolId,
uint256 deltaY
) public pure returns (bytes memory) {
return abi.encode(0, deltaY, deltaY);
}
}
Loading