-
Notifications
You must be signed in to change notification settings - Fork 116
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[TRA-85] scaffold x/vault endblocker (#1197)
* scaffold x/vault endblocker
- Loading branch information
Showing
9 changed files
with
128 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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 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,13 @@ | ||
package vault | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
"github.com/dydxprotocol/v4-chain/protocol/x/vault/keeper" | ||
) | ||
|
||
func EndBlocker( | ||
ctx sdk.Context, | ||
keeper *keeper.Keeper, | ||
) { | ||
keeper.RefreshAllVaultOrders(ctx) | ||
} |
This file contains 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 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,12 @@ | ||
package keeper | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
) | ||
|
||
// RefreshAllVaultOrders refreshes all orders for all vaults by | ||
// TODO(TRA-134) | ||
// 1. Cancelling all existing orders. | ||
// 2. Placing new orders. | ||
func (k Keeper) RefreshAllVaultOrders(ctx sdk.Context) { | ||
} |
This file contains 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 @@ | ||
package keeper_test |
This file contains 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 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 +1,38 @@ | ||
package types | ||
|
||
import ( | ||
sdk "github.com/cosmos/cosmos-sdk/types" | ||
clobtypes "github.com/dydxprotocol/v4-chain/protocol/x/clob/types" | ||
perptypes "github.com/dydxprotocol/v4-chain/protocol/x/perpetuals/types" | ||
pricestypes "github.com/dydxprotocol/v4-chain/protocol/x/prices/types" | ||
) | ||
|
||
type ClobKeeper interface { | ||
// Clob Pair. | ||
GetAllClobPairs(ctx sdk.Context) (list []clobtypes.ClobPair) | ||
|
||
// Order. | ||
GetLongTermOrderPlacement( | ||
ctx sdk.Context, | ||
orderId clobtypes.OrderId, | ||
) (val clobtypes.LongTermOrderPlacement, found bool) | ||
HandleMsgCancelOrder( | ||
ctx sdk.Context, | ||
msg *clobtypes.MsgCancelOrder, | ||
) (err error) | ||
HandleMsgPlaceOrder( | ||
ctx sdk.Context, | ||
msg *clobtypes.MsgPlaceOrder, | ||
) (err error) | ||
} | ||
|
||
type PerpetualsKeeper interface { | ||
GetAllPerpetuals(ctx sdk.Context) (list []perptypes.Perpetual) | ||
} | ||
|
||
type PricesKeeper interface { | ||
GetAllMarketPrices(ctx sdk.Context) (marketPrices []pricestypes.MarketPrice) | ||
} | ||
|
||
type SubaccountsKeeper interface { | ||
} |
This file contains 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,9 +1,23 @@ | ||
package types | ||
|
||
import ( | ||
fmt "fmt" | ||
|
||
authtypes "github.com/cosmos/cosmos-sdk/x/auth/types" | ||
) | ||
|
||
func (id *VaultId) ToStateKey() []byte { | ||
b, err := id.Marshal() | ||
if err != nil { | ||
panic(err) | ||
} | ||
return b | ||
} | ||
|
||
// ToModuleAccountAddress returns the module account address for the vault | ||
// (generated from string "vault-<type>-<number>") | ||
func (id *VaultId) ToModuleAccountAddress() string { | ||
return authtypes.NewModuleAddress( | ||
fmt.Sprintf("vault-%s-%d", id.Type, id.Number), | ||
).String() | ||
} |
This file contains 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