@velora-dex/sdk 9.4.1-dev.2 → 9.4.1
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.
Potentially problematic release.
This version of @velora-dex/sdk might be problematic. Click here for more details.
- package/dist/index.d.ts +5 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +4 -0
- package/dist/methods/delta/helpers/misc.d.ts +0 -8
- package/dist/methods/delta/helpers/misc.d.ts.map +1 -1
- package/dist/methods/delta/helpers/types.d.ts +2 -43
- package/dist/methods/delta/helpers/types.d.ts.map +1 -1
- package/dist/methods/delta/index.d.ts +1 -16
- package/dist/methods/delta/index.d.ts.map +1 -1
- package/dist/sdk/partial.d.ts +1 -3
- package/dist/sdk/partial.d.ts.map +1 -1
- package/dist/sdk.cjs.development.js +35 -623
- 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 +36 -619
- package/dist/sdk.esm.js.map +1 -1
- package/package.json +1 -1
- package/src/constants.js +6 -1
- package/src/index.js +125 -68
- package/src/index.ts +0 -63
- package/src/methods/delta/helpers/misc.ts +1 -35
- package/src/methods/delta/helpers/types.ts +2 -52
- package/src/methods/delta/index.ts +1 -78
- package/src/sdk/partial.ts +1 -3
- package/dist/methods/delta/buildTWAPDeltaOrder.d.ts +0 -65
- package/dist/methods/delta/buildTWAPDeltaOrder.d.ts.map +0 -1
- package/dist/methods/delta/helpers/buildTWAPOrderData.d.ts +0 -74
- package/dist/methods/delta/helpers/buildTWAPOrderData.d.ts.map +0 -1
- package/dist/methods/delta/postTWAPDeltaOrder.d.ts +0 -16
- package/dist/methods/delta/postTWAPDeltaOrder.d.ts.map +0 -1
- package/dist/methods/delta/preSignTWAPDeltaOrder.d.ts +0 -20
- package/dist/methods/delta/preSignTWAPDeltaOrder.d.ts.map +0 -1
- package/dist/methods/delta/signTWAPDeltaOrder.d.ts +0 -9
- package/dist/methods/delta/signTWAPDeltaOrder.d.ts.map +0 -1
- package/src/methods/delta/buildTWAPDeltaOrder.ts +0 -187
- package/src/methods/delta/helpers/buildTWAPOrderData.ts +0 -227
- package/src/methods/delta/postTWAPDeltaOrder.ts +0 -57
- package/src/methods/delta/preSignTWAPDeltaOrder.ts +0 -168
- package/src/methods/delta/signTWAPDeltaOrder.ts +0 -32
|
@@ -1,65 +0,0 @@
|
|
|
1
|
-
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
2
|
-
import type { BridgePrice } from './getDeltaPrice';
|
|
3
|
-
import { type SignableTWAPOrderData } from './helpers/buildTWAPOrderData';
|
|
4
|
-
import type { MarkOptional } from 'ts-essentials';
|
|
5
|
-
export type { SignableTWAPOrderData } from './helpers/buildTWAPOrderData';
|
|
6
|
-
type BuildTWAPDeltaOrderParamsBase = {
|
|
7
|
-
/** @description The address of the order owner */
|
|
8
|
-
owner: string;
|
|
9
|
-
/** @description The address of the order beneficiary */
|
|
10
|
-
beneficiary?: string;
|
|
11
|
-
/** @description The address of the src token */
|
|
12
|
-
srcToken: string;
|
|
13
|
-
/** @description The address of the dest token. For Crosschain Order - destination token on the destination chain */
|
|
14
|
-
destToken: string;
|
|
15
|
-
/** @description The deadline for the order */
|
|
16
|
-
deadline?: number;
|
|
17
|
-
/** @description The nonce of the order */
|
|
18
|
-
nonce?: number | string;
|
|
19
|
-
/** @description Optional permit signature for the src token */
|
|
20
|
-
permit?: string;
|
|
21
|
-
/** @description Partner string */
|
|
22
|
-
partner?: string;
|
|
23
|
-
/** @description Destination Chain ID for Crosschain Orders */
|
|
24
|
-
destChainId?: number;
|
|
25
|
-
/** @description Seconds between slice executions (min 60) */
|
|
26
|
-
interval: number;
|
|
27
|
-
/** @description Number of slices (min 2) */
|
|
28
|
-
numSlices: number;
|
|
29
|
-
/** @description Slippage in basis points (bps). 10000 = 100%, 50 = 0.5% */
|
|
30
|
-
slippage?: number;
|
|
31
|
-
/** @description price response received from /delta/prices (getDeltaPrice method) for a single slice */
|
|
32
|
-
deltaPrice: MarkOptional<Pick<BridgePrice, 'destAmount' | 'partner' | 'partnerFee' | 'destToken' | 'srcAmount' | 'bridge'>, 'partner' | 'partnerFee'>;
|
|
33
|
-
/** @description partner fee in basis points (bps), 50bps=0.5% */
|
|
34
|
-
partnerFeeBps?: number;
|
|
35
|
-
/** @description partner address */
|
|
36
|
-
partnerAddress?: string;
|
|
37
|
-
/** @description take surplus */
|
|
38
|
-
partnerTakesSurplus?: boolean;
|
|
39
|
-
/** @description A boolean indicating whether the surplus should be capped. True by default */
|
|
40
|
-
capSurplus?: boolean;
|
|
41
|
-
/** @description Metadata for the order, hex string */
|
|
42
|
-
metadata?: string;
|
|
43
|
-
};
|
|
44
|
-
export type BuildTWAPSellOrderParams = BuildTWAPDeltaOrderParamsBase & {
|
|
45
|
-
/** @description Must be "TWAPOrder" for sell orders */
|
|
46
|
-
onChainOrderType: 'TWAPOrder';
|
|
47
|
-
/** @description Total source token amount across all slices */
|
|
48
|
-
totalSrcAmount: string;
|
|
49
|
-
};
|
|
50
|
-
export type BuildTWAPBuyOrderParams = BuildTWAPDeltaOrderParamsBase & {
|
|
51
|
-
/** @description Must be "TWAPBuyOrder" for buy orders */
|
|
52
|
-
onChainOrderType: 'TWAPBuyOrder';
|
|
53
|
-
/** @description Total destination token amount to buy across all slices */
|
|
54
|
-
totalDestAmount: string;
|
|
55
|
-
/** @description Maximum source token amount willing to spend */
|
|
56
|
-
maxSrcAmount: string;
|
|
57
|
-
};
|
|
58
|
-
export type BuildTWAPDeltaOrderParams = BuildTWAPSellOrderParams | BuildTWAPBuyOrderParams;
|
|
59
|
-
type BuildTWAPDeltaOrder = (buildOrderParams: BuildTWAPDeltaOrderParams, requestParams?: RequestParameters) => Promise<SignableTWAPOrderData>;
|
|
60
|
-
export type BuildTWAPDeltaOrderFunctions = {
|
|
61
|
-
/** @description Build TWAP Orders (sell or buy) to be posted to Delta API for execution */
|
|
62
|
-
buildTWAPDeltaOrder: BuildTWAPDeltaOrder;
|
|
63
|
-
};
|
|
64
|
-
export declare const constructBuildTWAPDeltaOrder: (options: ConstructFetchInput) => BuildTWAPDeltaOrderFunctions;
|
|
65
|
-
//# sourceMappingURL=buildTWAPDeltaOrder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildTWAPDeltaOrder.d.ts","sourceRoot":"","sources":["../../../src/methods/delta/buildTWAPDeltaOrder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAG1E,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAEnD,OAAO,EAIL,KAAK,qBAAqB,EAC3B,MAAM,8BAA8B,CAAC;AAEtC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAClD,YAAY,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAE1E,KAAK,6BAA6B,GAAG;IACnC,kDAAkD;IAClD,KAAK,EAAE,MAAM,CAAC;IACd,wDAAwD;IACxD,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,gDAAgD;IAChD,QAAQ,EAAE,MAAM,CAAC;IACjB,oHAAoH;IACpH,SAAS,EAAE,MAAM,CAAC;IAClB,8CAA8C;IAC9C,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,0CAA0C;IAC1C,KAAK,CAAC,EAAE,MAAM,GAAG,MAAM,CAAC;IACxB,+DAA+D;IAC/D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,kCAAkC;IAClC,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,8DAA8D;IAC9D,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,6DAA6D;IAC7D,QAAQ,EAAE,MAAM,CAAC;IACjB,4CAA4C;IAC5C,SAAS,EAAE,MAAM,CAAC;IAClB,2EAA2E;IAC3E,QAAQ,CAAC,EAAE,MAAM,CAAC;IA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PDeltaOrder, TWAPBuyDeltaOrder, TWAPOnChainOrderType, OnChainOrderMap } from './types';
|
|
3
|
-
declare const TWAP_ORDER_EIP_712_TYPES: {
|
|
4
|
-
TWAPOrder: {
|
|
5
|
-
name: string;
|
|
6
|
-
type: string;
|
|
7
|
-
}[];
|
|
8
|
-
Bridge: {
|
|
9
|
-
name: string;
|
|
10
|
-
type: string;
|
|
11
|
-
}[];
|
|
12
|
-
};
|
|
13
|
-
declare const TWAP_BUY_ORDER_EIP_712_TYPES: {
|
|
14
|
-
TWAPBuyOrder: {
|
|
15
|
-
name: string;
|
|
16
|
-
type: string;
|
|
17
|
-
}[];
|
|
18
|
-
Bridge: {
|
|
19
|
-
name: string;
|
|
20
|
-
type: string;
|
|
21
|
-
}[];
|
|
22
|
-
};
|
|
23
|
-
export type SignableTWAPSellOrderData = {
|
|
24
|
-
types: typeof TWAP_ORDER_EIP_712_TYPES;
|
|
25
|
-
domain: Domain;
|
|
26
|
-
data: TWAPDeltaOrder;
|
|
27
|
-
};
|
|
28
|
-
export type SignableTWAPBuyOrderData = {
|
|
29
|
-
types: typeof TWAP_BUY_ORDER_EIP_712_TYPES;
|
|
30
|
-
domain: Domain;
|
|
31
|
-
data: TWAPBuyDeltaOrder;
|
|
32
|
-
};
|
|
33
|
-
export type SignableTWAPOrderData = SignableTWAPSellOrderData | SignableTWAPBuyOrderData;
|
|
34
|
-
type ProduceTWAPOrderTypedDataInput<T extends TWAPOnChainOrderType> = {
|
|
35
|
-
orderInput: OnChainOrderMap[T];
|
|
36
|
-
paraswapDeltaAddress: string;
|
|
37
|
-
chainId: number;
|
|
38
|
-
onChainOrderType: T;
|
|
39
|
-
};
|
|
40
|
-
export declare function produceTWAPOrderTypedData(params: ProduceTWAPOrderTypedDataInput<'TWAPOrder'>): SignableTWAPSellOrderData;
|
|
41
|
-
export declare function produceTWAPOrderTypedData(params: ProduceTWAPOrderTypedDataInput<'TWAPBuyOrder'>): SignableTWAPBuyOrderData;
|
|
42
|
-
export type TWAPOrderCommonInput = {
|
|
43
|
-
owner: string;
|
|
44
|
-
beneficiary?: string;
|
|
45
|
-
srcToken: string;
|
|
46
|
-
destToken: string;
|
|
47
|
-
nonce?: string;
|
|
48
|
-
deadline?: number;
|
|
49
|
-
permit?: string;
|
|
50
|
-
metadata?: string;
|
|
51
|
-
interval: number;
|
|
52
|
-
numSlices: number;
|
|
53
|
-
bridge: Bridge;
|
|
54
|
-
partnerAddress: string;
|
|
55
|
-
paraswapDeltaAddress: string;
|
|
56
|
-
partnerFeeBps: number;
|
|
57
|
-
partnerTakesSurplus?: boolean;
|
|
58
|
-
capSurplus?: boolean;
|
|
59
|
-
chainId: number;
|
|
60
|
-
};
|
|
61
|
-
export type BuildTWAPSellOrderDataInput = TWAPOrderCommonInput & {
|
|
62
|
-
onChainOrderType: 'TWAPOrder';
|
|
63
|
-
destAmountPerSlice: string;
|
|
64
|
-
totalSrcAmount: string;
|
|
65
|
-
};
|
|
66
|
-
export type BuildTWAPBuyOrderDataInput = TWAPOrderCommonInput & {
|
|
67
|
-
onChainOrderType: 'TWAPBuyOrder';
|
|
68
|
-
totalDestAmount: string;
|
|
69
|
-
maxSrcAmount: string;
|
|
70
|
-
};
|
|
71
|
-
export type BuildTWAPOrderDataInput = BuildTWAPSellOrderDataInput | BuildTWAPBuyOrderDataInput;
|
|
72
|
-
export declare function buildTWAPSignableOrderData(input: BuildTWAPOrderDataInput): SignableTWAPOrderData;
|
|
73
|
-
export {};
|
|
74
|
-
//# sourceMappingURL=buildTWAPOrderData.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"buildTWAPOrderData.d.ts","sourceRoot":"","sources":["../../../../src/methods/delta/helpers/buildTWAPOrderData.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oCAAoC,CAAC;AAC5D,OAAO,EACL,MAAM,EACN,cAAc,EACd,iBAAiB,EACjB,oBAAoB,EACpB,eAAe,EAChB,MAAM,SAAS,C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MAAM,CAAC;IAEf,cAAc,EAAE,MAAM,CAAC;IACvB,oBAAoB,EAAE,MAAM,CAAC;IAC7B,aAAa,EAAE,MAAM,CAAC;IACtB,mBAAmB,CAAC,EAAE,OAAO,CAAC;IAC9B,UAAU,CAAC,EAAE,OAAO,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,2BAA2B,GAAG,oBAAoB,GAAG;IAC/D,gBAAgB,EAAE,WAAW,CAAC;IAC9B,kBAAkB,EAAE,MAAM,CAAC;IAC3B,cAAc,EAAE,MAAM,CAAC;CACxB,CAAC;AAEF,MAAM,MAAM,0BAA0B,GAAG,oBAAoB,GAAG;IAC9D,gBAAgB,EAAE,cAAc,CAAC;IACjC,eAAe,EAAE,MAAM,CAAC;IACxB,YAAY,EAAE,MAAM,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,uBAAuB,GAC/B,2BAA2B,GAC3B,0BAA0B,CAAC;AAE/B,wBAAgB,0BAA0B,CACxC,KAAK,EAAE,uBAAuB,GAC7B,qBAAqB,CAwEvB"}
|
|
@@ -1,16 +0,0 @@
|
|
|
1
|
-
import { Prettify } from 'ts-essentials';
|
|
2
|
-
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
3
|
-
import type { DeltaAuction, TWAPOnChainOrderType } from './helpers/types';
|
|
4
|
-
import type { DeltaOrderToPost } from './postDeltaOrder';
|
|
5
|
-
export type PostTWAPDeltaOrderParams = Prettify<Omit<DeltaOrderToPost<'TWAPOrder'> | DeltaOrderToPost<'TWAPBuyOrder'>, 'chainId'> & {
|
|
6
|
-
/** @description Must be "TWAPOrder" or "TWAPBuyOrder" */
|
|
7
|
-
onChainOrderType: TWAPOnChainOrderType;
|
|
8
|
-
degenMode?: boolean;
|
|
9
|
-
}>;
|
|
10
|
-
type PostTWAPDeltaOrder = (postData: PostTWAPDeltaOrderParams, requestParams?: RequestParameters) => Promise<DeltaAuction<'TWAPOrder'> | DeltaAuction<'TWAPBuyOrder'>>;
|
|
11
|
-
export type PostTWAPDeltaOrderFunctions = {
|
|
12
|
-
postTWAPDeltaOrder: PostTWAPDeltaOrder;
|
|
13
|
-
};
|
|
14
|
-
export declare const constructPostTWAPDeltaOrder: ({ apiURL, chainId, fetcher, }: ConstructFetchInput) => PostTWAPDeltaOrderFunctions;
|
|
15
|
-
export {};
|
|
16
|
-
//# sourceMappingURL=postTWAPDeltaOrder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"postTWAPDeltaOrder.d.ts","sourceRoot":"","sources":["../../../src/methods/delta/postTWAPDeltaOrder.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAEzC,OAAO,KAAK,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAC1E,OAAO,KAAK,EAAE,YAAY,EAAE,oBAAoB,EAAE,MAAM,iBAAiB,CAAC;AAC1E,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,kBAAkB,CAAC;AAGzD,MAAM,MAAM,wBAAwB,GAAG,QAAQ,CAC7C,IAAI,CACF,gBAAgB,CAAC,WAAW,CAAC,GAAG,gBAAgB,CAAC,cAAc,CAAC,EAChE,SAAS,CACV,GAAG;IACF,yDAAyD;IACzD,gBAAgB,EAAE,oBAAoB,CAAC;IACvC,SAAS,CAAC,EAAE,OAAO,CAAC;CACrB,CACF,CAAC;AAEF,KAAK,kBAAkB,GAAG,CACxB,QAAQ,EAAE,wBAAwB,EAClC,aAAa,CAAC,EAAE,iBAAiB,KAC9B,OAAO,CAAC,YAAY,CAAC,WAAW,CAAC,GAAG,YAAY,CAAC,cAAc,CAAC,CAAC,CAAC;AAEvE,MAAM,MAAM,2BAA2B,GAAG;IACxC,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,2BAA2B,kCAIrC,mBAAmB,KAAG,2BAyBxB,CAAC"}
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import type { ConstructProviderFetchInput, RequestParameters, TxSendOverrides } from '../../types';
|
|
2
|
-
import { SignableTWAPOrderData } from './helpers/buildTWAPOrderData';
|
|
3
|
-
import type { TWAPDeltaOrder, TWAPBuyDeltaOrder } from './helpers/types';
|
|
4
|
-
type HashTWAPDeltaOrderTypedData = (signableOrderData: SignableTWAPOrderData) => string;
|
|
5
|
-
type HashTWAPDeltaOrder = {
|
|
6
|
-
(orderData: TWAPDeltaOrder, onChainOrderType: 'TWAPOrder', requestParams?: RequestParameters): Promise<string>;
|
|
7
|
-
(orderData: TWAPBuyDeltaOrder, onChainOrderType: 'TWAPBuyOrder', requestParams?: RequestParameters): Promise<string>;
|
|
8
|
-
};
|
|
9
|
-
export type SetTWAPDeltaOrderPreSignature<T> = (orderHash: string, overrides?: TxSendOverrides, requestParams?: RequestParameters) => Promise<T>;
|
|
10
|
-
export type PreSignTWAPDeltaOrder<T> = (signableOrderData: SignableTWAPOrderData, overrides?: TxSendOverrides, requestParams?: RequestParameters) => Promise<T>;
|
|
11
|
-
export type PreSignTWAPDeltaOrderFunctions<T> = {
|
|
12
|
-
hashTWAPDeltaOrderTypedData: HashTWAPDeltaOrderTypedData;
|
|
13
|
-
hashTWAPDeltaOrder: HashTWAPDeltaOrder;
|
|
14
|
-
setTWAPDeltaOrderPreSignature: SetTWAPDeltaOrderPreSignature<T>;
|
|
15
|
-
preSignTWAPDeltaOrder: PreSignTWAPDeltaOrder<T>;
|
|
16
|
-
};
|
|
17
|
-
export declare const constructPreSignTWAPDeltaOrder: <T>(options: ConstructProviderFetchInput<T, "transactCall">) => PreSignTWAPDeltaOrderFunctions<T>;
|
|
18
|
-
export declare function produceTWAPOrderHash(typedData: SignableTWAPOrderData): string;
|
|
19
|
-
export {};
|
|
20
|
-
//# sourceMappingURL=preSignTWAPDeltaOrder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"preSignTWAPDeltaOrder.d.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AO,MAAM,8BAA8B,GAAI,CAAC,WACrC,2BAA2B,CAAC,CAAC,EAAE,cAAc,CAAC,KACtD,8BAA8B,CAAC,CAAC,CA0FlC,CAAC;AAEF,wBAAgB,oBAAoB,CAAC,SAAS,EAAE,qBAAqB,GAAG,MAAM,CAgB7E"}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { ConstructProviderFetchInput } from '../../types';
|
|
2
|
-
import { SignableTWAPOrderData } from './helpers/buildTWAPOrderData';
|
|
3
|
-
type SignTWAPDeltaOrder = (signableOrderData: SignableTWAPOrderData) => Promise<string>;
|
|
4
|
-
export type SignTWAPDeltaOrderFunctions = {
|
|
5
|
-
signTWAPDeltaOrder: SignTWAPDeltaOrder;
|
|
6
|
-
};
|
|
7
|
-
export declare const constructSignTWAPDeltaOrder: (options: Pick<ConstructProviderFetchInput<any, "signTypedDataCall">, "contractCaller">) => SignTWAPDeltaOrderFunctions;
|
|
8
|
-
export {};
|
|
9
|
-
//# sourceMappingURL=signTWAPDeltaOrder.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"signTWAPDeltaOrder.d.ts","sourceRoot":"","sources":["../../../src/methods/delta/signTWAPDeltaOrder.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,aAAa,CAAC;AAC/D,OAAO,EAAE,qBAAqB,EAAE,MAAM,8BAA8B,CAAC;AAGrE,KAAK,kBAAkB,GAAG,CACxB,iBAAiB,EAAE,qBAAqB,KACrC,OAAO,CAAC,MAAM,CAAC,CAAC;AAErB,MAAM,MAAM,2BAA2B,GAAG;IACxC,kBAAkB,EAAE,kBAAkB,CAAC;CACxC,CAAC;AAEF,eAAO,MAAM,2BAA2B,YAC7B,IAAI,CACX,2BAA2B,CAAC,GAAG,EAAE,mBAAmB,CAAC,EACrD,gBAAgB,CACjB,KACA,2BAcF,CAAC"}
|
|
@@ -1,187 +0,0 @@
|
|
|
1
|
-
import type { ConstructFetchInput, RequestParameters } from '../../types';
|
|
2
|
-
import { DEFAULT_BRIDGE } from './constants';
|
|
3
|
-
import { constructGetDeltaContract } from './getDeltaContract';
|
|
4
|
-
import type { BridgePrice } from './getDeltaPrice';
|
|
5
|
-
import { constructGetPartnerFee } from './getPartnerFee';
|
|
6
|
-
import {
|
|
7
|
-
buildTWAPSignableOrderData,
|
|
8
|
-
TWAPOrderCommonInput,
|
|
9
|
-
type BuildTWAPOrderDataInput,
|
|
10
|
-
type SignableTWAPOrderData,
|
|
11
|
-
} from './helpers/buildTWAPOrderData';
|
|
12
|
-
import { applySlippage, resolvePartnerFee } from './helpers/misc';
|
|
13
|
-
import type { MarkOptional } from 'ts-essentials';
|
|
14
|
-
export type { SignableTWAPOrderData } from './helpers/buildTWAPOrderData';
|
|
15
|
-
|
|
16
|
-
type BuildTWAPDeltaOrderParamsBase = {
|
|
17
|
-
/** @description The address of the order owner */
|
|
18
|
-
owner: string;
|
|
19
|
-
/** @description The address of the order beneficiary */
|
|
20
|
-
beneficiary?: string;
|
|
21
|
-
/** @description The address of the src token */
|
|
22
|
-
srcToken: string;
|
|
23
|
-
/** @description The address of the dest token. For Crosschain Order - destination token on the destination chain */
|
|
24
|
-
destToken: string;
|
|
25
|
-
/** @description The deadline for the order */
|
|
26
|
-
deadline?: number;
|
|
27
|
-
/** @description The nonce of the order */
|
|
28
|
-
nonce?: number | string;
|
|
29
|
-
/** @description Optional permit signature for the src token */
|
|
30
|
-
permit?: string;
|
|
31
|
-
/** @description Partner string */
|
|
32
|
-
partner?: string;
|
|
33
|
-
/** @description Destination Chain ID for Crosschain Orders */
|
|
34
|
-
destChainId?: number;
|
|
35
|
-
/** @description Seconds between slice executions (min 60) */
|
|
36
|
-
interval: number;
|
|
37
|
-
/** @description Number of slices (min 2) */
|
|
38
|
-
numSlices: number;
|
|
39
|
-
/** @description Slippage in basis points (bps). 10000 = 100%, 50 = 0.5% */
|
|
40
|
-
slippage?: number;
|
|
41
|
-
|
|
42
|
-
/** @description price response received from /delta/prices (getDeltaPrice method) for a single slice */
|
|
43
|
-
deltaPrice: MarkOptional<
|
|
44
|
-
Pick<
|
|
45
|
-
BridgePrice,
|
|
46
|
-
| 'destAmount'
|
|
47
|
-
| 'partner'
|
|
48
|
-
| 'partnerFee'
|
|
49
|
-
| 'destToken'
|
|
50
|
-
| 'srcAmount'
|
|
51
|
-
| 'bridge'
|
|
52
|
-
>,
|
|
53
|
-
'partner' | 'partnerFee'
|
|
54
|
-
>;
|
|
55
|
-
|
|
56
|
-
/** @description partner fee in basis points (bps), 50bps=0.5% */
|
|
57
|
-
partnerFeeBps?: number;
|
|
58
|
-
/** @description partner address */
|
|
59
|
-
partnerAddress?: string;
|
|
60
|
-
/** @description take surplus */
|
|
61
|
-
partnerTakesSurplus?: boolean;
|
|
62
|
-
/** @description A boolean indicating whether the surplus should be capped. True by default */
|
|
63
|
-
capSurplus?: boolean;
|
|
64
|
-
/** @description Metadata for the order, hex string */
|
|
65
|
-
metadata?: string;
|
|
66
|
-
};
|
|
67
|
-
|
|
68
|
-
export type BuildTWAPSellOrderParams = BuildTWAPDeltaOrderParamsBase & {
|
|
69
|
-
/** @description Must be "TWAPOrder" for sell orders */
|
|
70
|
-
onChainOrderType: 'TWAPOrder';
|
|
71
|
-
/** @description Total source token amount across all slices */
|
|
72
|
-
totalSrcAmount: string;
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export type BuildTWAPBuyOrderParams = BuildTWAPDeltaOrderParamsBase & {
|
|
76
|
-
/** @description Must be "TWAPBuyOrder" for buy orders */
|
|
77
|
-
onChainOrderType: 'TWAPBuyOrder';
|
|
78
|
-
/** @description Total destination token amount to buy across all slices */
|
|
79
|
-
totalDestAmount: string;
|
|
80
|
-
/** @description Maximum source token amount willing to spend */
|
|
81
|
-
maxSrcAmount: string;
|
|
82
|
-
};
|
|
83
|
-
|
|
84
|
-
export type BuildTWAPDeltaOrderParams =
|
|
85
|
-
| BuildTWAPSellOrderParams
|
|
86
|
-
| BuildTWAPBuyOrderParams;
|
|
87
|
-
|
|
88
|
-
type BuildTWAPDeltaOrder = (
|
|
89
|
-
buildOrderParams: BuildTWAPDeltaOrderParams,
|
|
90
|
-
requestParams?: RequestParameters
|
|
91
|
-
) => Promise<SignableTWAPOrderData>;
|
|
92
|
-
|
|
93
|
-
export type BuildTWAPDeltaOrderFunctions = {
|
|
94
|
-
/** @description Build TWAP Orders (sell or buy) to be posted to Delta API for execution */
|
|
95
|
-
buildTWAPDeltaOrder: BuildTWAPDeltaOrder;
|
|
96
|
-
};
|
|
97
|
-
|
|
98
|
-
export const constructBuildTWAPDeltaOrder = (
|
|
99
|
-
options: ConstructFetchInput
|
|
100
|
-
): BuildTWAPDeltaOrderFunctions => {
|
|
101
|
-
const { chainId } = options;
|
|
102
|
-
|
|
103
|
-
const { getDeltaContract } = constructGetDeltaContract(options);
|
|
104
|
-
const { getPartnerFee } = constructGetPartnerFee(options);
|
|
105
|
-
|
|
106
|
-
const buildTWAPDeltaOrder: BuildTWAPDeltaOrder = async (
|
|
107
|
-
params,
|
|
108
|
-
requestParams
|
|
109
|
-
) => {
|
|
110
|
-
const ParaswapDelta = await getDeltaContract(requestParams);
|
|
111
|
-
if (!ParaswapDelta) {
|
|
112
|
-
throw new Error(`Delta is not available on chain ${chainId}`);
|
|
113
|
-
}
|
|
114
|
-
|
|
115
|
-
const { partnerAddress, partnerFeeBps, partnerTakesSurplus } =
|
|
116
|
-
await resolvePartnerFee(params, getPartnerFee, requestParams);
|
|
117
|
-
|
|
118
|
-
const commonInput: TWAPOrderCommonInput = {
|
|
119
|
-
owner: params.owner,
|
|
120
|
-
beneficiary: params.beneficiary,
|
|
121
|
-
srcToken: params.srcToken,
|
|
122
|
-
destToken: params.deltaPrice.destToken,
|
|
123
|
-
deadline: params.deadline,
|
|
124
|
-
nonce: params.nonce?.toString(10),
|
|
125
|
-
permit: params.permit,
|
|
126
|
-
metadata: params.metadata,
|
|
127
|
-
interval: params.interval,
|
|
128
|
-
numSlices: params.numSlices,
|
|
129
|
-
bridge: {
|
|
130
|
-
...params.deltaPrice.bridge,
|
|
131
|
-
// TWAP child orders get their bridge data at execution time
|
|
132
|
-
protocolData: DEFAULT_BRIDGE.protocolData,
|
|
133
|
-
},
|
|
134
|
-
|
|
135
|
-
chainId,
|
|
136
|
-
paraswapDeltaAddress: ParaswapDelta,
|
|
137
|
-
partnerAddress,
|
|
138
|
-
partnerTakesSurplus,
|
|
139
|
-
partnerFeeBps,
|
|
140
|
-
capSurplus: params.capSurplus,
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
let input: BuildTWAPOrderDataInput;
|
|
144
|
-
|
|
145
|
-
if (params.onChainOrderType === 'TWAPOrder') {
|
|
146
|
-
const slippage = params.slippage ?? 0;
|
|
147
|
-
const destAmountPerSlice =
|
|
148
|
-
slippage > 0
|
|
149
|
-
? applySlippage({
|
|
150
|
-
amount: params.deltaPrice.destAmount,
|
|
151
|
-
slippageBps: slippage,
|
|
152
|
-
increase: false,
|
|
153
|
-
})
|
|
154
|
-
: params.deltaPrice.destAmount;
|
|
155
|
-
|
|
156
|
-
input = {
|
|
157
|
-
...commonInput,
|
|
158
|
-
onChainOrderType: 'TWAPOrder',
|
|
159
|
-
destAmountPerSlice,
|
|
160
|
-
totalSrcAmount: params.totalSrcAmount,
|
|
161
|
-
};
|
|
162
|
-
} else {
|
|
163
|
-
const slippage = params.slippage ?? 0;
|
|
164
|
-
const maxSrcAmount =
|
|
165
|
-
slippage > 0
|
|
166
|
-
? applySlippage({
|
|
167
|
-
amount: params.maxSrcAmount,
|
|
168
|
-
slippageBps: slippage,
|
|
169
|
-
increase: true,
|
|
170
|
-
})
|
|
171
|
-
: params.maxSrcAmount;
|
|
172
|
-
|
|
173
|
-
input = {
|
|
174
|
-
...commonInput,
|
|
175
|
-
onChainOrderType: 'TWAPBuyOrder',
|
|
176
|
-
totalDestAmount: params.totalDestAmount,
|
|
177
|
-
maxSrcAmount,
|
|
178
|
-
};
|
|
179
|
-
}
|
|
180
|
-
|
|
181
|
-
return buildTWAPSignableOrderData(input);
|
|
182
|
-
};
|
|
183
|
-
|
|
184
|
-
return {
|
|
185
|
-
buildTWAPDeltaOrder,
|
|
186
|
-
};
|
|
187
|
-
};
|
|
@@ -1,227 +0,0 @@
|
|
|
1
|
-
import { Domain } from '../../common/orders/buildOrderData';
|
|
2
|
-
import {
|
|
3
|
-
Bridge,
|
|
4
|
-
TWAPDeltaOrder,
|
|
5
|
-
TWAPBuyDeltaOrder,
|
|
6
|
-
TWAPOnChainOrderType,
|
|
7
|
-
OnChainOrderMap,
|
|
8
|
-
} from './types';
|
|
9
|
-
import { DELTA_DEFAULT_EXPIRY, producePartnerAndFee } from './misc';
|
|
10
|
-
|
|
11
|
-
const BRIDGE_EIP_712_TYPE = [
|
|
12
|
-
{ name: 'protocolSelector', type: 'bytes4' },
|
|
13
|
-
{ name: 'destinationChainId', type: 'uint256' },
|
|
14
|
-
{ name: 'outputToken', type: 'address' },
|
|
15
|
-
{ name: 'scalingFactor', type: 'int8' },
|
|
16
|
-
{ name: 'protocolData', type: 'bytes' },
|
|
17
|
-
];
|
|
18
|
-
|
|
19
|
-
const TWAP_ORDER_EIP_712_TYPES = {
|
|
20
|
-
TWAPOrder: [
|
|
21
|
-
{ name: 'owner', type: 'address' },
|
|
22
|
-
{ name: 'beneficiary', type: 'address' },
|
|
23
|
-
{ name: 'srcToken', type: 'address' },
|
|
24
|
-
{ name: 'destToken', type: 'address' },
|
|
25
|
-
{ name: 'nonce', type: 'uint256' },
|
|
26
|
-
{ name: 'partnerAndFee', type: 'uint256' },
|
|
27
|
-
{ name: 'deadline', type: 'uint64' },
|
|
28
|
-
{ name: 'interval', type: 'uint64' },
|
|
29
|
-
{ name: 'numSlices', type: 'uint32' },
|
|
30
|
-
{ name: 'destAmountPerSlice', type: 'uint256' },
|
|
31
|
-
{ name: 'totalSrcAmount', type: 'uint256' },
|
|
32
|
-
{ name: 'permit', type: 'bytes' },
|
|
33
|
-
{ name: 'metadata', type: 'bytes' },
|
|
34
|
-
{ name: 'bridge', type: 'Bridge' },
|
|
35
|
-
],
|
|
36
|
-
Bridge: BRIDGE_EIP_712_TYPE,
|
|
37
|
-
};
|
|
38
|
-
|
|
39
|
-
const TWAP_BUY_ORDER_EIP_712_TYPES = {
|
|
40
|
-
TWAPBuyOrder: [
|
|
41
|
-
{ name: 'owner', type: 'address' },
|
|
42
|
-
{ name: 'beneficiary', type: 'address' },
|
|
43
|
-
{ name: 'srcToken', type: 'address' },
|
|
44
|
-
{ name: 'destToken', type: 'address' },
|
|
45
|
-
{ name: 'nonce', type: 'uint256' },
|
|
46
|
-
{ name: 'partnerAndFee', type: 'uint256' },
|
|
47
|
-
{ name: 'deadline', type: 'uint64' },
|
|
48
|
-
{ name: 'interval', type: 'uint64' },
|
|
49
|
-
{ name: 'numSlices', type: 'uint32' },
|
|
50
|
-
{ name: 'totalDestAmount', type: 'uint256' },
|
|
51
|
-
{ name: 'maxSrcAmount', type: 'uint256' },
|
|
52
|
-
{ name: 'permit', type: 'bytes' },
|
|
53
|
-
{ name: 'metadata', type: 'bytes' },
|
|
54
|
-
{ name: 'bridge', type: 'Bridge' },
|
|
55
|
-
],
|
|
56
|
-
Bridge: BRIDGE_EIP_712_TYPE,
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export type SignableTWAPSellOrderData = {
|
|
60
|
-
types: typeof TWAP_ORDER_EIP_712_TYPES;
|
|
61
|
-
domain: Domain;
|
|
62
|
-
data: TWAPDeltaOrder;
|
|
63
|
-
};
|
|
64
|
-
|
|
65
|
-
export type SignableTWAPBuyOrderData = {
|
|
66
|
-
types: typeof TWAP_BUY_ORDER_EIP_712_TYPES;
|
|
67
|
-
domain: Domain;
|
|
68
|
-
data: TWAPBuyDeltaOrder;
|
|
69
|
-
};
|
|
70
|
-
|
|
71
|
-
export type SignableTWAPOrderData =
|
|
72
|
-
| SignableTWAPSellOrderData
|
|
73
|
-
| SignableTWAPBuyOrderData;
|
|
74
|
-
|
|
75
|
-
type ProduceTWAPOrderTypedDataInput<T extends TWAPOnChainOrderType> = {
|
|
76
|
-
orderInput: OnChainOrderMap[T];
|
|
77
|
-
paraswapDeltaAddress: string;
|
|
78
|
-
chainId: number;
|
|
79
|
-
onChainOrderType: T;
|
|
80
|
-
};
|
|
81
|
-
|
|
82
|
-
export function produceTWAPOrderTypedData(
|
|
83
|
-
params: ProduceTWAPOrderTypedDataInput<'TWAPOrder'>
|
|
84
|
-
): SignableTWAPSellOrderData;
|
|
85
|
-
export function produceTWAPOrderTypedData(
|
|
86
|
-
params: ProduceTWAPOrderTypedDataInput<'TWAPBuyOrder'>
|
|
87
|
-
): SignableTWAPBuyOrderData;
|
|
88
|
-
export function produceTWAPOrderTypedData({
|
|
89
|
-
orderInput,
|
|
90
|
-
chainId,
|
|
91
|
-
paraswapDeltaAddress,
|
|
92
|
-
onChainOrderType,
|
|
93
|
-
}: ProduceTWAPOrderTypedDataInput<TWAPOnChainOrderType>) {
|
|
94
|
-
const domain: Domain = {
|
|
95
|
-
name: 'Portikus',
|
|
96
|
-
version: '2.0.0',
|
|
97
|
-
chainId,
|
|
98
|
-
verifyingContract: paraswapDeltaAddress,
|
|
99
|
-
};
|
|
100
|
-
|
|
101
|
-
if (onChainOrderType === 'TWAPOrder') {
|
|
102
|
-
return {
|
|
103
|
-
types: TWAP_ORDER_EIP_712_TYPES,
|
|
104
|
-
domain,
|
|
105
|
-
data: orderInput,
|
|
106
|
-
};
|
|
107
|
-
}
|
|
108
|
-
|
|
109
|
-
return {
|
|
110
|
-
types: TWAP_BUY_ORDER_EIP_712_TYPES,
|
|
111
|
-
domain,
|
|
112
|
-
data: orderInput,
|
|
113
|
-
};
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
export type TWAPOrderCommonInput = {
|
|
117
|
-
owner: string;
|
|
118
|
-
beneficiary?: string;
|
|
119
|
-
srcToken: string;
|
|
120
|
-
destToken: string;
|
|
121
|
-
nonce?: string;
|
|
122
|
-
deadline?: number;
|
|
123
|
-
permit?: string;
|
|
124
|
-
metadata?: string;
|
|
125
|
-
interval: number;
|
|
126
|
-
numSlices: number;
|
|
127
|
-
bridge: Bridge;
|
|
128
|
-
|
|
129
|
-
partnerAddress: string;
|
|
130
|
-
paraswapDeltaAddress: string;
|
|
131
|
-
partnerFeeBps: number;
|
|
132
|
-
partnerTakesSurplus?: boolean;
|
|
133
|
-
capSurplus?: boolean;
|
|
134
|
-
chainId: number;
|
|
135
|
-
};
|
|
136
|
-
|
|
137
|
-
export type BuildTWAPSellOrderDataInput = TWAPOrderCommonInput & {
|
|
138
|
-
onChainOrderType: 'TWAPOrder';
|
|
139
|
-
destAmountPerSlice: string;
|
|
140
|
-
totalSrcAmount: string;
|
|
141
|
-
};
|
|
142
|
-
|
|
143
|
-
export type BuildTWAPBuyOrderDataInput = TWAPOrderCommonInput & {
|
|
144
|
-
onChainOrderType: 'TWAPBuyOrder';
|
|
145
|
-
totalDestAmount: string;
|
|
146
|
-
maxSrcAmount: string;
|
|
147
|
-
};
|
|
148
|
-
|
|
149
|
-
export type BuildTWAPOrderDataInput =
|
|
150
|
-
| BuildTWAPSellOrderDataInput
|
|
151
|
-
| BuildTWAPBuyOrderDataInput;
|
|
152
|
-
|
|
153
|
-
export function buildTWAPSignableOrderData(
|
|
154
|
-
input: BuildTWAPOrderDataInput
|
|
155
|
-
): SignableTWAPOrderData {
|
|
156
|
-
const {
|
|
157
|
-
owner,
|
|
158
|
-
beneficiary = owner,
|
|
159
|
-
srcToken,
|
|
160
|
-
destToken,
|
|
161
|
-
nonce = Date.now().toString(10),
|
|
162
|
-
deadline = Math.floor(Date.now() / 1000 + DELTA_DEFAULT_EXPIRY),
|
|
163
|
-
permit = '0x',
|
|
164
|
-
metadata = '0x',
|
|
165
|
-
interval,
|
|
166
|
-
numSlices,
|
|
167
|
-
bridge,
|
|
168
|
-
|
|
169
|
-
partnerAddress,
|
|
170
|
-
partnerFeeBps,
|
|
171
|
-
partnerTakesSurplus = false,
|
|
172
|
-
capSurplus = true,
|
|
173
|
-
chainId,
|
|
174
|
-
paraswapDeltaAddress,
|
|
175
|
-
onChainOrderType,
|
|
176
|
-
} = input;
|
|
177
|
-
|
|
178
|
-
const partnerAndFee = producePartnerAndFee({
|
|
179
|
-
partnerFeeBps,
|
|
180
|
-
partnerAddress,
|
|
181
|
-
partnerTakesSurplus,
|
|
182
|
-
capSurplus,
|
|
183
|
-
});
|
|
184
|
-
|
|
185
|
-
const commonFields = {
|
|
186
|
-
owner,
|
|
187
|
-
beneficiary,
|
|
188
|
-
srcToken,
|
|
189
|
-
destToken,
|
|
190
|
-
nonce,
|
|
191
|
-
partnerAndFee,
|
|
192
|
-
deadline,
|
|
193
|
-
interval,
|
|
194
|
-
numSlices,
|
|
195
|
-
permit,
|
|
196
|
-
metadata,
|
|
197
|
-
bridge,
|
|
198
|
-
};
|
|
199
|
-
|
|
200
|
-
if (onChainOrderType === 'TWAPOrder') {
|
|
201
|
-
const orderInput: TWAPDeltaOrder = {
|
|
202
|
-
...commonFields,
|
|
203
|
-
destAmountPerSlice: input.destAmountPerSlice,
|
|
204
|
-
totalSrcAmount: input.totalSrcAmount,
|
|
205
|
-
};
|
|
206
|
-
|
|
207
|
-
return produceTWAPOrderTypedData({
|
|
208
|
-
orderInput,
|
|
209
|
-
chainId,
|
|
210
|
-
paraswapDeltaAddress,
|
|
211
|
-
onChainOrderType: 'TWAPOrder',
|
|
212
|
-
});
|
|
213
|
-
}
|
|
214
|
-
|
|
215
|
-
const orderInput: TWAPBuyDeltaOrder = {
|
|
216
|
-
...commonFields,
|
|
217
|
-
totalDestAmount: input.totalDestAmount,
|
|
218
|
-
maxSrcAmount: input.maxSrcAmount,
|
|
219
|
-
};
|
|
220
|
-
|
|
221
|
-
return produceTWAPOrderTypedData({
|
|
222
|
-
orderInput,
|
|
223
|
-
chainId,
|
|
224
|
-
paraswapDeltaAddress,
|
|
225
|
-
onChainOrderType: 'TWAPBuyOrder',
|
|
226
|
-
});
|
|
227
|
-
}
|