Awesome
dotnet-yieldly-sdk
Overview
This library provides access to the Yieldly No Loss Lottery and Staking contracts on the Algorand blockchain.
Stake pools
Arbitrary stake pools are now supported. Use the FetchStakingPoolAsync(...)
method on YieldlyClient
to retrieve pool, this object can be used by following the same pattern as the client itself. That is, either pass the account instance to a method, which will submit signed transactions to complete an operation, or use the Prepare...
methods to create a transaction group and handle signing the applicable transactions (see the example directory for sample implementations).
Roadmap
- Add support for TEAL5 Staking pools
- Add example projects for staking pool operations
- Create PowerShell module and cmdlets for common operations
- Investigate Liquidity Staking pool support
- Investigate NFT prize game support
Installation
Releases are available at nuget.org.
Package Manager
PM> Install-Package -Id Yieldly
.NET CLI
dotnet add package Yieldly
Getting Started
Other than initializing a client instance, no specific setup is required. However, if your application generates a high volume of requests it is suggested that you setup your own Algod node. See the links below for more information:
Notes
The default client connects to an Algod node maintained by AlgoNode.io (Thanks AlgoNode!). It's important that your application handle rate limiting (HTTP 429) responses by decreasing the frequency of requests. See this guide for a discussion on the topic.
Usage
This section contains examples for interacting with the lottery and staking contracts. It's possible to use this SDK without passing the Account object to SDK methods, see the Verbose
example projects in the example directory.
TEAL5 staking pools are now supported. The Type
property on AsaStakingPool
indicate the pool type.
Lottery Deposit
Deposit ALGO in the no loss lottery.
// Initialize the client
var client = new YieldlyClient();
// Deposit 10 ALGO in the no loss lottery
var amountToDeposit = Utils.AlgosToMicroalgos(10.0);
var result = await client.LotteryDepositAsync(account, amountToDeposit);
Lottery Withdrawal
Withdraw ALGO participating in the no loss lottery.
// Initialize the client
var client = new YieldlyClient();
// Fetch all Yieldly amounts
var amounts = await client.FetchAmountsAsync(account.Address);
// Withdraw all ALGO currently deposited in the no loss lottery
var result = await client.LotteryWithdrawAsync(account, amounts.AlgoInLottery);
Lottery Reward Claim
Claim reward from lottery participation. Note, this does not include winning the lottery, just the rewards in YLDY.
// Initialize the client
var client = new YieldlyClient();
// Fetch all Yieldly amounts
var amounts = await client.FetchAmountsAsync(account.Address);
// Claim current Yieldy rewards from lottery
var result = await client.LotteryClaimRewardAsync(account, amounts.LotteryReward.Yieldly);
Staking Deposit
Deposit YLDY in the staking pool.
// Initialize the client
var client = new YieldlyClient();
// Deposit 1000 YLDY in the Yieldly staking pool
var amountToDeposit = YieldlyUtils.YieldlyToMicroyieldly(1000.0);
var result = await client.YieldlyStakingDepositAsync(account, amountToDeposit);
Staking Withdrawal
Withdraw YLDY in the staking pool.
// Initialize the client
var client = new YieldlyClient();
// Fetch all Yieldly amounts
var amounts = await client.FetchAmountsAsync(account.Address);
// Withdraw all YLDY currently deposited in the Yieldly staking pool
var result = await client.YieldlyStakingWithdrawAsync(account, amounts.YieldlyStaked);
Staking Reward Claim
Claim rewards from staking pool participation.
// Initialize the client
var client = new YieldlyClient();
// Fetch all Yieldly amounts
var amounts = await client.FetchAmountsAsync(account.Address);
// Withdraw all ALGO and YLDY currently available as rewards from Yieldly staking pool participation
var result = await client.YieldyStakingClaimRewardAsync(account, amounts.StakingReward);
Examples
Full examples, simple and verbose, can be found in example.
How?
This SDK was built by analyzing the transactions created by the Yieldly website in AlgoExporer. A special thanks @JoshLmao, his code provided a starting point for reward calculations.
Notes
The order of transactions in each transaction group is significant. Each transaction group, except lottery winning, has been tested.
Special Thanks
Special thanks to @JoshLmao for yly-calc.
Build
dotnet-yieldly-sdk build pipelines use the Assembly Info Task extension.
License
dotnet-yieldly-sdk is licensed under a MIT license except for the exceptions listed below. See the LICENSE file for details.
Exceptions
None.
Disclaimer
Nothing in the repo constitutes professional and/or financial advice. Use this SDK at your own risk.