@argent/x-shared 1.44.4 → 1.45.0

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.
@@ -1,2 +1,3 @@
1
1
  export * from './schema';
2
+ export * from './sessionKeys';
2
3
  export type * from './types';
@@ -0,0 +1 @@
1
+ export * from './schema';
@@ -0,0 +1 @@
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const e=require("zod"),n=require("../../chains/starknet/address.cjs"),a=e.z.object({tokenAddress:n.addressSchemaArgentBackend,currentAmount:e.z.number(),maximumAmount:e.z.number()}),t=e.z.object({contractAddress:n.addressSchemaArgentBackend,method:e.z.string()}),s=e.z.object({projectID:e.z.string(),projectSignature:e.z.unknown().optional()}),o=e.z.object({network:e.z.string(),accountAddress:n.addressSchemaArgentBackend,sessionKey:e.z.string(),expirationTime:e.z.number(),gasFees:e.z.unknown().optional(),txFees:e.z.array(a),allowedMethods:e.z.array(t),revoked:e.z.boolean(),createdTime:e.z.number(),type:e.z.string(),metadata:s});exports.backendSessionAllowedMethodSchema=t;exports.backendSessionMetadataSchema=s;exports.backendSessionSchema=o;exports.backendSessionTxFeeSchema=a;
@@ -0,0 +1,123 @@
1
+ import { z } from 'zod';
2
+ export declare const backendSessionTxFeeSchema: z.ZodObject<{
3
+ tokenAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
4
+ currentAmount: z.ZodNumber;
5
+ maximumAmount: z.ZodNumber;
6
+ }, "strip", z.ZodTypeAny, {
7
+ tokenAddress: `0x${string}`;
8
+ currentAmount: number;
9
+ maximumAmount: number;
10
+ }, {
11
+ tokenAddress: string;
12
+ currentAmount: number;
13
+ maximumAmount: number;
14
+ }>;
15
+ export declare const backendSessionAllowedMethodSchema: z.ZodObject<{
16
+ contractAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
17
+ method: z.ZodString;
18
+ }, "strip", z.ZodTypeAny, {
19
+ method: string;
20
+ contractAddress: `0x${string}`;
21
+ }, {
22
+ method: string;
23
+ contractAddress: string;
24
+ }>;
25
+ export declare const backendSessionMetadataSchema: z.ZodObject<{
26
+ projectID: z.ZodString;
27
+ projectSignature: z.ZodOptional<z.ZodUnknown>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ projectID: string;
30
+ projectSignature?: unknown;
31
+ }, {
32
+ projectID: string;
33
+ projectSignature?: unknown;
34
+ }>;
35
+ export declare const backendSessionSchema: z.ZodObject<{
36
+ network: z.ZodString; /** "SEPOLIA" */
37
+ accountAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
38
+ sessionKey: z.ZodString;
39
+ expirationTime: z.ZodNumber;
40
+ gasFees: z.ZodOptional<z.ZodUnknown>;
41
+ txFees: z.ZodArray<z.ZodObject<{
42
+ tokenAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
43
+ currentAmount: z.ZodNumber;
44
+ maximumAmount: z.ZodNumber;
45
+ }, "strip", z.ZodTypeAny, {
46
+ tokenAddress: `0x${string}`;
47
+ currentAmount: number;
48
+ maximumAmount: number;
49
+ }, {
50
+ tokenAddress: string;
51
+ currentAmount: number;
52
+ maximumAmount: number;
53
+ }>, "many">;
54
+ allowedMethods: z.ZodArray<z.ZodObject<{
55
+ contractAddress: z.ZodEffects<z.ZodString, `0x${string}`, string>;
56
+ method: z.ZodString;
57
+ }, "strip", z.ZodTypeAny, {
58
+ method: string;
59
+ contractAddress: `0x${string}`;
60
+ }, {
61
+ method: string;
62
+ contractAddress: string;
63
+ }>, "many">;
64
+ revoked: z.ZodBoolean;
65
+ createdTime: z.ZodNumber;
66
+ type: z.ZodString;
67
+ metadata: z.ZodObject<{
68
+ projectID: z.ZodString;
69
+ projectSignature: z.ZodOptional<z.ZodUnknown>;
70
+ }, "strip", z.ZodTypeAny, {
71
+ projectID: string;
72
+ projectSignature?: unknown;
73
+ }, {
74
+ projectID: string;
75
+ projectSignature?: unknown;
76
+ }>;
77
+ }, "strip", z.ZodTypeAny, {
78
+ type: string;
79
+ accountAddress: `0x${string}`;
80
+ network: string;
81
+ sessionKey: string;
82
+ expirationTime: number;
83
+ txFees: {
84
+ tokenAddress: `0x${string}`;
85
+ currentAmount: number;
86
+ maximumAmount: number;
87
+ }[];
88
+ allowedMethods: {
89
+ method: string;
90
+ contractAddress: `0x${string}`;
91
+ }[];
92
+ revoked: boolean;
93
+ createdTime: number;
94
+ metadata: {
95
+ projectID: string;
96
+ projectSignature?: unknown;
97
+ };
98
+ gasFees?: unknown;
99
+ }, {
100
+ type: string;
101
+ accountAddress: string;
102
+ network: string;
103
+ sessionKey: string;
104
+ expirationTime: number;
105
+ txFees: {
106
+ tokenAddress: string;
107
+ currentAmount: number;
108
+ maximumAmount: number;
109
+ }[];
110
+ allowedMethods: {
111
+ method: string;
112
+ contractAddress: string;
113
+ }[];
114
+ revoked: boolean;
115
+ createdTime: number;
116
+ metadata: {
117
+ projectID: string;
118
+ projectSignature?: unknown;
119
+ };
120
+ gasFees?: unknown;
121
+ }>;
122
+ export type BackendSessionTxFee = z.infer<typeof backendSessionTxFeeSchema>;
123
+ export type BackendSession = z.infer<typeof backendSessionSchema>;
@@ -0,0 +1,31 @@
1
+ import { z as e } from "zod";
2
+ import { addressSchemaArgentBackend as n } from "../../chains/starknet/address.js";
3
+ const o = e.object({
4
+ tokenAddress: n,
5
+ currentAmount: e.number(),
6
+ maximumAmount: e.number()
7
+ }), t = e.object({
8
+ contractAddress: n,
9
+ method: e.string()
10
+ }), r = e.object({
11
+ projectID: e.string(),
12
+ projectSignature: e.unknown().optional()
13
+ }), c = e.object({
14
+ network: e.string(),
15
+ accountAddress: n,
16
+ sessionKey: e.string(),
17
+ expirationTime: e.number(),
18
+ gasFees: e.unknown().optional(),
19
+ txFees: e.array(o),
20
+ allowedMethods: e.array(t),
21
+ revoked: e.boolean(),
22
+ createdTime: e.number(),
23
+ type: e.string(),
24
+ metadata: r
25
+ });
26
+ export {
27
+ t as backendSessionAllowedMethodSchema,
28
+ r as backendSessionMetadataSchema,
29
+ c as backendSessionSchema,
30
+ o as backendSessionTxFeeSchema
31
+ };
@@ -3791,6 +3791,7 @@ export declare const activitySchema: z.ZodObject<{
3791
3791
  status: "pending" | "success" | "failure";
3792
3792
  type: "staking" | "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
3793
3793
  wallet: `0x${string}`;
3794
+ network: string;
3794
3795
  id: string;
3795
3796
  group: "security" | "finance";
3796
3797
  details: {
@@ -4000,7 +4001,6 @@ export declare const activitySchema: z.ZodObject<{
4000
4001
  counterParty?: `0x${string}` | undefined;
4001
4002
  counterPartyNetwork?: "ethereum" | "zksync" | "zksync2" | "starknet" | undefined;
4002
4003
  }[];
4003
- network: string;
4004
4004
  compositeId: string;
4005
4005
  txSender: `0x${string}`;
4006
4006
  source: string;
@@ -4189,6 +4189,7 @@ export declare const activitySchema: z.ZodObject<{
4189
4189
  status: "pending" | "success" | "failure";
4190
4190
  type: "staking" | "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
4191
4191
  wallet: string;
4192
+ network: string;
4192
4193
  id: string;
4193
4194
  group: "security" | "finance";
4194
4195
  details: {
@@ -4398,7 +4399,6 @@ export declare const activitySchema: z.ZodObject<{
4398
4399
  counterParty?: string | undefined;
4399
4400
  counterPartyNetwork?: "ethereum" | "zksync" | "zksync2" | "starknet" | undefined;
4400
4401
  }[];
4401
- network: string;
4402
4402
  compositeId: string;
4403
4403
  txSender: string;
4404
4404
  source: string;
@@ -4611,21 +4611,21 @@ export declare const nativeActivityMetaSchema: z.ZodObject<{
4611
4611
  amount: z.ZodString;
4612
4612
  }, "strip", z.ZodTypeAny, {
4613
4613
  amount: string;
4614
+ tokenAddress: `0x${string}`;
4614
4615
  stakerInfo: {
4615
4616
  address: string;
4616
4617
  name?: string | undefined;
4617
4618
  iconUrl?: string | undefined;
4618
4619
  };
4619
- tokenAddress: `0x${string}`;
4620
4620
  stakingAction: "stake" | "initiateWithdraw" | "withdraw" | "claim";
4621
4621
  }, {
4622
4622
  amount: string;
4623
+ tokenAddress: string;
4623
4624
  stakerInfo: {
4624
4625
  address: string;
4625
4626
  name?: string | undefined;
4626
4627
  iconUrl?: string | undefined;
4627
4628
  };
4628
- tokenAddress: string;
4629
4629
  stakingAction: "stake" | "initiateWithdraw" | "withdraw" | "claim";
4630
4630
  }>>;
4631
4631
  }, "strip", z.ZodTypeAny, {
@@ -4635,12 +4635,12 @@ export declare const nativeActivityMetaSchema: z.ZodObject<{
4635
4635
  subtitle?: string | undefined;
4636
4636
  investment?: {
4637
4637
  amount: string;
4638
+ tokenAddress: `0x${string}`;
4638
4639
  stakerInfo: {
4639
4640
  address: string;
4640
4641
  name?: string | undefined;
4641
4642
  iconUrl?: string | undefined;
4642
4643
  };
4643
- tokenAddress: `0x${string}`;
4644
4644
  stakingAction: "stake" | "initiateWithdraw" | "withdraw" | "claim";
4645
4645
  } | undefined;
4646
4646
  }, {
@@ -4650,12 +4650,12 @@ export declare const nativeActivityMetaSchema: z.ZodObject<{
4650
4650
  subtitle?: string | undefined;
4651
4651
  investment?: {
4652
4652
  amount: string;
4653
+ tokenAddress: string;
4653
4654
  stakerInfo: {
4654
4655
  address: string;
4655
4656
  name?: string | undefined;
4656
4657
  iconUrl?: string | undefined;
4657
4658
  };
4658
- tokenAddress: string;
4659
4659
  stakingAction: "stake" | "initiateWithdraw" | "withdraw" | "claim";
4660
4660
  } | undefined;
4661
4661
  }>;
@@ -7013,21 +7013,21 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7013
7013
  amount: z.ZodString;
7014
7014
  }, "strip", z.ZodTypeAny, {
7015
7015
  amount: string;
7016
+ tokenAddress: `0x${string}`;
7016
7017
  stakerInfo: {
7017
7018
  address: string;
7018
7019
  name?: string | undefined;
7019
7020
  iconUrl?: string | undefined;
7020
7021
  };
7021
- tokenAddress: `0x${string}`;
7022
7022
  stakingAction: "stake" | "initiateWithdraw" | "withdraw" | "claim";
7023
7023
  }, {
7024
7024
  amount: string;
7025
+ tokenAddress: string;
7025
7026
  stakerInfo: {
7026
7027
  address: string;
7027
7028
  name?: string | undefined;
7028
7029
  iconUrl?: string | undefined;
7029
7030
  };
7030
- tokenAddress: string;
7031
7031
  stakingAction: "stake" | "initiateWithdraw" | "withdraw" | "claim";
7032
7032
  }>>;
7033
7033
  }, "strip", z.ZodTypeAny, {
@@ -7037,12 +7037,12 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7037
7037
  subtitle?: string | undefined;
7038
7038
  investment?: {
7039
7039
  amount: string;
7040
+ tokenAddress: `0x${string}`;
7040
7041
  stakerInfo: {
7041
7042
  address: string;
7042
7043
  name?: string | undefined;
7043
7044
  iconUrl?: string | undefined;
7044
7045
  };
7045
- tokenAddress: `0x${string}`;
7046
7046
  stakingAction: "stake" | "initiateWithdraw" | "withdraw" | "claim";
7047
7047
  } | undefined;
7048
7048
  }, {
@@ -7052,12 +7052,12 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7052
7052
  subtitle?: string | undefined;
7053
7053
  investment?: {
7054
7054
  amount: string;
7055
+ tokenAddress: string;
7055
7056
  stakerInfo: {
7056
7057
  address: string;
7057
7058
  name?: string | undefined;
7058
7059
  iconUrl?: string | undefined;
7059
7060
  };
7060
- tokenAddress: string;
7061
7061
  stakingAction: "stake" | "initiateWithdraw" | "withdraw" | "claim";
7062
7062
  } | undefined;
7063
7063
  }>>;
@@ -7246,12 +7246,12 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7246
7246
  subtitle?: string | undefined;
7247
7247
  investment?: {
7248
7248
  amount: string;
7249
+ tokenAddress: `0x${string}`;
7249
7250
  stakerInfo: {
7250
7251
  address: string;
7251
7252
  name?: string | undefined;
7252
7253
  iconUrl?: string | undefined;
7253
7254
  };
7254
- tokenAddress: `0x${string}`;
7255
7255
  stakingAction: "stake" | "initiateWithdraw" | "withdraw" | "claim";
7256
7256
  } | undefined;
7257
7257
  } | undefined;
@@ -7440,12 +7440,12 @@ export declare const nativeActivitySchema: z.ZodObject<z.objectUtil.extendShape<
7440
7440
  subtitle?: string | undefined;
7441
7441
  investment?: {
7442
7442
  amount: string;
7443
+ tokenAddress: string;
7443
7444
  stakerInfo: {
7444
7445
  address: string;
7445
7446
  name?: string | undefined;
7446
7447
  iconUrl?: string | undefined;
7447
7448
  };
7448
- tokenAddress: string;
7449
7449
  stakingAction: "stake" | "initiateWithdraw" | "withdraw" | "claim";
7450
7450
  } | undefined;
7451
7451
  } | undefined;
@@ -9724,6 +9724,7 @@ export declare const activitiesSchema: z.ZodArray<z.ZodObject<{
9724
9724
  status: "pending" | "success" | "failure";
9725
9725
  type: "staking" | "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
9726
9726
  wallet: `0x${string}`;
9727
+ network: string;
9727
9728
  id: string;
9728
9729
  group: "security" | "finance";
9729
9730
  details: {
@@ -9933,7 +9934,6 @@ export declare const activitiesSchema: z.ZodArray<z.ZodObject<{
9933
9934
  counterParty?: `0x${string}` | undefined;
9934
9935
  counterPartyNetwork?: "ethereum" | "zksync" | "zksync2" | "starknet" | undefined;
9935
9936
  }[];
9936
- network: string;
9937
9937
  compositeId: string;
9938
9938
  txSender: `0x${string}`;
9939
9939
  source: string;
@@ -10122,6 +10122,7 @@ export declare const activitiesSchema: z.ZodArray<z.ZodObject<{
10122
10122
  status: "pending" | "success" | "failure";
10123
10123
  type: "staking" | "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
10124
10124
  wallet: string;
10125
+ network: string;
10125
10126
  id: string;
10126
10127
  group: "security" | "finance";
10127
10128
  details: {
@@ -10331,7 +10332,6 @@ export declare const activitiesSchema: z.ZodArray<z.ZodObject<{
10331
10332
  counterParty?: string | undefined;
10332
10333
  counterPartyNetwork?: "ethereum" | "zksync" | "zksync2" | "starknet" | undefined;
10333
10334
  }[];
10334
- network: string;
10335
10335
  compositeId: string;
10336
10336
  txSender: string;
10337
10337
  source: string;
@@ -12790,6 +12790,7 @@ export declare const activityResponseSchema: z.ZodObject<{
12790
12790
  status: "pending" | "success" | "failure";
12791
12791
  type: "staking" | "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
12792
12792
  wallet: `0x${string}`;
12793
+ network: string;
12793
12794
  id: string;
12794
12795
  group: "security" | "finance";
12795
12796
  details: {
@@ -12999,7 +13000,6 @@ export declare const activityResponseSchema: z.ZodObject<{
12999
13000
  counterParty?: `0x${string}` | undefined;
13000
13001
  counterPartyNetwork?: "ethereum" | "zksync" | "zksync2" | "starknet" | undefined;
13001
13002
  }[];
13002
- network: string;
13003
13003
  compositeId: string;
13004
13004
  txSender: `0x${string}`;
13005
13005
  source: string;
@@ -13188,6 +13188,7 @@ export declare const activityResponseSchema: z.ZodObject<{
13188
13188
  status: "pending" | "success" | "failure";
13189
13189
  type: "staking" | "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
13190
13190
  wallet: string;
13191
+ network: string;
13191
13192
  id: string;
13192
13193
  group: "security" | "finance";
13193
13194
  details: {
@@ -13397,7 +13398,6 @@ export declare const activityResponseSchema: z.ZodObject<{
13397
13398
  counterParty?: string | undefined;
13398
13399
  counterPartyNetwork?: "ethereum" | "zksync" | "zksync2" | "starknet" | undefined;
13399
13400
  }[];
13400
- network: string;
13401
13401
  compositeId: string;
13402
13402
  txSender: string;
13403
13403
  source: string;
@@ -13594,6 +13594,7 @@ export declare const activityResponseSchema: z.ZodObject<{
13594
13594
  status: "pending" | "success" | "failure";
13595
13595
  type: "staking" | "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
13596
13596
  wallet: `0x${string}`;
13597
+ network: string;
13597
13598
  id: string;
13598
13599
  group: "security" | "finance";
13599
13600
  details: {
@@ -13803,7 +13804,6 @@ export declare const activityResponseSchema: z.ZodObject<{
13803
13804
  counterParty?: `0x${string}` | undefined;
13804
13805
  counterPartyNetwork?: "ethereum" | "zksync" | "zksync2" | "starknet" | undefined;
13805
13806
  }[];
13806
- network: string;
13807
13807
  compositeId: string;
13808
13808
  txSender: `0x${string}`;
13809
13809
  source: string;
@@ -13998,6 +13998,7 @@ export declare const activityResponseSchema: z.ZodObject<{
13998
13998
  status: "pending" | "success" | "failure";
13999
13999
  type: "staking" | "payment" | "approval" | "changePubKey" | "dappInteraction" | "deploy" | "gift" | "multicall" | "security" | "trade";
14000
14000
  wallet: string;
14001
+ network: string;
14001
14002
  id: string;
14002
14003
  group: "security" | "finance";
14003
14004
  details: {
@@ -14207,7 +14208,6 @@ export declare const activityResponseSchema: z.ZodObject<{
14207
14208
  counterParty?: string | undefined;
14208
14209
  counterPartyNetwork?: "ethereum" | "zksync" | "zksync2" | "starknet" | undefined;
14209
14210
  }[];
14210
- network: string;
14211
14211
  compositeId: string;
14212
14212
  txSender: string;
14213
14213
  source: string;
@@ -1 +1 @@
1
- "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("url-join"),a=require("../../../errors/swap.cjs"),p=require("../../../utils/url/urlWithQuery.cjs"),l=require("../models/quote.model.cjs"),S=require("../utils/totalFee.cjs"),d=require("../models/trade.model.cjs"),i=require("../models/order.model.cjs");class y{constructor(e,r){if(this.httpService=e,!r)throw new a.SwapError({code:"NO_SWAP_URL"});this.swapQuoteUrl=u(r,"/quote"),this.swapOrderUrl=u(r,"/order")}async getSwapQuoteForPay(e,r,o,n,t="USD"){const s=p.urlWithQuery(this.swapQuoteUrl,{accountAddress:n,currency:t,chain:"starknet",sellToken:e,buyToken:r,sellAmount:o});try{const c=await this.httpService.get(s);return await l.SwapQuoteResponseSchema.parseAsync(c)}catch(c){throw console.error(c),new a.SwapError({code:"INVALID_QUOTE_RESPONSE"})}}async getSwapTradeFromQuote(e,r,o){if(!r||!o)throw new a.SwapError({code:"INVALID_SWAP_TOKENS"});const{totalFee:n,totalFeeInCurrency:t,totalFeePercentage:s}=S.calculateTotalFee(e);return d.TradeSchema.parse({payToken:r,receiveToken:o,payAmount:e.sellAmount,receiveAmount:e.buyAmount,payAmountInCurrency:e.sellAmountInCurrency,receiveAmountInCurrency:e.buyAmountInCurrency,totalFee:n,totalFeeInCurrency:t,totalFeePercentage:s,expiresAt:e.expiresAt,expiresIn:e.expiresIn,route:e.routes[0],data:e.data})}async getSwapOrderFromTrade(e,r,o){const n=i.SwapOrderRequestSchema.parse({chain:"starknet",sellToken:r.payToken.address,buyToken:r.receiveToken.address,sellAmount:r.payAmount,buyAmount:r.receiveAmount,accountAddress:e,slippage:o/1e4,data:r.data});try{const t=await this.httpService.post(this.swapOrderUrl,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"}});return await i.SwapOrderResponseSchema.parseAsync(t)}catch(t){throw console.error(t),new a.SwapError({code:"INVALID_SWAP_ORDER_RESPONSE"})}}}exports.SharedSwapService=y;
1
+ "use strict";Object.defineProperty(exports,Symbol.toStringTag,{value:"Module"});const u=require("url-join"),a=require("../../../errors/swap.cjs"),p=require("../models/quote.model.cjs"),l=require("../utils/totalFee.cjs"),S=require("../models/trade.model.cjs"),i=require("../models/order.model.cjs"),d=require("../../../utils/url/urlWithQuery.cjs");class y{constructor(e,r){if(this.httpService=e,!r)throw new a.SwapError({code:"NO_SWAP_URL"});this.swapQuoteUrl=u(r,"/quote"),this.swapOrderUrl=u(r,"/order")}async getSwapQuoteForPay(e,r,o,n,t="USD"){const s=d.urlWithQuery(this.swapQuoteUrl,{accountAddress:n,currency:t,chain:"starknet",sellToken:e,buyToken:r,sellAmount:o});try{const c=await this.httpService.get(s);return await p.SwapQuoteResponseSchema.parseAsync(c)}catch(c){throw console.error(c),new a.SwapError({code:"INVALID_QUOTE_RESPONSE"})}}async getSwapTradeFromQuote(e,r,o){if(!r||!o)throw new a.SwapError({code:"INVALID_SWAP_TOKENS"});const{totalFee:n,totalFeeInCurrency:t,totalFeePercentage:s}=l.calculateTotalFee(e);return S.TradeSchema.parse({payToken:r,receiveToken:o,payAmount:e.sellAmount,receiveAmount:e.buyAmount,payAmountInCurrency:e.sellAmountInCurrency,receiveAmountInCurrency:e.buyAmountInCurrency,totalFee:n,totalFeeInCurrency:t,totalFeePercentage:s,expiresAt:e.expiresAt,expiresIn:e.expiresIn,route:e.routes[0],data:e.data})}async getSwapOrderFromTrade(e,r,o){const n=i.SwapOrderRequestSchema.parse({chain:"starknet",sellToken:r.payToken.address,buyToken:r.receiveToken.address,sellAmount:r.payAmount,buyAmount:r.receiveAmount,accountAddress:e,slippage:o/1e4,data:r.data});try{const t=await this.httpService.post(this.swapOrderUrl,{body:JSON.stringify(n),headers:{"Content-Type":"application/json"}});return await i.SwapOrderResponseSchema.parseAsync(t)}catch(t){throw console.error(t),new a.SwapError({code:"INVALID_SWAP_ORDER_RESPONSE"})}}}exports.SharedSwapService=y;
@@ -1,10 +1,10 @@
1
1
  import p from "url-join";
2
2
  import { SwapError as a } from "../../../errors/swap.js";
3
- import { urlWithQuery as i } from "../../../utils/url/urlWithQuery.js";
4
- import { SwapQuoteResponseSchema as u } from "../models/quote.model.js";
5
- import { calculateTotalFee as m } from "../utils/totalFee.js";
6
- import { TradeSchema as l } from "../models/trade.model.js";
7
- import { SwapOrderRequestSchema as S, SwapOrderResponseSchema as y } from "../models/order.model.js";
3
+ import { SwapQuoteResponseSchema as i } from "../models/quote.model.js";
4
+ import { calculateTotalFee as u } from "../utils/totalFee.js";
5
+ import { TradeSchema as m } from "../models/trade.model.js";
6
+ import { SwapOrderRequestSchema as l, SwapOrderResponseSchema as S } from "../models/order.model.js";
7
+ import { urlWithQuery as y } from "../../../utils/url/urlWithQuery.js";
8
8
  class _ {
9
9
  constructor(e, r) {
10
10
  if (this.httpService = e, !r)
@@ -12,7 +12,7 @@ class _ {
12
12
  this.swapQuoteUrl = p(r, "/quote"), this.swapOrderUrl = p(r, "/order");
13
13
  }
14
14
  async getSwapQuoteForPay(e, r, o, n, t = "USD") {
15
- const s = i(this.swapQuoteUrl, {
15
+ const s = y(this.swapQuoteUrl, {
16
16
  accountAddress: n,
17
17
  currency: t,
18
18
  chain: "starknet",
@@ -22,7 +22,7 @@ class _ {
22
22
  });
23
23
  try {
24
24
  const c = await this.httpService.get(s);
25
- return await u.parseAsync(c);
25
+ return await i.parseAsync(c);
26
26
  } catch (c) {
27
27
  throw console.error(c), new a({ code: "INVALID_QUOTE_RESPONSE" });
28
28
  }
@@ -30,8 +30,8 @@ class _ {
30
30
  async getSwapTradeFromQuote(e, r, o) {
31
31
  if (!r || !o)
32
32
  throw new a({ code: "INVALID_SWAP_TOKENS" });
33
- const { totalFee: n, totalFeeInCurrency: t, totalFeePercentage: s } = m(e);
34
- return l.parse({
33
+ const { totalFee: n, totalFeeInCurrency: t, totalFeePercentage: s } = u(e);
34
+ return m.parse({
35
35
  payToken: r,
36
36
  receiveToken: o,
37
37
  payAmount: e.sellAmount,
@@ -48,7 +48,7 @@ class _ {
48
48
  });
49
49
  }
50
50
  async getSwapOrderFromTrade(e, r, o) {
51
- const n = S.parse({
51
+ const n = l.parse({
52
52
  chain: "starknet",
53
53
  sellToken: r.payToken.address,
54
54
  buyToken: r.receiveToken.address,
@@ -65,7 +65,7 @@ class _ {
65
65
  "Content-Type": "application/json"
66
66
  }
67
67
  });
68
- return await y.parseAsync(t);
68
+ return await S.parseAsync(t);
69
69
  } catch (t) {
70
70
  throw console.error(t), new a({ code: "INVALID_SWAP_ORDER_RESPONSE" });
71
71
  }
@@ -2551,23 +2551,23 @@ export declare const strkStakingCalldataSchema: z.ZodObject<{
2551
2551
  }, "strip", z.ZodTypeAny, {
2552
2552
  amount: string;
2553
2553
  accountAddress: `0x${string}`;
2554
+ tokenAddress: `0x${string}`;
2554
2555
  stakerInfo: {
2555
2556
  address: string;
2556
2557
  name?: string | undefined;
2557
2558
  iconUrl?: string | undefined;
2558
2559
  };
2559
2560
  investmentId: string;
2560
- tokenAddress: `0x${string}`;
2561
2561
  }, {
2562
2562
  amount: string;
2563
2563
  accountAddress: string;
2564
+ tokenAddress: string;
2564
2565
  stakerInfo: {
2565
2566
  address: string;
2566
2567
  name?: string | undefined;
2567
2568
  iconUrl?: string | undefined;
2568
2569
  };
2569
2570
  investmentId: string;
2570
- tokenAddress: string;
2571
2571
  }>;
2572
2572
  export type StrkStakingCalldata = z.infer<typeof strkStakingCalldataSchema>;
2573
2573
  export declare const stakingActionSchema: z.ZodEnum<["stake", "initiateWithdraw", "withdraw", "claim"]>;
@@ -2590,21 +2590,21 @@ export declare const investmentMetaSchema: z.ZodObject<{
2590
2590
  amount: z.ZodString;
2591
2591
  }, "strip", z.ZodTypeAny, {
2592
2592
  amount: string;
2593
+ tokenAddress: `0x${string}`;
2593
2594
  stakerInfo: {
2594
2595
  address: string;
2595
2596
  name?: string | undefined;
2596
2597
  iconUrl?: string | undefined;
2597
2598
  };
2598
- tokenAddress: `0x${string}`;
2599
2599
  stakingAction: "stake" | "initiateWithdraw" | "withdraw" | "claim";
2600
2600
  }, {
2601
2601
  amount: string;
2602
+ tokenAddress: string;
2602
2603
  stakerInfo: {
2603
2604
  address: string;
2604
2605
  name?: string | undefined;
2605
2606
  iconUrl?: string | undefined;
2606
2607
  };
2607
- tokenAddress: string;
2608
2608
  stakingAction: "stake" | "initiateWithdraw" | "withdraw" | "claim";
2609
2609
  }>;
2610
2610
  export type InvestmentMeta = z.infer<typeof investmentMetaSchema>;
@@ -159,8 +159,8 @@ export declare class TokenServiceWeb implements ITokenServiceWeb {
159
159
  id: string;
160
160
  totalBalances: Record<string, string>;
161
161
  tokenId: string;
162
- investmentId?: string | undefined;
163
162
  tokenAddress?: `0x${string}` | undefined;
163
+ investmentId?: string | undefined;
164
164
  }, {
165
165
  data: {
166
166
  poolFeePercentage: string;
@@ -185,8 +185,8 @@ export declare class TokenServiceWeb implements ITokenServiceWeb {
185
185
  id: string;
186
186
  totalBalances: Record<string, string>;
187
187
  tokenId: string;
188
- investmentId?: string | undefined;
189
188
  tokenAddress?: string | undefined;
189
+ investmentId?: string | undefined;
190
190
  }>, import('zod').ZodObject<import("zod").objectUtil.extendShape<{
191
191
  id: import('zod').ZodString;
192
192
  investmentId: import('zod').ZodOptional<import('zod').ZodString>;
@@ -222,8 +222,8 @@ export declare class TokenServiceWeb implements ITokenServiceWeb {
222
222
  };
223
223
  id: string;
224
224
  totalBalances: Record<string, string>;
225
- investmentId?: string | undefined;
226
225
  tokenAddress?: `0x${string}` | undefined;
226
+ investmentId?: string | undefined;
227
227
  }, {
228
228
  data: {
229
229
  lending: boolean;
@@ -234,8 +234,8 @@ export declare class TokenServiceWeb implements ITokenServiceWeb {
234
234
  };
235
235
  id: string;
236
236
  totalBalances: Record<string, string>;
237
- investmentId?: string | undefined;
238
237
  tokenAddress?: string | undefined;
238
+ investmentId?: string | undefined;
239
239
  }>]>, import('zod').ZodObject<import("zod").objectUtil.extendShape<{
240
240
  id: import('zod').ZodString;
241
241
  investmentId: import('zod').ZodOptional<import('zod').ZodString>;
@@ -257,16 +257,16 @@ export declare class TokenServiceWeb implements ITokenServiceWeb {
257
257
  };
258
258
  id: string;
259
259
  totalBalances: Record<string, string>;
260
- investmentId?: string | undefined;
261
260
  tokenAddress?: `0x${string}` | undefined;
261
+ investmentId?: string | undefined;
262
262
  }, {
263
263
  data: {
264
264
  delegatingTo: string;
265
265
  };
266
266
  id: string;
267
267
  totalBalances: Record<string, string>;
268
- investmentId?: string | undefined;
269
268
  tokenAddress?: string | undefined;
269
+ investmentId?: string | undefined;
270
270
  }>]>, import('zod').ZodObject<import("zod").objectUtil.extendShape<{
271
271
  id: import('zod').ZodString;
272
272
  investmentId: import('zod').ZodOptional<import('zod').ZodString>;
@@ -288,16 +288,16 @@ export declare class TokenServiceWeb implements ITokenServiceWeb {
288
288
  };
289
289
  id: string;
290
290
  totalBalances: Record<string, string>;
291
- investmentId?: string | undefined;
292
291
  tokenAddress?: `0x${string}` | undefined;
292
+ investmentId?: string | undefined;
293
293
  }, {
294
294
  data: {
295
295
  apy: string;
296
296
  };
297
297
  id: string;
298
298
  totalBalances: Record<string, string>;
299
- investmentId?: string | undefined;
300
299
  tokenAddress?: string | undefined;
300
+ investmentId?: string | undefined;
301
301
  }>]>, import('zod').ZodObject<import("zod").objectUtil.extendShape<{
302
302
  id: import('zod').ZodString;
303
303
  investmentId: import('zod').ZodOptional<import('zod').ZodString>;