Skip to content

Commit

Permalink
chore: remove fully collateralised field from the futurecap type
Browse files Browse the repository at this point in the history
Signed-off-by: Elias Van Ootegem <[email protected]>
  • Loading branch information
EVODelavega committed May 13, 2024
1 parent 663d28d commit 5013682
Show file tree
Hide file tree
Showing 6 changed files with 468 additions and 541 deletions.
18 changes: 11 additions & 7 deletions core/integration/steps/the_markets.go
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import (
"code.vegaprotocol.io/vega/core/netparams"
"code.vegaprotocol.io/vega/core/types"
"code.vegaprotocol.io/vega/libs/num"
"code.vegaprotocol.io/vega/libs/ptr"
proto "code.vegaprotocol.io/vega/protos/vega"

"github.com/cucumber/godog"
Expand Down Expand Up @@ -651,9 +650,7 @@ func newMarket(config *market.Config, row marketRow) types.Market {
}

tip := m.TradableInstrument.IntoProto()
if row.IsCapped() {
tip.MarginCalculator.FullyCollateralised = ptr.From(pCap.FullyCollateralised)
}
tip.MarginCalculator.FullyCollateralised = row.fullyCollateralised()
err = config.RiskModels.LoadModel(row.riskModel(), tip)
m.TradableInstrument = types.TradableInstrumentFromProto(tip)
if err != nil {
Expand Down Expand Up @@ -1127,14 +1124,21 @@ func (r marketRow) IsCapped() bool {
return r.row.HasColumn("max price cap")
}

func (r marketRow) fullyCollateralised() *bool {
if !r.IsCapped() || !r.row.HasColumn("fully collateralised") {
return nil
}
fc := r.row.MustBool("fully collateralised")
return &fc
}

func (r marketRow) getCapped() *types.FutureCap {
if !r.IsCapped() {
return nil
}
return &types.FutureCap{
MaxPrice: r.row.MustUint("max price cap"),
Binary: r.row.Bool("binary"),
FullyCollateralised: r.row.Bool("fully collateralised"),
MaxPrice: r.row.MustUint("max price cap"),
Binary: r.row.Bool("binary"),
}
}

Expand Down
22 changes: 9 additions & 13 deletions core/types/governance_new_market.go
Original file line number Diff line number Diff line change
Expand Up @@ -1002,9 +1002,8 @@ func InstrumentConfigurationFromProto(
}

type FutureCap struct {
MaxPrice *num.Uint
Binary bool
FullyCollateralised bool
MaxPrice *num.Uint
Binary bool
}

func FutureCapFromProto(fc *vegapb.FutureCap) (*FutureCap, error) {
Expand All @@ -1016,30 +1015,27 @@ func FutureCapFromProto(fc *vegapb.FutureCap) (*FutureCap, error) {
return nil, fmt.Errorf("invalid max price value")
}
return &FutureCap{
MaxPrice: mp,
Binary: ptr.UnBox(fc.BinarySettlement),
FullyCollateralised: ptr.UnBox(fc.FullyCollateralised),
MaxPrice: mp,
Binary: ptr.UnBox(fc.BinarySettlement),
}, nil
}

func (c FutureCap) IntoProto() *vegapb.FutureCap {
return &vegapb.FutureCap{
MaxPrice: c.MaxPrice.String(),
BinarySettlement: ptr.From(c.Binary),
FullyCollateralised: ptr.From(c.FullyCollateralised),
MaxPrice: c.MaxPrice.String(),
BinarySettlement: ptr.From(c.Binary),
}
}

func (c FutureCap) DeepClone() *FutureCap {
return &FutureCap{
MaxPrice: c.MaxPrice.Clone(),
Binary: c.Binary,
FullyCollateralised: c.FullyCollateralised,
MaxPrice: c.MaxPrice.Clone(),
Binary: c.Binary,
}
}

func (c FutureCap) String() string {
return fmt.Sprintf("max price(%s) binary(%t) fully collateralised(%t)", c.MaxPrice.String(), c.Binary, c.FullyCollateralised)
return fmt.Sprintf("max price(%s) binary(%t)", c.MaxPrice.String(), c.Binary)
}

type FutureProduct struct {
Expand Down
59 changes: 2 additions & 57 deletions datanode/gateway/graphql/generated.go

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

2 changes: 0 additions & 2 deletions datanode/gateway/graphql/schema.graphql
Original file line number Diff line number Diff line change
Expand Up @@ -2073,8 +2073,6 @@ type FutureCap {
maxPrice: String!
"True for options market"
binarySettlement: Boolean
"True if parties are fully collateralised on this market"
fullyCollateralised: Boolean
}

"A Future product"
Expand Down
2 changes: 0 additions & 2 deletions protos/sources/vega/markets.proto
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,6 @@ message FutureCap {
string max_price = 1;
// If set to true, the settlement price must either be zero, or equal to the max price.
optional bool binary_settlement = 2;
// If set to true, positions must be fully collateralised so there is no default risk for any party.
optional bool fully_collateralised = 3;
}

// Perpetual product definition
Expand Down
Loading

0 comments on commit 5013682

Please sign in to comment.