Skip to content
GitLab
Explore
Projects
Groups
Snippets
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Register
Sign in
Toggle navigation
Menu
Open sidebar
Tiger Ton
osmosis
Commits
5debecd3
Unverified
Commit
5debecd3
authored
2 years ago
by
Hieu Vu
Committed by
GitHub
2 years ago
Browse files
Options
Download
Email Patches
Plain Diff
Revert fixed gas cost for v12 (#2808)
* remove fix gas constant & related test * format
parent
8dfd9e27
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
x/gamm/keeper/swap_test.go
+0
-8
x/gamm/keeper/swap_test.go
x/gamm/pool-models/balancer/pool.go
+0
-2
x/gamm/pool-models/balancer/pool.go
x/gamm/types/constants.go
+1
-2
x/gamm/types/constants.go
with
1 addition
and
12 deletions
+1
-12
x/gamm/keeper/swap_test.go
+
0
-
8
View file @
5debecd3
...
...
@@ -97,13 +97,9 @@ func (suite *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountIn() {
spotPriceBefore
,
err
:=
keeper
.
CalculateSpotPrice
(
ctx
,
poolId
,
test
.
param
.
tokenIn
.
Denom
,
test
.
param
.
tokenOutDenom
)
suite
.
NoError
(
err
,
"test: %v"
,
test
.
name
)
prevGasConsumed
:=
suite
.
Ctx
.
GasMeter
()
.
GasConsumed
()
tokenOutAmount
,
err
:=
keeper
.
SwapExactAmountIn
(
ctx
,
suite
.
TestAccs
[
0
],
poolId
,
test
.
param
.
tokenIn
,
test
.
param
.
tokenOutDenom
,
test
.
param
.
tokenOutMinAmount
)
suite
.
NoError
(
err
,
"test: %v"
,
test
.
name
)
suite
.
True
(
tokenOutAmount
.
Equal
(
test
.
param
.
expectedTokenOut
),
"test: %v"
,
test
.
name
)
gasConsumedForSwap
:=
suite
.
Ctx
.
GasMeter
()
.
GasConsumed
()
-
prevGasConsumed
// We consume `types.GasFeeForSwap` directly, so the extra I/O operation mean we end up consuming more.
suite
.
Assert
()
.
Greater
(
gasConsumedForSwap
,
uint64
(
types
.
BalancerGasFeeForSwap
))
suite
.
AssertEventEmitted
(
ctx
,
types
.
TypeEvtTokenSwapped
,
1
)
...
...
@@ -205,15 +201,11 @@ func (suite *KeeperTestSuite) TestBalancerPoolSimpleSwapExactAmountOut() {
spotPriceBefore
,
err
:=
keeper
.
CalculateSpotPrice
(
ctx
,
poolId
,
test
.
param
.
tokenInDenom
,
test
.
param
.
tokenOut
.
Denom
)
suite
.
NoError
(
err
,
"test: %v"
,
test
.
name
)
prevGasConsumed
:=
suite
.
Ctx
.
GasMeter
()
.
GasConsumed
()
tokenInAmount
,
err
:=
keeper
.
SwapExactAmountOut
(
ctx
,
suite
.
TestAccs
[
0
],
poolId
,
test
.
param
.
tokenInDenom
,
test
.
param
.
tokenInMaxAmount
,
test
.
param
.
tokenOut
)
suite
.
NoError
(
err
,
"test: %v"
,
test
.
name
)
suite
.
True
(
tokenInAmount
.
Equal
(
test
.
param
.
expectedTokenInAmount
),
"test: %v
\n
expect_eq actual: %s, expected: %s"
,
test
.
name
,
tokenInAmount
,
test
.
param
.
expectedTokenInAmount
)
gasConsumedForSwap
:=
suite
.
Ctx
.
GasMeter
()
.
GasConsumed
()
-
prevGasConsumed
// We consume `types.GasFeeForSwap` directly, so the extra I/O operation mean we end up consuming more.
suite
.
Assert
()
.
Greater
(
gasConsumedForSwap
,
uint64
(
types
.
BalancerGasFeeForSwap
))
suite
.
AssertEventEmitted
(
ctx
,
types
.
TypeEvtTokenSwapped
,
1
)
...
...
This diff is collapsed.
Click to expand it.
x/gamm/pool-models/balancer/pool.go
+
0
-
2
View file @
5debecd3
...
...
@@ -583,8 +583,6 @@ func (p *Pool) SwapInAmtGivenOut(
// ApplySwap.
func
(
p
*
Pool
)
applySwap
(
ctx
sdk
.
Context
,
tokensIn
sdk
.
Coins
,
tokensOut
sdk
.
Coins
)
error
{
// Fixed gas consumption per swap to prevent spam
ctx
.
GasMeter
()
.
ConsumeGas
(
types
.
BalancerGasFeeForSwap
,
"balancer swap computation"
)
// Also ensures that len(tokensIn) = 1 = len(tokensOut)
inPoolAsset
,
outPoolAsset
,
err
:=
p
.
parsePoolAssetsCoins
(
tokensIn
,
tokensOut
)
if
err
!=
nil
{
...
...
This diff is collapsed.
Click to expand it.
x/gamm/types/constants.go
+
1
-
2
View file @
5debecd3
...
...
@@ -11,8 +11,7 @@ const (
OneShareExponent
=
18
// Raise 10 to the power of SigFigsExponent to determine number of significant figures.
// i.e. SigFigExponent = 8 is 10^8 which is 100000000. This gives 8 significant figures.
SigFigsExponent
=
8
BalancerGasFeeForSwap
=
10
_000
SigFigsExponent
=
8
)
var
(
...
...
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
Menu
Explore
Projects
Groups
Snippets