Skip to content

Commit

Permalink
feat: Add Create Market Permissionless transaction (#267)
Browse files Browse the repository at this point in the history
  • Loading branch information
jaredvu authored Oct 14, 2024
1 parent 781a620 commit 62b40ab
Show file tree
Hide file tree
Showing 8 changed files with 611 additions and 21 deletions.
568 changes: 550 additions & 18 deletions v4-client-js/__native__/__ios__/v4-native-client.js

Large diffs are not rendered by default.

4 changes: 2 additions & 2 deletions v4-client-js/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion v4-client-js/package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@dydxprotocol/v4-client-js",
"version": "1.3.8",
"version": "1.3.9",
"description": "General client library for the new dYdX system (v4 decentralized)",
"main": "build/src/index.js",
"scripts": {
Expand Down
10 changes: 10 additions & 0 deletions v4-client-js/src/clients/composite-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1207,4 +1207,14 @@ export class CompositeClient {

return this.send(wallet, () => msg, false, undefined, memo);
}

async createMarketPermissionless(
subaccount: SubaccountInfo,
ticker: string,
broadcastMode?: BroadcastMode,
gasAdjustment?: number,
memo?: string,
): Promise<BroadcastTxAsyncResponse | BroadcastTxSyncResponse | IndexedTx> {
return this.validatorClient.post.createMarketPermissionless(ticker, subaccount, broadcastMode, gasAdjustment, memo);
}
}
3 changes: 3 additions & 0 deletions v4-client-js/src/clients/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,9 @@ export const TYPE_URL_MSG_UPDATE_CLOB_PAIR = '/dydxprotocol.clob.MsgUpdateClobPa
// x/delaymsg
export const TYPE_URL_MSG_DELAY_MESSAGE = '/dydxprotocol.delaymsg.MsgDelayMessage';

// x/listing
export const TYPE_URL_MSG_CREATE_MARKET_PERMISSIONLESS = '/dydxprotocol.listing.MsgCreateMarketPermissionless';

// x/perpetuals
export const TYPE_URL_MSG_CREATE_PERPETUAL = '/dydxprotocol.perpetuals.MsgCreatePerpetual';

Expand Down
24 changes: 24 additions & 0 deletions v4-client-js/src/clients/modules/composer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ import {
TYPE_URL_MSG_REGISTER_AFFILIATE,
TYPE_URL_MSG_DEPOSIT_TO_MEGAVAULT,
TYPE_URL_MSG_WITHDRAW_FROM_MEGAVAULT,
TYPE_URL_MSG_CREATE_MARKET_PERMISSIONLESS,
} from '../constants';
import { DenomConfig } from '../types';
import {
Expand All @@ -62,6 +63,7 @@ import {
MsgPlaceOrder,
MsgCancelOrder,
SubaccountId,
MsgCreateMarketPermissionless,
MsgCreateTransfer,
Transfer,
MsgDepositToSubaccount,
Expand Down Expand Up @@ -551,6 +553,28 @@ export class Composer {
};
}

// ------------ x/listing ------------
public composeMsgCreateMarketPermissionless(
address: string,
ticker: string,
subaccountNumber: number,
): EncodeObject {
const subaccountId: SubaccountId = {
owner: address,
number: subaccountNumber,
};

const msg: MsgCreateMarketPermissionless = {
ticker,
subaccountId
};

return {
typeUrl: TYPE_URL_MSG_CREATE_MARKET_PERMISSIONLESS,
value: msg,
}
}

// ------------ util ------------
public validateGoodTilBlockAndTime(
orderFlags: number,
Expand Down
19 changes: 19 additions & 0 deletions v4-client-js/src/clients/modules/post.ts
Original file line number Diff line number Diff line change
Expand Up @@ -917,4 +917,23 @@ export class Post {
registerAffiliateMsg(...args: Parameters<Composer['composeMsgRegisterAffiliate']>): EncodeObject {
return this.composer.composeMsgRegisterAffiliate(...args);
}

launchMarketMsg(...args: Parameters<Composer['composeMsgCreateMarketPermissionless']>): EncodeObject {
return this.composer.composeMsgCreateMarketPermissionless(...args);
}

async createMarketPermissionless(ticker: string, subaccount: SubaccountInfo, broadcastMode?: BroadcastMode, gasAdjustment?: number, memo?: string): Promise<BroadcastTxAsyncResponse | BroadcastTxSyncResponse | IndexedTx> {
const msg = this.launchMarketMsg(subaccount.address, ticker, subaccount.subaccountNumber);

return this.send(
subaccount.wallet,
() => Promise.resolve([msg]),
false,
undefined,
memo,
broadcastMode,
undefined,
gasAdjustment,
);
}
}
2 changes: 2 additions & 0 deletions v4-client-js/src/clients/modules/proto-includes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ export * as BridgeModule from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/b
export * as DistributionModule from '@dydxprotocol/v4-proto/src/codegen/cosmos/distribution/v1beta1/query';
export * as AffiliateModule from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/affiliates/query';
export * as VaultModule from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/vault/query';
export * as ListingModule from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/listing/query';

export * from '@dydxprotocol/v4-proto/src/codegen/cosmos/base/abci/v1beta1/abci';
export * from '@dydxprotocol/v4-proto/src/codegen/cosmos/gov/v1/gov';
Expand All @@ -27,3 +28,4 @@ export * from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/sending/tx';
export * from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/sending/transfer';
export * from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/assets/genesis';
export * from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/assets/asset';
export * from '@dydxprotocol/v4-proto/src/codegen/dydxprotocol/listing/tx';

0 comments on commit 62b40ab

Please sign in to comment.