Go to file
Julien Cassis 4c73617d79 properly decode serum price and quantity 2020-11-09 10:03:33 -05:00
cli Added full-blown Solana vault, based on eosc vault. 2020-08-14 17:45:22 -04:00
cmd/slnc properly decode serum price and quantity 2020-11-09 10:03:33 -05:00
rpc fix ws response decoding 2020-11-09 09:57:03 -05:00
serum properly decode serum price and quantity 2020-11-09 10:03:33 -05:00
system properly decode serum price and quantity 2020-11-09 10:03:33 -05:00
token cleaned up readme and spl mint 2020-11-06 20:03:49 -05:00
vault Attempt at fixing the vault 2020-11-06 17:34:03 -05:00
.gitignore added serum types 2020-11-06 11:47:26 -05:00
README.md cleaned up readme and spl mint 2020-11-06 20:03:49 -05:00
go.mod properly decode serum price and quantity 2020-11-09 10:03:33 -05:00
go.sum properly decode serum price and quantity 2020-11-09 10:03:33 -05:00
instructions.go First draft of `spl` and `system` commands in the CLI. 2020-08-14 18:29:24 -04:00
logging.go Tried to make struc work with variant, but failed 2020-08-19 13:21:32 -04:00
nativetypes.go Added uint128 support 2020-11-07 21:30:28 -05:00
nativetypes_test.go First dent in Variants 2020-08-19 11:28:49 -04:00
transactions.go First dent in Variants 2020-08-19 11:28:49 -04:00
transactions_test.go First draft of `spl` and `system` commands in the CLI. 2020-08-14 18:29:24 -04:00
uti.go fix mint layout 2020-11-06 17:55:11 -05:00
variants.go properly decode serum price and quantity 2020-11-09 10:03:33 -05:00

README.md

Solana library for Go

Go library to interface with Solana nodes's JSON-RPC interface, Solana's SPL tokens and the [https://dex.projectserum.com](Serum DEX) instructions. More contracts to come.

Command-line

$ slnc get balance EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
1461600 lamports

$ slnc get account EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v
{
  "lamports": 1461600,
  "data": [
    "AQAAABzjWe1aAS4E+hQrnHUaHF6Hz9CgFhuchf/TG3jN/Nj2gCa3xLwWAAAGAQEAAAAqnl7btTwEZ5CY/3sSZRcUQ0/AjFYqmjuGEQXmctQicw==",
    "base64"
  ],
  "owner": "TokenkegQfeZyiNwAJbNbGKPFXCWuBvf9Ss623VQ5DA",
  "executable": false,
  "rentEpoch": 108
}

$ slnc spl get-mint  SRMuApVNdxXokk5GT7XD5cUUgXMBCoAz2LHeuAoKWRt

Mint Authority Option:  0
Mint Authority:  73uWQpzn1AmUZkZ7MhafSSwQJmNmQ3fN4guANBrXg8uD
Supply:  9999709435300000
Decimals:  6
Is Initialized:  true
Freeze Authority Option:  0
Freeze Authority:  73uWQpzn1AmUZkZ7MhafSSwQJmNmQ3fN4guANBrXg8uD

$ slnc serum markets
...
SUSHI/USDC -> 7LVJtqSrF6RudMaz5rKGTmR3F3V5TKoDcN6bnk68biYZ
SXP/USDC -> 13vjJ8pxDMmzen26bQ5UrouX8dkXYPW1p3VLVDjxXrKR
MSRM/USDC -> AwvPwwSprfDZ86beBJDNH5vocFvuw4ZbVQ6upJDbSCXZ
FTT/USDC -> FfDb3QZUdMW2R2aqJQgzeieys4ETb3rPrFFfPSemzq7R
YFI/USDC -> 4QL5AQvXdMSCVZmnKXiuMMU83Kq3LCwVfU8CyznqZELG
LINK/USDC -> 7JCG9TsCx3AErSV3pvhxiW4AbkKRcJ6ZAveRmJwrgQ16
HGET/USDC -> 3otQFkeQ7GNUKT3i2p3aGTQKS2SAw6NLYPE5qxh3PoqZ
CREAM/USDC -> 2M8EBxFbLANnCoHydypL1jupnRHG782RofnvkatuKyLL
...

$ slnc serum market 7JCG9TsCx3AErSV3pvhxiW4AbkKRcJ6ZAveRmJwrgQ16


Library usage

Loading a Serum market


import "github.com/dfuse-io/solana-go/rpc"

addr := solana.MustPublicKeyFromBase58("7JCG9TsCx3AErSV3pvhxiW4AbkKRcJ6ZAveRmJwrgQ16")
cli := rpc.NewClient("http://api.mainnet-beta.solana.com/rpc")
acct, err := cli.GetAccountInfo(context.Background(), addr)
// handle `err`

var m serum.MarketV2
err = struc.Unpack(bytes.NewReader(acct.Value.MustDataToBytes()), &m)
// handle `err`

json.NewEncoder(os.Stdout).Encode(m)
// {
//   "AccountFlags": 3,
//   "OwnAddress": "7JCG9TsCx3AErSV3pvhxiW4AbkKRcJ6ZAveRmJwrgQ16",
//   "VaultSignerNonce": 1,
//   "BaseMint": "CWE8jPTUYhdCTZYWPTe1o5DFqfdjzWKc9WKz6rSjQUdG",
//   "QuoteMint": "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v",
//   "BaseVault": "BWxmscpG77m1bWH7thDCisR84JJ1e3ho6rMm4udEq2u7",
//   "BaseDepositsTotal": "30750820000",
//   "BaseFeesAccrued": 0,
//   "QuoteVault": "5tFhdTCzTYMvfVTZnczZEL36YjFnkDTSaoQ7XAZvS7LR",
//   "QuoteDepositsTotal": "269134109688",
//   "QuoteFeesAccrued": 476785321,
//   "QuoteDustThreshold": 100,
//   "RequestQueue": "3SKQw5A69B72SEj3EWBe3DymWS9DPJ2mTUzJtV8i8DQ3",
//   "EventQueue": "DNh4agYmXGYv6po3tcCjM5yFQxZHrWnrF3dKhBXY24ZR",
//   "Bids": "627n4UWdaYxpiHrSd3RJrnhkq1zHSNuAgSg88uZXn1KZ",
//   "Asks": "AjgrF2tKVU96fwygfMdsAdBGa5S1Mttkh7XL9P24QWx7",
//   "BaseLotSize": 10000,
//   "QuoteLotSize": 10,
//   "FeeRateBPS": 0,
//   "ReferrerRebatesAccrued": 481639
// }

Examples

Contributing

Any contributions are welcome, use your standard GitHub-fu to pitch in and improve.

License

Apache-2