Skip to content

Commit

Permalink
all: split ExchangeTransferHistoryService
Browse files Browse the repository at this point in the history
  • Loading branch information
c9s committed Jan 23, 2025
1 parent 2a63dd7 commit 9ed83e9
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
8 changes: 4 additions & 4 deletions pkg/exchange/okex/convert.go
Original file line number Diff line number Diff line change
Expand Up @@ -401,7 +401,7 @@ Status of deposit
13: Sub-account deposit interception
14: KYC limit
*/
func toDepositStatusMessage(state types.StrInt64) string {
func toDepositStatusMessage(state int64) string {
switch state {
case 0:
return "Waiting for confirmation"
Expand All @@ -424,7 +424,7 @@ func toDepositStatusMessage(state types.StrInt64) string {
return ""
}

func toGlobalDepositStatus(state types.StrInt64) types.DepositStatus {
func toGlobalDepositStatus(state int64) types.DepositStatus {
switch state {
case 0:
return types.DepositPending
Expand All @@ -448,8 +448,8 @@ func toGlobalDeposit(record okexapi.DepositRecord) types.Deposit {
Address: record.To,
AddressTag: "",
TransactionID: record.DepId,
Status: toGlobalDepositStatus(record.State),
RawStatus: record.State.String(),
Status: toGlobalDepositStatus(int64(record.State)),
RawStatus: fmt.Sprintf("%s (%s)", record.State.String(), toDepositStatusMessage(int64(record.State))),
UnlockConfirm: 0,
Confirmation: record.ActualDepBlkConfirm.String(),
Network: strings.ToUpper(record.Chain),
Expand Down
4 changes: 2 additions & 2 deletions pkg/strategy/xalign/strategy.go
Original file line number Diff line number Diff line change
Expand Up @@ -152,7 +152,7 @@ func (s *Strategy) detectActiveWithdraw(
until := time.Now()
since := until.Add(-time.Hour * 24)
for _, session := range sessions {
transferService, ok := session.Exchange.(types.ExchangeTransferHistoryService)
transferService, ok := session.Exchange.(types.WithdrawHistoryService)
if !ok {
continue
}
Expand Down Expand Up @@ -184,7 +184,7 @@ func (s *Strategy) detectActiveDeposit(
until := time.Now()
since := until.Add(-time.Hour * 24)
for _, session := range sessions {
transferService, ok := session.Exchange.(types.ExchangeTransferHistoryService)
transferService, ok := session.Exchange.(types.DepositHistoryService)
if !ok {
continue
}
Expand Down
10 changes: 9 additions & 1 deletion pkg/types/exchange.go
Original file line number Diff line number Diff line change
Expand Up @@ -145,11 +145,19 @@ type CustomIntervalProvider interface {
IsSupportedInterval(interval Interval) bool
}

type ExchangeTransferHistoryService interface {
type DepositHistoryService interface {
QueryDepositHistory(ctx context.Context, asset string, since, until time.Time) (allDeposits []Deposit, err error)
}

type WithdrawHistoryService interface {
QueryWithdrawHistory(ctx context.Context, asset string, since, until time.Time) (allWithdraws []Withdraw, err error)
}

type ExchangeTransferHistoryService interface {
DepositHistoryService
WithdrawHistoryService
}

type ExchangeTransferService interface {
QueryDepositHistory(ctx context.Context, asset string, since, until time.Time) (allDeposits []Deposit, err error)
QueryWithdrawHistory(ctx context.Context, asset string, since, until time.Time) (allWithdraws []Withdraw, err error)
Expand Down

0 comments on commit 9ed83e9

Please sign in to comment.