Skip to content

Commit

Permalink
[E2E] Create stableswap and cl pools (#4175)
Browse files Browse the repository at this point in the history
* Create stableswap pools and CL pools

* Refactor code to make sure e2e test upgrading run well

* Update tests/e2e/configurer/chain/commands.go

delete redundant

Co-authored-by: Roman <[email protected]>

* Remove CL pool and change stable token denom

* renome debug bin

* Remove rate limiter

* resolve compile osmosis amd64 for linux error

* resolve conflict

* Update stablepool

Co-authored-by: Ruslan Akhtariev <[email protected]>

* update create function name

Co-authored-by: Ruslan Akhtariev <[email protected]>

* rename create stableswap function

* add rate_limiter.wasm

* Update whitespace error

* add some logic to execute a swap

* update wasm file

* Add stableswap pool test to e2e

* Change TestStableSwapPostUpgrade to try swapping the pool created in post upgrade

* avoid hard code on e2e test

* fix conflict

* Delete go.work.sum

---------

Co-authored-by: Roman <[email protected]>
Co-authored-by: Ruslan Akhtariev <[email protected]>
  • Loading branch information
3 people committed Mar 14, 2023
1 parent 8f98b24 commit c3700e1
Show file tree
Hide file tree
Showing 5 changed files with 70 additions and 15 deletions.
11 changes: 11 additions & 0 deletions tests/e2e/configurer/chain/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,17 @@ func (n *NodeConfig) CreateBalancerPool(poolFile, from string) uint64 {
return poolID
}

func (n *NodeConfig) CreateStableswapPool(poolFile, from string) uint64 {
n.LogActionF("creating stableswap pool from file %s", poolFile)
cmd := []string{"osmosisd", "tx", "gamm", "create-pool", fmt.Sprintf("--pool-file=/osmosis/%s", poolFile), "--pool-type=stableswap", fmt.Sprintf("--from=%s", from)}
_, _, err := n.containerManager.ExecTxCmd(n.t, n.chainId, n.Name, cmd)
require.NoError(n.t, err)

poolID := n.QueryNumPools()
n.LogActionF("successfully created stableswap pool with ID %d", poolID)
return poolID
}

func (n *NodeConfig) CreateConcentratedPool(from, denom1, denom2 string, tickSpacing uint64, exponentAtPriceOne int64, swapFee string) uint64 {
n.LogActionF("creating concentrated pool")

Expand Down
16 changes: 9 additions & 7 deletions tests/e2e/configurer/config/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,13 +28,15 @@ var (
InitialMinExpeditedDeposit = MinExpeditedDepositValue / 4
// The first id of a pool create via CLI before starting an
// upgrade.
// Note: that we create a pool with id 1 via genesis
// in the initialization package. As a result, the first
// pre-upgrade should have id 2.
// This value gets mutated during the pre-upgrade pool
// creation in case more pools are added to genesis
// in the future
PreUpgradePoolId uint64 = 2
PreUpgradePoolId uint64

PreUpgradeStableSwapPoolId uint64

StrideMigrateWallet = "stride-migration"

LockupWallet = "lockup-wallet"

LockupWalletSuperfluid = "lockup-wallet-superfluid"

StableswapWallet = "stableswap-wallet"
)
24 changes: 16 additions & 8 deletions tests/e2e/configurer/upgrade.go
Original file line number Diff line number Diff line change
Expand Up @@ -106,9 +106,6 @@ func (uc *UpgradeConfigurer) ConfigureChain(chainConfig *chain.Config) error {
}

func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {
const lockupWallet = "lockup-wallet"
const lockupWalletSuperfluid = "lockup-wallet-superfluid"

chainA := uc.chainConfigs[0]
chainANode, err := chainA.GetDefaultNode()
if err != nil {
Expand All @@ -128,14 +125,25 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {
config.PreUpgradePoolId = chainANode.CreateBalancerPool("pool1A.json", initialization.ValidatorWalletName)
poolShareDenom := fmt.Sprintf("gamm/pool/%d", config.PreUpgradePoolId)
chainBNode.CreateBalancerPool("pool1B.json", initialization.ValidatorWalletName)
config.PreUpgradeStableSwapPoolId = chainANode.CreateStableswapPool("stablePool.json", initialization.ValidatorWalletName)
chainBNode.CreateStableswapPool("stablePool.json", initialization.ValidatorWalletName)

// enable superfluid assets on chainA
chainA.EnableSuperfluidAsset(poolShareDenom)

// setup wallets and send gamm tokens to these wallets (only chainA)
lockupWalletAddrA, lockupWalletSuperfluidAddrA := chainANode.CreateWallet(lockupWallet), chainANode.CreateWallet(lockupWalletSuperfluid)
chainANode.BankSend("10000000000000000000"+poolShareDenom, chainA.NodeConfigs[0].PublicAddress, lockupWalletAddrA)
chainANode.BankSend("10000000000000000000"+poolShareDenom, chainA.NodeConfigs[0].PublicAddress, lockupWalletSuperfluidAddrA)
// Setup wallets and send tokens to wallets (only chainA)
config.LockupWallet = chainANode.CreateWalletAndFund(config.LockupWallet, []string{
"10000000000000000000" + poolShareDenom,
})
config.LockupWalletSuperfluid = chainANode.CreateWalletAndFund(config.LockupWalletSuperfluid, []string{
"10000000000000000000" + poolShareDenom,
})
config.StableswapWallet = chainANode.CreateWalletAndFund(config.LockupWalletSuperfluid, []string{
"100000stake",
})

// test swap exact amount in for stable swap pool (only chainA)A
chainANode.SwapExactAmountIn("2000stake", "1", fmt.Sprintf("%d", config.PreUpgradeStableSwapPoolId), "uosmo", config.StableswapWallet)

// Upload the rate limiting contract to both chains (as they both will be updated)
uc.t.Logf("Uploading rate limiting contract to both chains")
Expand All @@ -149,7 +157,7 @@ func (uc *UpgradeConfigurer) CreatePreUpgradeState() error {
}

// test lock and add to existing lock for both regular and superfluid lockups (only chainA)
chainA.LockAndAddToExistingLock(sdk.NewInt(1000000000000000000), poolShareDenom, lockupWalletAddrA, lockupWalletSuperfluidAddrA)
chainA.LockAndAddToExistingLock(sdk.NewInt(1000000000000000000), poolShareDenom, config.LockupWallet, config.LockupWalletSuperfluid)

// LP to pools 833, 817, 810
// initialize lp wallets
Expand Down
27 changes: 27 additions & 0 deletions tests/e2e/e2e_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,33 @@ func (s *IntegrationTestSuite) TestConcentratedLiquidity() {

}

func (s *IntegrationTestSuite) TestStableSwapPostUpgrade() {
if s.skipUpgrade {
s.T().Skip("Skipping StableSwapPostUpgrade test")
}

chainA := s.configurer.GetChainConfig(0)
chainANode, err := chainA.GetDefaultNode()
s.Require().NoError(err)

const (
denomA = "stake"
denomB = "uosmo"

minAmountOut = "1"
)

coinAIn, coinBIn := fmt.Sprintf("20000%s", denomA), fmt.Sprintf("1%s", denomB)

chainANode.BankSend(initialization.WalletFeeTokens.String(), chainA.NodeConfigs[0].PublicAddress, config.StableswapWallet)
chainANode.BankSend(coinAIn, chainA.NodeConfigs[0].PublicAddress, config.StableswapWallet)
chainANode.BankSend(coinBIn, chainA.NodeConfigs[0].PublicAddress, config.StableswapWallet)

s.T().Log("performing swaps")
chainANode.SwapExactAmountIn(coinAIn, minAmountOut, fmt.Sprintf("%d", config.PreUpgradeStableSwapPoolId), denomB, config.StableswapWallet)
chainANode.SwapExactAmountIn(coinBIn, minAmountOut, fmt.Sprintf("%d", config.PreUpgradeStableSwapPoolId), denomA, config.StableswapWallet)
}

// TestGeometricTwapMigration tests that the geometric twap record
// migration runs succesfully. It does so by attempting to execute
// the swap on the pool created pre-upgrade. When a pool is created
Expand Down
7 changes: 7 additions & 0 deletions tests/e2e/scripts/stablePool.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"initial-deposit": "1000000stake,1000uosmo",
"swap-fee": "0.005",
"exit-fee": "0",
"future-governor": "",
"scaling-factors": "1000,1"
}

0 comments on commit c3700e1

Please sign in to comment.