Skip to content

Commit

Permalink
[TRA-507] Add new gov message for upgrading markets: UpgradeIsolatedP…
Browse files Browse the repository at this point in the history
…erpetualToCross (#2551)
  • Loading branch information
hwray authored Nov 22, 2024
1 parent e700de9 commit e3d812e
Show file tree
Hide file tree
Showing 28 changed files with 1,245 additions and 272 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Rpc } from "../../helpers";
import * as _m0 from "protobufjs/minimal";
import { MsgSetMarketsHardCap, MsgSetMarketsHardCapResponse, MsgCreateMarketPermissionless, MsgCreateMarketPermissionlessResponse, MsgSetListingVaultDepositParams, MsgSetListingVaultDepositParamsResponse } from "./tx";
import { MsgSetMarketsHardCap, MsgSetMarketsHardCapResponse, MsgCreateMarketPermissionless, MsgCreateMarketPermissionlessResponse, MsgSetListingVaultDepositParams, MsgSetListingVaultDepositParamsResponse, MsgUpgradeIsolatedPerpetualToCross, MsgUpgradeIsolatedPerpetualToCrossResponse } from "./tx";
/** Msg defines the Msg service. */

export interface Msg {
Expand All @@ -12,6 +12,12 @@ export interface Msg {
/** SetListingVaultDepositParams sets PML megavault deposit params */

setListingVaultDepositParams(request: MsgSetListingVaultDepositParams): Promise<MsgSetListingVaultDepositParamsResponse>;
/**
* UpgradeIsolatedPerpetualToCross upgrades a perpetual from isolated to cross
* margin
*/

upgradeIsolatedPerpetualToCross(request: MsgUpgradeIsolatedPerpetualToCross): Promise<MsgUpgradeIsolatedPerpetualToCrossResponse>;
}
export class MsgClientImpl implements Msg {
private readonly rpc: Rpc;
Expand All @@ -21,6 +27,7 @@ export class MsgClientImpl implements Msg {
this.setMarketsHardCap = this.setMarketsHardCap.bind(this);
this.createMarketPermissionless = this.createMarketPermissionless.bind(this);
this.setListingVaultDepositParams = this.setListingVaultDepositParams.bind(this);
this.upgradeIsolatedPerpetualToCross = this.upgradeIsolatedPerpetualToCross.bind(this);
}

setMarketsHardCap(request: MsgSetMarketsHardCap): Promise<MsgSetMarketsHardCapResponse> {
Expand All @@ -41,4 +48,10 @@ export class MsgClientImpl implements Msg {
return promise.then(data => MsgSetListingVaultDepositParamsResponse.decode(new _m0.Reader(data)));
}

upgradeIsolatedPerpetualToCross(request: MsgUpgradeIsolatedPerpetualToCross): Promise<MsgUpgradeIsolatedPerpetualToCrossResponse> {
const data = MsgUpgradeIsolatedPerpetualToCross.encode(request).finish();
const promise = this.rpc.request("dydxprotocol.listing.Msg", "UpgradeIsolatedPerpetualToCross", data);
return promise.then(data => MsgUpgradeIsolatedPerpetualToCrossResponse.decode(new _m0.Reader(data)));
}

}
123 changes: 123 additions & 0 deletions indexer/packages/v4-protos/src/codegen/dydxprotocol/listing/tx.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,40 @@ export interface MsgSetListingVaultDepositParamsResponse {}
*/

export interface MsgSetListingVaultDepositParamsResponseSDKType {}
/**
* MsgUpgradeIsolatedPerpetualToCross is used to upgrade a market from
* isolated margin to cross margin.
*/

export interface MsgUpgradeIsolatedPerpetualToCross {
authority: string;
/** ID of the perpetual to be upgraded to CROSS */

perpetualId: number;
}
/**
* MsgUpgradeIsolatedPerpetualToCross is used to upgrade a market from
* isolated margin to cross margin.
*/

export interface MsgUpgradeIsolatedPerpetualToCrossSDKType {
authority: string;
/** ID of the perpetual to be upgraded to CROSS */

perpetual_id: number;
}
/**
* MsgUpgradeIsolatedPerpetualToCrossResponse defines the
* UpgradeIsolatedPerpetualToCross response type.
*/

export interface MsgUpgradeIsolatedPerpetualToCrossResponse {}
/**
* MsgUpgradeIsolatedPerpetualToCrossResponse defines the
* UpgradeIsolatedPerpetualToCross response type.
*/

export interface MsgUpgradeIsolatedPerpetualToCrossResponseSDKType {}

function createBaseMsgSetMarketsHardCap(): MsgSetMarketsHardCap {
return {
Expand Down Expand Up @@ -366,4 +400,93 @@ export const MsgSetListingVaultDepositParamsResponse = {
return message;
}

};

function createBaseMsgUpgradeIsolatedPerpetualToCross(): MsgUpgradeIsolatedPerpetualToCross {
return {
authority: "",
perpetualId: 0
};
}

export const MsgUpgradeIsolatedPerpetualToCross = {
encode(message: MsgUpgradeIsolatedPerpetualToCross, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
if (message.authority !== "") {
writer.uint32(10).string(message.authority);
}

if (message.perpetualId !== 0) {
writer.uint32(16).uint32(message.perpetualId);
}

return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpgradeIsolatedPerpetualToCross {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMsgUpgradeIsolatedPerpetualToCross();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
case 1:
message.authority = reader.string();
break;

case 2:
message.perpetualId = reader.uint32();
break;

default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(object: DeepPartial<MsgUpgradeIsolatedPerpetualToCross>): MsgUpgradeIsolatedPerpetualToCross {
const message = createBaseMsgUpgradeIsolatedPerpetualToCross();
message.authority = object.authority ?? "";
message.perpetualId = object.perpetualId ?? 0;
return message;
}

};

function createBaseMsgUpgradeIsolatedPerpetualToCrossResponse(): MsgUpgradeIsolatedPerpetualToCrossResponse {
return {};
}

export const MsgUpgradeIsolatedPerpetualToCrossResponse = {
encode(_: MsgUpgradeIsolatedPerpetualToCrossResponse, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer {
return writer;
},

decode(input: _m0.Reader | Uint8Array, length?: number): MsgUpgradeIsolatedPerpetualToCrossResponse {
const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input);
let end = length === undefined ? reader.len : reader.pos + length;
const message = createBaseMsgUpgradeIsolatedPerpetualToCrossResponse();

while (reader.pos < end) {
const tag = reader.uint32();

switch (tag >>> 3) {
default:
reader.skipType(tag & 7);
break;
}
}

return message;
},

fromPartial(_: DeepPartial<MsgUpgradeIsolatedPerpetualToCrossResponse>): MsgUpgradeIsolatedPerpetualToCrossResponse {
const message = createBaseMsgUpgradeIsolatedPerpetualToCrossResponse();
return message;
}

};
23 changes: 22 additions & 1 deletion proto/dydxprotocol/listing/tx.proto
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,11 @@ service Msg {
// SetListingVaultDepositParams sets PML megavault deposit params
rpc SetListingVaultDepositParams(MsgSetListingVaultDepositParams)
returns (MsgSetListingVaultDepositParamsResponse);

// UpgradeIsolatedPerpetualToCross upgrades a perpetual from isolated to cross
// margin
rpc UpgradeIsolatedPerpetualToCross(MsgUpgradeIsolatedPerpetualToCross)
returns (MsgUpgradeIsolatedPerpetualToCrossResponse);
}

// MsgSetMarketsHardCap is used to set a hard cap on the number of markets
Expand Down Expand Up @@ -69,4 +74,20 @@ message MsgSetListingVaultDepositParams {

// MsgSetListingVaultDepositParamsResponse defines the
// MsgSetListingVaultDepositParams response
message MsgSetListingVaultDepositParamsResponse {}
message MsgSetListingVaultDepositParamsResponse {}

// MsgUpgradeIsolatedPerpetualToCross is used to upgrade a market from
// isolated margin to cross margin.
message MsgUpgradeIsolatedPerpetualToCross {
// Authority is the address that controls the module.
option (cosmos.msg.v1.signer) = "authority";

string authority = 1 [ (cosmos_proto.scalar) = "cosmos.AddressString" ];

// ID of the perpetual to be upgraded to CROSS
uint32 perpetual_id = 2;
}

// MsgUpgradeIsolatedPerpetualToCrossResponse defines the
// UpgradeIsolatedPerpetualToCross response type.
message MsgUpgradeIsolatedPerpetualToCrossResponse {}
1 change: 1 addition & 0 deletions protocol/app/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -1242,6 +1242,7 @@ func New(
app.ClobKeeper,
&app.MarketMapKeeper,
app.PerpetualsKeeper,
app.SubaccountsKeeper,
app.VaultKeeper,
)
listingModule := listingmodule.NewAppModule(
Expand Down
14 changes: 8 additions & 6 deletions protocol/app/msgs/all_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -228,12 +228,14 @@ var (
"/dydxprotocol.govplus.MsgSlashValidatorResponse": {},

// listing
"/dydxprotocol.listing.MsgSetMarketsHardCap": {},
"/dydxprotocol.listing.MsgSetMarketsHardCapResponse": {},
"/dydxprotocol.listing.MsgCreateMarketPermissionless": {},
"/dydxprotocol.listing.MsgCreateMarketPermissionlessResponse": {},
"/dydxprotocol.listing.MsgSetListingVaultDepositParams": {},
"/dydxprotocol.listing.MsgSetListingVaultDepositParamsResponse": {},
"/dydxprotocol.listing.MsgSetMarketsHardCap": {},
"/dydxprotocol.listing.MsgSetMarketsHardCapResponse": {},
"/dydxprotocol.listing.MsgCreateMarketPermissionless": {},
"/dydxprotocol.listing.MsgCreateMarketPermissionlessResponse": {},
"/dydxprotocol.listing.MsgSetListingVaultDepositParams": {},
"/dydxprotocol.listing.MsgSetListingVaultDepositParamsResponse": {},
"/dydxprotocol.listing.MsgUpgradeIsolatedPerpetualToCross": {},
"/dydxprotocol.listing.MsgUpgradeIsolatedPerpetualToCrossResponse": {},

// perpetuals
"/dydxprotocol.perpetuals.MsgAddPremiumVotes": {},
Expand Down
10 changes: 6 additions & 4 deletions protocol/app/msgs/internal_msgs.go
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,12 @@ var (
"/dydxprotocol.govplus.MsgSlashValidatorResponse": nil,

// listing
"/dydxprotocol.listing.MsgSetMarketsHardCap": &listing.MsgSetMarketsHardCap{},
"/dydxprotocol.listing.MsgSetMarketsHardCapResponse": nil,
"/dydxprotocol.listing.MsgSetListingVaultDepositParams": &listing.MsgSetListingVaultDepositParams{},
"/dydxprotocol.listing.MsgSetListingVaultDepositParamsResponse": nil,
"/dydxprotocol.listing.MsgSetMarketsHardCap": &listing.MsgSetMarketsHardCap{},
"/dydxprotocol.listing.MsgSetMarketsHardCapResponse": nil,
"/dydxprotocol.listing.MsgSetListingVaultDepositParams": &listing.MsgSetListingVaultDepositParams{},
"/dydxprotocol.listing.MsgSetListingVaultDepositParamsResponse": nil,
"/dydxprotocol.listing.MsgUpgradeIsolatedPerpetualToCross": &listing.MsgUpgradeIsolatedPerpetualToCross{},
"/dydxprotocol.listing.MsgUpgradeIsolatedPerpetualToCrossResponse": nil,

// perpetuals
"/dydxprotocol.perpetuals.MsgCreatePerpetual": &perpetuals.MsgCreatePerpetual{},
Expand Down
2 changes: 2 additions & 0 deletions protocol/app/msgs/internal_msgs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -116,6 +116,8 @@ func TestInternalMsgSamples_Gov_Key(t *testing.T) {
"/dydxprotocol.listing.MsgSetListingVaultDepositParamsResponse",
"/dydxprotocol.listing.MsgSetMarketsHardCap",
"/dydxprotocol.listing.MsgSetMarketsHardCapResponse",
"/dydxprotocol.listing.MsgUpgradeIsolatedPerpetualToCross",
"/dydxprotocol.listing.MsgUpgradeIsolatedPerpetualToCrossResponse",

// perpeutals
"/dydxprotocol.perpetuals.MsgCreatePerpetual",
Expand Down
1 change: 1 addition & 0 deletions protocol/lib/ante/internal_msg.go
Original file line number Diff line number Diff line change
Expand Up @@ -103,6 +103,7 @@ func IsInternalMsg(msg sdk.Msg) bool {
// listing
*listing.MsgSetMarketsHardCap,
*listing.MsgSetListingVaultDepositParams,
*listing.MsgUpgradeIsolatedPerpetualToCross,

// perpetuals
*perpetuals.MsgCreatePerpetual,
Expand Down
20 changes: 0 additions & 20 deletions protocol/mocks/ClobKeeper.go

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

Loading

0 comments on commit e3d812e

Please sign in to comment.