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

fix: upgrade handler dai amount change #5633

Merged
merged 9 commits into from
Jun 27, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
12 changes: 6 additions & 6 deletions app/upgrades/v16/concentrated_pool_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -22,12 +22,12 @@ const (
)

var (
defaultDaiAmount = sdk.NewInt(7300000000)
defaultDenom0mount = sdk.NewInt(10000000000)
desiredDenom0 = v16.DesiredDenom0
desiredDenom0Coin = sdk.NewCoin(desiredDenom0, defaultDenom0mount)
daiCoin = sdk.NewCoin(v16.DAIIBCDenom, defaultDaiAmount)
usdcCoin = sdk.NewCoin(v16.USDCIBCDenom, defaultDaiAmount)
defaultDaiAmount, _ = sdk.NewIntFromString("73000000000000000000000")
defaultDenom0mount = sdk.NewInt(10000000000)
desiredDenom0 = v16.DesiredDenom0
desiredDenom0Coin = sdk.NewCoin(desiredDenom0, defaultDenom0mount)
daiCoin = sdk.NewCoin(v16.DAIIBCDenom, defaultDaiAmount)
usdcCoin = sdk.NewCoin(v16.USDCIBCDenom, defaultDaiAmount)
)

func (suite *ConcentratedUpgradeTestSuite) SetupTest() {
Expand Down
4 changes: 2 additions & 2 deletions app/upgrades/v16/upgrades.go
Original file line number Diff line number Diff line change
Expand Up @@ -139,8 +139,8 @@ func CreateUpgradeHandler(
return nil, err
}

// Swap one DAI for OSMO from the community pool.
oneDai := sdk.NewCoin(DAIIBCDenom, sdk.NewInt(1000000))
// Swap in a maximum of 10 OSMO for one DAI via the community pool.
oneDai := sdk.NewCoin(DAIIBCDenom, sdk.NewInt(1000000000000000000))
tokenInAmt, err := keepers.GAMMKeeper.SwapExactAmountOut(ctx, communityPoolAddress, daiOsmoPool, DesiredDenom0, sdk.NewInt(10000000), oneDai, sdk.ZeroDec())
if err != nil {
return nil, err
Expand Down
9 changes: 7 additions & 2 deletions app/upgrades/v16/upgrades_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ import (
"github.com/stretchr/testify/suite"
abci "github.com/tendermint/tendermint/abci/types"

"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/osmoutils"
"github.com/osmosis-labs/osmosis/osmoutils/osmoassert"
"github.com/osmosis-labs/osmosis/v16/app/apptesting"
v16 "github.com/osmosis-labs/osmosis/v16/app/upgrades/v16"
cltypes "github.com/osmosis-labs/osmosis/v16/x/concentrated-liquidity/types"
Expand Down Expand Up @@ -103,8 +103,13 @@ func (suite *UpgradeTestSuite) TestUpgrade() {
suite.Require().Equal(v16.DesiredDenom0, concentratedTypePool.GetToken0())
suite.Require().Equal(v16.DAIIBCDenom, concentratedTypePool.GetToken1())

// Allow 0.01% margin of error.
multiplicativeTolerance := osmomath.ErrTolerance{
MultiplicativeTolerance: sdk.MustNewDecFromStr("0.0001"),
}

// Validate that the spot price of the CL pool is what we expect
osmoassert.DecApproxEq(suite.T(), concentratedTypePool.GetCurrentSqrtPrice().Power(2), balancerSpotPrice, sdk.NewDec(4))
suite.Require().Equal(0, multiplicativeTolerance.CompareBigDec(osmomath.BigDecFromSDKDec(concentratedTypePool.GetCurrentSqrtPrice().Power(2)), osmomath.BigDecFromSDKDec(balancerSpotPrice)))

// Validate that link was created.
migrationInfo, err := suite.App.GAMMKeeper.GetAllMigrationInfo(suite.Ctx)
Expand Down
4 changes: 2 additions & 2 deletions tests/e2e/containers/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,10 +24,10 @@ const (
// It should be uploaded to Docker Hub. OSMOSIS_E2E_SKIP_UPGRADE should be unset
// for this functionality to be used.
previousVersionOsmoRepository = "osmolabs/osmosis-dev"
previousVersionOsmoTag = "v15.x-63e3f053-1685053483"
previousVersionOsmoTag = "v15.x-9fa047c2-1687827963"
// Pre-upgrade repo/tag for osmosis initialization (this should be one version below upgradeVersion)
previousVersionInitRepository = "osmolabs/osmosis-e2e-init-chain"
previousVersionInitTag = "v15.x-63e3f053-1685053483"
previousVersionInitTag = "v15.x-9fa047c2-1687827963"
// Hermes repo/version for relayer
relayerRepository = "osmolabs/hermes"
relayerTag = "1.3.0"
Expand Down
9 changes: 8 additions & 1 deletion tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (
transfertypes "github.com/cosmos/ibc-go/v4/modules/apps/transfer/types"
"github.com/iancoleman/orderedmap"

"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/v16/tests/e2e/configurer/chain"
"github.com/osmosis-labs/osmosis/v16/tests/e2e/util"

Expand Down Expand Up @@ -1690,5 +1691,11 @@ func (s *IntegrationTestSuite) TestAConcentratedLiquidity_CanonicalPool_And_Para
balancerDaiOsmoPool := s.updatedCFMMPool(chainANode, config.DaiOsmoPoolIdv16)
expectedSpotPrice, err := balancerDaiOsmoPool.SpotPrice(sdk.Context{}, v16.DAIIBCDenom, v16.DesiredDenom0)
s.Require().NoError(err)
osmoassert.DecApproxEq(s.T(), expectedSpotPrice, concentratedPool.GetCurrentSqrtPrice().Power(2), sdk.NewDecWithPrec(1, 3))

// Allow 0.01% margin of error.
multiplicativeTolerance := osmomath.ErrTolerance{
MultiplicativeTolerance: sdk.MustNewDecFromStr("0.0001"),
}

s.Require().Equal(0, multiplicativeTolerance.CompareBigDec(osmomath.BigDecFromSDKDec(expectedSpotPrice), osmomath.BigDecFromSDKDec(concentratedPool.GetCurrentSqrtPrice().Power(2))))
}
3 changes: 2 additions & 1 deletion tests/e2e/initialization/config.go
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ const (
StakeAmountA = 100000000000
UstBalanceA = 500000000000000
LuncBalanceA = 500000000000000
DaiBalanceA = "100000000000000000000000"
// chainB
ChainBID = "osmo-test-b"
OsmoBalanceB = 500000000000
Expand All @@ -93,7 +94,7 @@ var (
StakeAmountIntB = sdk.NewInt(StakeAmountB)
StakeAmountCoinB = sdk.NewCoin(OsmoDenom, StakeAmountIntB)

DaiOsmoPoolBalances = fmt.Sprintf("%d%s", LuncBalanceA, DaiDenom)
DaiOsmoPoolBalances = fmt.Sprintf("%s%s", DaiBalanceA, DaiDenom)

InitBalanceStrA = fmt.Sprintf("%d%s,%d%s,%d%s,%d%s,%d%s", OsmoBalanceA, OsmoDenom, StakeBalanceA, StakeDenom, IonBalanceA, IonDenom, UstBalanceA, UstIBCDenom, LuncBalanceA, LuncIBCDenom)
InitBalanceStrB = fmt.Sprintf("%d%s,%d%s,%d%s", OsmoBalanceB, OsmoDenom, StakeBalanceB, StakeDenom, IonBalanceB, IonDenom)
Expand Down
2 changes: 1 addition & 1 deletion tests/e2e/scripts/daiosmov16.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"weights": "5ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7,5uosmo",
"initial-deposit": "7300000000ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7,10000000000uosmo",
"initial-deposit": "73000000000000000000000ibc/0CD3A0285E1341859B5E86B6AB7682F023D03E97607CCC1DC95706411D866DF7,10000000000uosmo",
"swap-fee": "0.002",
"exit-fee": "0.00",
"future-governor": ""
Expand Down