Skip to content

Commit

Permalink
fix: utils
Browse files Browse the repository at this point in the history
  • Loading branch information
asolovov committed Nov 29, 2023
1 parent bce33e6 commit b5c7e6e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 23 deletions.
20 changes: 10 additions & 10 deletions utils/testing-contracts/perps-test/perps-market.go
Original file line number Diff line number Diff line change
Expand Up @@ -150,16 +150,16 @@ func (m *TestPerpsMarket) GetCollateralAmount(marketIDS string) {
logger.Log().WithField("layer", "TestPerpsMarket-GetCollateralAmount").Infof("collateral amount: %v", amount.String())
}

func (m *TestPerpsMarket) GetMaxCollateralAmount(marketIDS string) {
marketID := m.getBig(marketIDS)

amount, err := m.perpsMarket.GetMaxCollateralAmount(nil, marketID)
if err != nil {
logger.Log().WithField("layer", "TestPerpsMarket-GetMaxCollateralAmount").Fatalf("get max collateral amount err: %v", err.Error())
}

logger.Log().WithField("layer", "TestPerpsMarket-GetMaxCollateralAmount").Infof("max collateral amount: %v", amount.String())
}
//func (m *TestPerpsMarket) GetMaxCollateralAmount(marketIDS string) {
// marketID := m.getBig(marketIDS)
//
// amount, err := m.perpsMarket.GetMaxCollateralAmount(nil, marketID)
// if err != nil {
// logger.Log().WithField("layer", "TestPerpsMarket-GetMaxCollateralAmount").Fatalf("get max collateral amount err: %v", err.Error())
// }
//
// logger.Log().WithField("layer", "TestPerpsMarket-GetMaxCollateralAmount").Infof("max collateral amount: %v", amount.String())
//}

func (m *TestPerpsMarket) ModifyCollateral(marketIDS string, amountS string) {
aut := m.getAut("ModifyCollateral")
Expand Down
17 changes: 8 additions & 9 deletions utils/testing-contracts/perps-test/settle_order.go
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import (
"log"
"math/big"
"net/http"
"strings"
"time"

"github.com/ethereum/go-ethereum/accounts/abi/bind"
Expand Down Expand Up @@ -38,7 +37,7 @@ func (m *TestPerpsMarket) SettlePythOrder(accountID *big.Int, maxPythTries int,
logger.Log().WithField("layer", "TestPerpsMarket-SettlePythOrder").Fatalf("GetOrder err: %v", err)
}

settlementTime := time.Unix(ordData.SettlementTime.Int64(), 2)
settlementTime := time.Unix(ordData.CommitmentTime.Int64(), 2)
if time.Now().Before(settlementTime) {
duration := time.Until(settlementTime)
logger.Log().WithField("layer", "TestPerpsMarket-SettlePythOrder").Infof("Waiting %v until order can be settled??? Not in this attempt!", duration)
Expand All @@ -50,7 +49,7 @@ func (m *TestPerpsMarket) SettlePythOrder(accountID *big.Int, maxPythTries int,
settlementStrategy := GetSettlementStrategy(int(ordData.Request.MarketId.Int64()), 2)

settlementTimeBytes := make([]byte, 8)
binary.BigEndian.PutUint64(settlementTimeBytes, ordData.SettlementTime.Uint64())
binary.BigEndian.PutUint64(settlementTimeBytes, ordData.CommitmentTime.Uint64())
settlementTimeHex := hex.EncodeToString(settlementTimeBytes)
dataParam := fmt.Sprintf("0x%s%s", hex.EncodeToString(settlementStrategy.FeedID), settlementTimeHex)

Expand Down Expand Up @@ -97,13 +96,13 @@ func (m *TestPerpsMarket) SettlePythOrder(accountID *big.Int, maxPythTries int,

log.Printf("extra_data to string: %s", hex.EncodeToString(extraData))

data, err := hex.DecodeString(strings.TrimPrefix(priceUpdateData.Data, "0x"))
if err != nil {
logger.Log().WithField("layer", "TestPerpsMarket-SettlePythOrder").Fatalf("Failed to decode hex string priceUpdateData.Data: %v", err)
}
aut := m.getAut("SettlePythOrder")
//data, err := hex.DecodeString(strings.TrimPrefix(priceUpdateData.Data, "0x"))
//if err != nil {
// logger.Log().WithField("layer", "TestPerpsMarket-SettlePythOrder").Fatalf("Failed to decode hex string priceUpdateData.Data: %v", err)
//}
aut := m.getAut("SettleOrder")

tx, err := m.perpsMarket.SettlePythOrder(aut, data, extraData)
tx, err := m.perpsMarket.SettleOrder(aut, accountID)
if err != nil {
logger.Log().WithField("layer", "TestPerpsMarket-SettlePythOrder").Fatalf("SettlePythOrder: %+v", err)
}
Expand Down
8 changes: 4 additions & 4 deletions utils/testing-contracts/perps-test/src/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -37,10 +37,10 @@ func main() {
// Market ID
perps.GetCollateralAmount(args[2])
perps.Close()
case "GetMaxCollateralAmount":
// Market ID
perps.GetMaxCollateralAmount(args[2])
perps.Close()
//case "GetMaxCollateralAmount":
// // Market ID
// perps.GetMaxCollateralAmount(args[2])
// perps.Close()
case "SetApproval":
// Amount
perps.SetApproval(args[2])
Expand Down

0 comments on commit b5c7e6e

Please sign in to comment.