domeapi 0.0.1 → 0.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.release-please-manifest.json +1 -1
- data/CHANGELOG.md +26 -0
- data/Rakefile +6 -2
- data/Readme.adoc +32 -10
- data/lib/domeapi/client.rb +1 -1
- data/lib/domeapi/contract.rb +15 -0
- data/lib/domeapi/operations/.gitkeep +0 -0
- data/lib/domeapi/polymarket/activity.rb +33 -0
- data/lib/domeapi/polymarket/candlesticks.rb +31 -0
- data/lib/domeapi/polymarket/client.rb +26 -2
- data/lib/domeapi/polymarket/endpoint.rb +21 -0
- data/lib/domeapi/polymarket/listable.rb +44 -0
- data/lib/domeapi/polymarket/market_price.rb +28 -0
- data/lib/domeapi/polymarket/markets.rb +15 -40
- data/lib/domeapi/polymarket/orderbook.rb +31 -0
- data/lib/domeapi/polymarket/trade_history.rb +36 -0
- data/lib/domeapi/polymarket/wallet.rb +36 -0
- data/lib/domeapi/polymarket/wallet_profit_and_loss.rb +30 -0
- data/lib/domeapi/polymarket.rb +11 -0
- data/lib/domeapi/version.rb +1 -1
- metadata +13 -3
- data/lib/domeapi/polymarket/market_filter.rb +0 -37
- data/lib/domeapi/polymarket/orders.rb +0 -32
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 1f37b8d774eb782a074ad9c110b1854ccaef6cfa9c275f4afac5a6e537b9c827
|
|
4
|
+
data.tar.gz: b26840dcc2cdc8a745634a17912fb21a98a6e55de781c5e0dc6487149f79b1b8
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: be34b6a15e6f12220cb04563e0ea43bb7d24179f098252e38316fc941e692e94938e8fae89683287dcac8e9770fa213261c145cb2ac07f3524109cced353c0a1
|
|
7
|
+
data.tar.gz: 10c82d41e73d66235e572ed3c395124760a899459fe434fbace37bb35a47d3f571179a51ab78e1e2fbce4f2a01e9fe29cc7c93fb6a609071b0c4c118ff6e9d41
|
data/CHANGELOG.md
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
## [0.0.3](https://github.com/rubyists/domeapi/compare/v0.0.2...v0.0.3) (2026-01-04)
|
|
4
|
+
|
|
5
|
+
|
|
6
|
+
### Features
|
|
7
|
+
|
|
8
|
+
* adds the rest of the polymarket endpoints ([#2](https://github.com/rubyists/domeapi/issues/2)) ([d6deb3e](https://github.com/rubyists/domeapi/commit/d6deb3ebe9d5f8d24b7f02d765618b35f697d6e6))
|
|
9
|
+
* initial commit ([b2c9e75](https://github.com/rubyists/domeapi/commit/b2c9e75180e3da1f7a11ca588efe7cc00ed8f396))
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
### Bug Fixes
|
|
13
|
+
|
|
14
|
+
* adds .gitkeep to the operations directory to satisfy zeitwork loader ([489f73f](https://github.com/rubyists/domeapi/commit/489f73fb00082d13d566a569a7f2e8cab061e32a))
|
|
15
|
+
|
|
16
|
+
## [0.0.2](https://github.com/rubyists/domeapi/compare/v0.0.1...v0.0.2) (2026-01-04)
|
|
17
|
+
|
|
18
|
+
|
|
19
|
+
### Features
|
|
20
|
+
|
|
21
|
+
* initial commit ([b2c9e75](https://github.com/rubyists/domeapi/commit/b2c9e75180e3da1f7a11ca588efe7cc00ed8f396))
|
|
22
|
+
|
|
23
|
+
|
|
24
|
+
### Bug Fixes
|
|
25
|
+
|
|
26
|
+
* adds .gitkeep to the operations directory to satisfy zeitwork loader ([489f73f](https://github.com/rubyists/domeapi/commit/489f73fb00082d13d566a569a7f2e8cab061e32a))
|
data/Rakefile
CHANGED
|
@@ -1,9 +1,13 @@
|
|
|
1
1
|
# frozen_string_literal: true
|
|
2
2
|
|
|
3
3
|
require 'bundler/gem_tasks'
|
|
4
|
-
require '
|
|
4
|
+
require 'rake/testtask'
|
|
5
5
|
|
|
6
|
-
|
|
6
|
+
Rake::TestTask.new do |t|
|
|
7
|
+
t.libs << 'test'
|
|
8
|
+
t.test_files = FileList['test/**/*_test.rb']
|
|
9
|
+
t.ruby_opts = %w[-rhelper]
|
|
10
|
+
end
|
|
7
11
|
|
|
8
12
|
require 'rubocop/rake_task'
|
|
9
13
|
|
data/Readme.adoc
CHANGED
|
@@ -76,24 +76,46 @@ Get candlesticks:
|
|
|
76
76
|
|
|
77
77
|
[source,ruby]
|
|
78
78
|
----
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
79
|
+
filter = Rubyists::Domeapi::Polymarket::Candlesticks::Filter.new(
|
|
80
|
+
Rubyists::Domeapi::Polymarket::Candlesticks::Filter::Properties.new(
|
|
81
|
+
condition_id: 'condition_id',
|
|
82
|
+
start_time: 1625097600,
|
|
83
|
+
end_time: 1625184000,
|
|
84
|
+
interval: 60
|
|
85
|
+
)
|
|
86
|
+
)
|
|
87
|
+
candlesticks = client.polymarket.candlesticks.list(filter)
|
|
88
|
+
----
|
|
89
|
+
|
|
90
|
+
==== Trade History
|
|
91
|
+
|
|
92
|
+
Get trade history:
|
|
93
|
+
|
|
94
|
+
[source,ruby]
|
|
95
|
+
----
|
|
96
|
+
filter = Rubyists::Domeapi::Polymarket::TradeHistory::Filter.new(
|
|
97
|
+
Rubyists::Domeapi::Polymarket::TradeHistory::Filter::Properties.new(
|
|
98
|
+
market_slug: 'market_slug',
|
|
99
|
+
limit: 10
|
|
100
|
+
)
|
|
84
101
|
)
|
|
102
|
+
trades = client.polymarket.trade_history.list(filter)
|
|
85
103
|
----
|
|
86
104
|
|
|
87
|
-
====
|
|
105
|
+
==== Orderbook
|
|
88
106
|
|
|
89
|
-
|
|
107
|
+
Get orderbook history:
|
|
90
108
|
|
|
91
109
|
[source,ruby]
|
|
92
110
|
----
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
111
|
+
filter = Rubyists::Domeapi::Polymarket::Orderbook::Filter.new(
|
|
112
|
+
Rubyists::Domeapi::Polymarket::Orderbook::Filter::Properties.new(
|
|
113
|
+
token_id: 'token_id',
|
|
114
|
+
start_time: 1625097600000,
|
|
115
|
+
end_time: 1625184000000
|
|
116
|
+
)
|
|
96
117
|
)
|
|
118
|
+
snapshots = client.polymarket.orderbook.list(filter)
|
|
97
119
|
----
|
|
98
120
|
|
|
99
121
|
== Development
|
data/lib/domeapi/client.rb
CHANGED
data/lib/domeapi/contract.rb
CHANGED
|
@@ -9,6 +9,21 @@ module Rubyists
|
|
|
9
9
|
class Contract < Reform::Form
|
|
10
10
|
feature Reform::Form::Dry
|
|
11
11
|
|
|
12
|
+
# Custom class methods can be defined here
|
|
13
|
+
module ClassMethods
|
|
14
|
+
def propertize(*names)
|
|
15
|
+
# names is always an array because of the splat
|
|
16
|
+
names = names.flatten
|
|
17
|
+
const_set(:Properties, Struct.new(*custom_definitions, *names, keyword_init: true))
|
|
18
|
+
names.each { |name| property name, populator: ->(value:, **) { value || skip! } }
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
def self.inherited(subclass)
|
|
23
|
+
subclass.extend ClassMethods
|
|
24
|
+
super
|
|
25
|
+
end
|
|
26
|
+
|
|
12
27
|
def self.custom_definitions = instance_variable_get(:@definitions)&.keys&.map(&:to_sym) || []
|
|
13
28
|
|
|
14
29
|
def to_h
|
|
File without changes
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rubyists
|
|
4
|
+
module Domeapi
|
|
5
|
+
module Polymarket
|
|
6
|
+
# Activity API endpoints
|
|
7
|
+
class Activity < Endpoint
|
|
8
|
+
include Listable
|
|
9
|
+
|
|
10
|
+
polymarket_path 'activity'
|
|
11
|
+
|
|
12
|
+
# Filter for activity
|
|
13
|
+
class Filter < Contract
|
|
14
|
+
propertize(%i[user start_time end_time market_slug condition_id limit offset])
|
|
15
|
+
|
|
16
|
+
validation do
|
|
17
|
+
# :nocov:
|
|
18
|
+
params do
|
|
19
|
+
required(:user).filled(:string)
|
|
20
|
+
optional(:start_time).maybe(:integer)
|
|
21
|
+
optional(:end_time).maybe(:integer)
|
|
22
|
+
optional(:market_slug).maybe(:string)
|
|
23
|
+
optional(:condition_id).maybe(:string)
|
|
24
|
+
optional(:limit).maybe(:integer, gteq?: 1, lteq?: 1000)
|
|
25
|
+
optional(:offset).maybe(:integer, gteq?: 0)
|
|
26
|
+
end
|
|
27
|
+
# :nocov:
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rubyists
|
|
4
|
+
module Domeapi
|
|
5
|
+
module Polymarket
|
|
6
|
+
# Candlesticks API endpoints
|
|
7
|
+
class Candlesticks < Endpoint
|
|
8
|
+
include Listable
|
|
9
|
+
|
|
10
|
+
polymarket_path 'markets/get_candlesticks'
|
|
11
|
+
|
|
12
|
+
# Filter for listing candlesticks,
|
|
13
|
+
# from https://docs.domeapi.io/api-reference/endpoint/get-candlesticks
|
|
14
|
+
class Filter < Contract
|
|
15
|
+
propertize(%i[condition_id start_time end_time interval])
|
|
16
|
+
|
|
17
|
+
validation do
|
|
18
|
+
# :nocov:
|
|
19
|
+
params do
|
|
20
|
+
required(:condition_id).filled(:string)
|
|
21
|
+
required(:start_time).filled(:integer)
|
|
22
|
+
required(:end_time).filled(:integer)
|
|
23
|
+
optional(:interval).maybe(:integer, gteq?: 1, lteq?: 1440)
|
|
24
|
+
end
|
|
25
|
+
# :nocov:
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -20,8 +20,32 @@ module Rubyists
|
|
|
20
20
|
@markets ||= Markets.new(client)
|
|
21
21
|
end
|
|
22
22
|
|
|
23
|
-
def
|
|
24
|
-
@
|
|
23
|
+
def candlesticks
|
|
24
|
+
@candlesticks ||= Candlesticks.new(client)
|
|
25
|
+
end
|
|
26
|
+
|
|
27
|
+
def trade_history
|
|
28
|
+
@trade_history ||= TradeHistory.new(client)
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
def orderbook
|
|
32
|
+
@orderbook ||= Orderbook.new(client)
|
|
33
|
+
end
|
|
34
|
+
|
|
35
|
+
def activity
|
|
36
|
+
@activity ||= Activity.new(client)
|
|
37
|
+
end
|
|
38
|
+
|
|
39
|
+
def market_price
|
|
40
|
+
@market_price ||= MarketPrice.new(client)
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
def wallet
|
|
44
|
+
@wallet ||= Wallet.new(client)
|
|
45
|
+
end
|
|
46
|
+
|
|
47
|
+
def wallet_profit_and_loss
|
|
48
|
+
@wallet_profit_and_loss ||= WalletProfitAndLoss.new(client)
|
|
25
49
|
end
|
|
26
50
|
end
|
|
27
51
|
end
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rubyists
|
|
4
|
+
module Domeapi
|
|
5
|
+
module Polymarket
|
|
6
|
+
# Base class for Polymarket API endpoints
|
|
7
|
+
class Endpoint
|
|
8
|
+
attr_reader :client
|
|
9
|
+
|
|
10
|
+
# Initialize the Endpoint
|
|
11
|
+
#
|
|
12
|
+
# @param client [Client] The Domeapi client
|
|
13
|
+
#
|
|
14
|
+
# @return [void]
|
|
15
|
+
def initialize(client = nil)
|
|
16
|
+
@client = client || Client.new
|
|
17
|
+
end
|
|
18
|
+
end
|
|
19
|
+
end
|
|
20
|
+
end
|
|
21
|
+
end
|
|
@@ -0,0 +1,44 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rubyists
|
|
4
|
+
module Domeapi
|
|
5
|
+
module Polymarket
|
|
6
|
+
# Mixin for listable resources
|
|
7
|
+
module Listable
|
|
8
|
+
def self.included(base)
|
|
9
|
+
base.extend(ClassMethods)
|
|
10
|
+
end
|
|
11
|
+
|
|
12
|
+
# Class methods for Listable
|
|
13
|
+
module ClassMethods
|
|
14
|
+
attr_accessor :endpoint_path
|
|
15
|
+
|
|
16
|
+
# Set the endpoint path for the resource
|
|
17
|
+
#
|
|
18
|
+
# @param path [String] API endpoint path
|
|
19
|
+
#
|
|
20
|
+
# @return [String] endpoint path
|
|
21
|
+
def polymarket_path(path)
|
|
22
|
+
self.endpoint_path = path
|
|
23
|
+
end
|
|
24
|
+
|
|
25
|
+
def list(...)
|
|
26
|
+
new.list(...)
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
|
|
30
|
+
# List resources
|
|
31
|
+
#
|
|
32
|
+
# @param filter [Filter|Hash] Filter options
|
|
33
|
+
#
|
|
34
|
+
# @return [Hash|Array] resource data
|
|
35
|
+
def list(filter = self.class::Filter.new(self.class::Filter::Properties.new))
|
|
36
|
+
filter = self.class::Filter.new(self.class::Filter::Properties.new(**filter)) if filter.is_a?(Hash)
|
|
37
|
+
raise ArgumentError, filter.errors.full_messages.join(', ') unless filter.validate({})
|
|
38
|
+
|
|
39
|
+
client.get(self.class.endpoint_path, params: filter.to_h)
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
end
|
|
43
|
+
end
|
|
44
|
+
end
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rubyists
|
|
4
|
+
module Domeapi
|
|
5
|
+
module Polymarket
|
|
6
|
+
# Market Price API endpoints
|
|
7
|
+
class MarketPrice < Endpoint
|
|
8
|
+
include Listable
|
|
9
|
+
|
|
10
|
+
polymarket_path 'markets/get_market_price'
|
|
11
|
+
|
|
12
|
+
# Filter for market price
|
|
13
|
+
class Filter < Contract
|
|
14
|
+
propertize(%i[token_id at_time])
|
|
15
|
+
|
|
16
|
+
validation do
|
|
17
|
+
# :nocov:
|
|
18
|
+
params do
|
|
19
|
+
required(:token_id).filled(:string)
|
|
20
|
+
optional(:at_time).maybe(:integer)
|
|
21
|
+
end
|
|
22
|
+
# :nocov:
|
|
23
|
+
end
|
|
24
|
+
end
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
@@ -4,31 +4,24 @@ module Rubyists
|
|
|
4
4
|
module Domeapi
|
|
5
5
|
module Polymarket
|
|
6
6
|
# Markets API endpoints
|
|
7
|
-
class Markets
|
|
8
|
-
|
|
7
|
+
class Markets < Endpoint
|
|
8
|
+
include Listable
|
|
9
9
|
|
|
10
|
-
|
|
11
|
-
# @see #list
|
|
12
|
-
def list(...)
|
|
13
|
-
new.list(...)
|
|
14
|
-
end
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
# @param client [Rubyists::Domeapi::Polymarket::Client]
|
|
18
|
-
#
|
|
19
|
-
# @return [void]
|
|
20
|
-
def initialize(client = Rubyists::Domeapi::Polymarket::Client.new)
|
|
21
|
-
@client = client
|
|
22
|
-
end
|
|
10
|
+
polymarket_path 'markets'
|
|
23
11
|
|
|
24
|
-
#
|
|
25
|
-
#
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
def list(filter = MarketFilter.new(MarketFilter::Properties.new))
|
|
29
|
-
raise ArgumentError, filter.errors.full_messages.join(', ') unless filter.validate({})
|
|
12
|
+
# Filter for Polymarket markets,
|
|
13
|
+
# from https://docs.domeapi.io/api-reference/endpoint/get-markets
|
|
14
|
+
class Filter < Contract
|
|
15
|
+
propertize(%i[market_slug event_slug condition_id tags status min_volume limit offset start_time end_time])
|
|
30
16
|
|
|
31
|
-
|
|
17
|
+
validation do
|
|
18
|
+
# :nocov:
|
|
19
|
+
params do
|
|
20
|
+
optional(:status).maybe(:string, included_in?: %w[open closed])
|
|
21
|
+
optional(:offset).maybe(:integer, gteq?: 0, lteq?: 100)
|
|
22
|
+
end
|
|
23
|
+
# :nocov:
|
|
24
|
+
end
|
|
32
25
|
end
|
|
33
26
|
|
|
34
27
|
# Fetch current or historical price for a market
|
|
@@ -42,24 +35,6 @@ module Rubyists
|
|
|
42
35
|
params[:at_time] = at_time if at_time
|
|
43
36
|
client.get('markets/get_market_price', params: params)
|
|
44
37
|
end
|
|
45
|
-
|
|
46
|
-
# Get OHLC candlesticks
|
|
47
|
-
#
|
|
48
|
-
# @param condition_id [String]
|
|
49
|
-
# @param start_time [Integer]
|
|
50
|
-
# @param end_time [Integer]
|
|
51
|
-
# @param interval [Integer]
|
|
52
|
-
#
|
|
53
|
-
# @return [Hash] candlestick data
|
|
54
|
-
def candlesticks(condition_id:, start_time:, end_time:, interval:)
|
|
55
|
-
params = {
|
|
56
|
-
condition_id: condition_id,
|
|
57
|
-
start_time: start_time,
|
|
58
|
-
end_time: end_time,
|
|
59
|
-
interval: interval
|
|
60
|
-
}
|
|
61
|
-
client.get('markets/get_candlesticks', params: params)
|
|
62
|
-
end
|
|
63
38
|
end
|
|
64
39
|
end
|
|
65
40
|
end
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rubyists
|
|
4
|
+
module Domeapi
|
|
5
|
+
module Polymarket
|
|
6
|
+
# Orderbook API endpoints
|
|
7
|
+
class Orderbook < Endpoint
|
|
8
|
+
include Listable
|
|
9
|
+
|
|
10
|
+
polymarket_path 'markets/get_orderbook_history'
|
|
11
|
+
|
|
12
|
+
# Filter for orderbook history
|
|
13
|
+
class Filter < Contract
|
|
14
|
+
propertize(%i[token_id start_time end_time limit offset])
|
|
15
|
+
|
|
16
|
+
validation do
|
|
17
|
+
# :nocov:
|
|
18
|
+
params do
|
|
19
|
+
required(:token_id).filled(:string)
|
|
20
|
+
required(:start_time).filled(:integer)
|
|
21
|
+
required(:end_time).filled(:integer)
|
|
22
|
+
optional(:limit).maybe(:integer, gteq?: 1, lteq?: 1000)
|
|
23
|
+
optional(:offset).maybe(:integer, gteq?: 0)
|
|
24
|
+
end
|
|
25
|
+
# :nocov:
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
31
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rubyists
|
|
4
|
+
module Domeapi
|
|
5
|
+
module Polymarket
|
|
6
|
+
# Trade History API endpoints
|
|
7
|
+
class TradeHistory < Endpoint
|
|
8
|
+
include Listable
|
|
9
|
+
|
|
10
|
+
polymarket_path 'markets/get_trade_history'
|
|
11
|
+
|
|
12
|
+
attr_reader :client
|
|
13
|
+
|
|
14
|
+
# Filter for trade history
|
|
15
|
+
class Filter < Contract
|
|
16
|
+
propertize(%i[market_slug condition_id token_id start_time end_time limit offset user])
|
|
17
|
+
|
|
18
|
+
validation do
|
|
19
|
+
# :nocov:
|
|
20
|
+
params do
|
|
21
|
+
optional(:market_slug).maybe(:string)
|
|
22
|
+
optional(:condition_id).maybe(:string)
|
|
23
|
+
optional(:token_id).maybe(:string)
|
|
24
|
+
optional(:start_time).maybe(:integer)
|
|
25
|
+
optional(:end_time).maybe(:integer)
|
|
26
|
+
optional(:limit).maybe(:integer, gteq?: 1, lteq?: 1000)
|
|
27
|
+
optional(:offset).maybe(:integer, gteq?: 0)
|
|
28
|
+
optional(:user).maybe(:string)
|
|
29
|
+
end
|
|
30
|
+
# :nocov:
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rubyists
|
|
4
|
+
module Domeapi
|
|
5
|
+
module Polymarket
|
|
6
|
+
# Wallet API endpoints
|
|
7
|
+
class Wallet < Endpoint
|
|
8
|
+
include Listable
|
|
9
|
+
|
|
10
|
+
polymarket_path 'wallet'
|
|
11
|
+
|
|
12
|
+
# Filter for wallet
|
|
13
|
+
class Filter < Contract
|
|
14
|
+
propertize(%i[eoa proxy with_metrics start_time end_time])
|
|
15
|
+
|
|
16
|
+
validation do
|
|
17
|
+
# :nocov:
|
|
18
|
+
params do
|
|
19
|
+
optional(:eoa).maybe(:string)
|
|
20
|
+
optional(:proxy).maybe(:string)
|
|
21
|
+
optional(:with_metrics).maybe(:bool)
|
|
22
|
+
optional(:start_time).maybe(:integer)
|
|
23
|
+
optional(:end_time).maybe(:integer)
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
rule(:eoa, :proxy) do
|
|
27
|
+
key.failure('Either eoa or proxy must be provided, but not both') if values[:eoa] && values[:proxy]
|
|
28
|
+
key.failure('Either eoa or proxy must be provided') if !values[:eoa] && !values[:proxy]
|
|
29
|
+
end
|
|
30
|
+
# :nocov:
|
|
31
|
+
end
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
end
|
|
35
|
+
end
|
|
36
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
# frozen_string_literal: true
|
|
2
|
+
|
|
3
|
+
module Rubyists
|
|
4
|
+
module Domeapi
|
|
5
|
+
module Polymarket
|
|
6
|
+
# Wallet Profit and Loss API endpoints
|
|
7
|
+
class WalletProfitAndLoss < Endpoint
|
|
8
|
+
include Listable
|
|
9
|
+
|
|
10
|
+
polymarket_path 'wallet/pnl'
|
|
11
|
+
|
|
12
|
+
# Filter for wallet pnl
|
|
13
|
+
class Filter < Contract
|
|
14
|
+
propertize(%i[wallet_address granularity start_time end_time])
|
|
15
|
+
|
|
16
|
+
validation do
|
|
17
|
+
# :nocov:
|
|
18
|
+
params do
|
|
19
|
+
required(:wallet_address).filled(:string)
|
|
20
|
+
required(:granularity).filled(:string, included_in?: %w[day week month year all])
|
|
21
|
+
optional(:start_time).maybe(:integer)
|
|
22
|
+
optional(:end_time).maybe(:integer)
|
|
23
|
+
end
|
|
24
|
+
# :nocov:
|
|
25
|
+
end
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
data/lib/domeapi/polymarket.rb
CHANGED
|
@@ -7,3 +7,14 @@ module Rubyists
|
|
|
7
7
|
end
|
|
8
8
|
end
|
|
9
9
|
end
|
|
10
|
+
|
|
11
|
+
require_relative 'polymarket/endpoint'
|
|
12
|
+
require_relative 'polymarket/listable'
|
|
13
|
+
require_relative 'polymarket/markets'
|
|
14
|
+
require_relative 'polymarket/candlesticks'
|
|
15
|
+
require_relative 'polymarket/trade_history'
|
|
16
|
+
require_relative 'polymarket/orderbook'
|
|
17
|
+
require_relative 'polymarket/activity'
|
|
18
|
+
require_relative 'polymarket/market_price'
|
|
19
|
+
require_relative 'polymarket/wallet'
|
|
20
|
+
require_relative 'polymarket/wallet_profit_and_loss'
|
data/lib/domeapi/version.rb
CHANGED
metadata
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
|
2
2
|
name: domeapi
|
|
3
3
|
version: !ruby/object:Gem::Version
|
|
4
|
-
version: 0.0.
|
|
4
|
+
version: 0.0.3
|
|
5
5
|
platform: ruby
|
|
6
6
|
authors:
|
|
7
7
|
- Tj (bougyman) Vanderpoel
|
|
@@ -159,6 +159,7 @@ files:
|
|
|
159
159
|
- ".release-please-config.json"
|
|
160
160
|
- ".release-please-manifest.json"
|
|
161
161
|
- AGENTS.md
|
|
162
|
+
- CHANGELOG.md
|
|
162
163
|
- Rakefile
|
|
163
164
|
- Readme.adoc
|
|
164
165
|
- ci/build_image.sh
|
|
@@ -167,11 +168,19 @@ files:
|
|
|
167
168
|
- lib/domeapi.rb
|
|
168
169
|
- lib/domeapi/client.rb
|
|
169
170
|
- lib/domeapi/contract.rb
|
|
171
|
+
- lib/domeapi/operations/.gitkeep
|
|
170
172
|
- lib/domeapi/polymarket.rb
|
|
173
|
+
- lib/domeapi/polymarket/activity.rb
|
|
174
|
+
- lib/domeapi/polymarket/candlesticks.rb
|
|
171
175
|
- lib/domeapi/polymarket/client.rb
|
|
172
|
-
- lib/domeapi/polymarket/
|
|
176
|
+
- lib/domeapi/polymarket/endpoint.rb
|
|
177
|
+
- lib/domeapi/polymarket/listable.rb
|
|
178
|
+
- lib/domeapi/polymarket/market_price.rb
|
|
173
179
|
- lib/domeapi/polymarket/markets.rb
|
|
174
|
-
- lib/domeapi/polymarket/
|
|
180
|
+
- lib/domeapi/polymarket/orderbook.rb
|
|
181
|
+
- lib/domeapi/polymarket/trade_history.rb
|
|
182
|
+
- lib/domeapi/polymarket/wallet.rb
|
|
183
|
+
- lib/domeapi/polymarket/wallet_profit_and_loss.rb
|
|
175
184
|
- lib/domeapi/version.rb
|
|
176
185
|
- mise.toml
|
|
177
186
|
- sig/domeapi.rbs
|
|
@@ -182,6 +191,7 @@ metadata:
|
|
|
182
191
|
homepage_uri: https://github.com/rubyists/domeapi
|
|
183
192
|
source_code_uri: https://github.com/rubyists/domeapi
|
|
184
193
|
rubygems_mfa_required: 'true'
|
|
194
|
+
license: MIT
|
|
185
195
|
rdoc_options: []
|
|
186
196
|
require_paths:
|
|
187
197
|
- lib
|
|
@@ -1,37 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Rubyists
|
|
4
|
-
module Domeapi
|
|
5
|
-
module Polymarket
|
|
6
|
-
# Filter for Polymarket markets
|
|
7
|
-
class MarketFilter < Contract
|
|
8
|
-
Properties = Struct.new(
|
|
9
|
-
*custom_definitions,
|
|
10
|
-
:market_slug,
|
|
11
|
-
:event_slug,
|
|
12
|
-
:condition_id,
|
|
13
|
-
:tags,
|
|
14
|
-
:status,
|
|
15
|
-
:min_volume,
|
|
16
|
-
:limit,
|
|
17
|
-
:offset,
|
|
18
|
-
:start_time,
|
|
19
|
-
:end_time,
|
|
20
|
-
keyword_init: true
|
|
21
|
-
)
|
|
22
|
-
|
|
23
|
-
# Define properties with custom populator to skip optional params with nil values
|
|
24
|
-
(Properties.members - custom_definitions).each do |member|
|
|
25
|
-
property member, populator: ->(value:, **) { value || skip! }
|
|
26
|
-
end
|
|
27
|
-
|
|
28
|
-
validation do
|
|
29
|
-
params do
|
|
30
|
-
optional(:status).maybe(:string, included_in?: %w[open closed])
|
|
31
|
-
optional(:offset).maybe(:integer, gteq?: 0, lteq?: 100)
|
|
32
|
-
end
|
|
33
|
-
end
|
|
34
|
-
end
|
|
35
|
-
end
|
|
36
|
-
end
|
|
37
|
-
end
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
# frozen_string_literal: true
|
|
2
|
-
|
|
3
|
-
module Rubyists
|
|
4
|
-
module Domeapi
|
|
5
|
-
module Polymarket
|
|
6
|
-
# Orders API endpoints
|
|
7
|
-
class Orders
|
|
8
|
-
attr_reader :client
|
|
9
|
-
|
|
10
|
-
def initialize(client)
|
|
11
|
-
@client = client
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
# Query orders with filtering options
|
|
15
|
-
# @param market_slug [String]
|
|
16
|
-
# @param start_time [Integer]
|
|
17
|
-
# @param end_time [Integer]
|
|
18
|
-
# @param limit [Integer]
|
|
19
|
-
def list(market_slug: nil, start_time: nil, end_time: nil, limit: nil)
|
|
20
|
-
params = {
|
|
21
|
-
market_slug:,
|
|
22
|
-
start_time:,
|
|
23
|
-
end_time:,
|
|
24
|
-
limit:
|
|
25
|
-
}.compact
|
|
26
|
-
|
|
27
|
-
client.get('orders/get_orders', params: params)
|
|
28
|
-
end
|
|
29
|
-
end
|
|
30
|
-
end
|
|
31
|
-
end
|
|
32
|
-
end
|