Class: Hyperliquid::SDK
- Inherits:
-
Object
- Object
- Hyperliquid::SDK
- Defined in:
- lib/hyperliquid.rb
Overview
Main SDK class
Instance Attribute Summary collapse
-
#exchange ⇒ Object
readonly
Returns the value of attribute exchange.
-
#info ⇒ Object
readonly
Returns the value of attribute info.
-
#ws ⇒ Object
readonly
Returns the value of attribute ws.
Instance Method Summary collapse
-
#base_url ⇒ String
Get the base API URL being used.
-
#initialize(testnet: false, timeout: Constants::DEFAULT_TIMEOUT, retry_enabled: false, private_key: nil, expires_after: nil) ⇒ SDK
constructor
Initialize the SDK.
-
#testnet? ⇒ Boolean
Check if using testnet.
Constructor Details
#initialize(testnet: false, timeout: Constants::DEFAULT_TIMEOUT, retry_enabled: false, private_key: nil, expires_after: nil) ⇒ SDK
Initialize the SDK
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/hyperliquid.rb', line 46 def initialize(testnet: false, timeout: Constants::DEFAULT_TIMEOUT, retry_enabled: false, private_key: nil, expires_after: nil) base_url = testnet ? Constants::TESTNET_API_URL : Constants::MAINNET_API_URL client = Client.new(base_url: base_url, timeout: timeout, retry_enabled: retry_enabled) @info = Info.new(client) @testnet = testnet @exchange = nil @ws = WS::Client.new(testnet: testnet) return unless private_key signer = Signing::Signer.new(private_key: private_key, testnet: testnet) @exchange = Exchange.new( client: client, signer: signer, info: @info, testnet: testnet, expires_after: expires_after ) end |
Instance Attribute Details
#exchange ⇒ Object (readonly)
Returns the value of attribute exchange.
38 39 40 |
# File 'lib/hyperliquid.rb', line 38 def exchange @exchange end |
#info ⇒ Object (readonly)
Returns the value of attribute info.
38 39 40 |
# File 'lib/hyperliquid.rb', line 38 def info @info end |
#ws ⇒ Object (readonly)
Returns the value of attribute ws.
38 39 40 |
# File 'lib/hyperliquid.rb', line 38 def ws @ws end |
Instance Method Details
#base_url ⇒ String
Get the base API URL being used
76 77 78 |
# File 'lib/hyperliquid.rb', line 76 def base_url @testnet ? Constants::TESTNET_API_URL : Constants::MAINNET_API_URL end |
#testnet? ⇒ Boolean
Check if using testnet
70 71 72 |
# File 'lib/hyperliquid.rb', line 70 def testnet? @testnet end |