Skip to content

Commit 521f786

Browse files
authored
Beginning (#1)
* Project naming and namespaces * Readme and logo updates * Buffer decoding basics
1 parent 483f389 commit 521f786

File tree

15 files changed

+329
-125
lines changed

15 files changed

+329
-125
lines changed

PLACEHOLDER.md

Lines changed: 0 additions & 35 deletions
This file was deleted.

README.md

Lines changed: 42 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -1,38 +1,58 @@
1-
# Solnet.Template
1+
<p align="center">
2+
<img src="assets/icon.png" margin="auto" height="175"/>
3+
</p>
4+
<p align="center">
5+
<a href="https://github.com/bmresearch/Solnet.Raydium/actions/workflows/dotnet.yml">
6+
<img src="https://github.com/bmresearch/Solnet.Raydium/actions/workflows/dotnet.yml/badge.svg"
7+
alt="Build Status (main)" ></a>
8+
<a href="https://coveralls.io/github/bmresearch/Solnet.Raydium?branch=main">
9+
<img src="https://coveralls.io/repos/github/bmresearch/Solnet.Raydium/badge.svg?branch=main"
10+
alt="Coverage Status" ></a>
11+
</p>
212

3-
Template repository to easily bootstrap new program implementations using Solnet.
13+
# What is Solnet.Raydium?
414

5-
## Instructions
15+
[Solnet](https://github.com/bmresearch/Solnet) is Solana's .NET integration library, a number of packages that implement features to interact with
16+
Solana from .Net applications.
617

7-
To quickly bootstrap a new project using the current "standard" project structure for program implementations using Solnet do the following:
18+
Solnet.Raydium is a package within the same `Solnet.` namespace that implements a Client for the [Raydium](https://raydium.io/) protocol, this project is in a separate repository so it is contained, as the goal for [Solnet](https://github.com/bmresearch/Solnet) was to be a core SDK.
819

9-
- Click the `Use this template` button in the repository page.
20+
## Links
21+
- [Raydium Home](https://raydium.io/)
22+
- [Raydium Swap](https://raydium.io/swap/)
23+
- [Raydium Documentation](https://raydium.gitbook.io/raydium/)
24+
- [Raydium UI on Github](https://github.com/raydium-io/raydium-ui)
1025

11-
- Choose the desired name for the project (i.e. `Solnet.Serum`, `Solnet.Mango`, `Solnet.Pyth`).
26+
## Goals/Features
27+
- List the staking pools that belong to a wallet
28+
- Calculate the pending rewards for a pool
29+
- Deposit/Stake LP
30+
- Claim Rewards
31+
- Dex
32+
- Swaps
33+
- Add/remove liquidity
1234

13-
- Clone the newly created repository.
35+
## Requirements
36+
- net 5.0
1437

15-
- Change every `Solnet.Template` occurrence in the repository to the desired project name:
38+
## Dependencies
39+
- Solnet.Wallet 0.3.2
40+
- Solnet.Rpc 0.3.2
1641

17-
- Namespaces
18-
- `Solnet.Template.Examples` already features the `IRunnableExample` and the code to get the classes which implement the interface in the assembly
19-
- Directories
20-
- SharedBuildProperties
21-
- `build.cake`
22-
23-
- Add a "logo" to the `assets` directory.
42+
## Examples
2443

25-
- Remove the `README.md` file and rename `PLACEHOLDER.md` to `README.md`.
44+
- TO DO
2645

27-
- As you bootstrap the project, pipelines etc, change the badges accordingly.
46+
## Contribution
2847

29-
- For generic guidelines on how you should bootstrap the project itself, in order to easily maintain the codebase of a program client implementation, see:
30-
- [Solnet.Programs](https://github.com/bmresearch/Solnet/tree/master/src/Solnet.Programs)
31-
- [Solnet.Serum](https://github.com/bmresearch/Solnet.Serum)
48+
We encourage everyone to contribute, submit issues, PRs, discuss. Every kind of help is welcome.
3249

33-
- ??????
50+
## Contributors
3451

35-
- Profit.
52+
* **liquizard** - *Maintainer* - [liquizard](https://github.com/liquizard)
3653

54+
See also the list of [contributors](https://github.com/bmresearch/Solnet.Serum/contributors) who participated in this project.
3755

56+
## License
3857

58+
This project is licensed under the MIT License - see the [LICENSE](https://github.com/bmresearch/Solnet.Raydium/blob/main/LICENSE) file for details

SharedBuildProperties.props

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,19 +1,19 @@
11
<Project DefaultTargets="Build"
22
xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
33
<PropertyGroup>
4-
<Product>Solnet.Template</Product>
4+
<Product>Solnet.Raydium</Product>
55
<Version>0.0.1</Version>
66
<Copyright>Copyright 2021 &#169; blockmountain</Copyright>
77
<Authors>blockmountain</Authors>
88
<PublisherName>blockmountain</PublisherName>
9-
<RepositoryUrl>https://github.com/bmresearch/Solnet.Template</RepositoryUrl>
9+
<RepositoryUrl>https://github.com/bmresearch/Solnet.Raydium</RepositoryUrl>
1010
<GenerateDocumentationFile>true</GenerateDocumentationFile>
1111
<LangVersion>latest</LangVersion>
1212
<PackageLicenseExpression>MIT</PackageLicenseExpression>
1313
<PackageIcon>icon.png</PackageIcon>
14-
<PackageDescription>Solnet.Template is a .Net integration library for Template.</PackageDescription>
14+
<PackageDescription>Solnet.Raydium is a .Net integration library for the Raydium protocol.</PackageDescription>
1515
<PackageTags>solana;solnet;sol;net5</PackageTags>
16-
<PackageReleaseNotes>https://github.com/bmresearch/Solnet.Template/releases</PackageReleaseNotes>
16+
<PackageReleaseNotes>https://github.com/bmresearch/Solnet.Raydium/releases</PackageReleaseNotes>
1717
<RepositoryType>git</RepositoryType>
1818
</PropertyGroup>
1919

Lines changed: 42 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1,42 +1,42 @@
1-
using System;
2-
using System.Collections.Generic;
3-
using System.Linq;
4-
using System.Reflection;
5-
using System.Text;
6-
using System.Threading.Tasks;
7-
8-
namespace Solnet.Template.Examples
9-
{
10-
public class ExampleExplorer
11-
{
12-
public static void Main(string[] args)
13-
{
14-
var examples = Assembly.GetEntryAssembly().GetExportedTypes().Where(t => t.IsAssignableTo(typeof(IRunnableExample))).ToList();
15-
16-
while(true)
17-
{
18-
Console.WriteLine("Choose an example to run: ");
19-
int i = 0;
20-
foreach(var ex in examples)
21-
{
22-
Console.WriteLine($"{i++}){ex.Name}");
23-
}
24-
25-
var option = Console.ReadLine();
26-
27-
if(int.TryParse(option, out int res) && res <= examples.Count && res >= 0)
28-
{
29-
var t = examples[res];
30-
var example = (IRunnableExample)t.GetConstructor(Type.EmptyTypes).Invoke(null);
31-
32-
example.Run();
33-
}
34-
else
35-
{
36-
Console.WriteLine("invalid option");
37-
}
38-
}
39-
40-
}
41-
}
42-
}
1+
using System;
2+
using System.Collections.Generic;
3+
using System.Linq;
4+
using System.Reflection;
5+
using System.Text;
6+
using System.Threading.Tasks;
7+
8+
namespace Solnet.Raydium.Examples
9+
{
10+
public class ExampleExplorer
11+
{
12+
public static void Main(string[] args)
13+
{
14+
var examples = Assembly.GetEntryAssembly().GetExportedTypes().Where(t => t.IsAssignableTo(typeof(IRunnableExample))).ToList();
15+
16+
while(true)
17+
{
18+
Console.WriteLine("Choose an example to run: ");
19+
int i = 0;
20+
foreach(var ex in examples)
21+
{
22+
Console.WriteLine($"{i++}){ex.Name}");
23+
}
24+
25+
var option = Console.ReadLine();
26+
27+
if(int.TryParse(option, out int res) && res <= examples.Count && res >= 0)
28+
{
29+
var t = examples[res];
30+
var example = (IRunnableExample)t.GetConstructor(Type.EmptyTypes).Invoke(null);
31+
32+
example.Run();
33+
}
34+
else
35+
{
36+
Console.WriteLine("invalid option");
37+
}
38+
}
39+
40+
}
41+
}
42+
}
Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
namespace Solnet.Template.Examples
2-
{
3-
/// <summary>
4-
/// Defines functionality for an example.
5-
/// </summary>
6-
public interface IRunnableExample
7-
{
8-
/// <summary>
9-
/// Run the example.
10-
/// </summary>
11-
void Run();
12-
}
1+
namespace Solnet.Raydium.Examples
2+
{
3+
/// <summary>
4+
/// Defines functionality for an example.
5+
/// </summary>
6+
public interface IRunnableExample
7+
{
8+
/// <summary>
9+
/// Run the example.
10+
/// </summary>
11+
void Run();
12+
}
1313
}

Solnet.Template.Examples/Solnet.Template.Examples.csproj renamed to Solnet.Raydium.Examples/Solnet.Raydium.Examples.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@
33
<PropertyGroup>
44
<OutputType>Exe</OutputType>
55
<TargetFramework>net5.0</TargetFramework>
6-
<RootNamespace>Solnet.Template.Examples</RootNamespace>
6+
<RootNamespace>Solnet.Raydium.Examples</RootNamespace>
77
</PropertyGroup>
88

99
<ItemGroup>
10-
<ProjectReference Include="..\Solnet.Template\Solnet.Template.csproj" />
10+
<ProjectReference Include="..\Solnet.Raydium\Solnet.Raydium.csproj" />
1111
</ItemGroup>
1212

1313
<ItemGroup>
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
using Microsoft.VisualStudio.TestTools.UnitTesting;
2+
using Solnet.Raydium.Utilities;
3+
using System;
4+
using System.Collections.Generic;
5+
using System.Linq;
6+
using System.Text;
7+
using System.Threading.Tasks;
8+
9+
namespace Solnet.Raydium.Test
10+
{
11+
[TestClass]
12+
public class DecodingTests
13+
{
14+
15+
[TestMethod]
16+
public void TestBufferDecoder()
17+
{
18+
// 0x01 + 0x00000000 00000000
19+
var buf = BufferDecoder.CreateFromBase58("jpXCZedGfVR");
20+
Assert.AreEqual(1, buf.ReadByte());
21+
Assert.AreEqual(0U, buf.ReadU64());
22+
}
23+
24+
[TestMethod, ExpectedException(typeof(ApplicationException))]
25+
public void TestBufferByteExhausted()
26+
{
27+
var buf = BufferDecoder.CreateFromBase58("jpXCZedGfVR");
28+
Assert.AreEqual(1, buf.ReadByte());
29+
Assert.AreEqual(0U, buf.ReadU64());
30+
buf.ReadByte();
31+
}
32+
33+
[TestMethod, ExpectedException(typeof(ApplicationException))]
34+
public void TestBufferU64Exhausted()
35+
{
36+
var buf = BufferDecoder.CreateFromBase58("jpXCZedGfVR");
37+
Assert.AreEqual(1, buf.ReadByte());
38+
Assert.AreEqual(0, buf.ReadByte());
39+
buf.ReadU64();
40+
}
41+
42+
}
43+
}

Solnet.Template.Test/Solnet.Template.Test.csproj renamed to Solnet.Raydium.Test/Solnet.Raydium.Test.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@
2121
</ItemGroup>
2222

2323
<ItemGroup>
24-
<ProjectReference Include="..\Solnet.Template\Solnet.Template.csproj" />
24+
<ProjectReference Include="..\Solnet.Raydium\Solnet.Raydium.csproj" />
2525
</ItemGroup>
2626

2727
</Project>
Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
33
# Visual Studio Version 16
44
VisualStudioVersion = 16.6.30114.105
55
MinimumVisualStudioVersion = 10.0.40219.1
6-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Solnet.Template.Test", "Solnet.Template.Test\Solnet.Template.Test.csproj", "{BD4EB2AF-3BB3-4B1A-8C75-4A690B209949}"
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Solnet.Raydium.Test", "Solnet.Raydium.Test\Solnet.Raydium.Test.csproj", "{BD4EB2AF-3BB3-4B1A-8C75-4A690B209949}"
77
EndProject
8-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Solnet.Template", "Solnet.Template\Solnet.Template.csproj", "{71A4300E-545E-4754-99FD-BB1CBAD40CCA}"
8+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Solnet.Raydium", "Solnet.Raydium\Solnet.Raydium.csproj", "{71A4300E-545E-4754-99FD-BB1CBAD40CCA}"
99
EndProject
10-
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Solnet.Template.Examples", "Solnet.Template.Examples\Solnet.Template.Examples.csproj", "{9AC72DCB-8418-43C7-AFAB-9865265F2A40}"
10+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Solnet.Raydium.Examples", "Solnet.Raydium.Examples\Solnet.Raydium.Examples.csproj", "{9AC72DCB-8418-43C7-AFAB-9865265F2A40}"
1111
EndProject
1212
Global
1313
GlobalSection(SolutionConfigurationPlatforms) = preSolution

0 commit comments

Comments
 (0)