Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
osmosis
Commits
d9f20316
Unverified
Commit
d9f20316
authored
2 years ago
by
Dev Ojha
Committed by
GitHub
2 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Remove expected liquidity field (#1778)
parent
5f5184a7
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
x/gamm/pool-models/balancer/amm_test.go
+12
-36
x/gamm/pool-models/balancer/amm_test.go
with
12 additions
and
36 deletions
+12
-36
x/gamm/pool-models/balancer/amm_test.go
+
12
-
36
View file @
d9f20316
...
...
@@ -28,13 +28,14 @@ const (
)
var
(
oneTrillion
=
sdk
.
NewInt
(
1e12
)
oneTrillionEvenPoolAssets
=
[]
balancer
.
PoolAsset
{
{
Token
:
sdk
.
New
Int64
Coin
(
"uosmo"
,
1
_000_000_000_000
),
Token
:
sdk
.
NewCoin
(
"uosmo"
,
oneTrillion
),
Weight
:
sdk
.
NewInt
(
100
),
},
{
Token
:
sdk
.
New
Int64
Coin
(
"uatom"
,
1
_000_000_000_000
),
Token
:
sdk
.
NewCoin
(
"uatom"
,
oneTrillion
),
Weight
:
sdk
.
NewInt
(
100
),
},
}
...
...
@@ -78,7 +79,6 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{
poolAssets
:
oneTrillionEvenPoolAssets
,
tokensIn
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
expectShares
:
sdk
.
NewInt
(
2
_499_999_968_750
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
},
{
// Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10:
...
...
@@ -100,7 +100,6 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{
poolAssets
:
oneTrillionEvenPoolAssets
,
tokensIn
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
expectShares
:
sdk
.
NewInt
(
2
_487_500_000_000
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
},
{
// Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10:
...
...
@@ -122,7 +121,6 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{
poolAssets
:
oneTrillionEvenPoolAssets
,
tokensIn
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
expectShares
:
sdk
.
NewInt
(
1
_262_500_000_000
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
},
{
// Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10:
...
...
@@ -153,7 +151,6 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{
},
tokensIn
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
expectShares
:
sdk
.
NewInt
(
321
_875_000_000
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
},
{
// Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10:
...
...
@@ -183,7 +180,6 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{
},
tokensIn
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
expectShares
:
sdk
.
NewInt
(
4
_166_666_649_306
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
},
{
// Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10:
...
...
@@ -213,7 +209,6 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{
},
tokensIn
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
expectShares
:
sdk
.
NewInt
(
4
_159_722_200_000
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
},
{
// Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10:
...
...
@@ -243,7 +238,6 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{
},
tokensIn
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
expectShares
:
sdk
.
NewInt
(
833
_333_315_972
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
},
{
// Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10:
...
...
@@ -273,7 +267,6 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{
},
tokensIn
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
expectShares
:
sdk
.
NewInt
(
819
_444_430_000
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
50
_000
)),
},
{
// Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10:
...
...
@@ -304,7 +297,6 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{
// 156_736 * 3 / 4 = 117552
tokensIn
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
(
156
_736
*
3
)
/
4
)),
expectShares
:
sdk
.
NewIntFromUint64
(
9
_775_731_930_496_140_648
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
(
156
_736
*
3
)
/
4
)),
},
{
// Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10:
...
...
@@ -335,7 +327,6 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{
// 156_736 / 4 * 3 = 117552
tokensIn
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
156
_736
/
4
*
3
)),
expectShares
:
sdk
.
NewIntFromUint64
(
9
_644_655_900_000_000_000
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
156
_736
/
4
*
3
)),
},
{
// Expected output from Balancer paper (https://balancer.fi/whitepaper.pdf) using equation (25) on page 10:
...
...
@@ -365,7 +356,6 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{
},
tokensIn
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
499
_999
)),
expectShares
:
sdk
.
NewIntFromUint64
(
6
_504_099_261_800_144_638
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
499
_999
)),
},
{
// Currently, our Pow approximation function does not work correctly when one tries
...
...
@@ -387,7 +377,6 @@ var calcSingleAssetJoinTestCases = []calcJoinSharesTestCase{
},
tokensIn
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
500
_000
)),
expectShares
:
sdk
.
NewIntFromUint64
(
6
_504_099_261_800_144_638
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
499
_999
)),
expectPanic
:
true
,
},
{
...
...
@@ -740,10 +729,6 @@ func TestCalcJoinPoolShares(t *testing.T) {
// Initial number of pool shares = 100 * 10**18 = 10**20
// Expected increase = liquidity_increase_ratio * initial number of pool shares = (25_000 / 1_000_000_000_000) * 10**20 = 2500000000000.0 = 2.5 * 10**12
expectShares
:
sdk
.
NewInt
(
2.5e12
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
25
_000
),
sdk
.
NewInt64Coin
(
"uatom"
,
25
_000
),
),
},
{
name
:
"swap equal weights with 0.001 swap fee"
,
...
...
@@ -754,10 +739,6 @@ func TestCalcJoinPoolShares(t *testing.T) {
sdk
.
NewInt64Coin
(
"uatom"
,
25
_000
),
),
expectShares
:
sdk
.
NewInt
(
2500000000000
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
25
_000
),
sdk
.
NewInt64Coin
(
"uatom"
,
25
_000
),
),
},
{
// For uosmos and uatom
...
...
@@ -786,10 +767,6 @@ func TestCalcJoinPoolShares(t *testing.T) {
),
expectShares
:
sdk
.
NewInt
(
2.5e12
+
1249999992187
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
25
_000
),
sdk
.
NewInt64Coin
(
"uatom"
,
50
_000
),
),
},
{
// For uosmos and uatom
...
...
@@ -818,10 +795,6 @@ func TestCalcJoinPoolShares(t *testing.T) {
),
expectShares
:
sdk
.
NewInt
(
2.5e12
+
1243750000000
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
25
_000
),
sdk
.
NewInt64Coin
(
"uatom"
,
50
_000
),
),
},
{
// join pool is first done to the extent where the ratio can be preserved, which is 25,000 uosmo and 12,500 uatom.
...
...
@@ -858,12 +831,7 @@ func TestCalcJoinPoolShares(t *testing.T) {
sdk
.
NewInt64Coin
(
"uosmo"
,
25
_000
),
sdk
.
NewInt64Coin
(
"uatom"
,
50
_000
),
),
expectShares
:
sdk
.
NewInt
(
1250000000000
+
609374990000
),
expectLiq
:
sdk
.
NewCoins
(
sdk
.
NewInt64Coin
(
"uosmo"
,
25
_000
),
sdk
.
NewInt64Coin
(
"uatom"
,
50
_000
),
),
},
}
testCases
=
append
(
testCases
,
calcSingleAssetJoinTestCases
...
)
...
...
@@ -885,7 +853,7 @@ func TestCalcJoinPoolShares(t *testing.T) {
}
else
{
require
.
NoError
(
t
,
err
)
assertExpectedSharesErrRatio
(
t
,
tc
.
expectShares
,
shares
)
require
.
Equal
(
t
,
tc
.
expectLiq
,
liquidity
)
assertExpectedLiquidity
(
t
,
tc
.
expectLiq
,
tc
.
tokensIn
,
liquidity
)
}
}
...
...
@@ -1499,3 +1467,11 @@ func assertExpectedSharesErrRatio(t *testing.T, expectedShares, actualShares sdk
errTolerance
.
Compare
(
expectedShares
,
actualShares
),
fmt
.
Sprintf
(
"expectedShares: %s, actualShares: %s"
,
expectedShares
.
String
(),
actualShares
.
String
()))
}
func
assertExpectedLiquidity
(
t
*
testing
.
T
,
expectLiq
,
tokensJoined
,
liquidity
sdk
.
Coins
)
{
if
len
(
expectLiq
)
!=
0
{
require
.
Equal
(
t
,
expectLiq
,
liquidity
)
}
else
{
require
.
Equal
(
t
,
tokensJoined
,
liquidity
)
}
}
This diff is collapsed.
Click to expand it.
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment