How to get the current earnings of the farms via Elrond REST API - elrond

How I could obtain the current earnings of a farm from Maiar Exchange via Elrond REST API?
For example, for the LKMEX farm I want to determine the current earnings (My Earned MEX) in MEX and/or USDT since the latest harverst or 'reinvest'. Thanks!

Based on what I was looking in maiar.exchange. You can determine there is a graphql request for this.
You can do graphql request to https://graph.maiar.exchange/graphql. I did not search if there is any OpenAPI spec to know if there is any security bound to this route. However, to help you out, here is the graphql (with redacted content), that is used to get current amount in farm with current harvestable amount:
{
"variables": {
"getRewardsForPositionArgs": {
"farmsPositions": [
{
"attributes": "XXXX",
"identifier": "MEXFARM-XXXXX-XXXXX",
"farmAddress": "erd1XXXX",
"liquidity": "19700000000000000000000000"
},
{
"attributes": "XXX",
"identifier": "LKFARM-XXXXXXX-XXXXXX",
"farmAddress": "erd1XXXXX",
"liquidity": "19700000000000000000000000"
},
]
}
},
"query": "query ($getRewardsForPositionArgs: BatchFarmRewardsComputeArgs!) {\n getRewardsForPosition(farmsPositions: $getRewardsForPositionArgs) {\n rewards\n remainingFarmingEpochs\n decodedAttributes {\n aprMultiplier\n compoundedReward\n initialFarmingAmount\n currentFarmAmount\n lockedRewards\n identifier\n __typename\n }\n __typename\n }\n}\n"
}
Liquidity is from where you want to get the data. There might be a need to do another graphql request before doing this to know where you are for liquidity.

Related

Problem with create team with Microsoft Graph Api

I have a problem with creating teams using the Microsoft Graph Api. I can get/create groups but when I try to get/create teams I get an error. I'm using postman and the group has owners and members, just as the documentation of MS, also has the permissitions it asks for groups. If somebody can help me, cause I look everywhere for a same error but no found it.
PUT https://graph.microsoft.com/v1.0/groups/{id}/team
Headers: Authorization: bearer token and content-type: json
Body is
{
"memberSettings": {
"allowCreateUpdateChannels": true
},
"messagingSettings": {
"allowUserEditMessages": true,
"allowUserDeleteMessages": true
},
"funSettings": {
"allowGiphy": true,
"giphyContentRating": "strict"
}
}
I always get the same error
{
"error": {
"code": "BadGateway",
"message": "Failed to execute backend request.",
"innerError": {
"request-id": "45eeba8a-9d35-45e8-b42e-c60da7a47dde",
"date": "2020-01-23T21:55:44"
}
}
}
According to the Graph API docs for this, you're not calling the correct endpoint to create a new Team. It should be
POST https://graph.microsoft.com/beta/teams
and a payload similar to
Content-Type: application/json
{
"template#odata.bind": "https://graph.microsoft.com/beta/teamsTemplates('standard')",
"displayName": "My Sample Team",
"description": "My Sample Team’s Description",
"owners#odata.bind": [
"https://graph.microsoft.com/beta/users('userId')"
]
}
Note that it's slightly different, as per the docs, whether you're using delegated versus application permissons.

Apollo Client Query Deduplication on Cached Object

I recently read an article about Apollo Client Caching on the official blog, with a screenshot
here.
According to the article, if the current query contains a cached object, along with other objects, the query will be deduplicated to only query the rest of the objects.
However, I did some testing by logging out queries on the server, which suggested that the query had not been partially deduplicated. Instead, the entire query got sent to the server.
Can anyone provide any insight on this. Thanks very much.
Test:
First query:
{
post(_id: 1) {
_id
title
}
}
Second query:
{
post(_id: 1) {
_id
title
}
author(_id: 1) {
_id
firstName
}
}
Intended outcome:
The secomd query received by the server only contains
author(_id: 1) {
_id
firstName
}
since post(_id: 1) has been cached after the first query is sent, according to the blog.
Actual outcome:
Server log: (the second query has NOT been deduplicated)
{
"operationName": null,
"variables": {},
"query": "{\n post(_id: 1) {\n _id\n title\n __typename\n
}\n}\n"
} /graphql 200 81 - 0.520 ms
{
"operationName": null,
"variables": {},
"query": "{\n post(_id: 1) {\n _id\n title\n __typename\n
}\n author(_id: 1) {\n _id\n firstName\n __typename\n }\n}\n"
} /graphql 200 140 - 0.726 ms
There is a subject called Query deduplication in Apollo-Client
that comes from Apollo-Link (the transport layer of Apollo-Client)
but what it does is deduplicate existing queries that are currently being fetched
Query deduplication can be useful if many components display the same data, but you don’t want to fetch that data from the server many times. It works by comparing a query to all queries currently in flight
you can read more about it here and here
But it doesn't relate so much to the cache.. I think what you're looking for is a better understanding of how cache is managed in Apollo-Client
So how is caching handled in Apollo-Client? you can find a more through article about it here from their official docs: apollo-client-caching
more specifically to your case i believe that if you would use watchQuery / query and make sure the fetchPolicy is cache-first then it might not resend the query
I hope this gives you better insight on caching in Apollo-Client

Finding cleaned/bounced email addresses for a MailChimp campaign or list

I'd like to automate the gathering of unsubscribe and cleaned email accounts for a given campaign.
In the API playground, I see all the methods available on the List entity.
Unsubscribes
I see that it's in the LIST API
GET reports/xxxxxx/unsubscribed
Cleaned
Where can I find the cleaned/bounced emails from a list or campaign? I know I can see the count of bounced in various places, but I'd like to find the email addresses that actually bounced, and the first and last names of the list member. Basically I'd like the API same as the 'export cleaned to csv' available on the website.
How can I use the MailChimp 3.0 API to do this?
You can do
GET lists/list_id/members?status=unsubscribed
to get unsubscribed users
GET lists/list_id/members?status=cleaned
to get cleaned/bounced users
For the bounced emails in a specific campaign you need to do this:
GET /3.0/reports/campaign_id/email-activity
and iterate though all recipients in the campaign, manually locating actions with type=bounce.
{
"email_address": "xxx#example.com",
"activity": [
{
"action": "bounce",
"type": "hard",
"timestamp": "2019-04-08T00:00:00+00:00"
}
]
},
Unfortunately MailChimp has very bad performance on this endpoint, approximately 25 seconds to return activity for a campaign with 500 recipients.
Since soft bounce will not change status inside the list(audience), to get soft bounce email from the list without specific campaign, you can use
GET lists/{list-id}/members/{subscriber_hash}/activity
This endpoint will only return for single email(contact), so you need to iterate through all email(contact) in the list.
Sample response:
"activity": [
{
"action": "bounce",
"timestamp": "2019-05-01T23:02:26+00:00",
"type": "soft",
"campaign_id": "xxxxxxxxxx",
"title": "Xxxx Xxxxxxx"
},
{
"action": "sent",
"timestamp": "2019-05-01T23:00:00+00:00",
"type": "regular",
"campaign_id": "xxxxxxxxxx",
"title": "Xxxx Xxxxxxx"
}
],

Google Logging API - What service name to use when writing entries from non-Google application?

I am trying to use Google Cloud Logging API to write log entries from a web application I'm developing (happens to be .net).
To do this, I must use the logging.projects.logs.entries.write request. This request dictates that I provide a serviceName argument:
{
"entries": [
{
"textPayload": "test",
"metadata":
{
"serviceName": "compute.googleapis.com"
"projectId": "...",
"region": "us-central1",
"zone": "us-central1-a",
"severity": "DEFAULT",
"timestamp": "2015-01-13T19:17:01Z",
"userId": "",
}
}]
}
Unless I specify "compute.googleapis.com" as the serviceName I get an error 400 response:
{
"error":
{
"code": 400,
"message": "Unsupported service specified",
"status": "INVALID_ARGUMENT"
}
}
For now using "compute.googleapis.com" seems to work but I'm asking - what service name should I give, given that I'm not using Google Compute Engine or Google App Engine here?
The Cloud Logging API currently only officially supports Google resources, so the best course of action is to continue to use "compute.googleapis.com" as the service and supply the labels "compute.googleapis.com/resource_type" and "compute.googleapis.com/resource_id", which are used for indexing and visible in the UI drop-downs.
We also currently permit the service name "custom.googleapis.com" with index labels "custom.googleapis.com/primary_key" and "custom.googleapis.com/secondary_key" but that is not officially supported and subject to change in a future release.

What services can I use to fetch an image of a person based on their email address, without authentication

I know gravatar allows this, and I'd like to look into facebook, google plus, twitter, instagram, and anything else.
Do you guys know of any services like this?
EDIT: to clarify, by "without authentication" do I mean user authentication, I expect to use some sort of API
One possible approach, using Facebook Graph Api would be to perform a search against the name for users objects and also retrieve their pictures, using API version 2.2 it would be a call like:
GET graph.facebook.com
/search?q=miles davis&type=user&fields=id,name,picture
This would retrieve id, name and picture object for a search on miles davis, first results as example:
{
"data": [
{
"id": "805353876185303",
"name": "Miles Davis",
"picture": {
"data": {
"is_silhouette": true,
"url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xfp1/v/t1.0-1/c15.0.50.50/p50x50/10354686_10150004552801856_220367501106153455_n.jpg?oh=XXXXXXXXXXXXXXXX&oe=XXXXXX&__gda__=XXXXXXX_XXXXXXXXXXXXX"
}
}
},
{
"id": "1572370603017419",
"name": "Miles Davis",
"picture": {
"data": {
"is_silhouette": false,
"url": "https://fbcdn-profile-a.akamaihd.net/hprofile-ak-xap1/v/t1.0-1/p50x50/1501761_1382020035385811_1384168153_n.jpg?oh=XXXXXXXXX&oe=XXXXXXXXXXX&__gda__=XXXXXX_XXXXXX"
}
}
}, ...........
The field is_silhouette is false if the user has a profile picure.

Resources