@dzapio/sdk 1.0.2 → 1.0.3
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/dist/api/index.d.ts +1 -1
- package/dist/artifacts/ERC20Permit.d.ts +1 -1
- package/dist/artifacts/default/DZapCoreV2Abi.d.ts +2 -0
- package/dist/artifacts/default/index.d.ts +2 -1
- package/dist/artifacts/index.d.ts +2 -2
- package/dist/config/index.d.ts +36 -0
- package/dist/constants/chains.d.ts +1 -0
- package/dist/constants/contract.d.ts +2 -2
- package/dist/constants/erc20.d.ts +3 -0
- package/dist/constants/index.d.ts +1 -0
- package/dist/constants/rpc.d.ts +1 -1
- package/dist/dZapClient/index.d.ts +27 -16
- package/dist/enums/index.d.ts +8 -0
- package/dist/index.d.ts +6 -3
- package/dist/index.js +1 -1
- package/dist/index.m.js +1 -1
- package/dist/index.umd.js +1 -1
- package/dist/service/price/index.d.ts +1 -1
- package/dist/service/price/provider/coingecko/index.d.ts +1 -1
- package/dist/service/price/provider/defiLlama/index.d.ts +1 -1
- package/dist/service/price/types/IPriceProvider.d.ts +1 -1
- package/dist/transactionHandlers/generic.d.ts +2 -2
- package/dist/transactionHandlers/permit.d.ts +10 -8
- package/dist/transactionHandlers/trade.d.ts +7 -2
- package/dist/transactionHandlers/zap.d.ts +3 -3
- package/dist/types/chains.d.ts +1 -1
- package/dist/types/contract.d.ts +1 -1
- package/dist/types/index.d.ts +12 -13
- package/dist/types/wallet.d.ts +2 -0
- package/dist/types/zap/index.d.ts +1 -1
- package/dist/types/zap/path.d.ts +1 -1
- package/dist/types/zap/pool.d.ts +2 -1
- package/dist/types/zap/status.d.ts +3 -0
- package/dist/types/zap/step.d.ts +1 -1
- package/dist/utils/amount.d.ts +4 -4
- package/dist/utils/axios.d.ts +1 -1
- package/dist/utils/eip-5792/batchApproveTokens.d.ts +21 -0
- package/dist/utils/eip-5792/index.d.ts +3 -0
- package/dist/utils/eip-5792/isBatchTxnSupportedByWallet.d.ts +6 -0
- package/dist/utils/eip-5792/sendBatchCalls.d.ts +10 -0
- package/dist/utils/eip-5792/waitForBatchTransactionReceipt.d.ts +4 -0
- package/dist/utils/encodeApproveCall.d.ts +6 -0
- package/dist/utils/erc20.d.ts +8 -6
- package/dist/utils/errors.d.ts +2 -1
- package/dist/utils/index.d.ts +2 -3
- package/dist/utils/multicall.d.ts +4 -2
- package/dist/utils/permit/permit2Methods.d.ts +6 -5
- package/dist/utils/permit/permitMethods.d.ts +17 -9
- package/dist/utils/signTypedData.d.ts +3 -3
- package/dist/utils/tokens.d.ts +2 -2
- package/dist/utils/updateQuotes.d.ts +2 -2
- package/package.json +17 -3
- package/dist/config.d.ts +0 -5
package/dist/api/index.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { CancelToken } from 'axios';
|
|
2
|
-
import { ZapBuildTxnRequest, ZapPoolDetailsRequest, ZapPoolsRequest, ZapPositionsRequest, ZapQuoteRequest, ZapStatusRequest } from 'src/types/zap';
|
|
3
2
|
import { CalculatePointsRequest, TradeBuildTxnRequest, TradeQuotesRequest } from '../types';
|
|
3
|
+
import { ZapBuildTxnRequest, ZapPoolDetailsRequest, ZapPoolsRequest, ZapPositionsRequest, ZapQuoteRequest, ZapStatusRequest } from '../types/zap';
|
|
4
4
|
export declare const fetchTradeQuotes: (request: TradeQuotesRequest) => Promise<any>;
|
|
5
5
|
export declare const fetchTradeBuildTxnData: (request: TradeBuildTxnRequest) => Promise<any>;
|
|
6
6
|
export declare const fetchZapBuildTxnData: (request: ZapBuildTxnRequest, cancelToken?: CancelToken) => Promise<any>;
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { abi as dZapCoreAbi } from './DZapCoreAbi';
|
|
2
|
+
import { abi as dZapCoreV2Abi } from './DZapCoreV2Abi';
|
|
2
3
|
import { abi as dZapDcaAbi } from './DZapDcaAbi';
|
|
3
4
|
import { abi as permit2Abi } from './Permit2Abi';
|
|
4
5
|
import { abi as erc20Abi } from './erc20Abi';
|
|
5
|
-
export { dZapCoreAbi,
|
|
6
|
+
export { dZapCoreAbi, dZapCoreV2Abi, dZapDcaAbi, erc20Abi, permit2Abi };
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { dZapCoreAbi, dZapDcaAbi, permit2Abi, erc20Abi } from './default';
|
|
2
|
-
export { dZapCoreAbi, dZapDcaAbi, permit2Abi, erc20Abi };
|
|
1
|
+
import { dZapCoreAbi, dZapCoreV2Abi, dZapDcaAbi, permit2Abi, erc20Abi } from './default';
|
|
2
|
+
export { dZapCoreAbi, dZapCoreV2Abi, dZapDcaAbi, permit2Abi, erc20Abi };
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
export declare function createConfig(): {
|
|
2
|
+
getApiKey: () => string | null;
|
|
3
|
+
setApiKey: (apiKey: string) => void;
|
|
4
|
+
getRpcUrlsByChainId: (chainId: number) => string[];
|
|
5
|
+
setRpcUrlsByChainId: (rpcUrlsByChainId: Record<number, string[]>) => void;
|
|
6
|
+
getEip2612DisabledChains: () => number[];
|
|
7
|
+
setEip2612DisabledChains: (chains: number[]) => void;
|
|
8
|
+
getAppEnv: () => string;
|
|
9
|
+
setAppEnv: (env: string) => void;
|
|
10
|
+
getBaseApiUrl: () => string;
|
|
11
|
+
setBaseApiUrl: (url: string) => void;
|
|
12
|
+
getZapApiUrl: () => string;
|
|
13
|
+
setZapApiUrl: (url: string) => void;
|
|
14
|
+
getVersionPostfix: () => string;
|
|
15
|
+
setVersionPostfix: (postfix: string) => void;
|
|
16
|
+
getBaseUrl: () => string;
|
|
17
|
+
getBaseZapUrl: () => string;
|
|
18
|
+
};
|
|
19
|
+
export declare const config: {
|
|
20
|
+
getApiKey: () => string | null;
|
|
21
|
+
setApiKey: (apiKey: string) => void;
|
|
22
|
+
getRpcUrlsByChainId: (chainId: number) => string[];
|
|
23
|
+
setRpcUrlsByChainId: (rpcUrlsByChainId: Record<number, string[]>) => void;
|
|
24
|
+
getEip2612DisabledChains: () => number[];
|
|
25
|
+
setEip2612DisabledChains: (chains: number[]) => void;
|
|
26
|
+
getAppEnv: () => string;
|
|
27
|
+
setAppEnv: (env: string) => void;
|
|
28
|
+
getBaseApiUrl: () => string;
|
|
29
|
+
setBaseApiUrl: (url: string) => void;
|
|
30
|
+
getZapApiUrl: () => string;
|
|
31
|
+
setZapApiUrl: (url: string) => void;
|
|
32
|
+
getVersionPostfix: () => string;
|
|
33
|
+
setVersionPostfix: (postfix: string) => void;
|
|
34
|
+
getBaseUrl: () => string;
|
|
35
|
+
getBaseZapUrl: () => string;
|
|
36
|
+
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { HexString } from '
|
|
2
|
-
import { ExclusiveChainIds } from '
|
|
1
|
+
import { HexString } from '../types';
|
|
2
|
+
import { ExclusiveChainIds } from '../types/chains';
|
|
3
3
|
export declare const exclusivePermit2Addresses: {
|
|
4
4
|
[key: ExclusiveChainIds]: HexString;
|
|
5
5
|
};
|
|
@@ -13,6 +13,9 @@ export declare const erc20Functions: {
|
|
|
13
13
|
readonly balanceOf: "balanceOf";
|
|
14
14
|
readonly decimals: "decimals";
|
|
15
15
|
readonly symbol: "symbol";
|
|
16
|
+
readonly version: "version";
|
|
17
|
+
readonly nonces: "nonces";
|
|
18
|
+
readonly domainSeparator: "DOMAIN_SEPARATOR";
|
|
16
19
|
};
|
|
17
20
|
export declare const eip2612PermitFunctions: {
|
|
18
21
|
readonly permit: "permit";
|
package/dist/constants/rpc.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
export declare const RPC_RETRY_DELAY = 500;
|
|
2
|
-
export declare const RPC_BATCHING_WAIT_TIME =
|
|
2
|
+
export declare const RPC_BATCHING_WAIT_TIME = 1000;
|
|
@@ -1,19 +1,18 @@
|
|
|
1
|
-
import { Signer
|
|
2
|
-
import { StatusCodes, TxnStatus } from 'src/enums';
|
|
3
|
-
import { ApprovalMode, AvailableDZapServices, CalculatePointsRequest, ChainData, ExecuteTxnData, HexString, OtherAvailableAbis, PermitMode, TokenInfo, TokenResponse, TradeBuildTxnRequest, TradeBuildTxnResponse, TradeQuotesRequest, TradeQuotesResponse, TradeStatusResponse } from 'src/types';
|
|
4
|
-
import { ZapBuildTxnRequest, ZapBuildTxnResponse, ZapChains, ZapPoolDetails, ZapPoolDetailsRequest, ZapPoolsRequest, ZapPoolsResponse, ZapPositionsRequest, ZapPositionsResponse, ZapProviders, ZapQuoteRequest, ZapQuoteResponse, ZapStatusRequest, ZapStatusResponse } from 'src/types/zap';
|
|
5
|
-
import { ZapTransactionStep } from 'src/types/zap/step';
|
|
1
|
+
import { Signer } from 'ethers';
|
|
6
2
|
import { TransactionReceipt, WalletClient } from 'viem';
|
|
3
|
+
import { ContractVersion, StatusCodes, TxnStatus } from '../enums';
|
|
4
|
+
import { ApprovalMode, AvailableDZapServices, CalculatePointsRequest, ChainData, ExecuteTxnData, HexString, OtherAvailableAbis, PermitMode, TokenInfo, TokenResponse, TradeBuildTxnRequest, TradeBuildTxnResponse, TradeQuotesRequest, TradeQuotesResponse, TradeStatusResponse } from '../types';
|
|
5
|
+
import { ZapBuildTxnRequest, ZapBuildTxnResponse, ZapChains, ZapPoolDetails, ZapPoolDetailsRequest, ZapPoolsRequest, ZapPoolsResponse, ZapPositionsRequest, ZapPositionsResponse, ZapProviders, ZapQuoteRequest, ZapQuoteResponse, ZapStatusRequest, ZapStatusResponse, ZapTransactionStep } from '../types/zap';
|
|
6
|
+
import { BatchCallParams } from '../utils/eip-5792';
|
|
7
7
|
declare class DZapClient {
|
|
8
8
|
private static instance;
|
|
9
9
|
private cancelTokenSource;
|
|
10
10
|
private static chainConfig;
|
|
11
11
|
private priceService;
|
|
12
|
-
rpcUrlsByChainId: Record<number, string[]>;
|
|
13
12
|
private constructor();
|
|
14
|
-
static getInstance(rpcUrlsByChainId?: Record<number, string[]>): DZapClient;
|
|
13
|
+
static getInstance(apiKey?: string, rpcUrlsByChainId?: Record<number, string[]>): DZapClient;
|
|
15
14
|
static getChainConfig(): Promise<ChainData>;
|
|
16
|
-
static getDZapAbi(service: AvailableDZapServices): import("viem").Abi;
|
|
15
|
+
static getDZapAbi(service: AvailableDZapServices, version: ContractVersion): import("viem").Abi;
|
|
17
16
|
static getOtherAbi: (name: OtherAvailableAbis) => ({
|
|
18
17
|
inputs: {
|
|
19
18
|
internalType: string;
|
|
@@ -260,11 +259,13 @@ declare class DZapClient {
|
|
|
260
259
|
getTokenDetails(tokenAddress: string, chainId: number, account?: string, includeBalance?: boolean, includePrice?: boolean): Promise<TokenInfo>;
|
|
261
260
|
getTokensDetails(tokenAddresses: string[], chainId: number, account?: string, includeBalance?: boolean, includePrice?: boolean): Promise<Record<string, TokenInfo>>;
|
|
262
261
|
getTokenPrices(tokenAddresses: string[], chainId: number): Promise<Record<string, string | null>>;
|
|
263
|
-
trade({ request, signer, txnData, }: {
|
|
262
|
+
trade({ request, signer, txnData, batchTransaction, rpcUrls, }: {
|
|
264
263
|
request: TradeBuildTxnRequest;
|
|
265
264
|
signer: Signer | WalletClient;
|
|
266
265
|
txnData?: TradeBuildTxnResponse;
|
|
267
|
-
|
|
266
|
+
batchTransaction?: boolean;
|
|
267
|
+
rpcUrls?: string[];
|
|
268
|
+
}): Promise<import("../types").DZapTransactionResponse>;
|
|
268
269
|
sendTransaction({ signer, txnData }: {
|
|
269
270
|
chainId: number;
|
|
270
271
|
signer: Signer | WalletClient;
|
|
@@ -279,13 +280,17 @@ declare class DZapClient {
|
|
|
279
280
|
code: StatusCodes;
|
|
280
281
|
txnHash: HexString;
|
|
281
282
|
}>;
|
|
283
|
+
waitForBatchTransactionReceipt({ walletClient, batchHash }: {
|
|
284
|
+
walletClient: WalletClient;
|
|
285
|
+
batchHash: HexString;
|
|
286
|
+
}): Promise<import("..").WalletCallReceipt>;
|
|
282
287
|
decodeTxnData({ data, service, chainId }: {
|
|
283
288
|
data: TransactionReceipt;
|
|
284
289
|
service: AvailableDZapServices;
|
|
285
290
|
chainId: number;
|
|
286
291
|
}): Promise<{
|
|
287
292
|
swapFailPairs: string[];
|
|
288
|
-
swapInfo: import("
|
|
293
|
+
swapInfo: import("../types").SwapInfo | import("../types").SwapInfo[];
|
|
289
294
|
}>;
|
|
290
295
|
calculatePoints(request: CalculatePointsRequest): Promise<{
|
|
291
296
|
points: number;
|
|
@@ -299,7 +304,7 @@ declare class DZapClient {
|
|
|
299
304
|
sender: HexString;
|
|
300
305
|
tokens: {
|
|
301
306
|
address: HexString;
|
|
302
|
-
amount:
|
|
307
|
+
amount: string;
|
|
303
308
|
}[];
|
|
304
309
|
service: AvailableDZapServices;
|
|
305
310
|
rpcUrls?: string[];
|
|
@@ -321,7 +326,7 @@ declare class DZapClient {
|
|
|
321
326
|
signer: WalletClient | Signer;
|
|
322
327
|
tokens: {
|
|
323
328
|
address: HexString;
|
|
324
|
-
amount:
|
|
329
|
+
amount: string;
|
|
325
330
|
}[];
|
|
326
331
|
approvalTxnCallback?: ({ txnDetails, address, }: {
|
|
327
332
|
txnDetails: {
|
|
@@ -347,14 +352,14 @@ declare class DZapClient {
|
|
|
347
352
|
amount: string;
|
|
348
353
|
}[];
|
|
349
354
|
service: AvailableDZapServices;
|
|
350
|
-
signer: WalletClient |
|
|
355
|
+
signer: WalletClient | Signer;
|
|
351
356
|
spender?: HexString;
|
|
352
357
|
rpcUrls?: string[];
|
|
353
358
|
permitType?: PermitMode;
|
|
354
359
|
signatureCallback?: ({ permitData, srcToken, amount, permitType, }: {
|
|
355
360
|
permitData: HexString;
|
|
356
361
|
srcToken: string;
|
|
357
|
-
amount:
|
|
362
|
+
amount: string;
|
|
358
363
|
permitType: PermitMode;
|
|
359
364
|
}) => Promise<void>;
|
|
360
365
|
}): Promise<{
|
|
@@ -370,7 +375,7 @@ declare class DZapClient {
|
|
|
370
375
|
request: ZapBuildTxnRequest;
|
|
371
376
|
signer: WalletClient | Signer;
|
|
372
377
|
steps?: ZapTransactionStep[];
|
|
373
|
-
}): Promise<import("
|
|
378
|
+
}): Promise<import("../types").DZapTransactionResponse | {
|
|
374
379
|
status: TxnStatus.success;
|
|
375
380
|
code: StatusCodes | number;
|
|
376
381
|
txnHash: HexString;
|
|
@@ -379,6 +384,12 @@ declare class DZapClient {
|
|
|
379
384
|
getZapQuote(request: ZapQuoteRequest): Promise<ZapQuoteResponse>;
|
|
380
385
|
getZapTxnStatus(request: ZapStatusRequest): Promise<ZapStatusResponse>;
|
|
381
386
|
getBalances(chainId: number, account: string): Promise<Record<string, TokenResponse>>;
|
|
387
|
+
sendBatchCalls({ walletClient, calls }: {
|
|
388
|
+
walletClient: WalletClient;
|
|
389
|
+
calls: BatchCallParams[];
|
|
390
|
+
}): Promise<{
|
|
391
|
+
id: string;
|
|
392
|
+
} | null>;
|
|
382
393
|
getZapPositions(request: ZapPositionsRequest): Promise<ZapPositionsResponse>;
|
|
383
394
|
getZapPools(request: ZapPoolsRequest): Promise<ZapPoolsResponse>;
|
|
384
395
|
getZapPoolDetails(request: ZapPoolDetailsRequest): Promise<ZapPoolDetails>;
|
package/dist/enums/index.d.ts
CHANGED
|
@@ -11,6 +11,14 @@ export declare enum PermitType {
|
|
|
11
11
|
PERMIT2_TRANSFER_FROM = 1,
|
|
12
12
|
PERMIT2_APPROVE = 2
|
|
13
13
|
}
|
|
14
|
+
export declare enum V2PermitMode {
|
|
15
|
+
PERMIT = 0,
|
|
16
|
+
PERMIT2_APPROVE = 1
|
|
17
|
+
}
|
|
18
|
+
export declare enum ContractVersion {
|
|
19
|
+
v1 = "v1",
|
|
20
|
+
v2 = "v2"
|
|
21
|
+
}
|
|
14
22
|
export declare enum TxnStatus {
|
|
15
23
|
mining = "mining",
|
|
16
24
|
success = "success",
|
package/dist/index.d.ts
CHANGED
|
@@ -2,14 +2,17 @@ import { OtherAbis, QuoteFilters, Services, STATUS } from './constants';
|
|
|
2
2
|
import { SignatureExpiryInSecs } from './constants/permit2';
|
|
3
3
|
import { PermitType, StatusCodes, TxnStatus } from './enums';
|
|
4
4
|
import { ApiRpcResponse, ApprovalMode, Chain, ChainData, contractErrorActions, ContractErrorResponse, DZapTransactionResponse, ExecuteTxnData, Fee, FeeDetails, HexString, PermitMode, ProviderDetails, QuoteFilter, SwapInfo, Token, TokenInfo, TokenResponse, TradeBuildTxnRequest, TradeBuildTxnRequestData, TradeBuildTxnResponse, TradePath, TradeQuotesRequest, TradeQuotesRequestData, TradeQuotesResponse, TradeStatusResponse, TradeStep } from './types';
|
|
5
|
-
import { PsbtInput, PsbtOutput } from './types/btc';
|
|
5
|
+
import type { PsbtInput, PsbtOutput } from './types/btc';
|
|
6
6
|
import { formatToken, getTokensPairKey } from './utils';
|
|
7
7
|
import { ApprovalModes } from './constants/approval';
|
|
8
8
|
import { erc20Functions } from './constants/erc20';
|
|
9
9
|
import { PermitTypes } from './constants/permit';
|
|
10
10
|
import DZapClient from './dZapClient';
|
|
11
|
+
import type { WalletCallReceipt } from './types/wallet';
|
|
12
|
+
import type { ZapStatusResponse } from './types/zap';
|
|
13
|
+
import { isBatchTxnSupportedByWallet } from './utils/eip-5792/isBatchTxnSupportedByWallet';
|
|
11
14
|
import { checkEIP2612PermitSupport } from './utils/permit/permitMethods';
|
|
12
|
-
import { ZapStatusResponse } from './types/zap';
|
|
13
15
|
export * from './types/zap';
|
|
14
16
|
export * from './zap/constants';
|
|
15
|
-
export {
|
|
17
|
+
export { ApprovalModes, checkEIP2612PermitSupport, DZapClient, erc20Functions, formatToken, getTokensPairKey, OtherAbis, PermitType, PermitTypes, QuoteFilters, Services, SignatureExpiryInSecs, STATUS, StatusCodes, TxnStatus, contractErrorActions, isBatchTxnSupportedByWallet, };
|
|
18
|
+
export type { ApiRpcResponse, ApprovalMode, Chain, ChainData, ContractErrorResponse, DZapTransactionResponse, ExecuteTxnData, Fee, FeeDetails, HexString, PermitMode, ProviderDetails, PsbtInput, PsbtOutput, QuoteFilter, SwapInfo, Token, TokenInfo, TokenResponse, TradeBuildTxnRequest, TradeBuildTxnRequestData, TradeBuildTxnResponse, TradePath, TradeQuotesRequest, TradeQuotesRequestData, TradeQuotesResponse, TradeStatusResponse, TradeStep, ZapStatusResponse, WalletCallReceipt, };
|