zeriontech / defi-sdk-js Goto Github PK
View Code? Open in Web Editor NEWJavaScript/TypeScript wrapper for DeFi SDK
Home Page: https://docs.zerion.io
License: MIT License
JavaScript/TypeScript wrapper for DeFi SDK
Home Page: https://docs.zerion.io
License: MIT License
I'm trying to use the SDK and execute this script
import {client} from 'defi-sdk';
const BASE_URL = 'wss://api-v4.zerion.io/';
client.configure({url: BASE_URL, apiToken: 'my_token'});
client.subscribe({
namespace: 'address',
body: {
scope: ['transactions'],
payload: {
address: 'my_address',
currency: 'usd',
},
},
onMessage: (event, data) => {
console.log(data);
return;
},
});
but when I try to execute the script via npx ts-node server/zerion2.ts
I get this error
SyntaxError: Cannot use import statement outside a module
at Object.compileFunction (node:vm:352:18)
at wrapSafe (node:internal/modules/cjs/loader:1032:15)
at Module._compile (node:internal/modules/cjs/loader:1067:27)
at Module._extensions..js (node:internal/modules/cjs/loader:1157:10)
at Object.require.extensions.<computed> [as .js] (/Users/zerion/node_modules/ts-node/src/index.ts:1608:43)
at Module.load (node:internal/modules/cjs/loader:981:32)
at Function.Module._load (node:internal/modules/cjs/loader:822:12)
at Module.require (node:internal/modules/cjs/loader:1005:19)
at require (node:internal/modules/cjs/helpers:102:18)
at Object.<anonymous> (/Users/zerion/server/zerion2.ts:1:1)
HI, Kindly can you please help me out, is there any possibility to get assets of different chains such as FTM, AVAX, BNB etc. Thank You
Code example:
const entry = useAddressActions(
{
...params,
currency: 'usd',
actions_search_query: searchQuery,
},
{
limit: 30,
listenForUpdates: true,
paginatedCacheMode: 'first-page',
onAnyMessage: useCallback((a, b, c) => {
console.log('onAnyMessage', { a, b, c }); // this is called more than once for each item
}, []),
}
);
It's called twice for each item for first "page" and then increases for each next page load.
It could be great if you could export types in the main export so we can use them in our typescript codes.
I'm using this for now as a workaround:
import { ProtocolBalanceInterface } from 'defi-sdk/dist/protocols/interfaces'
sometimes got error contract not deployed (contractAddress="0x06FE76B2f432fdfEcAEf1a7d4f6C3d41B5861672", operation="getDeployed", version=4.0.48
according https://docs.zerion.io/smart-contracts/addresses/main-contracts
the new AdapterRegistry (v3) is 0xaDfc6460233221eCa99daC25d00f98d32eA3989e
Maker seems not supported
In output of getProtocolNames there is "Maker Governance" but no "Maker" or "Maker Dao"
Tried this code that works for "Compound"
var protocol = "Maker";
defiSdk.getProtocolBalance(account, protocol).then(function (balance) {
console.log('\n\ngetProtocolBalance "Maker"');
console.log(JSON.stringify(balance, null, 2));
});
I got exception
(node:7444) UnhandledPromiseRejectionWarning: ProtocolDoesNotExistError: Protocol [Maker] does not exists get exception
Please provide solution or workaround
Regards
Jayanta
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.