From dffd9fc98021e13befecf0ac4e59ebbdf4d846de Mon Sep 17 00:00:00 2001 From: c9s Date: Thu, 18 Mar 2021 17:57:52 +0800 Subject: [PATCH] add VipLevel api query support --- pkg/exchange/max/maxapi/account.go | 33 ++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/pkg/exchange/max/maxapi/account.go b/pkg/exchange/max/maxapi/account.go index 6d52e0c9b..652e95f42 100644 --- a/pkg/exchange/max/maxapi/account.go +++ b/pkg/exchange/max/maxapi/account.go @@ -51,6 +51,39 @@ type UserInfo struct { ReferralCode string `json:"referral_code"` } +type VipLevelSettings struct { + Level int `json:"level"` + MinimumTradingVolume float64 `json:"minimum_trading_volume"` + MinimumStakingVolume float64 `json:"minimum_staking_volume"` + MakerFee float64 `json:"maker_fee"` + TakerFee float64 `json:"taker_fee"` +} + +type VipLevel struct { + Current VipLevelSettings `json:"current_vip_level"` + Next VipLevelSettings `json:"next_vip_level"` +} + +func (s *AccountService) VipLevel() (*VipLevel, error) { + req, err := s.client.newAuthenticatedRequest("GET", "v2/members/vip_level", nil) + if err != nil { + return nil, err + } + + response, err := s.client.sendRequest(req) + if err != nil { + return nil, err + } + + var vipLevel VipLevel + err = response.DecodeJSON(&vipLevel) + if err != nil { + return nil, err + } + + return &vipLevel, nil +} + func (s *AccountService) Account(currency string) (*Account, error) { req, err := s.client.newAuthenticatedRequest("GET", "v2/members/accounts/"+currency, nil) if err != nil {