forked from ava-labs/subnet-evm
-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* handle settled markets * Get fresh hubble state (#191) * misc * fix settlement price slot --------- Co-authored-by: Shubham <[email protected]>
- Loading branch information
1 parent
d884795
commit 3b29c1a
Showing
12 changed files
with
133 additions
and
53 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
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,35 +1,11 @@ | ||
package hubbleutils | ||
|
||
import "math/big" | ||
|
||
var ( | ||
ChainId int64 | ||
VerifyingContract string | ||
hState *HubbleState | ||
) | ||
|
||
func SetChainIdAndVerifyingSignedOrdersContract(chainId int64, verifyingContract string) { | ||
ChainId = chainId | ||
VerifyingContract = verifyingContract | ||
} | ||
|
||
func SetHubbleState(_hState *HubbleState) { | ||
hState = _hState | ||
} | ||
|
||
func GetHubbleState() *HubbleState { | ||
assets := make([]Collateral, len(hState.Assets)) | ||
copy(assets, hState.Assets) | ||
|
||
activeMarkets := make([]Market, len(hState.ActiveMarkets)) | ||
copy(activeMarkets, hState.ActiveMarkets) | ||
|
||
return &HubbleState{ | ||
Assets: assets, | ||
ActiveMarkets: activeMarkets, | ||
MinAllowableMargin: new(big.Int).Set(hState.MinAllowableMargin), | ||
MaintenanceMargin: new(big.Int).Set(hState.MaintenanceMargin), | ||
TakerFee: new(big.Int).Set(hState.TakerFee), | ||
UpgradeVersion: hState.UpgradeVersion, | ||
} | ||
} |
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
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
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,26 @@ | ||
package orderbook | ||
|
||
import ( | ||
hu "github.com/ava-labs/subnet-evm/plugin/evm/orderbook/hubbleutils" | ||
) | ||
|
||
func GetHubbleState(configService IConfigService) *hu.HubbleState { | ||
count := configService.GetActiveMarketsCount() | ||
markets := make([]Market, count) | ||
for i := int64(0); i < count; i++ { | ||
markets[i] = Market(i) | ||
} | ||
hState := &hu.HubbleState{ | ||
Assets: configService.GetCollaterals(), | ||
OraclePrices: hu.ArrayToMap(configService.GetUnderlyingPrices()), | ||
MidPrices: hu.ArrayToMap(configService.GetMidPrices()), | ||
SettlementPrices: hu.ArrayToMap(configService.GetSettlementPrices()), | ||
ActiveMarkets: markets, | ||
MinAllowableMargin: configService.GetMinAllowableMargin(), | ||
MaintenanceMargin: configService.GetMaintenanceMargin(), | ||
TakerFee: configService.GetTakerFee(), | ||
UpgradeVersion: hu.V2, | ||
} | ||
|
||
return hState | ||
} |
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
Oops, something went wrong.