-
Notifications
You must be signed in to change notification settings - Fork 200
Check Leverage On Order Placement #3141
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
Merged
Changes from all commits
Commits
Show all changes
16 commits
Select commit
Hold shift + click to select a range
d139103
move leverage to subaccount and validate order placement
anmolagrawal345 121d9c1
fix margining.go
anmolagrawal345 e601e21
cleanup and remove collat transfers
anmolagrawal345 59169ff
change to imf_ppm
anmolagrawal345 01a48f2
using protobuf encoding for protocol lev storage
anmolagrawal345 9bfdf51
set cap on imf_ppm to 1m
anmolagrawal345 6c82ba1
rename to custom imf ppm
anmolagrawal345 146bc65
removing unnecessary code
anmolagrawal345 74f5e4f
ensure deterministic ordering on leverage query/update
anmolagrawal345 df08de7
fix proto builds
anmolagrawal345 b2a9faf
delete unused import
anmolagrawal345 79a5d41
ensure deterministic ordering in state
anmolagrawal345 79c4ea8
use sorted keys util
anmolagrawal345 e84a491
fix stash
anmolagrawal345 22d2f95
resolve import errro
anmolagrawal345 d35dd5d
remove outdated comment
anmolagrawal345 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Some comments aren't visible on the classic Files Changed page.
There are no files selected for viewing
282 changes: 142 additions & 140 deletions
282
indexer/packages/v4-protos/src/codegen/dydxprotocol/bundle.ts
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
138 changes: 138 additions & 0 deletions
138
indexer/packages/v4-protos/src/codegen/dydxprotocol/subaccounts/leverage.ts
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,138 @@ | ||
| import * as _m0 from "protobufjs/minimal"; | ||
| import { DeepPartial } from "../../helpers"; | ||
| /** | ||
| * PerpetualLeverageEntry represents a single perpetual leverage setting for | ||
| * internal storage | ||
| */ | ||
|
|
||
| export interface PerpetualLeverageEntry { | ||
| /** The perpetual ID (internal storage format) */ | ||
| perpetualId: number; | ||
| /** The user selected IMF in parts per million */ | ||
|
|
||
| customImfPpm: number; | ||
| } | ||
| /** | ||
| * PerpetualLeverageEntry represents a single perpetual leverage setting for | ||
| * internal storage | ||
| */ | ||
|
|
||
| export interface PerpetualLeverageEntrySDKType { | ||
| /** The perpetual ID (internal storage format) */ | ||
| perpetual_id: number; | ||
| /** The user selected IMF in parts per million */ | ||
|
|
||
| custom_imf_ppm: number; | ||
| } | ||
| /** LeverageData represents the leverage settings for a subaccount */ | ||
|
|
||
| export interface LeverageData { | ||
| /** List of leverage entries for this subaccount */ | ||
| entries: PerpetualLeverageEntry[]; | ||
| } | ||
| /** LeverageData represents the leverage settings for a subaccount */ | ||
|
|
||
| export interface LeverageDataSDKType { | ||
| /** List of leverage entries for this subaccount */ | ||
| entries: PerpetualLeverageEntrySDKType[]; | ||
| } | ||
|
|
||
| function createBasePerpetualLeverageEntry(): PerpetualLeverageEntry { | ||
| return { | ||
| perpetualId: 0, | ||
| customImfPpm: 0 | ||
| }; | ||
| } | ||
|
|
||
| export const PerpetualLeverageEntry = { | ||
| encode(message: PerpetualLeverageEntry, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { | ||
| if (message.perpetualId !== 0) { | ||
| writer.uint32(8).uint32(message.perpetualId); | ||
| } | ||
|
|
||
| if (message.customImfPpm !== 0) { | ||
| writer.uint32(16).uint32(message.customImfPpm); | ||
| } | ||
|
|
||
| return writer; | ||
| }, | ||
|
|
||
| decode(input: _m0.Reader | Uint8Array, length?: number): PerpetualLeverageEntry { | ||
| const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); | ||
| let end = length === undefined ? reader.len : reader.pos + length; | ||
| const message = createBasePerpetualLeverageEntry(); | ||
|
|
||
| while (reader.pos < end) { | ||
| const tag = reader.uint32(); | ||
|
|
||
| switch (tag >>> 3) { | ||
| case 1: | ||
| message.perpetualId = reader.uint32(); | ||
| break; | ||
|
|
||
| case 2: | ||
| message.customImfPpm = reader.uint32(); | ||
| break; | ||
|
|
||
| default: | ||
| reader.skipType(tag & 7); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| return message; | ||
| }, | ||
|
|
||
| fromPartial(object: DeepPartial<PerpetualLeverageEntry>): PerpetualLeverageEntry { | ||
| const message = createBasePerpetualLeverageEntry(); | ||
| message.perpetualId = object.perpetualId ?? 0; | ||
| message.customImfPpm = object.customImfPpm ?? 0; | ||
| return message; | ||
| } | ||
|
|
||
| }; | ||
|
|
||
| function createBaseLeverageData(): LeverageData { | ||
| return { | ||
| entries: [] | ||
| }; | ||
| } | ||
|
|
||
| export const LeverageData = { | ||
| encode(message: LeverageData, writer: _m0.Writer = _m0.Writer.create()): _m0.Writer { | ||
| for (const v of message.entries) { | ||
| PerpetualLeverageEntry.encode(v!, writer.uint32(10).fork()).ldelim(); | ||
| } | ||
|
|
||
| return writer; | ||
| }, | ||
|
|
||
| decode(input: _m0.Reader | Uint8Array, length?: number): LeverageData { | ||
| const reader = input instanceof _m0.Reader ? input : new _m0.Reader(input); | ||
| let end = length === undefined ? reader.len : reader.pos + length; | ||
| const message = createBaseLeverageData(); | ||
|
|
||
| while (reader.pos < end) { | ||
| const tag = reader.uint32(); | ||
|
|
||
| switch (tag >>> 3) { | ||
| case 1: | ||
| message.entries.push(PerpetualLeverageEntry.decode(reader, reader.uint32())); | ||
| break; | ||
|
|
||
| default: | ||
| reader.skipType(tag & 7); | ||
| break; | ||
| } | ||
| } | ||
|
|
||
| return message; | ||
| }, | ||
|
|
||
| fromPartial(object: DeepPartial<LeverageData>): LeverageData { | ||
| const message = createBaseLeverageData(); | ||
| message.entries = object.entries?.map(e => PerpetualLeverageEntry.fromPartial(e)) || []; | ||
| return message; | ||
| } | ||
|
|
||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,3 +1,3 @@ | ||
| import * as _132 from "./gogo"; | ||
| export const gogoproto = { ..._132 | ||
| import * as _133 from "./gogo"; | ||
| export const gogoproto = { ..._133 | ||
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,16 +1,16 @@ | ||
| import * as _133 from "./api/annotations"; | ||
| import * as _134 from "./api/http"; | ||
| import * as _135 from "./protobuf/descriptor"; | ||
| import * as _136 from "./protobuf/duration"; | ||
| import * as _137 from "./protobuf/timestamp"; | ||
| import * as _138 from "./protobuf/any"; | ||
| import * as _134 from "./api/annotations"; | ||
| import * as _135 from "./api/http"; | ||
| import * as _136 from "./protobuf/descriptor"; | ||
| import * as _137 from "./protobuf/duration"; | ||
| import * as _138 from "./protobuf/timestamp"; | ||
| import * as _139 from "./protobuf/any"; | ||
| export namespace google { | ||
| export const api = { ..._133, | ||
| ..._134 | ||
| export const api = { ..._134, | ||
| ..._135 | ||
| }; | ||
| export const protobuf = { ..._135, | ||
| ..._136, | ||
| export const protobuf = { ..._136, | ||
| ..._137, | ||
| ..._138 | ||
| ..._138, | ||
| ..._139 | ||
| }; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| syntax = "proto3"; | ||
| package dydxprotocol.subaccounts; | ||
|
|
||
| option go_package = "github.com/dydxprotocol/v4-chain/protocol/x/subaccounts/types"; | ||
|
|
||
| // PerpetualLeverageEntry represents a single perpetual leverage setting for | ||
| // internal storage | ||
| message PerpetualLeverageEntry { | ||
| // The perpetual ID (internal storage format) | ||
| uint32 perpetual_id = 1; | ||
| // The user selected IMF in parts per million | ||
| uint32 custom_imf_ppm = 2; | ||
| } | ||
|
|
||
| // LeverageData represents the leverage settings for a subaccount | ||
| message LeverageData { | ||
| // List of leverage entries for this subaccount | ||
| repeated PerpetualLeverageEntry entries = 1; | ||
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.