@velora-dex/sdk 9.5.3-dev.0 → 9.5.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/README.md +2 -2
- package/dist/examples/wagmi.d.ts.map +1 -1
- package/dist/methods/delta/helpers/orders.d.ts.map +1 -1
- package/dist/methods/delta/helpers/types.d.ts.map +1 -1
- package/dist/sdk.cjs.development.js +240 -387
- package/dist/sdk.cjs.development.js.map +1 -1
- package/dist/sdk.cjs.production.min.js +1 -1
- package/dist/sdk.cjs.production.min.js.map +1 -1
- package/dist/sdk.esm.js +240 -387
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +17 -9
- package/src/examples/wagmi.ts +2 -2
- package/src/index.js +13 -1
- package/src/methods/delta/helpers/orders.ts +9 -101
- package/src/methods/delta/helpers/types.ts +2 -1
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@velora-dex/sdk",
|
|
3
|
-
"version": "9.5.3
|
|
3
|
+
"version": "9.5.3",
|
|
4
4
|
"main": "dist/index.js",
|
|
5
5
|
"module": "dist/sdk.esm.js",
|
|
6
6
|
"typings": "dist/index.d.ts",
|
|
@@ -18,8 +18,8 @@
|
|
|
18
18
|
"start": "dts watch",
|
|
19
19
|
"test": "dts test",
|
|
20
20
|
"docs:html": "typedoc --gitRevision \"$(git branch --show-current)\"",
|
|
21
|
-
"docs:md": "MD=true
|
|
22
|
-
"docs": "
|
|
21
|
+
"docs:md": "MD=true pnpm docs:html",
|
|
22
|
+
"docs": "pnpm docs:html && pnpm docs:md"
|
|
23
23
|
},
|
|
24
24
|
"husky": {
|
|
25
25
|
"hooks": {
|
|
@@ -36,7 +36,7 @@
|
|
|
36
36
|
"testEnvironment": "node"
|
|
37
37
|
},
|
|
38
38
|
"engines": {
|
|
39
|
-
"node": ">=
|
|
39
|
+
"node": ">=22"
|
|
40
40
|
},
|
|
41
41
|
"size-limit": [
|
|
42
42
|
{
|
|
@@ -49,8 +49,15 @@
|
|
|
49
49
|
}
|
|
50
50
|
],
|
|
51
51
|
"devDependencies": {
|
|
52
|
-
"@
|
|
52
|
+
"@ethersproject/abstract-signer": "^5.8.0",
|
|
53
|
+
"@ethersproject/bignumber": "^5.8.0",
|
|
54
|
+
"@ethersproject/contracts": "^5.8.0",
|
|
55
|
+
"@ethersproject/providers": "^5.8.0",
|
|
56
|
+
"@size-limit/preset-small-lib": "^12.1.0",
|
|
53
57
|
"@tsconfig/recommended": "^1.0.8",
|
|
58
|
+
"@types/jest": "^30.0.0",
|
|
59
|
+
"@wagmi/connectors": "^8.0.13",
|
|
60
|
+
"@wagmi/core": "^3.4.11",
|
|
54
61
|
"axios": "^1.13.2",
|
|
55
62
|
"bignumber.js": "^9.1.2",
|
|
56
63
|
"dotenv": "^16.4.5",
|
|
@@ -61,15 +68,15 @@
|
|
|
61
68
|
"hardhat-switch-network": "^1.2.1",
|
|
62
69
|
"husky": "^9.1.6",
|
|
63
70
|
"isomorphic-unfetch": "^4.0.2",
|
|
64
|
-
"size-limit": "^12.
|
|
71
|
+
"size-limit": "^12.1.0",
|
|
65
72
|
"tslib": "^2.8.1",
|
|
66
73
|
"typedoc": "^0.26.11",
|
|
67
74
|
"typedoc-plugin-markdown": "^4.2.10",
|
|
68
75
|
"typedoc-plugin-missing-exports": "^3.0.0",
|
|
69
76
|
"typedoc-plugin-replace-text": "^4.0.0",
|
|
70
77
|
"typescript": "^5.6.3",
|
|
71
|
-
"
|
|
72
|
-
"web3": "
|
|
78
|
+
"web3": "^4.14.0",
|
|
79
|
+
"web3-eth-contract": "4.7.0"
|
|
73
80
|
},
|
|
74
81
|
"peerDependencies": {
|
|
75
82
|
"axios": ">=0.25.0 <2.0.0",
|
|
@@ -122,5 +129,6 @@
|
|
|
122
129
|
"publishConfig": {
|
|
123
130
|
"access": "public"
|
|
124
131
|
},
|
|
125
|
-
"bugs": "https://github.com/VeloraDEX/paraswap-sdk/issues"
|
|
132
|
+
"bugs": "https://github.com/VeloraDEX/paraswap-sdk/issues",
|
|
133
|
+
"packageManager": "pnpm@11.1.2"
|
|
126
134
|
}
|
package/src/examples/wagmi.ts
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
import axios from 'axios';
|
|
3
3
|
import { mainnet } from '@wagmi/core/chains';
|
|
4
4
|
import {
|
|
5
|
-
|
|
5
|
+
getConnection,
|
|
6
6
|
getWalletClient,
|
|
7
7
|
sendTransaction,
|
|
8
8
|
waitForTransactionReceipt,
|
|
@@ -23,7 +23,7 @@ export const config = createConfig({
|
|
|
23
23
|
|
|
24
24
|
async function simpleSDKExample() {
|
|
25
25
|
const walletClient = await getWalletClient(config, { chainId: mainnet.id });
|
|
26
|
-
const account =
|
|
26
|
+
const account = getConnection(config).address; // make sure wallet is connected at this point
|
|
27
27
|
assert(account, 'account is necessary for Order signing');
|
|
28
28
|
|
|
29
29
|
const simpleSDK = constructSimpleSDK(
|
package/src/index.js
CHANGED
|
@@ -35,12 +35,20 @@ import { constructApproveTokenForDelta, } from './methods/delta/approveForDelta'
|
|
|
35
35
|
import { constructGetPartnerFee, } from './methods/delta/getPartnerFee';
|
|
36
36
|
import { constructGetBridgeInfo, } from './methods/delta/getBridgeInfo';
|
|
37
37
|
import { constructIsTokenSupportedInDelta, } from './methods/delta/isTokenSupportedInDelta';
|
|
38
|
+
import { constructBuildExternalDeltaOrder, } from './methods/delta/buildExternalDeltaOrder';
|
|
39
|
+
import { constructSignExternalDeltaOrder, } from './methods/delta/signExternalDeltaOrder';
|
|
40
|
+
import { constructPostExternalDeltaOrder, } from './methods/delta/postExternalDeltaOrder';
|
|
41
|
+
import { constructPreSignExternalDeltaOrder, } from './methods/delta/preSignExternalDeltaOrder';
|
|
42
|
+
import { constructBuildTWAPDeltaOrder, } from './methods/delta/buildTWAPDeltaOrder';
|
|
43
|
+
import { constructSignTWAPDeltaOrder, } from './methods/delta/signTWAPDeltaOrder';
|
|
44
|
+
import { constructPostTWAPDeltaOrder, } from './methods/delta/postTWAPDeltaOrder';
|
|
45
|
+
import { constructPreSignTWAPDeltaOrder, } from './methods/delta/preSignTWAPDeltaOrder';
|
|
38
46
|
import { constructGetQuote, } from './methods/quote/getQuote';
|
|
39
47
|
import { constructCancelDeltaOrder, } from './methods/delta/cancelDeltaOrder';
|
|
40
48
|
import { constructDeltaTokenModule, } from './methods/delta/deltaTokenModule';
|
|
41
49
|
export { constructSwapSDK } from './methods/swap';
|
|
42
50
|
export { constructAllLimitOrdersHandlers, constructSubmitLimitOrder, } from './methods/limitOrders';
|
|
43
|
-
export { constructAllDeltaOrdersHandlers, constructSubmitDeltaOrder, } from './methods/delta';
|
|
51
|
+
export { constructAllDeltaOrdersHandlers, constructSubmitDeltaOrder, constructSubmitExternalDeltaOrder, constructSubmitTWAPDeltaOrder, } from './methods/delta';
|
|
44
52
|
export * from './constants';
|
|
45
53
|
// can import these individually
|
|
46
54
|
// and use in constructPartialSDK only what you need
|
|
@@ -56,6 +64,10 @@ constructBuildLimitOrder, constructSignLimitOrder, constructCancelLimitOrder, co
|
|
|
56
64
|
constructBuildNFTOrder, constructSignNFTOrder, constructCancelNFTOrder, constructGetNFTOrders, constructPostNFTOrder, constructApproveTokenForNFTOrder, constructGetNFTOrdersContract, constructBuildNFTOrderTx,
|
|
57
65
|
// Delta methods
|
|
58
66
|
constructBuildDeltaOrder, constructPostDeltaOrder, constructSignDeltaOrder, constructPreSignDeltaOrder, constructGetDeltaContract, constructGetDeltaPrice, constructGetDeltaOrders, constructCancelDeltaOrder, constructDeltaTokenModule, constructApproveTokenForDelta,
|
|
67
|
+
// External Delta methods
|
|
68
|
+
constructBuildExternalDeltaOrder, constructSignExternalDeltaOrder, constructPostExternalDeltaOrder, constructPreSignExternalDeltaOrder,
|
|
69
|
+
// TWAP Delta methods
|
|
70
|
+
constructBuildTWAPDeltaOrder, constructSignTWAPDeltaOrder, constructPostTWAPDeltaOrder, constructPreSignTWAPDeltaOrder,
|
|
59
71
|
// Quote methods
|
|
60
72
|
constructGetQuote,
|
|
61
73
|
// different helpers
|
|
@@ -7,7 +7,6 @@ import {
|
|
|
7
7
|
DeltaAuctionTransaction,
|
|
8
8
|
DeltaAuctionTWAP,
|
|
9
9
|
DeltaAuctionTWAPBuy,
|
|
10
|
-
DeltaAuctionUnion,
|
|
11
10
|
DeltaOrderUnion,
|
|
12
11
|
ExternalDeltaOrder,
|
|
13
12
|
OnChainOrderType,
|
|
@@ -359,6 +358,7 @@ function getAuctionAmounts(auction: DeltaAuction) {
|
|
|
359
358
|
|
|
360
359
|
let expected = {
|
|
361
360
|
srcAmount: auction.order.srcAmount,
|
|
361
|
+
// defensive fallback in case Order shape changes or legacy Orders don't have all fields
|
|
362
362
|
destAmount: auction.order.expectedAmount || auction.order.destAmount,
|
|
363
363
|
};
|
|
364
364
|
|
|
@@ -402,7 +402,7 @@ function isOrderCrosschain<T extends { bridge?: Bridge } | object>(
|
|
|
402
402
|
function scaleByFactor(amount: bigint, scalingFactor: number): bigint {
|
|
403
403
|
if (!amount) return 0n;
|
|
404
404
|
|
|
405
|
-
if (scalingFactor ===
|
|
405
|
+
if (scalingFactor === 0) return amount;
|
|
406
406
|
|
|
407
407
|
const base = 10n;
|
|
408
408
|
|
|
@@ -538,111 +538,19 @@ function isPartiallyExecutedAuction<
|
|
|
538
538
|
function getFilledPercent(
|
|
539
539
|
auction: Pick<DeltaAuction, 'order' | 'transactions'>
|
|
540
540
|
): number {
|
|
541
|
-
const
|
|
541
|
+
const completeTransactions = !isOrderCrosschain(auction.order)
|
|
542
542
|
? auction.transactions
|
|
543
543
|
: auction.transactions.filter(
|
|
544
544
|
(transaction) => transaction.bridgeStatus === 'filled'
|
|
545
545
|
);
|
|
546
546
|
|
|
547
|
-
const filledPercentBps =
|
|
548
|
-
|
|
549
|
-
|
|
547
|
+
const filledPercentBps = completeTransactions.reduce(
|
|
548
|
+
(acc, { filledPercent }) => {
|
|
549
|
+
return acc + filledPercent;
|
|
550
|
+
},
|
|
551
|
+
0
|
|
552
|
+
);
|
|
550
553
|
|
|
551
554
|
const filledPercent = filledPercentBps / 100;
|
|
552
555
|
return filledPercent;
|
|
553
556
|
}
|
|
554
|
-
|
|
555
|
-
///// TESTS //////
|
|
556
|
-
// @TODO remove
|
|
557
|
-
|
|
558
|
-
const auction = {} as DeltaAuctionUnion;
|
|
559
|
-
const minAuction = {
|
|
560
|
-
onChainOrderType: 'TWAPOrder' as OnChainOrderType,
|
|
561
|
-
gas: 6,
|
|
562
|
-
};
|
|
563
|
-
if (isTWAPAuction(minAuction)) {
|
|
564
|
-
console.log('🚀 ~ auction:', minAuction);
|
|
565
|
-
/**
|
|
566
|
-
* {
|
|
567
|
-
onChainOrderType: OnChainOrderType;
|
|
568
|
-
gas: number;
|
|
569
|
-
} & {
|
|
570
|
-
onChainOrderType: "TWAPOrder" | "TWAPBuyOrder";
|
|
571
|
-
}
|
|
572
|
-
*/
|
|
573
|
-
}
|
|
574
|
-
if (isTWAPAuction(auction)) {
|
|
575
|
-
console.log('🚀 ~ auction:', auction);
|
|
576
|
-
/**
|
|
577
|
-
(DeltaAuctionBase & {
|
|
578
|
-
onChainOrderType: "TWAPOrder";
|
|
579
|
-
order: TWAPDeltaOrder;
|
|
580
|
-
}) | (DeltaAuctionBase & {
|
|
581
|
-
onChainOrderType: "TWAPBuyOrder";
|
|
582
|
-
order: TWAPBuyDeltaOrder;
|
|
583
|
-
})
|
|
584
|
-
*/
|
|
585
|
-
}
|
|
586
|
-
if (isTWAPSellAuction(auction)) {
|
|
587
|
-
console.log('🚀 ~ auction:', auction);
|
|
588
|
-
/**
|
|
589
|
-
* DeltaAuctionBase & {
|
|
590
|
-
onChainOrderType: "TWAPOrder";
|
|
591
|
-
order: TWAPDeltaOrder;
|
|
592
|
-
}
|
|
593
|
-
*/
|
|
594
|
-
}
|
|
595
|
-
if (isTWAPBuyAuction(auction)) {
|
|
596
|
-
console.log('🚀 ~ auction:', auction);
|
|
597
|
-
/**
|
|
598
|
-
* DeltaAuctionBase & {
|
|
599
|
-
onChainOrderType: "TWAPBuyOrder";
|
|
600
|
-
order: TWAPBuyDeltaOrder;
|
|
601
|
-
}
|
|
602
|
-
*/
|
|
603
|
-
}
|
|
604
|
-
if (isDeltaAuction(auction)) {
|
|
605
|
-
console.log('🚀 ~ auction:', auction);
|
|
606
|
-
/**
|
|
607
|
-
* DeltaAuctionBase & {
|
|
608
|
-
onChainOrderType: "Order";
|
|
609
|
-
order: DeltaAuctionOrder;
|
|
610
|
-
}
|
|
611
|
-
*/
|
|
612
|
-
}
|
|
613
|
-
|
|
614
|
-
if (isExternalAuction(auction)) {
|
|
615
|
-
console.log('🚀 ~ auction:', auction);
|
|
616
|
-
/**
|
|
617
|
-
* DeltaAuctionBase & {
|
|
618
|
-
onChainOrderType: "ExternalOrder";
|
|
619
|
-
order: ExternalDeltaOrder;
|
|
620
|
-
}
|
|
621
|
-
*/
|
|
622
|
-
}
|
|
623
|
-
// ------------------------------------------------------------ //
|
|
624
|
-
|
|
625
|
-
const orderAny = {} as DeltaOrderUnion;
|
|
626
|
-
if (isOrderCrosschain(orderAny)) {
|
|
627
|
-
console.log('🚀 ~ order:', orderAny);
|
|
628
|
-
/**
|
|
629
|
-
DeltaAuctionOrder | TWAPDeltaOrder | TWAPBuyDeltaOrder
|
|
630
|
-
*/
|
|
631
|
-
}
|
|
632
|
-
const orderExternal = {} as ExternalDeltaOrder;
|
|
633
|
-
if (isOrderCrosschain(orderExternal)) {
|
|
634
|
-
console.log('🚀 ~ order:', orderExternal);
|
|
635
|
-
/**
|
|
636
|
-
never
|
|
637
|
-
*/
|
|
638
|
-
}
|
|
639
|
-
const orderLike = {} as { bridge?: Bridge; a: 2 };
|
|
640
|
-
if (isOrderCrosschain(orderLike)) {
|
|
641
|
-
console.log('🚀 ~ order:', orderLike);
|
|
642
|
-
/**
|
|
643
|
-
* {
|
|
644
|
-
bridge: Bridge;
|
|
645
|
-
a: 2;
|
|
646
|
-
}
|
|
647
|
-
*/
|
|
648
|
-
}
|
|
@@ -204,7 +204,7 @@ export type DeltaAuctionTransaction = {
|
|
|
204
204
|
agent: string;
|
|
205
205
|
auctionId: string;
|
|
206
206
|
|
|
207
|
-
// bridge*
|
|
207
|
+
// transactgion.bridge* fields = null for single-chain orders
|
|
208
208
|
bridgeMetadata: BridgeMetadata | null;
|
|
209
209
|
bridgeStatus: BridgeStatus | null;
|
|
210
210
|
bridgeProtocol: string | null;
|
|
@@ -248,6 +248,7 @@ type DeltaAuctionBase = {
|
|
|
248
248
|
excludeAgents: string[] | null;
|
|
249
249
|
includeAgents: string[] | null;
|
|
250
250
|
|
|
251
|
+
// bridge* fields = null for single-chain orders and all TWAP orders
|
|
251
252
|
bridgeMetadata: BridgeMetadata | null;
|
|
252
253
|
bridgeStatus: BridgeStatus | null;
|
|
253
254
|
|