@xswap-link/sdk 0.0.7 → 0.0.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +12 -0
- package/dist/index.d.mts +15 -1
- package/dist/index.d.ts +15 -1
- package/dist/index.js +11 -0
- package/dist/index.mjs +10 -0
- package/package.json +1 -1
- package/src/models/BridgeToken.ts +3 -0
- package/src/models/Prices.ts +9 -0
- package/src/models/index.ts +2 -0
- package/src/services/api.ts +13 -0
package/CHANGELOG.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -5,6 +5,10 @@ type ApiOverrides = {
|
|
|
5
5
|
apiUrl?: string;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
type BridgeToken = {
|
|
9
|
+
[chainId: string]: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
8
12
|
declare enum Web3Environment {
|
|
9
13
|
DEVNET = "devnet",
|
|
10
14
|
TESTNET = "testnet",
|
|
@@ -149,6 +153,15 @@ type ReferralInfo = {
|
|
|
149
153
|
ipAddress: string;
|
|
150
154
|
};
|
|
151
155
|
|
|
156
|
+
type Prices = {
|
|
157
|
+
blockchainId: string;
|
|
158
|
+
updatedAt: Date;
|
|
159
|
+
prices: TokenPrice;
|
|
160
|
+
};
|
|
161
|
+
type TokenPrice = {
|
|
162
|
+
[tokenAddress: string]: string;
|
|
163
|
+
};
|
|
164
|
+
|
|
152
165
|
declare const DEFAULT_API_URL = "https://xswap.link/api";
|
|
153
166
|
declare const DEFAULT_DB_ERROR = "No data for provided parameters";
|
|
154
167
|
declare const DEFAULT_ECOSYSTEM = Ecosystem.EVM;
|
|
@@ -344,6 +357,7 @@ declare function getChainData(chainId?: string, ecosystem?: Ecosystem, overrides
|
|
|
344
357
|
* @param overrides optional - e.g. {apiUrl}
|
|
345
358
|
*/
|
|
346
359
|
declare function getTokens(chainId: string, address?: string, ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Token[]>;
|
|
360
|
+
declare function getBridgeTokens(overrides?: ApiOverrides): Promise<BridgeToken[]>;
|
|
347
361
|
|
|
348
362
|
declare const safeBigNumberFrom: (value: string) => BigNumber;
|
|
349
363
|
|
|
@@ -353,4 +367,4 @@ declare const generateApproveTxData: (tokenAddress: string, spender: string, amo
|
|
|
353
367
|
data: string;
|
|
354
368
|
};
|
|
355
369
|
|
|
356
|
-
export { type AddReferralPayload, type ApiOverrides, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, DEFAULT_API_URL, DEFAULT_DB_ERROR, DEFAULT_ECOSYSTEM, DEFAULT_GAS_LIMIT_MULTIPLIER, DEFAULT_NATIVE_FEE_MULTIPLIER_PERCENTAGE, ERC20Abi, Ecosystem, Environment, type GetRoutePayload, type Protocol, type Referral, type ReferralInfo, type Route, type Token, Web3Environment, XSwapCallType, type XSwapFee, type XSwapFees, XSwapRouterAbi, generateApproveTxData, getChainData, getChains, getRoute, getTokens, safeBigNumberFrom };
|
|
370
|
+
export { type AddReferralPayload, type ApiOverrides, type BridgeToken, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, DEFAULT_API_URL, DEFAULT_DB_ERROR, DEFAULT_ECOSYSTEM, DEFAULT_GAS_LIMIT_MULTIPLIER, DEFAULT_NATIVE_FEE_MULTIPLIER_PERCENTAGE, ERC20Abi, Ecosystem, Environment, type GetRoutePayload, type Prices, type Protocol, type Referral, type ReferralInfo, type Route, type Token, type TokenPrice, Web3Environment, XSwapCallType, type XSwapFee, type XSwapFees, XSwapRouterAbi, generateApproveTxData, getBridgeTokens, getChainData, getChains, getRoute, getTokens, safeBigNumberFrom };
|
package/dist/index.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ type ApiOverrides = {
|
|
|
5
5
|
apiUrl?: string;
|
|
6
6
|
};
|
|
7
7
|
|
|
8
|
+
type BridgeToken = {
|
|
9
|
+
[chainId: string]: string;
|
|
10
|
+
};
|
|
11
|
+
|
|
8
12
|
declare enum Web3Environment {
|
|
9
13
|
DEVNET = "devnet",
|
|
10
14
|
TESTNET = "testnet",
|
|
@@ -149,6 +153,15 @@ type ReferralInfo = {
|
|
|
149
153
|
ipAddress: string;
|
|
150
154
|
};
|
|
151
155
|
|
|
156
|
+
type Prices = {
|
|
157
|
+
blockchainId: string;
|
|
158
|
+
updatedAt: Date;
|
|
159
|
+
prices: TokenPrice;
|
|
160
|
+
};
|
|
161
|
+
type TokenPrice = {
|
|
162
|
+
[tokenAddress: string]: string;
|
|
163
|
+
};
|
|
164
|
+
|
|
152
165
|
declare const DEFAULT_API_URL = "https://xswap.link/api";
|
|
153
166
|
declare const DEFAULT_DB_ERROR = "No data for provided parameters";
|
|
154
167
|
declare const DEFAULT_ECOSYSTEM = Ecosystem.EVM;
|
|
@@ -344,6 +357,7 @@ declare function getChainData(chainId?: string, ecosystem?: Ecosystem, overrides
|
|
|
344
357
|
* @param overrides optional - e.g. {apiUrl}
|
|
345
358
|
*/
|
|
346
359
|
declare function getTokens(chainId: string, address?: string, ecosystem?: Ecosystem, overrides?: ApiOverrides): Promise<Token[]>;
|
|
360
|
+
declare function getBridgeTokens(overrides?: ApiOverrides): Promise<BridgeToken[]>;
|
|
347
361
|
|
|
348
362
|
declare const safeBigNumberFrom: (value: string) => BigNumber;
|
|
349
363
|
|
|
@@ -353,4 +367,4 @@ declare const generateApproveTxData: (tokenAddress: string, spender: string, amo
|
|
|
353
367
|
data: string;
|
|
354
368
|
};
|
|
355
369
|
|
|
356
|
-
export { type AddReferralPayload, type ApiOverrides, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, DEFAULT_API_URL, DEFAULT_DB_ERROR, DEFAULT_ECOSYSTEM, DEFAULT_GAS_LIMIT_MULTIPLIER, DEFAULT_NATIVE_FEE_MULTIPLIER_PERCENTAGE, ERC20Abi, Ecosystem, Environment, type GetRoutePayload, type Protocol, type Referral, type ReferralInfo, type Route, type Token, Web3Environment, XSwapCallType, type XSwapFee, type XSwapFees, XSwapRouterAbi, generateApproveTxData, getChainData, getChains, getRoute, getTokens, safeBigNumberFrom };
|
|
370
|
+
export { type AddReferralPayload, type ApiOverrides, type BridgeToken, type Chain, type CoinTypeAddress, type CollectFees, type ContractCall, DEFAULT_API_URL, DEFAULT_DB_ERROR, DEFAULT_ECOSYSTEM, DEFAULT_GAS_LIMIT_MULTIPLIER, DEFAULT_NATIVE_FEE_MULTIPLIER_PERCENTAGE, ERC20Abi, Ecosystem, Environment, type GetRoutePayload, type Prices, type Protocol, type Referral, type ReferralInfo, type Route, type Token, type TokenPrice, Web3Environment, XSwapCallType, type XSwapFee, type XSwapFees, XSwapRouterAbi, generateApproveTxData, getBridgeTokens, getChainData, getChains, getRoute, getTokens, safeBigNumberFrom };
|
package/dist/index.js
CHANGED
|
@@ -32,6 +32,7 @@ __export(xswap_sdk_exports, {
|
|
|
32
32
|
XSwapCallType: () => XSwapCallType,
|
|
33
33
|
XSwapRouterAbi: () => XSwapRouterAbi,
|
|
34
34
|
generateApproveTxData: () => generateApproveTxData,
|
|
35
|
+
getBridgeTokens: () => getBridgeTokens,
|
|
35
36
|
getChainData: () => getChainData,
|
|
36
37
|
getChains: () => getChains,
|
|
37
38
|
getRoute: () => getRoute,
|
|
@@ -1607,6 +1608,15 @@ async function getTokens(chainId, address, ecosystem, overrides) {
|
|
|
1607
1608
|
overrides
|
|
1608
1609
|
);
|
|
1609
1610
|
}
|
|
1611
|
+
async function getBridgeTokens(overrides) {
|
|
1612
|
+
return _sendRequest(
|
|
1613
|
+
`/bridgeTokens`,
|
|
1614
|
+
{
|
|
1615
|
+
method: "GET"
|
|
1616
|
+
},
|
|
1617
|
+
overrides
|
|
1618
|
+
);
|
|
1619
|
+
}
|
|
1610
1620
|
|
|
1611
1621
|
// src/utils/bigNumbers.ts
|
|
1612
1622
|
var import_bignumber = require("bignumber.js");
|
|
@@ -1641,6 +1651,7 @@ var generateApproveTxData = (tokenAddress, spender, amount) => {
|
|
|
1641
1651
|
XSwapCallType,
|
|
1642
1652
|
XSwapRouterAbi,
|
|
1643
1653
|
generateApproveTxData,
|
|
1654
|
+
getBridgeTokens,
|
|
1644
1655
|
getChainData,
|
|
1645
1656
|
getChains,
|
|
1646
1657
|
getRoute,
|
package/dist/index.mjs
CHANGED
|
@@ -1565,6 +1565,15 @@ async function getTokens(chainId, address, ecosystem, overrides) {
|
|
|
1565
1565
|
overrides
|
|
1566
1566
|
);
|
|
1567
1567
|
}
|
|
1568
|
+
async function getBridgeTokens(overrides) {
|
|
1569
|
+
return _sendRequest(
|
|
1570
|
+
`/bridgeTokens`,
|
|
1571
|
+
{
|
|
1572
|
+
method: "GET"
|
|
1573
|
+
},
|
|
1574
|
+
overrides
|
|
1575
|
+
);
|
|
1576
|
+
}
|
|
1568
1577
|
|
|
1569
1578
|
// src/utils/bigNumbers.ts
|
|
1570
1579
|
import { BigNumber as BigNumberJS } from "bignumber.js";
|
|
@@ -1598,6 +1607,7 @@ export {
|
|
|
1598
1607
|
XSwapCallType,
|
|
1599
1608
|
XSwapRouterAbi,
|
|
1600
1609
|
generateApproveTxData,
|
|
1610
|
+
getBridgeTokens,
|
|
1601
1611
|
getChainData,
|
|
1602
1612
|
getChains,
|
|
1603
1613
|
getRoute,
|
package/package.json
CHANGED
package/src/models/index.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
export * from "./ApiOverrides";
|
|
2
|
+
export * from "./BridgeToken";
|
|
2
3
|
export * from "./Chain";
|
|
3
4
|
export * from "./CoinTypeAddress";
|
|
4
5
|
export * from "./CollectFees";
|
|
@@ -14,3 +15,4 @@ export * from "./XSwapCallType";
|
|
|
14
15
|
export * from "./XSwapFee";
|
|
15
16
|
export * from "./XSwapFees";
|
|
16
17
|
export * from "./Referral";
|
|
18
|
+
export * from "./Prices";
|
package/src/services/api.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import {
|
|
2
2
|
ApiOverrides,
|
|
3
|
+
BridgeToken,
|
|
3
4
|
Chain,
|
|
4
5
|
Ecosystem,
|
|
5
6
|
GetRoutePayload,
|
|
@@ -115,3 +116,15 @@ export async function getTokens(
|
|
|
115
116
|
overrides
|
|
116
117
|
);
|
|
117
118
|
}
|
|
119
|
+
|
|
120
|
+
export async function getBridgeTokens(
|
|
121
|
+
overrides?: ApiOverrides
|
|
122
|
+
): Promise<BridgeToken[]> {
|
|
123
|
+
return _sendRequest<BridgeToken[]>(
|
|
124
|
+
`/bridgeTokens`,
|
|
125
|
+
{
|
|
126
|
+
method: "GET",
|
|
127
|
+
},
|
|
128
|
+
overrides
|
|
129
|
+
);
|
|
130
|
+
}
|