-
Notifications
You must be signed in to change notification settings - Fork 44
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
128 changed files
with
1,972 additions
and
340 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 |
---|---|---|
@@ -0,0 +1,44 @@ | ||
// Copyright 2023 The AthanorLabs/atomic-swap Authors | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
package types | ||
|
||
import ( | ||
"github.com/cockroachdb/apd/v3" | ||
|
||
"github.com/athanorlabs/atomic-swap/coins" | ||
) | ||
|
||
// Pair represents a pair (Such as ETH / XMR) | ||
type Pair struct { | ||
ReportedLiquidityXMR *apd.Decimal `json:"reportedLiquidityXmr" validate:"required"` | ||
EthAsset EthAsset `json:"ethAsset" validate:"required"` | ||
Token coins.ERC20TokenInfo `json:"token" validate:"required"` | ||
Offers uint64 `json:"offers" validate:"required"` | ||
Verified bool `json:"verified" valdate:"required"` | ||
} | ||
|
||
// NewPair creates and returns a Pair | ||
func NewPair(EthAsset EthAsset) *Pair { | ||
pair := &Pair{ | ||
ReportedLiquidityXMR: apd.New(0, 0), | ||
EthAsset: EthAsset, | ||
|
||
// Always set to false for now until the verified-list | ||
// is implemented | ||
Verified: false, | ||
} | ||
return pair | ||
} | ||
|
||
// AddOffer adds an offer to a pair | ||
func (pair *Pair) AddOffer(o *Offer) error { | ||
_, err := coins.DecimalCtx().Add(pair.ReportedLiquidityXMR, pair.ReportedLiquidityXMR, o.MaxAmount) | ||
if err != nil { | ||
return err | ||
} | ||
|
||
pair.Offers++ | ||
|
||
return nil | ||
} |
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,27 @@ | ||
// Copyright 2023 The AthanorLabs/atomic-swap Authors | ||
// SPDX-License-Identifier: LGPL-3.0-only | ||
|
||
package rpcclient | ||
|
||
import ( | ||
"github.com/athanorlabs/atomic-swap/common/rpctypes" | ||
) | ||
|
||
// Pairs calls net_pairs to get pairs from all offers. | ||
func (c *Client) Pairs(searchTime uint64) (*rpctypes.PairsResponse, error) { | ||
const ( | ||
method = "net_pairs" | ||
) | ||
|
||
req := &rpctypes.PairsRequest{ | ||
SearchTime: searchTime, | ||
} | ||
|
||
res := &rpctypes.PairsResponse{} | ||
|
||
if err := c.post(method, req, res); err != nil { | ||
return nil, err | ||
} | ||
|
||
return res, nil | ||
} |
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.