Skip to content

Commit

Permalink
Fix CL client to be compatible with recent state of Bigbang (#5200)
Browse files Browse the repository at this point in the history
* Fix cl client to follow most recent state

* Run go mod tidy
  • Loading branch information
mattverse authored and pysel committed Jun 6, 2023
1 parent 96caf36 commit 5f0332e
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 42 deletions.
8 changes: 0 additions & 8 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -936,16 +936,8 @@ github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20230326212251-7a2cf2993434 h1:RetE
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20230326212251-7a2cf2993434/go.mod h1:ss3tUfPTwaa6NsoPZrCR7xOqLqCK0LwoNbc2Q8Zs5/Y=
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3 h1:YlmchqTmlwdWSmrRmXKR+PcU96ntOd8u10vTaTZdcNY=
github.com/osmosis-labs/go-mutesting v0.0.0-20221208041716-b43bcd97b3b3/go.mod h1:lV6KnqXYD/ayTe7310MHtM3I2q8Z6bBfMAi+bhwPYtI=
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230503232557-ba905586c111 h1:1ahWbf9iF9sxDOjxrHWFaBGLE0nWFdpiX1pqObUaJO8=
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230503232557-ba905586c111/go.mod h1:a7lhiXRpn8QJ21OhFpaEnUNErTSIafaYpp02q6uI/Dk=
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230516200639-ee915a97c5c1 h1:NM8H0Nqhy+qvtx0P06Q46GWUPB/qyIUBzXj53Rv25is=
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230516200639-ee915a97c5c1/go.mod h1:a7lhiXRpn8QJ21OhFpaEnUNErTSIafaYpp02q6uI/Dk=
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230516205127-c213fddde069 h1:ZgDrTJ2GCH4CJGbV6rudw4O9rPMAuwWoLVZnG6cUr+A=
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230516205127-c213fddde069/go.mod h1:a7lhiXRpn8QJ21OhFpaEnUNErTSIafaYpp02q6uI/Dk=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230511015306-615fa4fcbe56 h1:27yWLC0uXSatRy8aRn0yinHU+K31bkjBRmNnQUDO0Ks=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230511015306-615fa4fcbe56/go.mod h1:hk/o9/kmTSZmZqwXcSrPuwj/gpRMCqbE/d3vj6teL2A=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230516200639-ee915a97c5c1 h1:hB/CvutX3XhtWec01Esr/GMBS1uE4JGO+PtCUvAgsf8=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230516200639-ee915a97c5c1/go.mod h1:hk/o9/kmTSZmZqwXcSrPuwj/gpRMCqbE/d3vj6teL2A=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230516205127-c213fddde069 h1:9C/n+Nx5rre/AHPMlPsQrk1isgydrCNB68aqer86ygE=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230516205127-c213fddde069/go.mod h1:hk/o9/kmTSZmZqwXcSrPuwj/gpRMCqbE/d3vj6teL2A=
github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304 h1:RIrWLzIiZN5Xd2JOfSOtGZaf6V3qEQYg6EaDTAkMnCo=
Expand Down
49 changes: 21 additions & 28 deletions tests/cl-genesis-positions/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,14 @@ import (
"fmt"
"math/rand"
"os"
"strconv"

"github.com/cosmos/cosmos-sdk/baseapp"
"github.com/cosmos/cosmos-sdk/simapp"
sdk "github.com/cosmos/cosmos-sdk/types"
banktypes "github.com/cosmos/cosmos-sdk/x/bank/types"

"github.com/osmosis-labs/osmosis/osmomath"
"github.com/osmosis-labs/osmosis/osmoutils/accum"
"github.com/osmosis-labs/osmosis/v15/app"
"github.com/osmosis-labs/osmosis/v15/app/apptesting"
cl "github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity"
Expand All @@ -22,20 +22,8 @@ import (
clgenesis "github.com/osmosis-labs/osmosis/v15/x/concentrated-liquidity/types/genesis"
)

// TODO: consider importing from big bang if use of the script
// becomes frequent, requiring frequent updates.
type BigBangPosition struct {
Address string `json:"address"`
JoinTime string `json:"join_time"`
Liquidity string `json:"liquidity"`
LowerTick string `json:"lower_tick"`
PoolID string `json:"pool_id"`
PositionID string `json:"position_id"`
UpperTick string `json:"upper_tick"`
}

type BigBangPositions struct {
Positions []BigBangPosition `json:"positions"`
PositionsData []clgenesis.PositionData `json:"position_data"`
}

type OsmosisApp struct {
Expand Down Expand Up @@ -132,7 +120,7 @@ func ConvertSubgraphToOsmosisGenesis(positionCreatorAddresses []sdk.AccAddress,

numberOfSuccesfulPositions := 0

bigBangPositions := make([]BigBangPosition, 0)
bigBangPositions := make([]clgenesis.PositionData, 0)

for _, uniV3Position := range positions {
lowerPrice := parsePrice(uniV3Position.TickLower.Price0)
Expand All @@ -157,7 +145,7 @@ func ConvertSubgraphToOsmosisGenesis(positionCreatorAddresses []sdk.AccAddress,
}

if lowerTickOsmosis > upperTickOsmosis {
fmt.Printf("lowerTickOsmosis (%s) > upperTickOsmosis (%s), skipping", lowerTickOsmosis, upperTickOsmosis)
fmt.Printf("lowerTickOsmosis (%d) > upperTickOsmosis (%d), skipping", lowerTickOsmosis, upperTickOsmosis)
continue
}

Expand Down Expand Up @@ -194,22 +182,27 @@ func ConvertSubgraphToOsmosisGenesis(positionCreatorAddresses []sdk.AccAddress,
})
if err != nil {
fmt.Printf("\n\n\nWARNING: Failed to create position: %v\n\n\n", err)
fmt.Printf("attempted creation between ticks (%s) and (%s), desired amount 0: (%s), desired amount 1 (%s)\n", lowerTickOsmosis, upperTickOsmosis, depositedAmount0, depositedAmount1)
fmt.Printf("attempted creation between ticks (%d) and (%d), desired amount 0: (%s), desired amount 1 (%s)\n", lowerTickOsmosis, upperTickOsmosis, depositedAmount0, depositedAmount1)
fmt.Println()
continue
}

fmt.Printf("created position with liquidity (%s) between ticks (%s) and (%s)\n", position.LiquidityCreated, lowerTickOsmosis, upperTickOsmosis)
fmt.Printf("created position with liquidity (%s) between ticks (%d) and (%d)\n", position.LiquidityCreated, lowerTickOsmosis, upperTickOsmosis)
numberOfSuccesfulPositions++

bigBangPositions = append(bigBangPositions, BigBangPosition{
Address: randomCreator.String(),
PoolID: strconv.FormatUint(poolId, 10),
JoinTime: osmosis.Ctx.BlockTime().Format("2006-01-02T15:04:05Z"), // ISO 8601
Liquidity: position.LiquidityCreated.String(),
PositionID: strconv.FormatUint(position.PositionId, 10),
LowerTick: strconv.FormatInt(lowerTickOsmosis, 10),
UpperTick: strconv.FormatInt(upperTickOsmosis, 10),
bigBangPositions = append(bigBangPositions, clgenesis.PositionData{
Position: &model.Position{
Address: randomCreator.String(),
PoolId: poolId,
JoinTime: osmosis.Ctx.BlockTime(),
Liquidity: position.LiquidityCreated,
PositionId: position.PositionId,
LowerTick: lowerTickOsmosis,
UpperTick: upperTickOsmosis,
},
FeeAccumRecord: accum.Record{
NumShares: position.LiquidityCreated,
},
})
}

Expand Down Expand Up @@ -277,10 +270,10 @@ func writeStateToDisk(state map[string]json.RawMessage) {
}
}

func writeBigBangPositionsToState(positions []BigBangPosition) {
func writeBigBangPositionsToState(positions []clgenesis.PositionData) {
fmt.Println("writing big bang positions to disk")
positionsBytes, err := json.MarshalIndent(BigBangPositions{
Positions: positions,
PositionsData: positions,
}, "", " ")
if err != nil {
panic(err)
Expand Down
5 changes: 3 additions & 2 deletions tests/cl-genesis-positions/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ require (
github.com/cosmos/cosmos-sdk v0.47.2
github.com/ignite/cli v0.23.0
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230503232557-ba905586c111
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230513050746-13c81d83ef0d
// this commit points to https://github.com/osmosis-labs/osmosis/commit/6e8fbee70d9067b69a900cfc7441b5c4185ec495
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230516091847-6e8fbee70d90
github.com/tendermint/tendermint v0.34.26
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230510161551-8bf252f26bae
)

require (
Expand Down Expand Up @@ -94,7 +96,6 @@ require (
github.com/mitchellh/mapstructure v1.5.0 // indirect
github.com/mtibben/percent v0.2.1 // indirect
github.com/opencontainers/go-digest v1.0.0 // indirect
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230510161551-8bf252f26bae // indirect
github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304 // indirect
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230331072320-5d6f6cfa2627 // indirect
github.com/pelletier/go-toml/v2 v2.0.6 // indirect
Expand Down
8 changes: 4 additions & 4 deletions tests/cl-genesis-positions/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -695,10 +695,10 @@ github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20230326212251-7a2cf2993434 h1:RetE
github.com/osmosis-labs/cosmos-sdk v0.45.1-0.20230326212251-7a2cf2993434/go.mod h1:ss3tUfPTwaa6NsoPZrCR7xOqLqCK0LwoNbc2Q8Zs5/Y=
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230503232557-ba905586c111 h1:1ahWbf9iF9sxDOjxrHWFaBGLE0nWFdpiX1pqObUaJO8=
github.com/osmosis-labs/osmosis/osmomath v0.0.3-dev.0.20230503232557-ba905586c111/go.mod h1:a7lhiXRpn8QJ21OhFpaEnUNErTSIafaYpp02q6uI/Dk=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230510161551-8bf252f26bae h1:I1Cy+GpTPWbVi0lBw9+bS1w42YfQjvXNK9bW4YbHhcs=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230510161551-8bf252f26bae/go.mod h1:hk/o9/kmTSZmZqwXcSrPuwj/gpRMCqbE/d3vj6teL2A=
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230513050746-13c81d83ef0d h1:8lJNaOABRchMwMO+DoHEGrlrBXlhDloms1GKs/ti8HA=
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230513050746-13c81d83ef0d/go.mod h1:mdvXaHvcLi1Loo2sUF1FPV3RynReBpexO3g3ktEWQA4=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230511015306-615fa4fcbe56 h1:27yWLC0uXSatRy8aRn0yinHU+K31bkjBRmNnQUDO0Ks=
github.com/osmosis-labs/osmosis/osmoutils v0.0.0-20230511015306-615fa4fcbe56/go.mod h1:hk/o9/kmTSZmZqwXcSrPuwj/gpRMCqbE/d3vj6teL2A=
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230516091847-6e8fbee70d90 h1:VNzFovCaXgUA76Rb4yRjCSei1TV8gm0pEccvKgQ/4wY=
github.com/osmosis-labs/osmosis/v15 v15.0.0-20230516091847-6e8fbee70d90/go.mod h1:oYQ6+o0MKx9SAjSYvqMh1L1wK2IViXGdcvsHVFjA3Ok=
github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304 h1:RIrWLzIiZN5Xd2JOfSOtGZaf6V3qEQYg6EaDTAkMnCo=
github.com/osmosis-labs/osmosis/x/epochs v0.0.0-20230328024000-175ec88e4304/go.mod h1:yPWoJTj5RKrXKUChAicp+G/4Ni/uVEpp27mi/FF/L9c=
github.com/osmosis-labs/osmosis/x/ibc-hooks v0.0.0-20230331072320-5d6f6cfa2627 h1:A0SwZgp4bmJFbivYJc8mmVhMjrr3EdUZluBYFke11+w=
Expand Down

0 comments on commit 5f0332e

Please sign in to comment.