Пример #1
0
        public async Task <GrapheneOrder[]> GetLimitOrderHistory(string baseSymbol, string quoteSymbol, int limit)
        {
            var cli = new GrapheneWallet(_webSocketClientFactory);
            await cli.StartAndConnect(_lstCreds);

            var lh = cli.LimitOrders(baseSymbol, quoteSymbol, limit);

            return(lh);
        }
Пример #2
0
        public async Task <List <AssetDescription> > ListAsset(string lowerBound, int limit)
        {
            _logger.LogInformation($"[BlockchainApi] ListAsset: lowerBound {lowerBound}, limit {limit}");

            var cli = new GrapheneWallet(_webSocketClientFactory);
            await cli.StartAndConnect(_lstCreds);

            return(_mapper.Map <List <GrapheneAsset>, List <AssetDescription> >(cli.ListAssets(lowerBound, limit).ToList()));
        }
Пример #3
0
        public async Task <TransactionAssetIssuedDescription> IssueAsset(string to, decimal amount, string symbol, string memo = "", bool broadcast = true)
        {
            _logger.LogInformation($"[BlockchainApi] IssueAsset: to {to}, amount {amount}, symbol {symbol}, broadcast {broadcast}");
            var cli = new GrapheneWallet(_webSocketClientFactory);
            await cli.StartAndConnect(_lstCreds);

            var cAsset = cli.IssueAsset(to, amount, symbol, memo, broadcast);

            return(_mapper.Map <GrapheneTransactionRecord <GrapheneAssetIssued>, TransactionAssetIssuedDescription>(cAsset));
        }
Пример #4
0
        public async Task <BitassetDataDescription> GetBitassetById(string id)
        {
            _logger.LogInformation($"[BlockchainApi] GetAssetById: to {id}");
            var cli = new GrapheneWallet(_webSocketClientFactory);
            await cli.StartAndConnect(_lstCreds);

            var cAsset = cli.GetBitasset(id);

            return(cAsset);
        }
Пример #5
0
        public async Task <Dictionary <string, TransactionRecordDescription> > Transfer(string from, string to, decimal amount, string symbol, string memo, bool broadcast)
        {
            _logger.LogInformation($"[BlockchainApi] Transfer: from {from}, to {to}, amount {amount}, symbol {symbol}, memo {memo}, broadcast {broadcast}");
            var cli = new GrapheneWallet(_webSocketClientFactory);
            await cli.StartAndConnect(_creds);

            var transferDico = cli.Transfer(from, to, amount, symbol, memo);

            return(_mapper.Map <Dictionary <string, GrapheneTransactionRecord <GrapheneOperation> >, Dictionary <string, TransactionRecordDescription> >(transferDico));
        }
Пример #6
0
        public async Task <List <GrapheneOpContainerMain> > ListHistory(string accountId, uint limit)
        {
            _logger.LogInformation($"[BlockchainApi] ListHistory: accountId {accountId}");
            var cli = new GrapheneWallet(_webSocketClientFactory);
            await cli.StartAndConnect(_creds);

            var lstHisto1 = cli.GetAccountHistory(accountId, limit).ToList();

            return(lstHisto1);
        }
Пример #7
0
        public async Task <List <AmountDescriptionSimple> > ListBalance(string accountId)
        {
            _logger.LogInformation($"[BlockchainApi] ListBalance: accountId {accountId}");
            var cli = new GrapheneWallet(_webSocketClientFactory);
            await cli.StartAndConnect(_creds);

            var lstBalances = cli.ListAccountBalances(accountId).ToList();

            return(_mapper.Map <List <GrapheneAmount>, List <AmountDescriptionSimple> >(lstBalances));
        }
Пример #8
0
        public async Task <TransactionAssetCreatorDescription> BorrowAsset(string borrower_name, decimal amount_to_borrow,
                                                                           string asset_symbol, decimal amount_of_collateral, bool broadcast = false)
        {
            _logger.LogInformation($"[BlockchainApi] BorrowAsset: borrower_name {borrower_name}, amount_to_borrow {amount_to_borrow}, asset_symbol {asset_symbol}, broadcast {broadcast}");

            var cli = new GrapheneWallet(_webSocketClientFactory);
            await cli.StartAndConnect(_lstCreds);

            var cAsset = cli.BorrowAsset(borrower_name, amount_to_borrow, asset_symbol, amount_of_collateral, broadcast);

            return(_mapper.Map <GrapheneTransactionRecord <GrapheneAssetCreator>, TransactionAssetCreatorDescription>(cAsset));
        }
Пример #9
0
        public async Task <TransactionAssetCreatorDescription> PublishAssetFeed(string publishing_account, string symbol,
                                                                                PriceFeedCreateOrUpdate feed, bool broadcast = false)
        {
            _logger.LogInformation($"[BlockchainApi] PublishAssetFeed: publishing_account {publishing_account}, symbol {symbol}, broadcast {broadcast}");

            var cli = new GrapheneWallet(_webSocketClientFactory);
            await cli.StartAndConnect(_lstCreds);

            var c1 = _mapper.Map <PriceFeedCreateOrUpdate, GraphenePriceFeed>(feed);

            var cAsset = cli.PublishAssetFeed(publishing_account, symbol, c1, broadcast);

            return(_mapper.Map <GrapheneTransactionRecord <GrapheneAssetCreator>, TransactionAssetCreatorDescription>(cAsset));
        }
Пример #10
0
        public async Task <TransactionAssetCreatorDescription> CreateAsset(string issuer, string symbol,
                                                                           uint precision, AssetOptionCreateOrUpdate common,
                                                                           BitassetOptionCreateOrUpdate bitassetOpts, bool broadcast = false)
        {
            _logger.LogInformation($"[BlockchainApi] CreateAsset: issuer {issuer}, symbol {symbol}, broadcast {broadcast}");
            var cli = new GrapheneWallet(_webSocketClientFactory);
            await cli.StartAndConnect(_lstCreds);

            var c1  = _mapper.Map <AssetOptionCreateOrUpdate, GrapheneAssetOptions>(common);
            var bc1 = _mapper.Map <BitassetOptionCreateOrUpdate, GrapheneBitAssetOptions>(bitassetOpts);

            var cAsset = cli.CreateAsset(issuer, symbol, precision, c1, bc1, broadcast);

            return(_mapper.Map <GrapheneTransactionRecord <GrapheneAssetCreator>, TransactionAssetCreatorDescription>(cAsset));
        }
Пример #11
0
        public async Task <List <AccountProfileSimple> > ListAccount(string lowerBound, int limit)
        {
            _logger.LogInformation($"[BlockchainApi] ListAccount: lowerBound {lowerBound}, limit {limit}");
            var cli = new GrapheneWallet(_webSocketClientFactory);
            await cli.StartAndConnect(_creds);

            var lstAccount = cli.ListAccounts(lowerBound, limit).ToList();

            var lstRes = new List <GrapheneAccountSimple>();

            foreach (var r in lstAccount)
            {
                lstRes.Add(new GrapheneAccountSimple()
                {
                    AccountName = r.First(),
                    Id          = r.Skip(1).First()
                });
            }

            return(_mapper.Map <List <GrapheneAccountSimple>, List <AccountProfileSimple> >(lstRes));
        }
Пример #12
0
        public async Task <TransactionLimitOrderDescription> CreateLimitOrder(string account, decimal sellAmount, string sellAsset,
                                                                              decimal buyAmount, string buyAsset, string expiration,
                                                                              bool isFillOrKill, string fee_asset_id, string feeAssetSymbol, string labelGuid, bool broadcast)
        {
            _logger.LogInformation($"[BlockchainApi] CreateLimitOrder: account {account}, sellAmount {sellAmount}, sellAsset {sellAsset}, buyAmount {buyAmount}, buyAsset {buyAsset}, expiration {expiration}, isFillOrKill {isFillOrKill}, fee_asset_id {fee_asset_id}, feeAssetSymbol {feeAssetSymbol}, guidLabel {labelGuid}, broadcast {broadcast}");


            var cli = new GrapheneWallet(_webSocketClientFactory);
            await cli.StartAndConnect(_lstCreds);

            //begin_builder_transaction,
            //add_operation_to_builder_transaction,
            //replace_operation_in_builder_transaction,
            //set_fees_on_builder_transaction,
            //preview_builder_transaction,
            //sign_builder_transaction,
            //propose_builder_transaction,
            //remove_builder_transaction,

            var resTransId = cli.ApiCall <int>(GrapheneMethodEnum.begin_builder_transaction, GrapheneApi.@public);

            //var feeAsset = cli.GetAsset(fee_asset_id);

            var feeObj = new JObject();

            feeObj.Add("amount", 0);
            feeObj.Add("asset_id", fee_asset_id);

            var jObj = new JObject();

            jObj.Add("fee", JObject.FromObject(new GrapheneAmount()
            {
                Amount   = 0,
                Asset_id = fee_asset_id
            }));

            jObj.Add("seller", account);

            jObj.Add("amount_to_sell", JObject.FromObject(new GrapheneAmount()
            {
                Amount   = Convert.ToUInt64(sellAmount),
                Asset_id = sellAsset
            }));

            jObj.Add("min_to_receive", JObject.FromObject(new GrapheneAmount()
            {
                Amount   = Convert.ToUInt64(buyAmount),
                Asset_id = buyAsset
            }));

            jObj.Add("expiration", expiration);

            jObj.Add("fill_or_kill", isFillOrKill);

            jObj.Add("strguid", labelGuid);

            var jArr = new JArray();

            jArr.Add(1);
            jArr.Add(jObj);

            var resAddOp = cli.ApiCall <string>(GrapheneMethodEnum.add_operation_to_builder_transaction, GrapheneApi.@public, resTransId, jArr);

            var resAddFee = cli.ApiCall <GrapheneAmount>(GrapheneMethodEnum.set_fees_on_builder_transaction, GrapheneApi.@public, resTransId, feeAssetSymbol);

            var resAddSign = cli.ApiCall <GrapheneTransactionRecord <GrapheneLimitOrderBody> >(GrapheneMethodEnum.sign_builder_transaction, GrapheneApi.@public, resTransId, broadcast);

            return(_mapper.Map <GrapheneTransactionRecord <GrapheneLimitOrderBody>, TransactionLimitOrderDescription>(resAddSign));
        }
Пример #13
0
        public async Task <TransactionAssetCreatorDescription> CreateUiAsset(string issuer, string symbol,
                                                                             uint precision, ulong maxSupply, decimal marketFeePercent,
                                                                             ulong maxMarketFee, ulong amountBase, ulong amountQuote,
                                                                             string description)
        {
            _logger.LogInformation($"[BlockchainApi] CreateUiAsset: issuer {issuer}, symbol {symbol}");
            var cli = new GrapheneWallet(_webSocketClientFactory);
            await cli.StartAndConnect(_lstCreds);

            var h1 = new AssetOptionHelper();

            var common = new GrapheneAssetOptions();

            common.Max_supply         = maxSupply;
            common.Market_fee_percent = marketFeePercent;
            common.Max_market_fee     = maxMarketFee;
            common.Issuer_permissions = h1.GetPermissions(false);
            common.Flags = h1.GetFlag();
            common.Whitelist_authorities = new List <string>();
            common.Blacklist_authorities = new List <string>();
            common.Whitelist_markets     = new List <string>();
            common.Blacklist_markets     = new List <string>();

            common.Core_exchange_rate = new GrapheneExchangeRate()
            {
                Base = new GrapheneAmount()
                {
                    Amount   = amountBase,
                    Asset_id = "1.3.0"
                },
                Quote = new GrapheneAmount()
                {
                    Amount   = amountQuote,
                    Asset_id = "1.3.1"
                }
            };

            common.Description        = description;
            common.IsPredictionMarket = false;

            //var optBitAsset = new GrapheneBitAssetOptions();

            ///*

            //"feed_lifetime_sec" : 60 * 60 * 24,
            //"minimum_feeds" : 7,
            //"force_settlement_delay_sec" : 60 * 60 * 24,
            //"force_settlement_offset_percent" : 1 * assetConstants.GRAPHENE_1_PERCENT,
            //"maximum_force_settlement_volume" : 20 * assetConstants.GRAPHENE_1_PERCENT,
            //"short_backing_asset" : "1.3.0"

            //*/

            //optBitAsset.Feed_lifetime_sec = 60 * 60 * 24;
            //optBitAsset.Minimum_feeds = 7;
            //optBitAsset.Force_settlement_delay_sec = 60 * 60 * 24;
            //optBitAsset.Force_settlement_offset_percent = 1 * h1.GRAPHENE_1_PERCENT;
            //optBitAsset.Maximum_force_settlement_volume = 20 * h1.GRAPHENE_1_PERCENT;
            //optBitAsset.Short_backing_asset = "1.3.0";

            var cAsset = cli.CreateAsset(issuer, symbol, precision, common, null, true);

            return(_mapper.Map <GrapheneTransactionRecord <GrapheneAssetCreator>, TransactionAssetCreatorDescription>(cAsset));
        }