Skip to content

Commit

Permalink
export title and summary helpers
Browse files Browse the repository at this point in the history
  • Loading branch information
ttl33 committed Jan 24, 2024
1 parent 26f3d50 commit b611cdc
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 16 deletions.
19 changes: 3 additions & 16 deletions v4-client-js/examples/gov_add_new_market.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import Long from 'long';
import { GovAddNewMarketParams, LocalWallet, ProposalStatus } from '../src';
import { CompositeClient } from '../src/clients/composite-client';
import { BECH32_PREFIX, Network } from '../src/clients/constants';
import { sleep } from '../src/lib/utils';
import { getAddNewMarketSummary, getAddNewMarketTitle, sleep } from '../src/lib/utils';
import { DYDX_LOCAL_MNEMONIC } from './constants';

const INITIAL_DEPOSIT_AMOUNT = 10_000_000_000_000; // 10,000 whole native tokens.
Expand Down Expand Up @@ -66,8 +66,8 @@ async function test(): Promise<void> {
const tx = await client.submitGovAddNewMarketProposal(
wallet,
MOCK_DATA,
getTitle(MOCK_DATA.ticker),
getSummary(MOCK_DATA.ticker, MOCK_DATA.delayBlocks),
getAddNewMarketTitle(MOCK_DATA.ticker),
getAddNewMarketSummary(MOCK_DATA.ticker, MOCK_DATA.delayBlocks),
INITIAL_DEPOSIT_AMOUNT,
);
console.log('**Tx**');
Expand All @@ -88,19 +88,6 @@ async function test(): Promise<void> {
console.log(votingProposals);
}

function getTitle(
ticker: string,
): string {
return `Add ${ticker} perpetual market`;
}

function getSummary(
ticker: string,
delayBlocks: number,
): string {
return `Add the x/prices, x/perpetuals and x/clob parameters needed for a ${ticker} perpetual market. Create the market in INITIALIZING status and transition it to ACTIVE status after ${delayBlocks} blocks.`;
}

test().catch((error) => {
console.error(error);
});
24 changes: 24 additions & 0 deletions v4-client-js/src/lib/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -43,3 +43,27 @@ export function clientIdFromString(
export async function sleep(ms: number): Promise<void> {
return new Promise((resolve) => setTimeout(resolve, ms));
}

/**
* Returns a title to use for a gov proposal that adds a new market.
*
* @param ticker ticker symbol for the new market.
* @returns title for the gov proposal.
*/
export function getAddNewMarketTitle(ticker: string): string {
return `Add ${ticker} perpetual market`;
}

/**
* Returns a summary to use for a gov proposal that adds a new market.
*
* @param ticker ticker symbol for the new market.
* @param delayBlocks number of blocks to wait before activating the market.
* @returns summary for the gov proposal.
*/
export function getAddNewMarketSummary(
ticker: string,
delayBlocks: number,
): string {
return `Add the x/prices, x/perpetuals and x/clob parameters needed for a ${ticker} perpetual market. Create the market in INITIALIZING status and transition it to ACTIVE status after ${delayBlocks} blocks.`;
}

0 comments on commit b611cdc

Please sign in to comment.