@xyo-network/chain-bridge 1.20.5 → 1.20.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/dist/node/index.mjs +147 -90
- package/dist/node/index.mjs.map +1 -1
- package/dist/node/queue/workers/EthTransactionMonitor.d.ts.map +1 -1
- package/dist/node/queue/workers/Xl1TransactionSubmissionStorage.d.ts.map +1 -1
- package/dist/node/server/app.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/getRouteDefinitions.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.d.ts.map +1 -1
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteMaxEstimate.d.ts +77 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteMaxEstimate.d.ts.map +1 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/index.d.ts +1 -0
- package/dist/node/server/routes/bridge/routeDefinitions/routes/index.d.ts.map +1 -1
- package/dist/node/util/calculateMaxBridgeAmount.d.ts +11 -0
- package/dist/node/util/calculateMaxBridgeAmount.d.ts.map +1 -0
- package/dist/node/util/index.d.ts +1 -0
- package/dist/node/util/index.d.ts.map +1 -1
- package/dist/node/validation/validateBridgeEstimateExact.d.ts.map +1 -1
- package/package.json +32 -49
- package/src/queue/workers/EthTransactionMonitor.ts +0 -1
- package/src/queue/workers/Xl1TransactionSubmissionStorage.ts +0 -1
- package/src/server/app.ts +3 -15
- package/src/server/routes/bridge/routeDefinitions/getRouteDefinitions.ts +2 -1
- package/src/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.ts +11 -2
- package/src/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteMaxEstimate.ts +64 -0
- package/src/server/routes/bridge/routeDefinitions/routes/index.ts +1 -0
- package/src/util/calculateBridgeFees.ts +4 -4
- package/src/util/calculateMaxBridgeAmount.ts +22 -0
- package/src/util/index.ts +1 -0
- package/src/validation/validateBridgeEstimateExact.ts +6 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"EthTransactionMonitor.d.ts","sourceRoot":"","sources":["../../../../src/queue/workers/EthTransactionMonitor.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"EthTransactionMonitor.d.ts","sourceRoot":"","sources":["../../../../src/queue/workers/EthTransactionMonitor.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAOjC,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAEvE,MAAM,MAAM,4BAA4B,GAAG,qBAAqB,CAAA;AAChE,MAAM,WAAW,8BAA8B;IAC7C,SAAS,EAAE,MAAM,CAAA;IACjB,WAAW,EAAE,MAAM,CAAA;IACnB,cAAc,EAAE,MAAM,CAAA;CACvB;AACD,MAAM,MAAM,wBAAwB,GAAG,GAAG,CAAC,4BAA4B,EAAE,8BAA8B,CAAC,CAAA;AAsCxG,eAAO,MAAM,qBAAqB,EAAE,iBAEnC,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Xl1TransactionSubmissionStorage.d.ts","sourceRoot":"","sources":["../../../../src/queue/workers/Xl1TransactionSubmissionStorage.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"Xl1TransactionSubmissionStorage.d.ts","sourceRoot":"","sources":["../../../../src/queue/workers/Xl1TransactionSubmissionStorage.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,QAAQ,CAAA;AAKjC,OAAO,KAAK,EAA4B,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEnF,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,wBAAwB,CAAA;AAC/D,OAAO,KAAK,EAAE,qBAAqB,EAAE,MAAM,4BAA4B,CAAA;AAIvE,MAAM,MAAM,sCAAsC,GAAG,qBAAqB,CAAA;AAC1E,MAAM,WAAW,wCAAwC;IACvD,cAAc,EAAE,QAAQ,CAAC,UAAU,CAAC,CAAC,gBAAgB,CAAC,CAAA;CACvD;AACD,MAAM,MAAM,kCAAkC,GAAG,GAAG,CAAC,sCAAsC,EAAE,wCAAwC,CAAC,CAAA;AAwDtI,eAAO,MAAM,+BAA+B,EAAE,iBAE7C,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/server/app.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"app.d.ts","sourceRoot":"","sources":["../../../src/server/app.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAC5D,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,SAAS,CAAA;AAOtC,eAAO,MAAM,MAAM,GAAI,QAAQ,YAAY,EAAE,SAAS,gBAAgB,KAAG,OAQxE,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"getRouteDefinitions.d.ts","sourceRoot":"","sources":["../../../../../../src/server/routes/bridge/routeDefinitions/getRouteDefinitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAM5D,eAAO,MAAM,mBAAmB,GAAI,QAAQ,YAAY,EAAE,SAAS,gBAAgB,KAAG,eAAe,
|
|
1
|
+
{"version":3,"file":"getRouteDefinitions.d.ts","sourceRoot":"","sources":["../../../../../../src/server/routes/bridge/routeDefinitions/getRouteDefinitions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AACtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AACpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAM5D,eAAO,MAAM,mBAAmB,GAAI,QAAQ,YAAY,EAAE,SAAS,gBAAgB,KAAG,eAAe,EASpG,CAAA"}
|
package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"bridgeToRemoteEstimate.d.ts","sourceRoot":"","sources":["../../../../../../../src/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;
|
|
1
|
+
{"version":3,"file":"bridgeToRemoteEstimate.d.ts","sourceRoot":"","sources":["../../../../../../../src/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteEstimate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAKtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAI5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,eAAO,MAAM,6BAA6B;;;;iBAIxC,CAAA;AACF,MAAM,MAAM,0BAA0B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,6BAA6B,CAAC,CAAA;AAEtF,eAAO,MAAM,iCAAiC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAI5C,CAAA;AAEF,MAAM,MAAM,8BAA8B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,iCAAiC,CAAC,CAAA;AAE9F,eAAO,MAAM,+BAA+B,GAAI,QAAQ,YAAY,EAAE,SAAS,gBAAgB,KAAG,eAoCjG,CAAA"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
import type { RouteDefinition } from '@xylabs/express';
|
|
2
|
+
import type { BridgeConfig } from '@xyo-network/chain-orchestration';
|
|
3
|
+
import type { XyoGatewayRunner } from '@xyo-network/xl1-sdk';
|
|
4
|
+
import { z } from 'zod';
|
|
5
|
+
export declare const BridgeToRemoteMaxEstimateBodyZod: z.ZodObject<{
|
|
6
|
+
srcAmount: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
7
|
+
srcAddress: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
8
|
+
destAddress: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
9
|
+
}, z.core.$strip>;
|
|
10
|
+
export type BridgeToRemoteMaxEstimateBody = z.infer<typeof BridgeToRemoteMaxEstimateBodyZod>;
|
|
11
|
+
export declare const BridgeToRemoteMaxEstimateResponseZod: z.ZodTuple<[z.ZodObject<{
|
|
12
|
+
schema: z.ZodLiteral<"network.xyo.boundwitness" & {
|
|
13
|
+
readonly __schema: true;
|
|
14
|
+
}>;
|
|
15
|
+
addresses: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<Lowercase<string> & {
|
|
16
|
+
readonly __hex: true;
|
|
17
|
+
} & {
|
|
18
|
+
readonly __address: true;
|
|
19
|
+
}, string>>>;
|
|
20
|
+
payload_hashes: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHash, string>>>;
|
|
21
|
+
payload_schemas: z.ZodArray<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xyo-network/sdk-js").BrandedSchema<string>, string>>>;
|
|
22
|
+
previous_hashes: z.ZodArray<z.ZodNullable<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHash, string>>>>;
|
|
23
|
+
$destination: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<Lowercase<string> & {
|
|
24
|
+
readonly __hex: true;
|
|
25
|
+
} & {
|
|
26
|
+
readonly __address: true;
|
|
27
|
+
}, string>>>;
|
|
28
|
+
$sourceQuery: z.ZodOptional<z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHash, string>>>;
|
|
29
|
+
$signatures: z.ZodArray<z.ZodUnion<readonly [z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>, z.ZodNull]>>;
|
|
30
|
+
nbf: z.ZodPipe<z.ZodNumber, z.ZodTransform<import("@xyo-network/xl1-sdk").XL1BlockNumber, number>>;
|
|
31
|
+
exp: z.ZodPipe<z.ZodNumber, z.ZodTransform<import("@xyo-network/xl1-sdk").XL1BlockNumber, number>>;
|
|
32
|
+
fees: z.ZodObject<{
|
|
33
|
+
base: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
34
|
+
gasLimit: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
35
|
+
gasPrice: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
36
|
+
priority: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
37
|
+
}, z.core.$strip>;
|
|
38
|
+
chain: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
39
|
+
from: z.ZodPipe<z.ZodString, z.ZodTransform<Lowercase<string> & {
|
|
40
|
+
readonly __hex: true;
|
|
41
|
+
} & {
|
|
42
|
+
readonly __address: true;
|
|
43
|
+
}, string>>;
|
|
44
|
+
script: z.ZodOptional<z.ZodArray<z.ZodString>>;
|
|
45
|
+
}, z.core.$strip>, z.ZodObject<{
|
|
46
|
+
schema: z.ZodLiteral<"network.xyo.chain.bridge.intent" & {
|
|
47
|
+
readonly __schema: true;
|
|
48
|
+
}>;
|
|
49
|
+
src: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
50
|
+
srcAddress: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
51
|
+
srcAmount: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
52
|
+
srcToken: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
53
|
+
dest: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
54
|
+
destAddress: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
55
|
+
destAmount: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
56
|
+
destToken: z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>;
|
|
57
|
+
nonce: z.ZodString;
|
|
58
|
+
}, z.core.$strict>, z.ZodObject<{
|
|
59
|
+
schema: z.ZodLiteral<"network.xyo.transfer" & {
|
|
60
|
+
readonly __schema: true;
|
|
61
|
+
}>;
|
|
62
|
+
context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodType<unknown, unknown, z.core.$ZodTypeInternals<unknown, unknown>>>>;
|
|
63
|
+
epoch: z.ZodNumber;
|
|
64
|
+
from: z.ZodPipe<z.ZodString, z.ZodTransform<Lowercase<string> & {
|
|
65
|
+
readonly __hex: true;
|
|
66
|
+
} & {
|
|
67
|
+
readonly __address: true;
|
|
68
|
+
}, string>>;
|
|
69
|
+
transfers: z.ZodRecord<z.ZodPipe<z.ZodString, z.ZodTransform<Lowercase<string> & {
|
|
70
|
+
readonly __hex: true;
|
|
71
|
+
} & {
|
|
72
|
+
readonly __address: true;
|
|
73
|
+
}, string>>, z.ZodPipe<z.ZodString, z.ZodTransform<import("@xylabs/sdk-js").BrandedHex, string>>>;
|
|
74
|
+
}, z.core.$strip>], null>;
|
|
75
|
+
export type BridgeToRemoteMaxEstimateResponse = z.infer<typeof BridgeToRemoteMaxEstimateResponseZod>;
|
|
76
|
+
export declare const makeBridgeToRemoteMaxEstimateRoute: (config: BridgeConfig, gateway: XyoGatewayRunner) => RouteDefinition;
|
|
77
|
+
//# sourceMappingURL=bridgeToRemoteMaxEstimate.d.ts.map
|
package/dist/node/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteMaxEstimate.d.ts.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bridgeToRemoteMaxEstimate.d.ts","sourceRoot":"","sources":["../../../../../../../src/server/routes/bridge/routeDefinitions/routes/bridgeToRemoteMaxEstimate.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,iBAAiB,CAAA;AAKtD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAEpE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAA;AAI5D,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAMvB,eAAO,MAAM,gCAAgC;;;;iBAI3C,CAAA;AACF,MAAM,MAAM,6BAA6B,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,gCAAgC,CAAC,CAAA;AAE5F,eAAO,MAAM,oCAAoC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;yBAI/C,CAAA;AAEF,MAAM,MAAM,iCAAiC,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,oCAAoC,CAAC,CAAA;AAEpG,eAAO,MAAM,kCAAkC,GAAI,QAAQ,YAAY,EAAE,SAAS,gBAAgB,KAAG,eA+BpG,CAAA"}
|
|
@@ -2,5 +2,6 @@ export * from './bridgeConfig.ts';
|
|
|
2
2
|
export * from './bridgeFromRemoteStatus.ts';
|
|
3
3
|
export * from './bridgeToRemote.ts';
|
|
4
4
|
export * from './bridgeToRemoteEstimate.ts';
|
|
5
|
+
export * from './bridgeToRemoteMaxEstimate.ts';
|
|
5
6
|
export * from './bridgeToRemoteStatus.ts';
|
|
6
7
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/server/routes/bridge/routeDefinitions/routes/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA;AACnC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,2BAA2B,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../../../src/server/routes/bridge/routeDefinitions/routes/index.ts"],"names":[],"mappings":"AAAA,cAAc,mBAAmB,CAAA;AACjC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,qBAAqB,CAAA;AACnC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,gCAAgC,CAAA;AAC9C,cAAc,2BAA2B,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
import type { Hex } from '@xylabs/sdk-js';
|
|
2
|
+
import type { FeeStructure } from './calculateBridgeFees.ts';
|
|
3
|
+
/**
|
|
4
|
+
* Given a user's total available balance, calculates the maximum amount they can bridge
|
|
5
|
+
* after accounting for the fixed and variable bridge fees.
|
|
6
|
+
*
|
|
7
|
+
* Solving for M where: M + feeFixed + (M * basisPoints / 10_000) = balance
|
|
8
|
+
* => M = (balance - feeFixed) * 10_000 / (10_000 + basisPoints)
|
|
9
|
+
*/
|
|
10
|
+
export declare const calculateMaxBridgeAmount: (balance: Hex, feeStructure: FeeStructure) => Hex;
|
|
11
|
+
//# sourceMappingURL=calculateMaxBridgeAmount.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"calculateMaxBridgeAmount.d.ts","sourceRoot":"","sources":["../../../src/util/calculateMaxBridgeAmount.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,gBAAgB,CAAA;AAGzC,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,0BAA0B,CAAA;AAE5D;;;;;;GAMG;AACH,eAAO,MAAM,wBAAwB,GAAI,SAAS,GAAG,EAAE,cAAc,YAAY,KAAG,GASnF,CAAA"}
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './BridgeFees.ts';
|
|
2
2
|
export * from './bridgeFeesAsBigInt.ts';
|
|
3
3
|
export * from './calculateBridgeFees.ts';
|
|
4
|
+
export * from './calculateMaxBridgeAmount.ts';
|
|
4
5
|
export * from './createBridgeTransfer.ts';
|
|
5
6
|
export * from './generateBridgeEstimate.ts';
|
|
6
7
|
export * from './getConfigFromEnv.ts';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,0BAA0B,CAAA;AACxC,cAAc,2BAA2B,CAAA;AACzC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/util/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAA;AAC/B,cAAc,yBAAyB,CAAA;AACvC,cAAc,0BAA0B,CAAA;AACxC,cAAc,+BAA+B,CAAA;AAC7C,cAAc,2BAA2B,CAAA;AACzC,cAAc,6BAA6B,CAAA;AAC3C,cAAc,uBAAuB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"validateBridgeEstimateExact.d.ts","sourceRoot":"","sources":["../../../src/validation/validateBridgeEstimateExact.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;
|
|
1
|
+
{"version":3,"file":"validateBridgeEstimateExact.d.ts","sourceRoot":"","sources":["../../../src/validation/validateBridgeEstimateExact.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,kCAAkC,CAAA;AAEpE,OAAO,KAAK,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,sBAAsB,CAAA;AAKlE;;;;;;;GAOG;AACH,eAAO,MAAM,2BAA2B,GACtC,QAAQ,YAAY,EACpB,UAAU,QAAQ,EAClB,QAAQ,YAAY,KACnB,OAAO,CAAC,OAAO,CAkBjB,CAAA"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@xyo-network/chain-bridge",
|
|
3
|
-
"version": "1.20.
|
|
3
|
+
"version": "1.20.9",
|
|
4
4
|
"description": "XYO Layer One Bridge",
|
|
5
5
|
"homepage": "https://xylabs.com",
|
|
6
6
|
"bugs": {
|
|
@@ -49,72 +49,55 @@
|
|
|
49
49
|
"types": "tsc --noEmit -p tsconfig.test.json"
|
|
50
50
|
},
|
|
51
51
|
"dependencies": {
|
|
52
|
-
"@opentelemetry/
|
|
52
|
+
"@opentelemetry/api": "^1.9.1",
|
|
53
|
+
"@opentelemetry/instrumentation": "~0.214.0",
|
|
53
54
|
"@opentelemetry/instrumentation-express": "~0.61.0",
|
|
54
|
-
"@opentelemetry/instrumentation-http": "~0.
|
|
55
|
-
"@xylabs/express": "~5.0.
|
|
56
|
-
"@xylabs/mongo": "~5.0.
|
|
57
|
-
"@xylabs/sdk-js": "~5.0.
|
|
58
|
-
"@xyo-network/boundwitness-validator": "~5.3.
|
|
59
|
-
"@xyo-network/chain-orchestration": "~1.20.
|
|
60
|
-
"@xyo-network/chain-protocol": "~1.20.
|
|
61
|
-
"@xyo-network/chain-services": "~1.20.
|
|
62
|
-
"@xyo-network/sdk-js": "~5.3.
|
|
63
|
-
"@xyo-network/sentinel-abstract": "~5.3.15",
|
|
64
|
-
"@xyo-network/sentinel-model": "~5.3.15",
|
|
55
|
+
"@opentelemetry/instrumentation-http": "~0.214.0",
|
|
56
|
+
"@xylabs/express": "~5.0.87",
|
|
57
|
+
"@xylabs/mongo": "~5.0.87",
|
|
58
|
+
"@xylabs/sdk-js": "~5.0.87",
|
|
59
|
+
"@xyo-network/boundwitness-validator": "~5.3.16",
|
|
60
|
+
"@xyo-network/chain-orchestration": "~1.20.9",
|
|
61
|
+
"@xyo-network/chain-protocol": "~1.20.9",
|
|
62
|
+
"@xyo-network/chain-services": "~1.20.9",
|
|
63
|
+
"@xyo-network/sdk-js": "~5.3.16",
|
|
65
64
|
"@xyo-network/typechain": "~4.1.2",
|
|
66
|
-
"@xyo-network/wallet-model": "~5.3.
|
|
67
|
-
"@xyo-network/xl1-sdk": "~1.
|
|
65
|
+
"@xyo-network/wallet-model": "~5.3.16",
|
|
66
|
+
"@xyo-network/xl1-sdk": "~1.26.4",
|
|
68
67
|
"async-mutex": "~0.5.0",
|
|
69
|
-
"bullmq": "~5.
|
|
68
|
+
"bullmq": "~5.71.1",
|
|
70
69
|
"bullmq-otel": "~1.3.0",
|
|
71
|
-
"compression": "~1.8.1",
|
|
72
|
-
"cors": "~2.8.6",
|
|
73
70
|
"ethers": "^6.16.0",
|
|
74
71
|
"express": "~5.2.1",
|
|
75
|
-
"ioredis": "5.
|
|
72
|
+
"ioredis": "5.10.1",
|
|
73
|
+
"mongodb": "~7.1.1",
|
|
76
74
|
"uuid": "~13.0.0",
|
|
77
75
|
"yargs-parser": "~22.0.0"
|
|
78
76
|
},
|
|
79
77
|
"devDependencies": {
|
|
80
|
-
"@opentelemetry/api": "^1.9.
|
|
81
|
-
"@types/
|
|
82
|
-
"@types/
|
|
83
|
-
"@
|
|
84
|
-
"@
|
|
85
|
-
"@xylabs/
|
|
86
|
-
"@xylabs/
|
|
87
|
-
"@xylabs/
|
|
88
|
-
"@
|
|
89
|
-
"@
|
|
90
|
-
"@xyo-network/
|
|
91
|
-
"@xyo-network/
|
|
92
|
-
"@xyo-network/
|
|
93
|
-
"@xyo-network/archivist-mongodb": "~5.3.15",
|
|
94
|
-
"@xyo-network/archivist-view": "~5.3.15",
|
|
95
|
-
"@xyo-network/bios": "~7.2.1",
|
|
96
|
-
"@xyo-network/bios-model": "~7.2.1",
|
|
97
|
-
"@xyo-network/boundwitness-builder": "~5.3.15",
|
|
98
|
-
"@xyo-network/chain-protocol": "~1.20.5",
|
|
99
|
-
"@xyo-network/chain-services": "~1.20.5",
|
|
100
|
-
"@xyo-network/chain-telemetry": "~1.20.5",
|
|
101
|
-
"@xyo-network/module-abstract": "~5.3.15",
|
|
102
|
-
"@xyo-network/module-abstract-mongodb": "~5.3.15",
|
|
103
|
-
"@xyo-network/node-memory": "~5.3.15",
|
|
104
|
-
"@xyo-network/sdk-js": "~5.3.15",
|
|
105
|
-
"@xyo-network/sentinel-memory": "~5.3.15",
|
|
106
|
-
"@xyo-network/xl1-sdk": "~1.25.22",
|
|
78
|
+
"@opentelemetry/api": "^1.9.1",
|
|
79
|
+
"@types/node": "~25.5.0",
|
|
80
|
+
"@types/yargs-parser": "~21.0.3",
|
|
81
|
+
"@xylabs/mongo": "~5.0.87",
|
|
82
|
+
"@xylabs/sdk-js": "~5.0.87",
|
|
83
|
+
"@xylabs/ts-scripts-yarn3": "~7.4.28",
|
|
84
|
+
"@xylabs/tsconfig": "~7.4.28",
|
|
85
|
+
"@xylabs/vitest-extended": "~5.0.87",
|
|
86
|
+
"@xyo-network/chain-protocol": "~1.20.9",
|
|
87
|
+
"@xyo-network/chain-services": "~1.20.9",
|
|
88
|
+
"@xyo-network/chain-test-helpers": "workspace:packages/test-helpers",
|
|
89
|
+
"@xyo-network/sdk-js": "~5.3.16",
|
|
90
|
+
"@xyo-network/xl1-sdk": "~1.26.4",
|
|
107
91
|
"async-mutex": "~0.5.0",
|
|
108
92
|
"axios": "~1.13.6",
|
|
109
93
|
"dotenv": "~17.3.1",
|
|
110
|
-
"eslint": "^9.39.4",
|
|
111
94
|
"ethers": "^6.16.0",
|
|
112
95
|
"http-status-codes": "~2.3.0",
|
|
113
|
-
"mongodb": "~7.1.
|
|
96
|
+
"mongodb": "~7.1.1",
|
|
114
97
|
"nodemon": "~3.1.14",
|
|
115
98
|
"tslib": "~2.8.1",
|
|
116
99
|
"typescript": "~5.9.3",
|
|
117
|
-
"vitest": "
|
|
100
|
+
"vitest": "^4.1.1",
|
|
118
101
|
"vitest-mock-extended": "~3.1.0",
|
|
119
102
|
"zod": "~4.3.6"
|
|
120
103
|
},
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assertEx } from '@xylabs/sdk-js'
|
|
2
2
|
import { PayloadBuilder } from '@xyo-network/sdk-js'
|
|
3
|
-
import type { SignedHydratedTransaction } from '@xyo-network/xl1-sdk'
|
|
4
3
|
import type { Job } from 'bullmq'
|
|
5
4
|
import { Worker } from 'bullmq'
|
|
6
5
|
import type { BullMQOtel } from 'bullmq-otel'
|
|
@@ -1,6 +1,5 @@
|
|
|
1
1
|
import { assertEx, isDefined } from '@xylabs/sdk-js'
|
|
2
2
|
import { PayloadBuilder } from '@xyo-network/sdk-js'
|
|
3
|
-
import { type SignedHydratedTransaction } from '@xyo-network/xl1-sdk'
|
|
4
3
|
import type { Job } from 'bullmq'
|
|
5
4
|
import { Worker } from 'bullmq'
|
|
6
5
|
import type { BullMQOtel } from 'bullmq-otel'
|
package/src/server/app.ts
CHANGED
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
import {
|
|
2
|
-
customPoweredByHeader, disableCaseSensitiveRouting, disableExpressDefaultPoweredByHeader, getJsonBodyParser, getJsonBodyParserOptions, responseProfiler,
|
|
3
|
-
standardErrors, standardResponses,
|
|
4
|
-
} from '@xylabs/express'
|
|
1
|
+
import { standardErrors } from '@xylabs/express'
|
|
5
2
|
import type { BridgeConfig } from '@xyo-network/chain-orchestration'
|
|
3
|
+
import { sharedMiddleware } from '@xyo-network/chain-orchestration'
|
|
6
4
|
import type { XyoGatewayRunner } from '@xyo-network/xl1-sdk'
|
|
7
|
-
import compression from 'compression'
|
|
8
|
-
import cors from 'cors'
|
|
9
5
|
import type { Express } from 'express'
|
|
10
6
|
import express from 'express'
|
|
11
7
|
|
|
@@ -16,15 +12,7 @@ import { addRoutes } from './routes/index.ts'
|
|
|
16
12
|
export const getApp = (config: BridgeConfig, gateway: XyoGatewayRunner): Express => {
|
|
17
13
|
addInstrumentation()
|
|
18
14
|
const app = express()
|
|
19
|
-
app
|
|
20
|
-
app.use(cors())
|
|
21
|
-
app.use(compression())
|
|
22
|
-
app.use(responseProfiler)
|
|
23
|
-
app.use(getJsonBodyParser(getJsonBodyParserOptions({ limit: '1mb' })))
|
|
24
|
-
app.use(standardResponses)
|
|
25
|
-
disableExpressDefaultPoweredByHeader(app)
|
|
26
|
-
app.use(customPoweredByHeader)
|
|
27
|
-
disableCaseSensitiveRouting(app)
|
|
15
|
+
sharedMiddleware(app)
|
|
28
16
|
addFlowProducer(app, config)
|
|
29
17
|
addRoutes(app, config, gateway)
|
|
30
18
|
app.use(standardErrors)
|
|
@@ -3,13 +3,14 @@ import type { BridgeConfig } from '@xyo-network/chain-orchestration'
|
|
|
3
3
|
import type { XyoGatewayRunner } from '@xyo-network/xl1-sdk'
|
|
4
4
|
|
|
5
5
|
import {
|
|
6
|
-
makeBridgeConfigRoute, makeBridgeFromRemoteStatusRoute, makeBridgeToRemoteEstimateRoute, makeBridgeToRemoteRoute, makeBridgeToRemoteStatusRoute,
|
|
6
|
+
makeBridgeConfigRoute, makeBridgeFromRemoteStatusRoute, makeBridgeToRemoteEstimateRoute, makeBridgeToRemoteMaxEstimateRoute, makeBridgeToRemoteRoute, makeBridgeToRemoteStatusRoute,
|
|
7
7
|
} from './routes/index.ts'
|
|
8
8
|
|
|
9
9
|
export const getRouteDefinitions = (config: BridgeConfig, gateway: XyoGatewayRunner): RouteDefinition[] => {
|
|
10
10
|
return [
|
|
11
11
|
makeBridgeConfigRoute(config),
|
|
12
12
|
makeBridgeToRemoteEstimateRoute(config, gateway),
|
|
13
|
+
makeBridgeToRemoteMaxEstimateRoute(config, gateway),
|
|
13
14
|
makeBridgeToRemoteRoute(config),
|
|
14
15
|
makeBridgeToRemoteStatusRoute(config),
|
|
15
16
|
makeBridgeFromRemoteStatusRoute(config),
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
import type { RouteDefinition } from '@xylabs/express'
|
|
2
2
|
import { requestHandlerValidator } from '@xylabs/express'
|
|
3
|
-
import {
|
|
3
|
+
import {
|
|
4
|
+
assertEx, hexToBigInt, toAddress,
|
|
5
|
+
} from '@xylabs/sdk-js'
|
|
4
6
|
import type { BridgeConfig } from '@xyo-network/chain-orchestration'
|
|
5
7
|
import { PayloadZodStrictOfSchema } from '@xyo-network/sdk-js'
|
|
6
8
|
import type { XyoGatewayRunner } from '@xyo-network/xl1-sdk'
|
|
@@ -9,7 +11,7 @@ import {
|
|
|
9
11
|
} from '@xyo-network/xl1-sdk'
|
|
10
12
|
import { z } from 'zod'
|
|
11
13
|
|
|
12
|
-
import { getXl1ChainId } from '../../../../../config/index.ts'
|
|
14
|
+
import { getBridgeSettings, getXl1ChainId } from '../../../../../config/index.ts'
|
|
13
15
|
import { generateBridgeEstimate } from '../../../../../util/index.ts'
|
|
14
16
|
import { getRemoteChainIdZod } from '../pathParams/index.ts'
|
|
15
17
|
|
|
@@ -41,6 +43,13 @@ export const makeBridgeToRemoteEstimateRoute = (config: BridgeConfig, gateway: X
|
|
|
41
43
|
const {
|
|
42
44
|
srcAddress, srcAmount, destAddress,
|
|
43
45
|
} = req.body
|
|
46
|
+
|
|
47
|
+
const { maxBridgeAmount } = await getBridgeSettings(config)
|
|
48
|
+
if (hexToBigInt(srcAmount) > hexToBigInt(maxBridgeAmount)) {
|
|
49
|
+
res.status(400).send()
|
|
50
|
+
return
|
|
51
|
+
}
|
|
52
|
+
|
|
44
53
|
const [bridgeIntent, transfer] = await generateBridgeEstimate(srcAddress, srcAmount, destAddress, config)
|
|
45
54
|
const sender = toAddress(srcAddress)
|
|
46
55
|
|
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
import type { RouteDefinition } from '@xylabs/express'
|
|
2
|
+
import { requestHandlerValidator } from '@xylabs/express'
|
|
3
|
+
import {
|
|
4
|
+
assertEx, hexToBigInt, toAddress, toHex,
|
|
5
|
+
} from '@xylabs/sdk-js'
|
|
6
|
+
import type { BridgeConfig } from '@xyo-network/chain-orchestration'
|
|
7
|
+
import { PayloadZodStrictOfSchema } from '@xyo-network/sdk-js'
|
|
8
|
+
import type { XyoGatewayRunner } from '@xyo-network/xl1-sdk'
|
|
9
|
+
import {
|
|
10
|
+
BridgeIntentFieldsZod, BridgeIntentSchema, buildUnsignedTransaction, toXL1BlockNumber, TransactionBoundWitnessZod, TransferZod,
|
|
11
|
+
} from '@xyo-network/xl1-sdk'
|
|
12
|
+
import { z } from 'zod'
|
|
13
|
+
|
|
14
|
+
import { getBridgeSettings } from '../../../../../config/index.ts'
|
|
15
|
+
import { calculateMaxBridgeAmount, generateBridgeEstimate } from '../../../../../util/index.ts'
|
|
16
|
+
import { getRemoteChainIdZod } from '../pathParams/index.ts'
|
|
17
|
+
|
|
18
|
+
export const BridgeToRemoteMaxEstimateBodyZod = BridgeIntentFieldsZod.pick({
|
|
19
|
+
destAddress: true,
|
|
20
|
+
srcAddress: true,
|
|
21
|
+
srcAmount: true,
|
|
22
|
+
})
|
|
23
|
+
export type BridgeToRemoteMaxEstimateBody = z.infer<typeof BridgeToRemoteMaxEstimateBodyZod>
|
|
24
|
+
|
|
25
|
+
export const BridgeToRemoteMaxEstimateResponseZod = z.tuple([
|
|
26
|
+
TransactionBoundWitnessZod,
|
|
27
|
+
PayloadZodStrictOfSchema(BridgeIntentSchema).extend(BridgeIntentFieldsZod.shape),
|
|
28
|
+
TransferZod,
|
|
29
|
+
])
|
|
30
|
+
|
|
31
|
+
export type BridgeToRemoteMaxEstimateResponse = z.infer<typeof BridgeToRemoteMaxEstimateResponseZod>
|
|
32
|
+
|
|
33
|
+
export const makeBridgeToRemoteMaxEstimateRoute = (config: BridgeConfig, gateway: XyoGatewayRunner): RouteDefinition => {
|
|
34
|
+
const params = z.object({ chainId: getRemoteChainIdZod(config) })
|
|
35
|
+
const validateRequest = requestHandlerValidator({
|
|
36
|
+
params, body: BridgeToRemoteMaxEstimateBodyZod, response: BridgeToRemoteMaxEstimateResponseZod,
|
|
37
|
+
})
|
|
38
|
+
return {
|
|
39
|
+
method: 'post',
|
|
40
|
+
path: '/bridge/chains/:chainId/bridgeToRemote/maxEstimate',
|
|
41
|
+
handlers: validateRequest(async (req, res) => {
|
|
42
|
+
const {
|
|
43
|
+
feeFixed, feeRateBasisPoints, maxBridgeAmount: configMax, xl1ChainId,
|
|
44
|
+
} = await getBridgeSettings(config)
|
|
45
|
+
const {
|
|
46
|
+
srcAddress, srcAmount: balance, destAddress,
|
|
47
|
+
} = req.body
|
|
48
|
+
|
|
49
|
+
const balanceMax = calculateMaxBridgeAmount(balance, { feeFixed, feeRateBasisPoints })
|
|
50
|
+
const maxBridgeAmount = toHex(hexToBigInt(balanceMax) < hexToBigInt(configMax) ? balanceMax : configMax)
|
|
51
|
+
|
|
52
|
+
const [bridgeIntent, transfer] = await generateBridgeEstimate(srcAddress, maxBridgeAmount, destAddress, config)
|
|
53
|
+
const sender = toAddress(srcAddress)
|
|
54
|
+
|
|
55
|
+
const viewer = assertEx(gateway.connection.viewer, () => new Error('Viewer not available on gateway connection'))
|
|
56
|
+
const currentBlockNumber = await viewer.currentBlockNumber()
|
|
57
|
+
const nbf = toXL1BlockNumber(currentBlockNumber, true)
|
|
58
|
+
const exp = toXL1BlockNumber(currentBlockNumber + 1000, true)
|
|
59
|
+
const [txBw] = await buildUnsignedTransaction(xl1ChainId, [transfer], [bridgeIntent], nbf, exp, sender)
|
|
60
|
+
|
|
61
|
+
res.json([txBw, bridgeIntent, transfer])
|
|
62
|
+
}),
|
|
63
|
+
}
|
|
64
|
+
}
|
|
@@ -13,7 +13,7 @@ export const calculateBridgeFees = (srcAmount: Hex, feeStructure: FeeStructure):
|
|
|
13
13
|
const srcAmountBigInt = hexToBigInt(srcAmount)
|
|
14
14
|
|
|
15
15
|
// Calculate fixed fee
|
|
16
|
-
const feeFixedBigInt = hexToBigInt(feeFixed)
|
|
16
|
+
// const feeFixedBigInt = hexToBigInt(feeFixed)
|
|
17
17
|
|
|
18
18
|
// Integer-safe basis point calculation (floor division)
|
|
19
19
|
const feeVariableBigInt
|
|
@@ -21,11 +21,11 @@ export const calculateBridgeFees = (srcAmount: Hex, feeStructure: FeeStructure):
|
|
|
21
21
|
const feeVariable = toHex(feeVariableBigInt)
|
|
22
22
|
|
|
23
23
|
// Calculate total fee
|
|
24
|
-
const feeTotalBigInt = feeFixedBigInt + feeVariableBigInt
|
|
24
|
+
// const feeTotalBigInt = feeFixedBigInt + feeVariableBigInt
|
|
25
25
|
|
|
26
26
|
// Calculate destination amount
|
|
27
|
-
const destAmountBigInt = srcAmountBigInt > feeTotalBigInt ? srcAmountBigInt - feeTotalBigInt : 0n
|
|
28
|
-
const destAmount = toHex(destAmountBigInt)
|
|
27
|
+
// const destAmountBigInt = srcAmountBigInt > feeTotalBigInt ? srcAmountBigInt - feeTotalBigInt : 0n
|
|
28
|
+
// const destAmount = toHex(destAmountBigInt)
|
|
29
29
|
|
|
30
30
|
return {
|
|
31
31
|
feeFixed, feeVariable, srcAmount,
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
import type { Hex } from '@xylabs/sdk-js'
|
|
2
|
+
import { hexToBigInt, toHex } from '@xylabs/sdk-js'
|
|
3
|
+
|
|
4
|
+
import type { FeeStructure } from './calculateBridgeFees.ts'
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Given a user's total available balance, calculates the maximum amount they can bridge
|
|
8
|
+
* after accounting for the fixed and variable bridge fees.
|
|
9
|
+
*
|
|
10
|
+
* Solving for M where: M + feeFixed + (M * basisPoints / 10_000) = balance
|
|
11
|
+
* => M = (balance - feeFixed) * 10_000 / (10_000 + basisPoints)
|
|
12
|
+
*/
|
|
13
|
+
export const calculateMaxBridgeAmount = (balance: Hex, feeStructure: FeeStructure): Hex => {
|
|
14
|
+
const { feeFixed, feeRateBasisPoints } = feeStructure
|
|
15
|
+
const balanceBigInt = hexToBigInt(balance)
|
|
16
|
+
const feeFixedBigInt = hexToBigInt(feeFixed)
|
|
17
|
+
|
|
18
|
+
if (balanceBigInt <= feeFixedBigInt) return toHex(0n)
|
|
19
|
+
|
|
20
|
+
const maxAmount = ((balanceBigInt - feeFixedBigInt) * 10_000n) / (10_000n + BigInt(feeRateBasisPoints))
|
|
21
|
+
return toHex(maxAmount)
|
|
22
|
+
}
|
package/src/util/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
export * from './BridgeFees.ts'
|
|
2
2
|
export * from './bridgeFeesAsBigInt.ts'
|
|
3
3
|
export * from './calculateBridgeFees.ts'
|
|
4
|
+
export * from './calculateMaxBridgeAmount.ts'
|
|
4
5
|
export * from './createBridgeTransfer.ts'
|
|
5
6
|
export * from './generateBridgeEstimate.ts'
|
|
6
7
|
export * from './getConfigFromEnv.ts'
|
|
@@ -1,8 +1,9 @@
|
|
|
1
|
-
import { isUndefined } from '@xylabs/sdk-js'
|
|
1
|
+
import { hexToBigInt, isUndefined } from '@xylabs/sdk-js'
|
|
2
2
|
import type { BridgeConfig } from '@xyo-network/chain-orchestration'
|
|
3
3
|
import { PayloadBuilder } from '@xyo-network/sdk-js'
|
|
4
4
|
import type { BridgeIntent, Transfer } from '@xyo-network/xl1-sdk'
|
|
5
5
|
|
|
6
|
+
import { getMaxBridgeAmount } from '../config/index.ts'
|
|
6
7
|
import { generateBridgeEstimate } from '../util/index.ts'
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -21,6 +22,10 @@ export const validateBridgeEstimateExact = async (
|
|
|
21
22
|
const {
|
|
22
23
|
srcAddress, srcAmount, destAddress,
|
|
23
24
|
} = intent
|
|
25
|
+
|
|
26
|
+
// Reject if the requested amount exceeds the configured maximum
|
|
27
|
+
if (hexToBigInt(srcAmount) > hexToBigInt(getMaxBridgeAmount(config))) return false
|
|
28
|
+
|
|
24
29
|
const [calculatedIntent, calculatedTransfer] = await generateBridgeEstimate(srcAddress, srcAmount, destAddress, config)
|
|
25
30
|
if (isUndefined(calculatedIntent) || isUndefined(calculatedTransfer)) return false
|
|
26
31
|
const { nonce: expectedIntentNonce, ...expectedIntentStatic } = calculatedIntent
|