paltalabs / mercury-sdk Goto Github PK
View Code? Open in Web Editor NEWHome Page: https://mercury-sdk.paltalabs.io/
License: GNU General Public License v3.0
Home Page: https://mercury-sdk.paltalabs.io/
License: GNU General Public License v3.0
KEY_XDR="AAAFA=="
to subscribe to instance storage (with durability="persistent")value_xdr
to get the pair addresses of all pairsvalue_xdr
to get the reservesQuery:
{
"data": {
"liquidityPoolDepositByPublicKey": {
"edges": [
{
"node": {
"source": 401811,
"sourceMuxed": null,
"poolId": "\\xe82e661eb1a24479b34e96451908c339ad9d3f7af3aaab786f1536c4e4211f05",
"maxAmountA": "10000000000",
"maxAmountB": "30000000000",
"minPriceN": 3,
"minPriceD": 10,
"maxPriceN": 3666667,
"maxPriceD": 10000000,
"ledger": 2684822
}
}
]
}
}
}
and
query MyQuery {
liquidityPoolWithdrawByPublicKey(
publicKeyText: "GBXRF7BXKPNQIIWAAO6Y6CFIUXX6GCVLILANFPSENPKAFFZA4KOVCLMB"
) {
edges {
node {
source
sourceMuxed
poolId
amount
minAmountA
minAmountB
ledger
}
}
}
}
Test ADdress:
GBXRF7BXKPNQIIWAAO6Y6CFIUXX6GCVLILANFPSENPKAFFZA4KOVCLMB
Query:
https://developers.mercurydata.app/path-payemnt-strict-receive
Test address:
GBXRF7BXKPNQIIWAAO6Y6CFIUXX6GCVLILANFPSENPKAFFZA4KOVCLMB
We are using as body:
{address: "someAddress"}
We should use
{ publicKey: "someAddress"}
Note that for contracts we are fine
Current Node type is
export interface Node {
ledgerByLedger: LedgerByLedger;
accountBySource: AccountBy;
accountByDestination: AccountBy;
assetByDestAsset: AssetBy;
assetByPath1: AssetBy;
assetByPath2: AssetBy;
assetByPath3: AssetBy;
assetByPath4: AssetBy;
assetByPath5: AssetBy;
assetBySendAsset: AssetBy;
destAssetNative: boolean;
destMin: string;
path1Native: boolean;
path2Native: boolean;
path3Native: boolean;
path4Native: boolean;
path5Native: AssetBy;
sendAmount: string;
sendAssetNative: boolean;
}
That is for getPathPaymentsStrictSendByPublicKey but not for getPathPaymentsStrictReceiveByPublicKey
Can you add something like
export interface NodeBase {
ledgerByLedger: LedgerByLedger;
accountBySource: AccountBy;
accountByDestination: AccountBy;
assetByDestAsset: AssetBy;
assetByPath1: AssetBy;
assetByPath2: AssetBy;
assetByPath3: AssetBy;
assetByPath4: AssetBy;
assetByPath5: AssetBy;
assetBySendAsset: AssetBy;
destAssetNative: boolean;
path1Native: boolean;
path2Native: boolean;
path3Native: boolean;
path4Native: boolean;
path5Native: AssetBy;
sendAssetNative: boolean;
}
export interface NodeStrictSend extends NodeBase {
sendAmount: string;
destMin: string;
}
export interface NodeStrictReceive extends NodeBase {
destAmount: string;
sendMax: string;
}
From contract events get the reserves of a pair.
Query:
# Example variables:
# {
# contractId: "CAVKFXGNANLFPXORKNLZEFNHO2VIN54KCAILJKZZF3UUZ6OYDPVJ3V23"
# }
query getAllContractEvents($contractId: String) {
eventByContractId(
searchedContractId: $contractId
) {
edges {
node {
contractId
data
ledger
ledgerTimestamp
topic2
topic1
topic4
topic3
}
}
}
}
Currently there are severals warnings when generating documentation:
root@5ec42bd4fde0:/workspace# yarn doc
yarn run v1.22.19
warning package.json: License should be a valid SPDX license expression
$ typedoc src/
[warning] The signature Mercury._backendRequest has an @param with name "method", which was not used.
[warning] The signature Mercury._backendRequest has an @param with name "url", which was not used.
[warning] The signature Mercury._backendRequest has an @param with name "body", which was not used.
[warning] The signature Mercury._backendRequest has an @param with name "updateToken", which was not used.
[warning] The signature Mercury._graphqlRequest has an @param with name "body", which was not used.
[warning] The signature Mercury._graphqlRequest has an @param with name "updateToken", which was not used.
[warning] The signature Mercury._graphqlRequest has an @param with name "headers", which was not used.
[warning] ParsedRouterEntry, defined in ./src/types/getContractEntries.ts, is referenced by factoryInstanceParser.factoryInstanceParser but not included in the documentation.
[warning] getLiquidityPoolDepositParsed, defined in ./src/utils/parsers/getLiquidityPoolDepositParser.ts, is referenced by getLiquidityPoolDepositParser.getLiquidityPoolDepositParser but not included in the documentation.
[warning] getLiquidityPoolWithdrawParsed, defined in ./src/utils/parsers/getLiquidityPoolWithdrawParser.ts, is referenced by getLiquidityPoolWithdrawParser.getLiquidityPoolWithdrawParser but not included in the documentation.
[warning] getPathPaymentsStrictReceiveParsed, defined in ./src/utils/parsers/getPathPaymentsStrictReceiveParser.ts, is referenced by getPathPaymentsStrictReceiveParser.getPathPaymentsStrictReceiveParser but not included in the documentation.
[warning] getPathPaymentsStrictSendParsed, defined in ./src/utils/parsers/getPathPaymentsStrictSendParser.ts, is referenced by getPathPaymentsStrictSendParser.getPathPaymentsStrictSendParser but not included in the documentation.
[warning] getReceivedPaymentsParsed, defined in ./src/utils/parsers/getReceivedPaymentsParser.ts, is referenced by getReceivedPaymentsParser.getReceivedPaymentsParser but not included in the documentation.
[warning] getSentPaymentsParsed, defined in ./src/utils/parsers/getSentPaymentsParser.ts, is referenced by getSentPaymentsParser.getSentPaymentsParser but not included in the documentation.
[warning] PairEntry, defined in ./src/types/pairEntry.ts, is referenced by pairInstanceParser.pairInstanceParser but not included in the documentation.
[warning] ApiResponse, defined in ./src/types/mercury.ts, is referenced by Mercury._backendRequest._backendRequest but not included in the documentation.
[warning] GetAllContractEventSubscriptionsResponse, defined in ./src/types/getAllContractEventSubscriptions.ts, is referenced by Mercury.getAllContractEventSubscriptions.getAllContractEventSubscriptions but not included in the documentation.
[warning] GetAllFullAccountSubscriptionsResponse, defined in ./src/types/getAllFullAccountSubscriptions.ts, is referenced by Mercury.getAllFullAccountSubscriptions.getAllFullAccountSubscriptions but not included in the documentation.
[warning] ContractEntriesResponse, defined in ./src/types/getContractEntries.ts, is referenced by Mercury.getContractEntries.getContractEntries but not included in the documentation.
[warning] GetContractEventsResponse, defined in ./src/types/getContractEvents.ts, is referenced by Mercury.getContractEvents.getContractEvents but not included in the documentation.
[warning] LiquidityPoolDepositByPublicKeyResponse, defined in ./src/types/liquidityPool.ts, is referenced by Mercury.getLiquidityPoolDeposit.getLiquidityPoolDeposit but not included in the documentation.
[warning] LiquidityPoolWithdrawByPublicKeyResponse, defined in ./src/types/liquidityPool.ts, is referenced by Mercury.getLiquidityPoolWithdraw.getLiquidityPoolWithdraw but not included in the documentation.
[warning] GetPathPaymentsStrictReceiveByPublicKeyResponse, defined in ./src/types/pathPayments.ts, is referenced by Mercury.getPathPaymentsStrictReceive.getPathPaymentsStrictReceive but not included in the documentation.
[warning] GetPathPaymentsStrictSendByPublicKeyResponse, defined in ./src/types/pathPayments.ts, is referenced by Mercury.getPathPaymentsStrictSend.getPathPaymentsStrictSend but not included in the documentation.
[warning] GetReceivedPaymentsResponse, defined in ./src/types/payments.ts, is referenced by Mercury.getReceivedPayments.getReceivedPayments but not included in the documentation.
[warning] GetSentPaymentsResponse, defined in ./src/types/payments.ts, is referenced by Mercury.getSentPayments.getSentPayments but not included in the documentation.
[warning] AuthenticateResponse, defined in ./src/types/authenticate.ts, is referenced by Mercury.updateAccessToken.updateAccessToken but not included in the documentation.
[warning] MercuryOptions, defined in ./src/Mercury.ts, is referenced by Mercury.constructor.new Mercury.options but not included in the documentation.
[warning] backendRequestArgs, defined in ./src/types/mercury.ts, is referenced by Mercury._backendRequest._backendRequest.__namedParameters but not included in the documentation.
[warning] GraphQLRequestArgs, defined in ./src/types/mercury.ts, is referenced by Mercury._graphqlRequest._graphqlRequest.__namedParameters but not included in the documentation.
[warning] SubscribeToContractEventsArgs, defined in ./src/types/subscriptions.ts, is referenced by Mercury.subscribeToContractEvents.subscribeToContractEvents.args but not included in the documentation.
[warning] SubscribeToFullAccountArgs, defined in ./src/types/subscriptions.ts, is referenced by Mercury.subscribeToFullAccount.subscribeToFullAccount.args but not included in the documentation.
[warning] SubscribeToLedgerEntriesArgs, defined in ./src/types/subscriptions.ts, is referenced by Mercury.subscribeToLedgerEntries.subscribeToLedgerEntries.args but not included in the documentation.
[warning] SubscribeToLedgerEntriesExpirationArgs, defined in ./src/types/subscriptions.ts, is referenced by Mercury.subscribeToLedgerEntriesExpiration.subscribeToLedgerEntriesExpiration.args but not included in the documentation.
[warning] SubscribeToMultipleLedgerEntriesArgs, defined in ./src/types/subscriptions.ts, is referenced by Mercury.subscribeToMultipleLedgerEntries.subscribeToMultipleLedgerEntries.args but not included in the documentation.
[info] Documentation generated at ./docs
Done in 2.07s.
Proposed Implementation:
Ideally, I envision being able to use the library as follows:
const mercury = new Mercury(...);
mercury.soroswap.getAllLiquidityPools;
mercury.soroswap.getProvidedLiquidityOperations({filters});
The above methods are just examples, but the key idea is to be able to parse specific events from Soroswap contracts seamlessly.
Additionally, considering that contract addresses may change and that other AMM should be added (Phoenix, Comet, ...), I propose the Soroswap module should adhere to the following design principles:
Motivation:
Integrating a dedicated Soroswap module into the Mercury SDK would significantly streamline the development process for projects targeting Soroswap.
I believe this addition could represent a valuable collaboration opportunity and further the SDK's adoption and utility for the Stellar/Soroban developer community.
Useful code on mercury-client:
Implement this functions
Review subscriptions:
mercuryInstance.getContractSubscriptions({
contractId:"someContractAddress"
})
or for Accounts
mercuryInstance.getFullAccountSubscriptions({
publicKey:"someStellarAddress"
})
Also update readme
Example response:
{
"data": {
"eventByContractId": {
"edges": [
{
"node": {
"contractId": "CAGC46HNBMEZJP62PPTSUBUCS7LWBS5QLRNFSRCA4Q2A57YSPYBKGSTM",
"data": "AAAAEQAAAAEAAAAHAAAADwAAAAhhbW91bnRfYQAAAAoAAAAAAAAAAAAAAAAAB6EgAAAADwAAAAhhbW91bnRfYgAAAAoAAAAAAAAAAAAAAAAAB6EgAAAADwAAAAlsaXF1aWRpdHkAAAAAAAAKAAAAAAAAAAAAAAAAAAedOAAAAA8AAAAEcGFpcgAAABIAAAABKWo8s1oqRs3m6SECrLbp1lwHUFZQyZsSrXtFHvCChowAAAAPAAAAAnRvAAAAAAASAAAAAAAAAAB8PsDzDkmNms8A4lnHIdZ9cTT74tNur363of7rcGhnrAAAAA8AAAAHdG9rZW5fYQAAAAASAAAAAXUaFx81PMmF/kd4w+tGbMn5Z71hnhczKNB8SbKUEUsdAAAADwAAAAd0b2tlbl9iAAAAABIAAAABlVXiXu6Hby7pN7xOcqGomnOIu/y6TvVyHozgurQbF9E=",
"ledger": 3029089,
"ledgerTimestamp": 1702655890,
"topic2": "AAAADwAAAANhZGQA",
"topic1": "AAAADgAAAA5Tb3Jvc3dhcFJvdXRlcgAA",
"topic4": null,
"topic3": null
}
}
]
}
}
}
You can use router address : CAGC46HNBMEZJP62PPTSUBUCS7LWBS5QLRNFSRCA4Q2A57YSPYBKGSTM
write functions that parses data, for example:
Parse sent payments:
import { parseSentPayment } from "mercury-sdk/utils";
async function someFunction() {
const data = await mercuryInstance.getSentPayments({
address:"someStellarAddress"
})
const parsedData = parseSentPayment(data)
console.log("parsedData:", parsedData)
}
The output:
[
{
"from": "address1",
"to": "address2",
"asset": {
"asset_type": "",
"isuer":""
},
"amount":"1000",
]
Do it for:
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.