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

[E2E] Create stableswap and cl pools #4175

Merged
Merged
Show file tree
Hide file tree
Changes from 25 commits
Commits
Show all changes
26 commits
Select commit Hold shift + click to select a range
3815303
Create stableswap pools and CL pools
phamminh0811 Jan 31, 2023
f34a8b4
Refactor code to make sure e2e test upgrading run well
phamminh0811 Jan 31, 2023
a51508e
Update tests/e2e/configurer/chain/commands.go
phamminh0811 Jan 31, 2023
f51ee8d
Remove CL pool and change stable token denom
phamminh0811 Feb 1, 2023
f387979
renome debug bin
phamminh0811 Feb 1, 2023
3d73423
Merge branch 'minh/create-stableswap-and-cl-pools' of https://github.…
phamminh0811 Feb 1, 2023
f157d7b
Remove rate limiter
phamminh0811 Feb 3, 2023
e1ca8cf
resolve compile osmosis amd64 for linux error
phamminh0811 Feb 3, 2023
3a9b011
Merge branch 'minh/create-stableswap-and-cl-pools' of https://github.…
phamminh0811 Feb 3, 2023
33bb4aa
resolve conflict
phamminh0811 Feb 3, 2023
ab120e7
Update stablepool
phamminh0811 Feb 6, 2023
e5658fa
update create function name
phamminh0811 Feb 6, 2023
ee984e4
rename create stableswap function
phamminh0811 Feb 6, 2023
08f0b2b
add rate_limiter.wasm
phamminh0811 Feb 7, 2023
653a1e4
Update whitespace error
phamminh0811 Feb 7, 2023
7676830
add some logic to execute a swap
phamminh0811 Feb 10, 2023
71a5904
update wasm file
phamminh0811 Feb 10, 2023
05e4b76
fix conflict main
phamminh0811 Feb 20, 2023
67cd658
Add stableswap pool test to e2e
phamminh0811 Feb 20, 2023
e1ab28e
Change TestStableSwapPostUpgrade to try swapping the pool created in …
phamminh0811 Feb 22, 2023
b6ad44e
merge stable pool migrate
phamminh0811 Feb 27, 2023
2ca5dd1
avoid hard code on e2e test
phamminh0811 Feb 27, 2023
5dfcc36
fix conflict
phamminh0811 Feb 28, 2023
47468ed
fix conflict
phamminh0811 Feb 28, 2023
a8fb39a
resolve conflict main
phamminh0811 Mar 9, 2023
eaec8fb
Delete go.work.sum
phamminh0811 Mar 11, 2023
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
2,205 changes: 2,035 additions & 170 deletions go.work.sum

Large diffs are not rendered by default.

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",
phamminh0811 marked this conversation as resolved.
Show resolved Hide resolved
"swap-fee": "0.005",
"exit-fee": "0",
"future-governor": "",
"scaling-factors": "1000,1"
}