gmx 0.0.0

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.
Files changed (3) hide show
  1. checksums.yaml +7 -0
  2. data/lib/gmx.rb +50 -0
  3. metadata +43 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA256:
3
+ metadata.gz: 7398fdb20b98cbf6af978018d4ff664a3537c680963b8a159525173b7a9f88f5
4
+ data.tar.gz: 4ee77b82016bcbff4f0688575a94d97a2fd0a58a9721e6d33cd7e1aafbbb9e49
5
+ SHA512:
6
+ metadata.gz: 62b96ef8ed2707a61f5499b7c17699e809666915f77dd6ef09478dfa5d9766edc2fd9e13692a967f94b938813c3ad363133676489cb80a87b2e888b9905c0788
7
+ data.tar.gz: 76f12c0afcc4f91c674b5f1bcd1692a598a3c516d9532c659045827246485a3723b513b7aba3f42642735a3e7a125557fede9cbf174af8f2eee56496f78cf111
data/lib/gmx.rb ADDED
@@ -0,0 +1,50 @@
1
+ require 'ethereum.rb'
2
+ require 'pp'
3
+ require 'pry'
4
+
5
+ class Gmx
6
+
7
+ def self.reader
8
+ client = Ethereum::HttpClient.new('https://weathered-polished-seed.arbitrum-mainnet.discover.quiknode.pro/3645e6d37df1cdfaba185b39d45eff7d16238456/')
9
+ address = "0x22199a49A999c351eF7927602CFB187ec3cae489"
10
+ abi = JSON.parse(File.open("abis/gmx.json").read)
11
+ Ethereum::Contract.create(name: "GMX", address: address, abi: abi, client: client)
12
+ end
13
+
14
+ def self.get_positions(account)
15
+ vault = "0x489ee077994B6658eAfA855C308275EAd8097C4A"
16
+ wbtc = "0x2f2a2543B76A4166549F7aaB2e75Bef0aefC5B0f"
17
+ weth = "0x82aF49447D8a07e3bd95BD0d56f35241523fBab1"
18
+ usdc = "0xFF970A61A04b1cA14834A43f5dE4533eBDDB5CC8"
19
+
20
+ collateral_tokens = [wbtc,weth,usdc,usdc]
21
+ index_tokens = [wbtc,weth,wbtc,weth]
22
+ is_long = [true,true,false,false]
23
+ positions = reader.call.get_positions(vault, account, collateral_tokens, index_tokens, is_long)
24
+ format_positions(positions)
25
+ end
26
+
27
+
28
+ def self.format_positions(positions)
29
+ formatted = {}
30
+ position_names = ["btcLong", "ethLong", "btcShort", "ethShort"]
31
+ fields = ["size","collateral", "averagePrice", "entryFundingRate", "hasRealisedProfit", "realisedProfit", "lastIncreasedTime", "hasProfit", "delta"]
32
+ divisors = [30,30,30,10,0,0,0,0,30]
33
+
34
+ position_names.each_with_index do |pos, i|
35
+ formatted[position_names[i]] = {}
36
+ fields.each_with_index do |field, j|
37
+ idx = i * 9 + j
38
+ if j == 0 && positions[idx] == 0
39
+ break
40
+ end
41
+ formatted[position_names[i]][fields[j]] = (positions[idx] / 10**divisors[j])
42
+ end
43
+ end
44
+ formatted
45
+ end
46
+ end
47
+
48
+
49
+ account = "0xe8c19db00287e3536075114b2576c70773e039bd"
50
+ pp Gmx.get_positions(account)
metadata ADDED
@@ -0,0 +1,43 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: gmx
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.0
5
+ platform: ruby
6
+ authors:
7
+ - Gmx Core
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2023-03-21 00:00:00.000000000 Z
12
+ dependencies: []
13
+ description: gmx
14
+ email: gmx@support.io
15
+ executables: []
16
+ extensions: []
17
+ extra_rdoc_files: []
18
+ files:
19
+ - lib/gmx.rb
20
+ homepage: https://app.gmx.io
21
+ licenses:
22
+ - MIT
23
+ metadata: {}
24
+ post_install_message:
25
+ rdoc_options: []
26
+ require_paths:
27
+ - lib
28
+ required_ruby_version: !ruby/object:Gem::Requirement
29
+ requirements:
30
+ - - ">="
31
+ - !ruby/object:Gem::Version
32
+ version: '0'
33
+ required_rubygems_version: !ruby/object:Gem::Requirement
34
+ requirements:
35
+ - - ">="
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ requirements: []
39
+ rubygems_version: 3.1.6
40
+ signing_key:
41
+ specification_version: 4
42
+ summary: gmx
43
+ test_files: []