This library provides access to the Yieldly No Loss Lottery and Staking contracts on the Algorand blockchain.
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).
- 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
Releases are available at nuget.org.
PM> Install-Package -Id Yieldly
dotnet add package Yieldly
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:
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.
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.
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);
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);
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);
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);
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);
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);
Full examples, simple and verbose, can be found in example.
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.
The order of transactions in each transaction group is significant. Each transaction group, except lottery winning, has been tested.
Special thanks to @JoshLmao for yly-calc.
dotnet-yieldly-sdk build pipelines use the Assembly Info Task extension.
dotnet-yieldly-sdk is licensed under a MIT license except for the exceptions listed below. See the LICENSE file for details.
None.
Nothing in the repo constitutes professional and/or financial advice. Use this SDK at your own risk.