Skip to content

Commit

Permalink
Merge remote-tracking branch 'upstream/main' into eric/bump-1.0.8
Browse files Browse the repository at this point in the history
  • Loading branch information
Eric-Warehime committed Aug 14, 2024
2 parents 809f1b9 + 246ebc5 commit 3f6d9d4
Show file tree
Hide file tree
Showing 31 changed files with 322 additions and 242 deletions.
3 changes: 2 additions & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,8 @@ on:

jobs:
docker:
runs-on: self-hosted
runs-on:
group: Neutron-Core
env:
DOCKER_BUILDKIT: 1

Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/lint.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ permissions:
jobs:
golangci:
name: lint
runs-on: self-hosted
runs-on: ubuntu-latest
steps:
- uses: actions/setup-go@v4
with:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ on: [push, pull_request]
jobs:
tests:
name: Test
runs-on: self-hosted
runs-on: ubuntu-latest
steps:
- name: Set up Go 1.22
uses: actions/setup-go@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/test_trigger.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
jobs:
dispatch:
name: Dispatch Tests Workflow
runs-on: self-hosted
runs-on: ubuntu-latest
steps:
- name: Evaluate PR Merged Status and Labels
run: |
Expand Down
7 changes: 7 additions & 0 deletions docs/static/swagger.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15860,6 +15860,7 @@ definitions:
- GOOD_TIL_TIME
type: string
shares_cancelled:
title: 'TODO: remove this in next release. It is no longer used'
type: string
shares_owned:
type: string
Expand Down Expand Up @@ -16193,6 +16194,7 @@ definitions:
- GOOD_TIL_TIME
type: string
shares_cancelled:
title: 'TODO: remove this in next release. It is no longer used'
type: string
shares_owned:
type: string
Expand Down Expand Up @@ -16256,6 +16258,7 @@ definitions:
- GOOD_TIL_TIME
type: string
shares_cancelled:
title: 'TODO: remove this in next release. It is no longer used'
type: string
shares_owned:
type: string
Expand Down Expand Up @@ -16794,6 +16797,7 @@ definitions:
- GOOD_TIL_TIME
type: string
shares_cancelled:
title: 'TODO: remove this in next release. It is no longer used'
type: string
shares_owned:
type: string
Expand Down Expand Up @@ -41155,6 +41159,7 @@ paths:
- GOOD_TIL_TIME
type: string
shares_cancelled:
title: 'TODO: remove this in next release. It is no longer used'
type: string
shares_owned:
type: string
Expand Down Expand Up @@ -41263,6 +41268,7 @@ paths:
- GOOD_TIL_TIME
type: string
shares_cancelled:
title: 'TODO: remove this in next release. It is no longer used'
type: string
shares_owned:
type: string
Expand Down Expand Up @@ -42488,6 +42494,7 @@ paths:
- GOOD_TIL_TIME
type: string
shares_cancelled:
title: 'TODO: remove this in next release. It is no longer used'
type: string
shares_owned:
type: string
Expand Down
6 changes: 3 additions & 3 deletions go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -14,8 +14,8 @@ require (
cosmossdk.io/x/tx v0.13.4
cosmossdk.io/x/upgrade v0.1.4
github.com/CosmWasm/wasmd v0.51.0
github.com/CosmWasm/wasmvm/v2 v2.0.1
github.com/cometbft/cometbft v0.38.10
github.com/CosmWasm/wasmvm/v2 v2.0.2
github.com/cometbft/cometbft v0.38.11
github.com/cosmos/admin-module/v2 v2.0.0-20240430142959-8b3328d1b1a2
github.com/cosmos/cosmos-db v1.0.2
github.com/cosmos/cosmos-proto v1.0.0-beta.5
Expand Down Expand Up @@ -254,7 +254,7 @@ require (

replace (
github.com/99designs/keyring => github.com/cosmos/keyring v1.2.0
github.com/CosmWasm/wasmd => github.com/neutron-org/wasmd v0.51.0
github.com/CosmWasm/wasmd => github.com/neutron-org/wasmd v0.51.1
github.com/cosmos/admin-module/v2 => github.com/neutron-org/admin-module/v2 v2.0.0
github.com/cosmos/cosmos-sdk => github.com/neutron-org/cosmos-sdk v0.50.8-neutron
// explicitely replace iavl to v1.2.0 cause sometimes go mod tidy uses not right version
Expand Down
12 changes: 6 additions & 6 deletions go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -227,8 +227,8 @@ github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161 h1:L/gRVlceqvL25
github.com/Azure/go-ansiterm v0.0.0-20230124172434-306776ec8161/go.mod h1:xomTg63KZ2rFqZQzSB4Vz2SUXa1BpHTVz9L5PTmPC4E=
github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU=
github.com/BurntSushi/xgb v0.0.0-20160522181843-27f122750802/go.mod h1:IVnqGOEym/WlBOVXweHU+Q+/VP0lqqI8lqeDx9IjBqo=
github.com/CosmWasm/wasmvm/v2 v2.0.1 h1:0YCQ7MKGNri7NFeRp75erPJXrqyCtH4gdc9jMstyMzk=
github.com/CosmWasm/wasmvm/v2 v2.0.1/go.mod h1:su9lg5qLr7adV95eOfzjZWkGiky8WNaNIHDr7Fpu7Ck=
github.com/CosmWasm/wasmvm/v2 v2.0.2 h1:UuIqCfpFEyh1UWFzCwKzS5m1fQj7EstGeRCwb8NqMyA=
github.com/CosmWasm/wasmvm/v2 v2.0.2/go.mod h1:su9lg5qLr7adV95eOfzjZWkGiky8WNaNIHDr7Fpu7Ck=
github.com/DataDog/datadog-go v3.2.0+incompatible h1:qSG2N4FghB1He/r2mFrWKCaL7dXCilEuNEeAn20fdD4=
github.com/DataDog/datadog-go v3.2.0+incompatible/go.mod h1:LButxg5PwREeZtORoXG3tL4fMGNddJ+vMq1mwgfaqoQ=
github.com/DataDog/zstd v1.5.5 h1:oWf5W7GtOLgp6bciQYDmhHHjdhYkALu6S/5Ni9ZgSvQ=
Expand Down Expand Up @@ -364,8 +364,8 @@ github.com/cockroachdb/redact v1.1.5/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZ
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06 h1:zuQyyAKVxetITBuuhv3BI9cMrmStnpT18zmgmTxunpo=
github.com/cockroachdb/tokenbucket v0.0.0-20230807174530-cc333fc44b06/go.mod h1:7nc4anLGjupUW/PeY5qiNYsdNXj7zopG+eqsS7To5IQ=
github.com/codahale/hdrhistogram v0.0.0-20161010025455-3a0bb77429bd/go.mod h1:sE/e/2PUdi/liOCUjSTXgM1o87ZssimdTWN964YiIeI=
github.com/cometbft/cometbft v0.38.10 h1:2ePuglchT+j0Iao+cfmt/nw5U7K2lnGDzXSUPGVdXaU=
github.com/cometbft/cometbft v0.38.10/go.mod h1:jHPx9vQpWzPHEAiYI/7EDKaB1NXhK6o3SArrrY8ExKc=
github.com/cometbft/cometbft v0.38.11 h1:6bNDUB8/xq4uYonYwIfGc9OqK1ZH4NkdaMmR1LZIJqk=
github.com/cometbft/cometbft v0.38.11/go.mod h1:jHPx9vQpWzPHEAiYI/7EDKaB1NXhK6o3SArrrY8ExKc=
github.com/cometbft/cometbft-db v0.12.0 h1:v77/z0VyfSU7k682IzZeZPFZrQAKiQwkqGN0QzAjMi0=
github.com/cometbft/cometbft-db v0.12.0/go.mod h1:aX2NbCrjNVd2ZajYxt1BsiFf/Z+TQ2MN0VxdicheYuw=
github.com/consensys/bavard v0.1.13 h1:oLhMLOFGTLdlda/kma4VOJazblc7IM5y5QPd2A/YjhQ=
Expand Down Expand Up @@ -936,8 +936,8 @@ github.com/neutron-org/admin-module/v2 v2.0.0 h1:MlkSc1821sQ+G5/cYOajuqZ5/lM53xT
github.com/neutron-org/admin-module/v2 v2.0.0/go.mod h1:RfOyabXsdJ5btcOKyKPZDYiZhtuKFubbJMOb8EJZtvA=
github.com/neutron-org/cosmos-sdk v0.50.8-neutron h1:L+4obYi/KkkmS05gBlXNF+FhipHYTl0iO3EkmpMBXkE=
github.com/neutron-org/cosmos-sdk v0.50.8-neutron/go.mod h1:Zb+DgHtiByNwgj71IlJBXwOq6dLhtyAq3AgqpXm/jHo=
github.com/neutron-org/wasmd v0.51.0 h1:OBp5aG8xeEz199Crepwb3q6YtuJVL0sudsD7F2oyyfs=
github.com/neutron-org/wasmd v0.51.0/go.mod h1:7TSaj5HoolghujuVWeExqmcUKgpcYWEySGLSODbnnwY=
github.com/neutron-org/wasmd v0.51.1 h1:EXfu8BFJDZY3SRF2O3C3iTPa8fUDGBcqxET89jWXSfA=
github.com/neutron-org/wasmd v0.51.1/go.mod h1:7TSaj5HoolghujuVWeExqmcUKgpcYWEySGLSODbnnwY=
github.com/niemeyer/pretty v0.0.0-20200227124842-a10e7caefd8e/go.mod h1:zD1mROLANZcx1PVRCS0qkT7pwLkGfwJo4zjcN/Tysno=
github.com/nkovacs/streamquote v1.0.0/go.mod h1:BN+NaZ2CmdKqUuTUXUEm9j95B2TRbpOWpxbJYzzgUsc=
github.com/nxadm/tail v1.4.4/go.mod h1:kenIhsEOeOJmVchQTgglprH7qJGnHDVpk1VPCcaMI8A=
Expand Down
3 changes: 2 additions & 1 deletion network/hermes/config.toml
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,5 @@ clock_drift = '5s'
max_block_time = '10s'
trusting_period = '14days'
trust_threshold = { numerator = '1', denominator = '3' }
address_type = { derivation = 'cosmos' }
address_type = { derivation = 'cosmos' }
dynamic_gas_price = { enabled = false, multiplier = 1.1, max = 0.6 }
13 changes: 13 additions & 0 deletions network/init-gaiad.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,8 +8,21 @@ CHAIN_DIR="$BASE_DIR/$CHAINID"

STAKEDENOM=${STAKEDENOM:-stake}

function set_genesis_param_jq() {
param_path=$1
param_value=$2
jq "${param_path} = ${param_value}" > tmp_genesis_file.json < "$CHAIN_DIR/config/genesis.json" && mv tmp_genesis_file.json "$CHAIN_DIR/config/genesis.json"
}

echo "Creating and collecting gentx..."
$BINARY genesis gentx val1 "7000000000$STAKEDENOM" --home "$CHAIN_DIR" --chain-id "$CHAINID" --keyring-backend test
$BINARY genesis collect-gentxs --home "$CHAIN_DIR"

sed -i -e 's/\*/\/cosmos.bank.v1beta1.MsgSend\", \"\/cosmos.staking.v1beta1.MsgDelegate\", \"\/cosmos.staking.v1beta1.MsgUndelegate/g' "$CHAIN_DIR/config/genesis.json"

set_genesis_param_jq ".app_state.feemarket.params.enabled" "false" # feemarket
set_genesis_param_jq ".app_state.feemarket.params.fee_denom" "\"uatom\"" # feemarket
set_genesis_param_jq ".app_state.feemarket.state.base_gas_price" "\"0.0025\"" # feemarket
set_genesis_param_jq ".app_state.feemarket.params.min_base_gas_price" "\"0.0025\"" # feemarket

set_genesis_param_jq ".app_state.ibc.client_genesis.params.allowed_clients" "[\"*\"]" # ibc
1 change: 1 addition & 0 deletions proto/neutron/dex/limit_order_tranche_user.proto
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ message LimitOrderTrancheUser {
(gogoproto.nullable) = false,
(gogoproto.jsontag) = "shares_withdrawn"
];
// TODO: remove this in next release. It is no longer used
string shares_cancelled = 7 [
(gogoproto.moretags) = "yaml:\"shares_cancelled\"",
(gogoproto.customtype) = "cosmossdk.io/math.Int",
Expand Down
3 changes: 2 additions & 1 deletion proto/neutron/interchainqueries/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ message MsgSubmitQueryResult {

// is the IBC client ID for an IBC connection between Neutron chain and target
// chain (where the result was obtained from)
string client_id = 3;
// Deprecated: populating this field does not make any affect
string client_id = 3 [deprecated = true];
QueryResult result = 4;
}

Expand Down
2 changes: 0 additions & 2 deletions x/dex/genesis_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,6 @@ func TestGenesis(t *testing.T) {
Address: "fakeAddr",
SharesOwned: math.NewInt(10),
SharesWithdrawn: math.NewInt(0),
SharesCancelled: math.NewInt(0),
},
{
TradePairId: &types.TradePairID{
Expand All @@ -39,7 +38,6 @@ func TestGenesis(t *testing.T) {
Address: "fakeAddr",
SharesOwned: math.NewInt(10),
SharesWithdrawn: math.NewInt(0),
SharesCancelled: math.NewInt(0),
},
},
TickLiquidityList: []*types.TickLiquidity{
Expand Down
34 changes: 22 additions & 12 deletions x/dex/keeper/cancel_limit_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -17,16 +17,17 @@ func (k Keeper) CancelLimitOrderCore(
) error {
ctx := sdk.UnwrapSDKContext(goCtx)

coinOut, tradePairID, err := k.ExecuteCancelLimitOrder(ctx, trancheKey, callerAddr)
makerCoinOut, takerCoinOut, tradePairID, err := k.ExecuteCancelLimitOrder(ctx, trancheKey, callerAddr)
if err != nil {
return err
}

coinsOut := sdk.NewCoins(makerCoinOut, takerCoinOut)
err = k.bankKeeper.SendCoinsFromModuleToAccount(
ctx,
types.ModuleName,
callerAddr,
sdk.Coins{coinOut},
coinsOut,
)
if err != nil {
return err
Expand All @@ -40,7 +41,8 @@ func (k Keeper) CancelLimitOrderCore(
pairID.Token1,
tradePairID.MakerDenom,
tradePairID.TakerDenom,
coinOut.Amount,
makerCoinOut.Amount,
takerCoinOut.Amount,
trancheKey,
))

Expand All @@ -54,10 +56,10 @@ func (k Keeper) ExecuteCancelLimitOrder(
ctx sdk.Context,
trancheKey string,
callerAddr sdk.AccAddress,
) (coinOut sdk.Coin, tradePairID *types.TradePairID, error error) {
) (makerCoinOut, takerCoinOut sdk.Coin, tradePairID *types.TradePairID, error error) {
trancheUser, found := k.GetLimitOrderTrancheUser(ctx, callerAddr.String(), trancheKey)
if !found {
return sdk.Coin{}, nil, types.ErrActiveLimitOrderNotFound
return sdk.Coin{}, sdk.Coin{}, nil, types.ErrActiveLimitOrderNotFound
}

tradePairID, tickIndex := trancheUser.TradePairId, trancheUser.TickIndexTakerToMaker
Expand All @@ -70,14 +72,20 @@ func (k Keeper) ExecuteCancelLimitOrder(
},
)
if tranche == nil {
return sdk.Coin{}, nil, types.ErrActiveLimitOrderNotFound
return sdk.Coin{}, sdk.Coin{}, nil, types.ErrActiveLimitOrderNotFound
}

amountToCancel := tranche.RemoveTokenIn(trancheUser)
trancheUser.SharesCancelled = trancheUser.SharesCancelled.Add(amountToCancel)
makerAmountToReturn := tranche.RemoveTokenIn(trancheUser)
_, takerAmountOut := tranche.Withdraw(trancheUser)

if !amountToCancel.IsPositive() {
return sdk.Coin{}, nil, sdkerrors.Wrapf(types.ErrCancelEmptyLimitOrder, "%s", tranche.Key.TrancheKey)
trancheUser.SharesWithdrawn = trancheUser.SharesOwned

// Remove the canceled shares from the limitOrder
tranche.TotalMakerDenom = tranche.TotalMakerDenom.Sub(trancheUser.SharesOwned)
tranche.TotalTakerDenom = tranche.TotalTakerDenom.Sub(takerAmountOut)

if !makerAmountToReturn.IsPositive() && !takerAmountOut.IsPositive() {
return sdk.Coin{}, sdk.Coin{}, nil, sdkerrors.Wrapf(types.ErrCancelEmptyLimitOrder, "%s", tranche.Key.TrancheKey)
}

k.SaveTrancheUser(ctx, trancheUser)
Expand All @@ -86,7 +94,9 @@ func (k Keeper) ExecuteCancelLimitOrder(
if trancheUser.OrderType.HasExpiration() {
k.RemoveLimitOrderExpiration(ctx, *tranche.ExpirationTime, tranche.Key.KeyMarshal())
}
coinOut = sdk.NewCoin(tradePairID.MakerDenom, amountToCancel)

return coinOut, tradePairID, nil
makerCoinOut = sdk.NewCoin(tradePairID.MakerDenom, makerAmountToReturn)
takerCoinOut = sdk.NewCoin(tradePairID.TakerDenom, takerAmountOut)

return makerCoinOut, takerCoinOut, tradePairID, nil
}
Loading

0 comments on commit 3f6d9d4

Please sign in to comment.