dusa 1.0.5 dusa: ^1.0.5 copied to clipboard
Dusa package is an SDK that connects your Dart and Flutter applications to Dusa - a decentralized exchange (DEX) built on the Massa blockchain.
dusa #
Dusa is a decentralised exchange (DEX) built on the Massa blockchain. As a fully on-chain DEX, Dusa leverages the benefits of blockchain technology to provide a secure and transparent platform for users to buy and sell cryptocurrency.
Introduction #
Dusa-dart is an SDK that is able to connect your Dart and Flutter applications to the Dusa decentralised exchange and allows you to swap/trade tokens.
Features #
Dusa has a number of smart contracts, each with several functions. The implementation status of these functions are detailed below
Factory #
- ❌ acceptOwnership
- ❌ addQuoteAsset
- ❌ createLBPair
- ❌ forceDecay
- ❌ getAllBinSteps
- ✅ getAllLBPairs
- ❌ getAvailableLBPairBinSteps
- ✅ getLBPairInformation
- ❌ getPreset
- ❌ proposeNewOwner
- ❌ receiveCoins
- ❌ removePreset
- ❌ removeQuoteAsset
- ❌ setFactoryLockedState
- ❌ setFeeRecipient
- ❌ setFeesParametersOnPair
- ❌ setFlashLoanFee
- ❌ setLBPairIgnored
- ❌ setPreset
Pair #
- ❌ balanceOf
- ❌ balanceOfBatch
- ❌ burn
- ❌ collectFees
- ❌ collectProtocolFees
- ❌ findFirstNonEmptyBinId
- ❌ flashLoan
- ❌ forceDecay
- ❌ getBin
- ❌ getGlobalFees
- ❌ getOracleParameters
- ❌ getOracleSampleFrom
- ❌ getPairInformation
- ❌ getUserBins
- ❌ increaseOracleLength
- ❌ isApprovedForAll
- ❌ mint
- ❌ name
- ❌ pendingFees
- ❌ receiveCoins
- ❌ safeBatchTransferFrom
- ❌ safeTransferFrom
- ❌ setApprovalForAll
- ❌ setFeesParameters
- ❌ swap
- ❌ symbol
- ❌ totalSupply
Quoter #
- ✅ findBestPathFromAmountIn
- ✅ findBestPathFromAmountOut
Router #
- ❌ addLiquidity
- ❌ addLiquidityMAS
- ❌ createLBPair
- ✅ getSwapIn
- ✅ getSwapOut
- ❌ receiveCoins
- ❌ removeLiquidity
- ❌ removeLiquidityMAS
- ✅ swapExactMASForTokens
- ❌ swapExactMASForTokensSupportingFeeOnTransferTokens
- ❌ swapExactTokensForMAS
- ❌ swapExactTokensForMASSupportingFeeOnTransferTokens
- ❌ swapExactTokensForTokens
- ❌ swapExactTokensForTokensSupportingFeeOnTransferTokens
- ❌ swapMASForExactTokens
- ✅ swapTokensForExactMAS
- ❌ swapTokensForExactTokens
- ❌ sweep
- ❌ sweepLBToken
Getting started #
Check usage in /example
folder to test some examples:
To run the examples, follow the following steps:
- Navigate to the example folder.
- To run a specific example, navigate to the given folder, and run the command
dart run example_folder_name/example_filename.dart
Testing #
To run the test cases, navigate to the project root folder and run dart test
You need to have flutter/dart sdk installed in your machine.
Usage #
View more examples in /example
folder.
NOTE: For smart contract examples, all the smart contracts are already deployed on the buildnet, so you do not need to deploy them.
The example below shows how to get list of stakers
import 'package:dusa/dusa.dart';
import 'package:massa/massa.dart';
void main() async {
final wallet = Wallet();
final account = await wallet.addAccountFromSecretKey(Env.privateKey, AddressType.user, NetworkType.BUILDNET);
final quoter = Quoter(account);
final amountIn = doubleToMassaInt(200.00);
final (route, pair, binSteps, amounts, amountsWithoutSlippage, fees) =
await quoter.findBestPathFromAmountIn(TokenName.WMAS, TokenName.USDC, BigInt.from(amountIn));
print('amount in: $amountIn');
print('route: $route');
print('pair: $pair');
print('bin steps: $binSteps');
final massaAmount = toMAS(amounts[0]);
final usdcAmount = bigIntToDecimal(amounts[1], getTokenDecimal(TokenName.USDC));
print('amounts: $amounts => $massaAmount MAS = $usdcAmount USDC');
print('amounts without slippage: $amountsWithoutSlippage');
print('fees: $fees');
}
Additional information #
You can get more information about Dusa by visiting the links below.
Links #
- Dusa: Dusa official website
- Dusa App
- Testnet: Dusa testnet
- Dusa Documentation: Valuable dusa documentation
- Dusa Github: Dusa official github repository
Other links #
- Massa: Massa main website
- Massa Foundation website
- Massa buildnet
- Massa station
- Massa Web3: massa-dart will have similar functionalities as massa-web3
- Massa Dart SDK Repository
- Massa Dart SDK documentation
Support #
Part of this project is supported by Massa Foundation
Contribute #
You can contribute to this package, request new features or report any bug by visiting the package repository at dusa-dart
License #
The MIT License (MIT). Please see License File for more information.