Exemple #1
0
        public async Task <ApiStake> GetStakes(
            [Required, FromRoute] Symbol symbol, [FromQuery] ApiCurrencyQueryFilter queryFilter)
        {
            var stake = await stakeService.GetStakeAsync(symbol, queryFilter.CurrencyCode);

            return(MapStake(stake));
        }
Exemple #2
0
 public async IAsyncEnumerable <ApiStake> GetStakes([FromQuery] ApiCurrencyQueryFilter queryFilter)
 {
     await foreach (var stake in stakeService
                    .ListStakesAsync(queryFilter.CurrencyCode)
                    .WithCancellation(scopedCancellationToken.Token))
     {
         yield return(MapStake(stake));
     }
 }
 public async IAsyncEnumerable <ApiFund> GetFunds([FromQuery] ApiCurrencyQueryFilter queryFilter)
 {
     await foreach (var fund in fundService
                    .ListFundsAsync(queryFilter.CurrencyCode)
                    .WithCancellation(scopedCancellationToken.Token))
     {
         yield return(MapFund(fund));
     }
 }
 public async IAsyncEnumerable <ApiTransactionSet> ListBurns(
     [Required, FromRoute] Symbol symbol, [FromQuery] ApiCurrencyQueryFilter queryFilter)
 {
     await foreach (var transaction in fundService
                    .ListBurnsAsync(symbol, queryFilter.CurrencyCode)
                    .WithCancellation(scopedCancellationToken.Token))
     {
         yield return(MapTransactionSet(transaction));
     }
 }
Exemple #5
0
        public async Task <ApiTransactionSet> GetTransaction(
            [Required, FromRoute, EthereumAddress] string address,
            [Required, FromRoute] Symbol symbol,
            [Required, FromRoute, TransactionHash] string hash,
            [FromQuery] ApiCurrencyQueryFilter queryFilter)
        {
            var addr = GetAddress(address);

            var transaction = await fundService.GetTransactionAsync(symbol, new EthereumTransactionHash(hash), queryFilter.CurrencyCode);

            return(MapTransactionSet(transaction, addr));
        }
Exemple #6
0
 public async IAsyncEnumerable <ApiInvestment> ListInvestments(
     [Required, FromRoute, EthereumAddress] string address, [FromQuery] ApiCurrencyQueryFilter queryFilter)
 {
     await foreach (var investment in investmentService
                    .ListInvestmentsAsync(GetAddress(address), queryFilter.CurrencyCode)
                    .WithCancellation(scopedCancellationToken.Token))
     {
         yield return(new ApiInvestment()
         {
             Fund = MapFund(investment.Fund),
             Held = investment.Held,
             Legacy = investment.Legacy,
             Share = investment.Share,
             RealValue = investment.RealValue,
             MarketValue = investment.MarketValue
         });
     }
 }
Exemple #7
0
        public async Task <ApiInvestment> GetInvestment(
            [Required, FromRoute, EthereumAddress] string address, [Required, FromRoute] Symbol symbol, [FromQuery] ApiCurrencyQueryFilter queryFilter)
        {
            var investment = await investmentService.GetInvestmentAsync(GetAddress(address), symbol, queryFilter.CurrencyCode);

            return(new ApiInvestment()
            {
                Fund = MapFund(investment.Fund),
                Held = investment.Held,
                Legacy = investment.Legacy,
                Share = investment.Share,
                RealValue = investment.RealValue,
                MarketValue = investment.MarketValue,
                Stakes = investment.Stakes.Select(MapStakeEvent).ToList(),
                SubInvestments = investment.SubInvestments
                                 .Select(i => new ApiSubInvestment()
                {
                    Held = i.Held,
                    MarketValue = i.MarketValue,
                    Coin = new ApiHolding()
                    {
                        Name = i.Holding.Name,
                        Symbol = i.Holding.Symbol ?? "-",
                        ContractAddress = i.Holding.ContractAddress?.Address,
                        HexColour = i.Holding.HexColour,
                        Decimals = i.Holding.Decimals,
                        Links = new ApiHoldingLinks()
                        {
                            [nameof(ApiHoldingLinks.Link)] = i.Holding.Link,
                            [nameof(ApiHoldingLinks.ImageLink)] = i.Holding.ImageLink,
                            [nameof(ApiHoldingLinks.MarketLink)] = i.Holding.MarketLink,
                        }
                    }
                })
                                 .ToList()
            });
        }
Exemple #8
0
        public async IAsyncEnumerable <ApiTransactionSet> GetTransactions(
            [Required, FromRoute, EthereumAddress] string address, [Required, FromRoute] Symbol symbol, [FromQuery] ApiCurrencyQueryFilter queryFilter)
        {
            var addr = GetAddress(address);

            var transactions = await investmentService
                               .ListTransactionsAsync(addr, symbol, queryFilter.CurrencyCode)
                               .ToListAsync(scopedCancellationToken.Token);

            foreach (var transaction in transactions.OrderByDescending(x => x.ConfirmedAt))
            {
                yield return(MapTransactionSet(transaction, addr));
            }
        }
        public async Task <ApiFund> GetFund([Required, FromRoute] Symbol symbol, [FromQuery] ApiCurrencyQueryFilter queryFilter)
        {
            var fund = await fundService.GetFundAsync(symbol, queryFilter.CurrencyCode);

            return(MapFund(fund));
        }