Go to file
Julien Cassis 7825271d30 fix mint layout 2020-11-06 17:55:11 -05:00
cli Added full-blown Solana vault, based on eosc vault. 2020-08-14 17:45:22 -04:00
rpc moves slnc cmds to solana-go 2020-11-06 16:31:18 -05:00
serum fix mint layout 2020-11-06 17:55:11 -05:00
slnc fix mint layout 2020-11-06 17:55:11 -05:00
system Decode orders. 2020-11-06 16:13:32 -05:00
token fix mint layout 2020-11-06 17:55:11 -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 Updated README.md 2020-11-06 17:42:35 -05:00
go.mod Start printing the orderbook. 2020-11-06 17:04:39 -05:00
go.sum Start printing the orderbook. 2020-11-06 17:04:39 -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 SECURITY notice 2020-08-21 12:49:46 -04: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 First working variant for SystemInstructions, pretty hard-coded for now. 2020-11-06 16:13:17 -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 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 an SPL Mint


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

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

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

	json.NewEncoder(os.Stdout).Encode(m)
	// {"OwnerOption":1,
	//  "Owner":"2wmVCSfPxGPjrnMMn7rchp4uaeoTqN39mXFC2zhPdri9",
	//  "Decimals":128,
	//  "IsInitialized":true}

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