Skip to content

Commit

Permalink
Merge branch 'feat/sdk-50' into chore/replace-keeper-methods
Browse files Browse the repository at this point in the history
  • Loading branch information
joldie777 committed May 3, 2024
2 parents 186498e + b5bffe2 commit f02bad1
Show file tree
Hide file tree
Showing 21 changed files with 876 additions and 225 deletions.
6 changes: 6 additions & 0 deletions contracts_tge_migration/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Contracts migrate

This folder contains contracts involved in TGE liquidity migration which versions require to be fixed.

- current_neutron_lockdrop — the pre-migration version of the lockdrop contract;
- current_vesting_lp — the pre-migration version of the vesting LP contract;
Binary file not shown.
Binary file not shown.
Binary file added contracts_tge_migration/current_vesting_lp.wasm
Binary file not shown.
Binary file added contracts_thirdparty/astroport_incentives.wasm
Binary file not shown.
Binary file not shown.
Binary file added contracts_thirdparty/astroport_xastro_token.wasm
Binary file not shown.
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,9 @@
"scripts": {
"test": "yarn test:parallel && yarn test:run_in_band",
"test:parallel": "jest -b src/testcases/parallel",
"test:run_in_band": "yarn test:tge:auction && yarn test:tge:credits && yarn test:interchaintx && yarn test:interchain_kv_query && yarn test:interchain_tx_query_plain && yarn test:tokenomics && yarn test:reserve && yarn test:ibc_hooks && yarn test:float && yarn test:parameters && yarn test:dex_stargate && yarn test:globalfee && yarn test:dex_bindings && yarn test:pob",
"test:run_in_band": "yarn test:tge:auction && yarn test:tge:credits && yarn test:interchaintx && yarn test:interchain_kv_query && yarn test:interchain_tx_query_plain && yarn test:tokenomics && yarn test:reserve && yarn test:ibc_hooks && yarn test:float && yarn test:parameters && yarn test:dex_stargate && yarn test:globalfee && yarn test:dex_bindings && yarn test:pob && yarn test:slinky",
"test:simple": "jest -b src/testcases/parallel/simple",
"test:slinky": "jest -b src/testcases/run_in_band/slinky",
"test:stargate_queries": "jest -b src/testcases/parallel/stargate_queries",
"test:interchaintx": "jest -b src/testcases/run_in_band/interchaintx",
"test:interchain_kv_query": "jest -b src/testcases/run_in_band/interchain_kv_query",
Expand Down Expand Up @@ -45,7 +46,7 @@
"@cosmos-client/core": "^0.47.4",
"@cosmos-client/cosmwasm": "^0.40.3",
"@cosmos-client/ibc": "^1.2.1",
"@neutron-org/neutronjsplus": "neutron-org/neutronjsplus#2e558bfa04d32fe3ed20f893bad40b964925687f",
"@neutron-org/neutronjsplus": "https://github.com/neutron-org/neutronjsplus.git#59ba508e53502e3a8622d62e93b94f0b841bd0c8",
"@types/lodash": "^4.14.182",
"@types/long": "^5.0.0",
"axios": "^0.27.2",
Expand Down
1 change: 1 addition & 0 deletions setup/.tool-versions
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
nodejs 16.20.0
5 changes: 4 additions & 1 deletion setup/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ build-hermes:
build-relayer:
cd $(APP_DIR)/neutron-query-relayer/ && make build-docker

build-all: build-gaia build-neutron build-hermes build-relayer
build-slinky:
@docker buildx build --load --build-context app=$(APP_DIR)/slinky -t skip-mev/slinky-e2e-oracle -f dockerbuilds/Dockerfile.slinky .

build-all: build-gaia build-neutron build-hermes build-relayer build-slinky

start-cosmopark:
@$(COMPOSE) up -d
Expand Down
16 changes: 16 additions & 0 deletions setup/docker-compose.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ services:
- 8090:9090
environment:
- RUN_BACKGROUND=0
- ORACLE_ADDRESS=oracle:8080
networks:
- neutron-testing

Expand Down Expand Up @@ -78,6 +79,21 @@ services:
networks:
- neutron-testing

oracle:
image: skip-mev/slinky-e2e-oracle
entrypoint: [
"slinky",
"--oracle-config-path",
"/oracle/oracle.json",
"--market-config-path",
"/oracle/market.json",
]
ports:
- "8080:8080" # main oracle port
- "8002:8002" # oracle metrics port
networks:
- neutron-testing

volumes:
data:
name: neutron-testing-data
Expand Down
21 changes: 21 additions & 0 deletions setup/dockerbuilds/Dockerfile.slinky
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
FROM golang:1.22-bullseye AS builder

WORKDIR /src/slinky
COPY --from=app go.mod .

RUN go mod download

COPY --from=app . .

RUN make build

FROM ubuntu:rolling
EXPOSE 8080
EXPOSE 8002

COPY --from=builder /src/slinky/build/* /usr/local/bin/
COPY --from=builder /src/slinky/config/local/* /oracle/
RUN apt-get update && apt-get install ca-certificates -y

WORKDIR /usr/local/bin/
ENTRYPOINT ["slinky", "--oracle-config-path", "/oracle/oracle.json", "--market-config-path", "/oracle/market.json"]
59 changes: 59 additions & 0 deletions src/helpers/gaia.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,11 +3,19 @@ import {
MsgDelegate,
MsgUndelegate,
} from '@neutron-org/neutronjsplus/dist/proto/cosmos_sdk/cosmos/staking/v1beta1/tx_pb';
import {
MsgSubmitProposal,
MsgVote,
} from '@neutron-org/neutronjsplus/dist/proto/cosmos_sdk/cosmos/gov/v1beta1/tx_pb';
import {
packAnyMsg,
WalletWrapper,
} from '@neutron-org/neutronjsplus/dist/cosmos';
import Long from 'long';
import {
TextProposal,
VoteOption,
} from '@neutron-org/neutronjsplus/dist/proto/cosmos_sdk/cosmos/gov/v1beta1/gov_pb';

export const msgDelegate = async (
wallet: WalletWrapper,
Expand Down Expand Up @@ -48,5 +56,56 @@ export const msgUndelegate = async (
},
[packAnyMsg('/cosmos.staking.v1beta1.MsgUndelegate', msgUndelegate)],
);

return res?.tx_response;
};

export const msgSubmitProposal = async (
wallet: WalletWrapper,
proposer: string,
amount = '0',
): Promise<BroadcastTx200ResponseTxResponse> => {
const msgSubmitProposal = new MsgSubmitProposal({
proposer,
content: {
typeUrl: '/cosmos.gov.v1beta1.TextProposal',
value: new TextProposal({
title: 'mock',
description: 'mock',
}).toBinary(),
},
initialDeposit: [{ denom: wallet.chain.denom, amount: '10000000' }],
});
const res = await wallet.execTx(
{
gas_limit: Long.fromString('500000'),
amount: [{ denom: wallet.chain.denom, amount: amount }],
},
[packAnyMsg('/cosmos.gov.v1beta1.MsgSubmitProposal', msgSubmitProposal)],
);

return res?.tx_response;
};

export const msgVote = async (
wallet: WalletWrapper,
voter: string,
proposalId: number,
amount = '0',
): Promise<BroadcastTx200ResponseTxResponse> => {
const msgVote = new MsgVote({
voter,
proposalId: BigInt(proposalId),
option: VoteOption.YES,
});

const res = await wallet.execTx(
{
gas_limit: Long.fromString('500000'),
amount: [{ denom: wallet.chain.denom, amount: amount }],
},
[packAnyMsg('/cosmos.gov.v1beta1.MsgVote', msgVote)],
);

return res?.tx_response;
};
2 changes: 1 addition & 1 deletion src/testcases/parallel/overrule.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ import {

const config = require('../../config.json');

describe('Neutron / Subdao', () => {
describe('Neutron / Subdao Overrule', () => {
let testState: TestStateLocalCosmosTestNet;
let neutronChain: CosmosWrapper;
let neutronAccount1: WalletWrapper;
Expand Down
90 changes: 88 additions & 2 deletions src/testcases/parallel/subdao.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -18,10 +18,16 @@ import {
TimelockConfig,
TimelockProposalListResponse,
} from '@neutron-org/neutronjsplus/dist/dao';
import { Wallet } from '@neutron-org/neutronjsplus/dist/types';
import {
SingleChoiceProposal,
Wallet,
} from '@neutron-org/neutronjsplus/dist/types';
import { BroadcastTx200ResponseTxResponse } from '@cosmos-client/core/cjs/openapi/api';
import cosmosclient from '@cosmos-client/core';
import { waitSeconds } from '@neutron-org/neutronjsplus/dist/wait';
import {
getWithAttempts,
waitSeconds,
} from '@neutron-org/neutronjsplus/dist/wait';
import {
paramChangeProposal,
sendProposal,
Expand Down Expand Up @@ -480,6 +486,86 @@ describe('Neutron / Subdao', () => {
});
});

describe('Timelock3: Closed overruled proposal should not prevent execution', () => {
let proposalId: number;
beforeAll(async () => {
proposalId = await subdaoMember1.submitUpdateSubDaoConfigProposal(
{
name: 'dao name after timelock3',
},
'single2',
);

// move proposal to the timelocked state where it can be overruled
const timelockedProp = await subdaoMember1.supportAndExecuteProposal(
proposalId,
'single2',
);

expect(timelockedProp.id).toEqual(proposalId);
expect(timelockedProp.status).toEqual('timelocked');
expect(timelockedProp.msgs).toHaveLength(1);
});

test('close rejected overrule proposal', async () => {
const overruleProposalId = await mainDao.getOverruleProposalId(
subDao.contracts.proposals.single2.pre_propose.timelock!.address,
proposalId,
);

// wait 20 seconds
await waitSeconds(20);

const propOverruledTest =
await mainDao.chain.queryContract<SingleChoiceProposal>(
mainDaoMember.dao.contracts.proposals.overrule?.address,
{
proposal: {
proposal_id: overruleProposalId,
},
},
);
expect(propOverruledTest.proposal.status).toEqual('rejected');

await subdaoMember1.user.executeContract(
mainDaoMember.dao.contracts.proposals.overrule.address,
JSON.stringify({
close: { proposal_id: overruleProposalId },
}),
);

const propOverruledTest2 = await getWithAttempts(
neutronChain.blockWaiter,
async () =>
await mainDao.chain.queryContractWithWait<SingleChoiceProposal>(
mainDaoMember.dao.contracts.proposals.overrule?.address,
{
proposal: {
proposal_id: overruleProposalId,
},
},
),
async (p) => p.proposal.status === 'closed',
5,
);

expect(propOverruledTest2.proposal.status).toEqual('closed');
});

test('execute timelocked: success', async () => {
await waitSeconds(20);
await subdaoMember1.executeTimelockedProposal(proposalId, 'single2');

const timelockedProp = await subDao.getTimelockedProposal(
proposalId,
'single2',
);
expect(timelockedProp.id).toEqual(proposalId);
expect(timelockedProp.status).toEqual('executed');
expect(timelockedProp.msgs).toHaveLength(1);
});
});

describe('Non-timelock typed duration pause proposal: Succeed creation', () => {
let proposalId: number;

Expand Down
2 changes: 1 addition & 1 deletion src/testcases/parallel/tge.vesting_lp_vault.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ import { waitSeconds } from '@neutron-org/neutronjsplus/dist/wait';
const config = require('../../config.json');

// general contract keys used across the tests
const ASTRO_PAIR_CONTRACT_KEY = 'ASTRO_PAIR';
const ASTRO_PAIR_CONTRACT_KEY = 'ASTRO_PAIR_XYK';
const ASTRO_FACTORY_CONTRACT_KEY = 'ASTRO_FACTORY';
const ASTRO_TOKEN_CONTRACT_KEY = 'ASTRO_TOKEN';
const ASTRO_COIN_REGISTRY_CONTRACT_KEY = 'ASTRO_COIN_REGISTRY';
Expand Down
2 changes: 1 addition & 1 deletion src/testcases/run_in_band/dex_bindings.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -548,7 +548,7 @@ describe('Neutron / dex module bindings', () => {
);
console.log(resp);
expect(Number(resp.deposits[0].total_shares)).toBeGreaterThan(0);
expect(Number(resp.deposits[0].pool!.id)).toEqual(0);
expect(Number(resp.deposits[0].pool.id)).toEqual(0);

const respNoPoolData =
await neutronAccount.chain.queryContract<AllUserDepositsResponse>(
Expand Down
22 changes: 21 additions & 1 deletion src/testcases/run_in_band/dex_stargate.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -356,13 +356,33 @@ describe('Neutron / dex module (stargate contract)', () => {
);
});
test('LimitOrderTrancheUserQuery', async () => {
const resTx = await neutronAccount.executeContract(
contractAddress,
JSON.stringify({
place_limit_order: {
receiver: contractAddress,
token_in: 'untrn',
token_out: 'uibcusdc',
tick_index_in_to_out: 1,
amount_in: '10',
order_type: LimitOrderType.JustInTime,
},
}),
);
expect(resTx.code).toEqual(0);
trancheKeyToWithdraw = getEventAttributesFromTx(
{ tx_response: resTx },
'TickUpdate',
['TrancheKey'],
)[0]['TrancheKey'];
const res =
await neutronAccount.chain.queryContract<LimitOrderTrancheUserResponse>(
contractAddress,
{
get_limit_order_tranche_user: {
address: contractAddress,
tranche_key: trancheKeyToWithdraw,
calc_withdrawable_shares: true,
},
},
);
Expand Down Expand Up @@ -447,7 +467,7 @@ describe('Neutron / dex module (stargate contract)', () => {
);
console.log(resp);
expect(Number(resp.deposits[0].total_shares)).toBeGreaterThan(0);
expect(Number(resp.deposits[0].pool!.id)).toEqual(0);
expect(Number(resp.deposits[0].pool.id)).toEqual(0);

const respNoPoolData =
await neutronAccount.chain.queryContract<AllUserDepositsResponse>(
Expand Down
Loading

0 comments on commit f02bad1

Please sign in to comment.