@pendle/sdk-boros 1.0.11-strategies → 1.0.12-cross-deposit-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.
Files changed (107) hide show
  1. package/dist/addresses.d.ts +11 -1
  2. package/dist/addresses.js +23 -1
  3. package/dist/addresses.js.map +1 -1
  4. package/dist/backend/secrettune/BorosCoreSDK.d.ts +165 -21
  5. package/dist/backend/secrettune/BorosCoreSDK.js +72 -6
  6. package/dist/backend/secrettune/BorosCoreSDK.js.map +1 -1
  7. package/dist/backend/secrettune/BorosSendTxsBotSDK.d.ts +4 -3
  8. package/dist/backend/secrettune/BorosSendTxsBotSDK.js.map +1 -1
  9. package/dist/backend/secrettune/PendleV2SDK.d.ts +2281 -0
  10. package/dist/backend/secrettune/PendleV2SDK.js +970 -0
  11. package/dist/backend/secrettune/PendleV2SDK.js.map +1 -0
  12. package/dist/backend/secrettune/module.d.ts +6 -0
  13. package/dist/backend/secrettune/module.js +25 -0
  14. package/dist/backend/secrettune/module.js.map +1 -1
  15. package/dist/common/chainId.d.ts +12 -0
  16. package/dist/common/chainId.js +17 -0
  17. package/dist/common/chainId.js.map +1 -0
  18. package/dist/contracts/abis/viemAbiDepositBoxFactory.d.ts +75 -0
  19. package/dist/contracts/abis/viemAbiDepositBoxFactory.js +103 -0
  20. package/dist/contracts/abis/viemAbiDepositBoxFactory.js.map +1 -0
  21. package/dist/contracts/abis/viemAbiRouter.d.ts +1983 -0
  22. package/dist/contracts/abis/viemAbiRouter.js +2549 -0
  23. package/dist/contracts/abis/viemAbiRouter.js.map +1 -0
  24. package/dist/contracts/contracts.factory.d.ts +8 -2
  25. package/dist/contracts/contracts.factory.js +16 -4
  26. package/dist/contracts/contracts.factory.js.map +1 -1
  27. package/dist/contracts/deposit-box-factory.d.ts +86 -0
  28. package/dist/contracts/deposit-box-factory.js +16 -0
  29. package/dist/contracts/deposit-box-factory.js.map +1 -0
  30. package/dist/contracts/erc20.d.ts +158 -0
  31. package/dist/contracts/erc20.js +52 -0
  32. package/dist/contracts/erc20.js.map +1 -0
  33. package/dist/contracts/router.d.ts +1987 -0
  34. package/dist/contracts/router.js +12 -0
  35. package/dist/contracts/router.js.map +1 -0
  36. package/dist/entities/crossChainDeposit/AggregatorHelper.d.ts +109 -0
  37. package/dist/entities/crossChainDeposit/AggregatorHelper.js +26 -0
  38. package/dist/entities/crossChainDeposit/AggregatorHelper.js.map +1 -0
  39. package/dist/entities/crossChainDeposit/AggregatorHelperErrors.d.ts +80 -0
  40. package/dist/entities/crossChainDeposit/AggregatorHelperErrors.js +116 -0
  41. package/dist/entities/crossChainDeposit/AggregatorHelperErrors.js.map +1 -0
  42. package/dist/entities/crossChainDeposit/Depositor.d.ts +31 -0
  43. package/dist/entities/crossChainDeposit/Depositor.js +64 -0
  44. package/dist/entities/crossChainDeposit/Depositor.js.map +1 -0
  45. package/dist/entities/crossChainDeposit/aggregators/Boros/index.d.ts +36 -0
  46. package/dist/entities/crossChainDeposit/aggregators/Boros/index.js +191 -0
  47. package/dist/entities/crossChainDeposit/aggregators/Boros/index.js.map +1 -0
  48. package/dist/entities/crossChainDeposit/aggregators/Boros/types.d.ts +10 -0
  49. package/dist/entities/crossChainDeposit/aggregators/Boros/types.js.map +1 -0
  50. package/dist/entities/crossChainDeposit/aggregators/Lifi/index.d.ts +39 -0
  51. package/dist/entities/crossChainDeposit/aggregators/Lifi/index.js +159 -0
  52. package/dist/entities/crossChainDeposit/aggregators/Lifi/index.js.map +1 -0
  53. package/dist/entities/crossChainDeposit/aggregators/Lifi/types.d.ts +186 -0
  54. package/dist/entities/crossChainDeposit/aggregators/Lifi/types.js +28 -0
  55. package/dist/entities/crossChainDeposit/aggregators/Lifi/types.js.map +1 -0
  56. package/dist/entities/crossChainDeposit/aggregators/Pendle/index.d.ts +38 -0
  57. package/dist/entities/crossChainDeposit/aggregators/Pendle/index.js +171 -0
  58. package/dist/entities/crossChainDeposit/aggregators/Pendle/index.js.map +1 -0
  59. package/dist/entities/crossChainDeposit/helpers/TokenHelper.d.ts +23 -0
  60. package/dist/entities/crossChainDeposit/helpers/TokenHelper.js +67 -0
  61. package/dist/entities/crossChainDeposit/helpers/TokenHelper.js.map +1 -0
  62. package/dist/entities/crossChainDeposit/helpers/utils.d.ts +4 -0
  63. package/dist/entities/crossChainDeposit/helpers/utils.js +25 -0
  64. package/dist/entities/crossChainDeposit/helpers/utils.js.map +1 -0
  65. package/dist/entities/crossChainDeposit/index.d.ts +2 -0
  66. package/dist/entities/{Calculator → crossChainDeposit}/index.js +2 -6
  67. package/dist/entities/crossChainDeposit/index.js.map +1 -0
  68. package/dist/entities/index.d.ts +2 -1
  69. package/dist/entities/index.js +2 -1
  70. package/dist/entities/index.js.map +1 -1
  71. package/dist/entities/token/Token.d.ts +31 -0
  72. package/dist/entities/token/Token.js +61 -0
  73. package/dist/entities/token/Token.js.map +1 -0
  74. package/dist/entities/token/index.d.ts +1 -0
  75. package/dist/entities/token/index.js +18 -0
  76. package/dist/entities/token/index.js.map +1 -0
  77. package/dist/errors/PendleSdkError.d.ts +7 -0
  78. package/dist/errors/PendleSdkError.js +15 -0
  79. package/dist/errors/PendleSdkError.js.map +1 -0
  80. package/dist/types/common.d.ts +16 -0
  81. package/dist/utils/signing/index.d.ts +1 -1
  82. package/dist/utils/signing/index.js +2 -1
  83. package/dist/utils/signing/index.js.map +1 -1
  84. package/dist/utils/signing/sensitive.d.ts +2 -1
  85. package/dist/utils/signing/sensitive.js +29 -0
  86. package/dist/utils/signing/sensitive.js.map +1 -1
  87. package/package.json +1 -1
  88. package/dist/entities/Calculator/exchangeFees.d.ts +0 -47
  89. package/dist/entities/Calculator/exchangeFees.js +0 -93
  90. package/dist/entities/Calculator/exchangeFees.js.map +0 -1
  91. package/dist/entities/Calculator/index.d.ts +0 -6
  92. package/dist/entities/Calculator/index.js.map +0 -1
  93. package/dist/entities/Calculator/marginCalculator.d.ts +0 -10
  94. package/dist/entities/Calculator/marginCalculator.js +0 -67
  95. package/dist/entities/Calculator/marginCalculator.js.map +0 -1
  96. package/dist/entities/Calculator/strategyApr.d.ts +0 -30
  97. package/dist/entities/Calculator/strategyApr.js +0 -94
  98. package/dist/entities/Calculator/strategyApr.js.map +0 -1
  99. package/dist/entities/Calculator/strategyExecution.d.ts +0 -28
  100. package/dist/entities/Calculator/strategyExecution.js +0 -130
  101. package/dist/entities/Calculator/strategyExecution.js.map +0 -1
  102. package/dist/entities/Calculator/strategyFinder.d.ts +0 -11
  103. package/dist/entities/Calculator/strategyFinder.js +0 -162
  104. package/dist/entities/Calculator/strategyFinder.js.map +0 -1
  105. package/dist/entities/Calculator/types.d.ts +0 -84
  106. package/dist/entities/Calculator/types.js.map +0 -1
  107. /package/dist/entities/{Calculator → crossChainDeposit/aggregators/Boros}/types.js +0 -0
@@ -0,0 +1,38 @@
1
+ import { Hex, PublicClient } from 'viem';
2
+ import { PendleSwapResponse } from '../../../../backend/secrettune/PendleV2SDK';
3
+ import { BorosCoreSdk, PendleV2Sdk } from '../../../../backend/secrettune/module';
4
+ import { DepositBoxFactoryContract } from '../../../../contracts/deposit-box-factory';
5
+ import { AggregatorChain, AggregatorHelper, AggregatorName, AggregatorResult, AggregatorRoute, AggregatorRouteStatus, AggregatorSwapData, AggregatorTransferData, QuoteDepositParams } from '../../AggregatorHelper';
6
+ import { TokenHelper, TokenLookupTable } from '../../helpers/TokenHelper';
7
+ export declare class PendleSwapResult implements AggregatorResult {
8
+ routes: AggregatorRoute[];
9
+ private rawResult;
10
+ private req;
11
+ private helper;
12
+ constructor(params: {
13
+ req: QuoteDepositParams;
14
+ res: PendleSwapResponse;
15
+ tokenLookupTable: TokenLookupTable;
16
+ helper: PendleSwapHelper;
17
+ });
18
+ getAggregatorName(): AggregatorName;
19
+ selectRoute(): PendleSwapResponse | undefined;
20
+ getRouteData(): Promise<{
21
+ transferData: AggregatorTransferData;
22
+ swapData: AggregatorSwapData;
23
+ }>;
24
+ }
25
+ export declare class PendleSwapHelper implements AggregatorHelper {
26
+ private readonly pendleV2Sdk;
27
+ private readonly coreSdk;
28
+ private readonly publicClient;
29
+ private readonly tokenHelper;
30
+ private readonly depositBoxFactoryContract;
31
+ aggregatorName: AggregatorName;
32
+ constructor(pendleV2Sdk: PendleV2Sdk, coreSdk: BorosCoreSdk, publicClient: PublicClient, tokenHelper: TokenHelper, depositBoxFactoryContract: DepositBoxFactoryContract);
33
+ getChains(): Promise<AggregatorChain[]>;
34
+ getTokenLookupTable(): Promise<TokenLookupTable>;
35
+ getRouteStatus(txHash: Hex): Promise<AggregatorRouteStatus>;
36
+ quoteDeposit(params: QuoteDepositParams): Promise<PendleSwapResult>;
37
+ prepareTransferCall(params: QuoteDepositParams): Promise<AggregatorTransferData>;
38
+ }
@@ -0,0 +1,171 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.PendleSwapHelper = exports.PendleSwapResult = void 0;
10
+ const viem_1 = require("viem");
11
+ const chains_1 = require("viem/chains");
12
+ const addresses_1 = require("../../../../addresses");
13
+ const cacheDecorators_1 = require("../../../../common/cacheDecorators");
14
+ const constants_1 = require("../../../../multicall/constants");
15
+ const Token_1 = require("../../../token/Token");
16
+ const AggregatorHelper_1 = require("../../AggregatorHelper");
17
+ const AggregatorHelperErrors_1 = require("../../AggregatorHelperErrors");
18
+ const utils_1 = require("../../helpers/utils");
19
+ class PendleSwapResult {
20
+ routes = [];
21
+ rawResult;
22
+ req;
23
+ helper;
24
+ constructor(params) {
25
+ const { req, res, tokenLookupTable, helper } = params;
26
+ this.helper = helper;
27
+ this.req = req;
28
+ const fromToken = tokenLookupTable.lookup(chains_1.arbitrum.id, req.fromToken, true);
29
+ const toToken = tokenLookupTable.lookup(chains_1.arbitrum.id, req.toToken, true);
30
+ this.routes = [
31
+ {
32
+ id: 'pendle',
33
+ inputTokenAmount: new Token_1.TokenAmount(fromToken, BigInt(req.fromAmount)),
34
+ outputTokenAmount: new Token_1.TokenAmount(toToken, BigInt(res.data.amountOut)),
35
+ minOutputTokenAmount: new Token_1.TokenAmount(toToken, BigInt(res.data.amountOut)).slipDown(req.slippage),
36
+ steps: [
37
+ {
38
+ fromTokenAmount: new Token_1.TokenAmount(fromToken, BigInt(req.fromAmount)),
39
+ toTokenAmount: new Token_1.TokenAmount(toToken, BigInt(res.data.amountOut)),
40
+ executionDuration: 0.25,
41
+ feeCosts: [],
42
+ gasCosts: [],
43
+ tool: {
44
+ key: 'pendle',
45
+ name: 'Pendle Swap',
46
+ logoURI: 'https://storage.googleapis.com/prod-pendle-bucket-a/images/assets/pro/ea33e392-1876-46a5-b7ce-c8434b5a7e71.svg',
47
+ },
48
+ },
49
+ ],
50
+ },
51
+ ];
52
+ this.rawResult = res;
53
+ }
54
+ getAggregatorName() {
55
+ return AggregatorHelper_1.AggregatorName.PENDLE;
56
+ }
57
+ selectRoute() {
58
+ return this.rawResult;
59
+ }
60
+ async getRouteData() {
61
+ const transferData = await this.helper.prepareTransferCall(this.req);
62
+ return {
63
+ transferData,
64
+ swapData: {
65
+ tokenSpent: this.req.fromToken,
66
+ amountSpent: BigInt(this.req.fromAmount),
67
+ extRouter: (0, addresses_1.toAddress)(this.rawResult.tx.to),
68
+ extCalldata: this.rawResult.tx.data,
69
+ },
70
+ };
71
+ }
72
+ }
73
+ exports.PendleSwapResult = PendleSwapResult;
74
+ class PendleSwapHelper {
75
+ pendleV2Sdk;
76
+ coreSdk;
77
+ publicClient;
78
+ tokenHelper;
79
+ depositBoxFactoryContract;
80
+ aggregatorName = AggregatorHelper_1.AggregatorName.PENDLE;
81
+ constructor(pendleV2Sdk, coreSdk, publicClient, tokenHelper, depositBoxFactoryContract) {
82
+ this.pendleV2Sdk = pendleV2Sdk;
83
+ this.coreSdk = coreSdk;
84
+ this.publicClient = publicClient;
85
+ this.tokenHelper = tokenHelper;
86
+ this.depositBoxFactoryContract = depositBoxFactoryContract;
87
+ }
88
+ async getChains() {
89
+ return [
90
+ {
91
+ chainId: chains_1.arbitrum.id,
92
+ name: 'Arbitrum',
93
+ key: 'arbitrum',
94
+ coin: 'ETH',
95
+ logoURI: 'https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/chains/arbitrum.svg',
96
+ },
97
+ ];
98
+ }
99
+ async getTokenLookupTable() {
100
+ return this.tokenHelper.getTokenLookupTable();
101
+ }
102
+ async getRouteStatus(txHash) {
103
+ try {
104
+ const receipt = await this.publicClient.getTransactionReceipt({ hash: txHash });
105
+ return receipt.status === 'success' ? AggregatorHelper_1.AggregatorRouteStatus.DONE : AggregatorHelper_1.AggregatorRouteStatus.FAILED;
106
+ }
107
+ catch (error) {
108
+ if (error instanceof viem_1.TransactionReceiptNotFoundError) {
109
+ return AggregatorHelper_1.AggregatorRouteStatus.NOT_FOUND;
110
+ }
111
+ throw (0, AggregatorHelperErrors_1.classifyAggregatorError)(AggregatorHelper_1.AggregatorName.PENDLE, error, [500, 502, 503, 504], 'getRouteStatus', txHash, () => undefined);
112
+ }
113
+ }
114
+ async quoteDeposit(params) {
115
+ const { box } = await this.depositBoxFactoryContract.computeDepositBox(params.fromAddress, params.boxId);
116
+ const req = {
117
+ receiver: box,
118
+ inputs: [
119
+ {
120
+ token: params.fromToken,
121
+ amount: params.fromAmount.toString(),
122
+ },
123
+ ],
124
+ tokenOut: params.toToken,
125
+ slippage: params.slippage,
126
+ aggregators: 'kyberswap,okx',
127
+ };
128
+ (0, utils_1.ensureDepositBoxAddress)(params.fromAddress, params.boxId, req.receiver);
129
+ try {
130
+ const [{ data }, tokenLookupTable] = await Promise.all([
131
+ this.pendleV2Sdk.sdk.sdkControllerPendleSwapV2(chains_1.arbitrum.id, req),
132
+ this.getTokenLookupTable(),
133
+ ]);
134
+ return new PendleSwapResult({ req: params, res: data, tokenLookupTable, helper: this });
135
+ }
136
+ catch (error) {
137
+ throw (0, AggregatorHelperErrors_1.classifyAggregatorError)(AggregatorHelper_1.AggregatorName.PENDLE, error, [500, 502, 503, 504], 'quote', req, () => undefined);
138
+ }
139
+ }
140
+ async prepareTransferCall(params) {
141
+ try {
142
+ const { data } = await this.coreSdk.depositBox.depositBoxControllerPrepareTransferToBox({
143
+ chainId: chains_1.arbitrum.id,
144
+ token: params.fromToken,
145
+ amount: params.fromAmount.toString(),
146
+ root: params.fromAddress,
147
+ boxId: params.boxId,
148
+ });
149
+ return {
150
+ aggregatorName: AggregatorHelper_1.AggregatorName.BOROS,
151
+ approvalAddress: viem_1.zeroAddress,
152
+ chainId: chains_1.arbitrum.id,
153
+ calldata: data.calldata,
154
+ value: BigInt(data.value),
155
+ from: params.fromAddress,
156
+ to: (0, addresses_1.toAddress)(data.to),
157
+ };
158
+ }
159
+ catch (error) {
160
+ throw (0, AggregatorHelperErrors_1.classifyAggregatorError)(AggregatorHelper_1.AggregatorName.BOROS, error, [500, 502, 503, 504], 'prepareTransferCall', params, () => undefined);
161
+ }
162
+ }
163
+ }
164
+ exports.PendleSwapHelper = PendleSwapHelper;
165
+ __decorate([
166
+ (0, cacheDecorators_1.GlobalCache)({
167
+ generateLookupKey: () => 'PendleSwapHelper.getTokenLookupTable',
168
+ ttl_ms: constants_1.MILLISECONDS_IN_A_MINUTE * 10,
169
+ })
170
+ ], PendleSwapHelper.prototype, "getTokenLookupTable", null);
171
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/entities/crossChainDeposit/aggregators/Pendle/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+BAAgG;AA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AAC,UAAU,CAAC,QAAQ,EAAE;gBACpC,IAAI,EAAE,MAAM,CAAC,WAAW;gBACxB,KAAK,EAAE,MAAM,CAAC,KAAK;aACpB,CAAC,CAAC;YACH,OAAO;gBACL,cAAc,EAAE,iCAAc,CAAC,KAAK;gBACpC,eAAe,EAAE,kBAAW;gBAC5B,OAAO,EAAE,iBAAQ,CAAC,EAAE;gBACpB,QAAQ,EAAE,IAAI,CAAC,QAAe;gBAC9B,KAAK,EAAE,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC;gBACzB,IAAI,EAAE,MAAM,CAAC,WAAW;gBACxB,EAAE,EAAE,IAAA,qBAAS,EAAC,IAAI,CAAC,EAAE,CAAC;aACvB,CAAC;QACJ,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAA,gDAAuB,EAC3B,iCAAc,CAAC,KAAK,EACpB,KAAK,EACL,CAAC,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,CAAC,EACpB,qBAAqB,EACrB,MAAM,EACN,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA7GD,4CA6GC;AAlFO;IAJL,IAAA,6BAAW,EAA0C;QACpD,iBAAiB,EAAE,GAAG,EAAE,CAAC,sCAAsC;QAC/D,MAAM,EAAE,oCAAwB,GAAG,EAAE;KACtC,CAAC;2DAGD"}
@@ -0,0 +1,23 @@
1
+ import { Address } from 'viem';
2
+ import { Token } from '../..';
3
+ import { BorosCoreSdk } from '../../../backend/secrettune/module';
4
+ import { ChainId } from '../../../common/chainId';
5
+ import { TokenId } from '../../../types';
6
+ export declare class TokenHelper {
7
+ private readonly borosCoreSdk;
8
+ constructor(borosCoreSdk: BorosCoreSdk);
9
+ getTokens(params?: {
10
+ dstTokenId?: TokenId;
11
+ srcChainId?: ChainId;
12
+ }): Promise<Token[]>;
13
+ getTokenLookupTable(params?: {
14
+ dstTokenId?: TokenId;
15
+ }): Promise<TokenLookupTable>;
16
+ }
17
+ export declare class TokenLookupTable {
18
+ private readonly tokens;
19
+ private readonly tokenMap;
20
+ constructor(tokens: Token[]);
21
+ lookup(chainId: ChainId, tokenAddress: Address, checked?: false): Token | undefined;
22
+ lookup(chainId: ChainId, tokenAddress: Address, checked: true): Token;
23
+ }
@@ -0,0 +1,67 @@
1
+ "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ Object.defineProperty(exports, "__esModule", { value: true });
9
+ exports.TokenLookupTable = exports.TokenHelper = void 0;
10
+ const __1 = require("../..");
11
+ const cacheDecorators_1 = require("../../../common/cacheDecorators");
12
+ const constants_1 = require("../../../multicall/constants");
13
+ class TokenHelper {
14
+ borosCoreSdk;
15
+ constructor(borosCoreSdk) {
16
+ this.borosCoreSdk = borosCoreSdk;
17
+ }
18
+ async getTokens(params) {
19
+ const { dstTokenId, srcChainId } = params ?? {};
20
+ const { data } = await this.borosCoreSdk.depositBox.depositBoxControllerGetAssets();
21
+ const filterSrcChainId = srcChainId == null ? () => true : (asset) => asset.chainId === srcChainId;
22
+ const filterDstTokenId = dstTokenId == null
23
+ ? () => true
24
+ : (() => {
25
+ const isExclusiveTokenId = data.assets.some((asset) => asset.dstTokenId === dstTokenId);
26
+ return isExclusiveTokenId
27
+ ? (asset) => asset.dstTokenId === dstTokenId
28
+ : (asset) => asset.dstTokenId == null;
29
+ })();
30
+ return data.assets
31
+ .filter(filterSrcChainId)
32
+ .filter(filterDstTokenId)
33
+ .map((asset) => __1.Token.createFromBorosCore(asset));
34
+ }
35
+ async getTokenLookupTable(params) {
36
+ const tokens = await this.getTokens(params);
37
+ return new TokenLookupTable(tokens);
38
+ }
39
+ }
40
+ exports.TokenHelper = TokenHelper;
41
+ __decorate([
42
+ (0, cacheDecorators_1.GlobalCache)({
43
+ generateLookupKey: (_, [params]) => `TokenHelper.getTokens.${params?.dstTokenId}.${params?.srcChainId}`,
44
+ ttl_ms: constants_1.MILLISECONDS_IN_A_MINUTE * 10,
45
+ })
46
+ ], TokenHelper.prototype, "getTokens", null);
47
+ class TokenLookupTable {
48
+ tokens;
49
+ tokenMap;
50
+ constructor(tokens) {
51
+ this.tokens = tokens;
52
+ this.tokenMap = new Map();
53
+ for (const token of tokens) {
54
+ this.tokenMap.set(`${token.chainId}-${token.address}`, token);
55
+ }
56
+ }
57
+ lookup(chainId, tokenAddress, checked) {
58
+ const key = `${chainId}-${tokenAddress}`;
59
+ const res = this.tokenMap.get(key);
60
+ if (checked && res == null) {
61
+ throw new Error(`Cannot find token ${tokenAddress} in the lookup table`);
62
+ }
63
+ return res;
64
+ }
65
+ }
66
+ exports.TokenLookupTable = TokenLookupTable;
67
+ //# sourceMappingURL=TokenHelper.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"TokenHelper.js","sourceRoot":"","sources":["../../../../src/entities/crossChainDeposit/helpers/TokenHelper.ts"],"names":[],"mappings":";;;;;;;;;AACA,6BAA8B;AAE9B,qEAA8D;AAE9D,4DAAwE;AAGxE,MAAa,WAAW;IACO;IAA7B,YAA6B,YAA0B;QAA1B,iBAAY,GAAZ,YAAY,CAAc;IAAG,CAAC;IAMrD,AAAN,KAAK,CAAC,SAAS,CAAC,MAAuD;QACrE,MAAM,EAAE,UAAU,EAAE,UAAU,EAAE,GAAG,MAAM,IAAI,EAAE,CAAC;QAChD,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,6BAA6B,EAAE,CAAC;QAEpF,MAAM,gBAAgB,GACpB,UAAU,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4CAqBD;AAQH,MAAa,gBAAgB;IAGE;IAFZ,QAAQ,CAAsC;IAE/D,YAA6B,MAAe;QAAf,WAAM,GAAN,MAAM,CAAS;QAC1C,IAAI,CAAC,QAAQ,GAAG,IAAI,GAAG,EAAkC,CAAC;QAC1D,KAAK,MAAM,KAAK,IAAI,MAAM,EAAE,CAAC;YAC3B,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC,OAAkB,IAAI,KAAK,CAAC,OAAO,EAAE,EAAE,KAAK,CAAC,CAAC;QAC3E,CAAC;IACH,CAAC;IAID,MAAM,CAAC,OAAgB,EAAE,YAAqB,EAAE,OAAiB;QAC/D,MAAM,GAAG,GAA4B,GAAG,OAAO,IAAI,YAAY,EAAE,CAAC;QAClE,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnC,IAAI,OAAO,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;YAC3B,MAAM,IAAI,KAAK,CAAC,qBAAqB,YAAY,sBAAsB,CAAC,CAAC;QAC3E,CAAC;QACD,OAAO,GAAG,CAAC;IACb,CAAC;CACF;AApBD,4CAoBC"}
@@ -0,0 +1,4 @@
1
+ import { Address, Hex } from 'viem';
2
+ export declare function computeDepositBoxAddress(root: Address, boxId: number): `0x${string}`;
3
+ export declare function ensureDepositBoxAddress(root: Address, boxId: number, box?: string): void;
4
+ export declare function ensureCalldataHasBoxAddress(calldata: Hex, box: Address): void;
@@ -0,0 +1,25 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.computeDepositBoxAddress = computeDepositBoxAddress;
4
+ exports.ensureDepositBoxAddress = ensureDepositBoxAddress;
5
+ exports.ensureCalldataHasBoxAddress = ensureCalldataHasBoxAddress;
6
+ const viem_1 = require("viem");
7
+ const addresses_1 = require("../../../addresses");
8
+ function computeDepositBoxAddress(root, boxId) {
9
+ const bytecodeHash = (0, addresses_1.getDepositBoxCodeHash)();
10
+ const depositBoxFactoryAddress = (0, addresses_1.getDepositBoxFactoryAddress)();
11
+ const salt = (0, viem_1.keccak256)((0, viem_1.encodeAbiParameters)((0, viem_1.parseAbiParameters)('address, uint32'), [root, boxId]));
12
+ return (0, viem_1.getCreate2Address)({ from: depositBoxFactoryAddress, salt, bytecodeHash });
13
+ }
14
+ function ensureDepositBoxAddress(root, boxId, box) {
15
+ if (box == null || box.toLowerCase() !== (0, addresses_1.toAddress)(computeDepositBoxAddress(root, boxId))) {
16
+ throw new Error(`Deposit box address mismatch: root=${root}, boxId=${boxId}, box=${box}`);
17
+ }
18
+ }
19
+ function ensureCalldataHasBoxAddress(calldata, box) {
20
+ const normalizedBox = (0, addresses_1.toAddress)(box).slice(2);
21
+ if (!calldata.includes(normalizedBox)) {
22
+ throw new Error(`Calldata does not contain box address: box=${box}, calldata=${calldata}`);
23
+ }
24
+ }
25
+ //# sourceMappingURL=utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"utils.js","sourceRoot":"","sources":["../../../../src/entities/crossChainDeposit/helpers/utils.ts"],"names":[],"mappings":";;AAGA,4DAKC;AAED,0DAIC;AAED,kEAMC;AAtBD,+BAA2G;AAC3G,kDAAmG;AAEnG,SAAgB,wBAAwB,CAAC,IAAa,EAAE,KAAa;IACnE,MAAM,YAAY,GAAG,IAAA,iCAAqB,GAAE,CAAC;IAC7C,MAAM,wBAAwB,GAAG,IAAA,uCAA2B,GAAE,CAAC;IAC/D,MAAM,IAAI,GAAG,IAAA,gBAAS,EAAC,IAAA,0BAAmB,EAAC,IAAA,yBAAkB,EAAC,iBAAiB,CAAC,EAAE,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,CAAC,CAAC;IAClG,OAAO,IAAA,wBAAiB,EAAC,EAAE,IAAI,EAAE,wBAAwB,EAAE,IAAI,EAAE,YAAY,EAAE,CAAC,CAAC;AACnF,CAAC;AAED,SAAgB,uBAAuB,CAAC,IAAa,EAAE,KAAa,EAAE,GAAY;IAChF,IAAI,GAAG,IAAI,IAAI,IAAI,GAAG,CAAC,WAAW,EAAE,KAAK,IAAA,qBAAS,EAAC,wBAAwB,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC,EAAE,CAAC;QAC1F,MAAM,IAAI,KAAK,CAAC,sCAAsC,IAAI,WAAW,KAAK,SAAS,GAAG,EAAE,CAAC,CAAC;IAC5F,CAAC;AACH,CAAC;AAED,SAAgB,2BAA2B,CAAC,QAAa,EAAE,GAAY;IACrE,MAAM,aAAa,GAAG,IAAA,qBAAS,EAAC,GAAG,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAE9C,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,aAAa,CAAC,EAAE,CAAC;QACtC,MAAM,IAAI,KAAK,CAAC,8CAA8C,GAAG,cAAc,QAAQ,EAAE,CAAC,CAAC;IAC7F,CAAC;AACH,CAAC"}
@@ -0,0 +1,2 @@
1
+ export * from './Depositor';
2
+ export * from './AggregatorHelper';
@@ -14,10 +14,6 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./types"), exports);
18
- __exportStar(require("./strategyFinder"), exports);
19
- __exportStar(require("./strategyExecution"), exports);
20
- __exportStar(require("./strategyApr"), exports);
21
- __exportStar(require("./exchangeFees"), exports);
22
- __exportStar(require("./marginCalculator"), exports);
17
+ __exportStar(require("./Depositor"), exports);
18
+ __exportStar(require("./AggregatorHelper"), exports);
23
19
  //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entities/crossChainDeposit/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,qDAAmC"}
@@ -8,4 +8,5 @@ export * from './multiTokenMerkleDistributor';
8
8
  export * from './wrappedEth';
9
9
  export * from './subaccount';
10
10
  export * from './vePendle';
11
- export * from './Calculator';
11
+ export * from './crossChainDeposit';
12
+ export * from './token';
@@ -24,5 +24,6 @@ __exportStar(require("./multiTokenMerkleDistributor"), exports);
24
24
  __exportStar(require("./wrappedEth"), exports);
25
25
  __exportStar(require("./subaccount"), exports);
26
26
  __exportStar(require("./vePendle"), exports);
27
- __exportStar(require("./Calculator"), exports);
27
+ __exportStar(require("./crossChainDeposit"), exports);
28
+ __exportStar(require("./token"), exports);
28
29
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB;AACzB,6CAA2B;AAC3B,wCAAsB;AACtB,+CAA6B;AAC7B,gDAA8B;AAC9B,gEAA8C;AAC9C,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B;AAC3B,+CAA6B"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/entities/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,2CAAyB;AACzB,6CAA2B;AAC3B,wCAAsB;AACtB,+CAA6B;AAC7B,gDAA8B;AAC9B,gEAA8C;AAC9C,+CAA6B;AAC7B,+CAA6B;AAC7B,6CAA2B;AAC3B,sDAAoC;AACpC,0CAAwB"}
@@ -0,0 +1,31 @@
1
+ import { Address, PublicClient } from 'viem';
2
+ import { AssetResponse } from '../../backend/secrettune/BorosCoreSDK';
3
+ import { LifiTokenResponse } from '../crossChainDeposit/aggregators/Lifi/types';
4
+ export declare class Token {
5
+ readonly chainId: number;
6
+ readonly address: Address;
7
+ readonly decimals: number;
8
+ readonly symbol: string;
9
+ readonly name: string;
10
+ readonly logoURI?: string | undefined;
11
+ readonly priceUSD?: number | undefined;
12
+ constructor(chainId: number, address: Address, decimals: number, symbol: string, name: string, logoURI?: string | undefined, priceUSD?: number | undefined);
13
+ static createFromLifi(token: LifiTokenResponse): Token;
14
+ static createFromBorosCore(token: AssetResponse & {
15
+ chainId?: number;
16
+ }): Token;
17
+ balanceOf(address: Address, params: {
18
+ client: PublicClient;
19
+ }): Promise<TokenAmount>;
20
+ allowance(address: Address, spender: Address, params: {
21
+ client: PublicClient;
22
+ }): Promise<TokenAmount>;
23
+ }
24
+ export declare class TokenAmount {
25
+ readonly token: Token;
26
+ readonly amount: bigint;
27
+ constructor(token: Token, amount: bigint);
28
+ static createFromLifi(token: LifiTokenResponse, amount: string): TokenAmount;
29
+ static createFromBorosCore(token: AssetResponse, amount: string): TokenAmount;
30
+ slipDown(slippage: number): TokenAmount;
31
+ }
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.TokenAmount = exports.Token = void 0;
4
+ const boros_offchain_math_1 = require("@pendle/boros-offchain-math");
5
+ const chains_1 = require("viem/chains");
6
+ const addresses_1 = require("../../addresses");
7
+ const erc20_1 = require("../../contracts/erc20");
8
+ class Token {
9
+ chainId;
10
+ address;
11
+ decimals;
12
+ symbol;
13
+ name;
14
+ logoURI;
15
+ priceUSD;
16
+ constructor(chainId, address, decimals, symbol, name, logoURI, priceUSD) {
17
+ this.chainId = chainId;
18
+ this.address = address;
19
+ this.decimals = decimals;
20
+ this.symbol = symbol;
21
+ this.name = name;
22
+ this.logoURI = logoURI;
23
+ this.priceUSD = priceUSD;
24
+ }
25
+ static createFromLifi(token) {
26
+ return new Token(token.chainId, token.address, token.decimals, token.symbol, token.name, token.logoURI, token.priceUSD != null ? Number(token.priceUSD) : undefined);
27
+ }
28
+ static createFromBorosCore(token) {
29
+ return new Token(token?.chainId ?? chains_1.arbitrum.id, (0, addresses_1.toAddress)(token.address), token.decimals, token.symbol, token.name, token.metadata.icon, Number(token.usdPrice));
30
+ }
31
+ async balanceOf(address, params) {
32
+ const erc20 = erc20_1.ERC20.create(this.address, { client: params.client, multicall: undefined });
33
+ const balance = await erc20.balanceOf(address);
34
+ return new TokenAmount(this, balance);
35
+ }
36
+ async allowance(address, spender, params) {
37
+ const erc20 = erc20_1.ERC20.create(this.address, { client: params.client, multicall: undefined });
38
+ const allowance = await erc20.allowance(address, spender);
39
+ return new TokenAmount(this, allowance);
40
+ }
41
+ }
42
+ exports.Token = Token;
43
+ class TokenAmount {
44
+ token;
45
+ amount;
46
+ constructor(token, amount) {
47
+ this.token = token;
48
+ this.amount = amount;
49
+ }
50
+ static createFromLifi(token, amount) {
51
+ return new TokenAmount(Token.createFromLifi(token), BigInt(amount));
52
+ }
53
+ static createFromBorosCore(token, amount) {
54
+ return new TokenAmount(Token.createFromBorosCore(token), BigInt(amount));
55
+ }
56
+ slipDown(slippage) {
57
+ return new TokenAmount(this.token, boros_offchain_math_1.FixedX18.fromRawValue(this.amount).mulDown(boros_offchain_math_1.FixedX18.fromNumber(1 - slippage)).value);
58
+ }
59
+ }
60
+ exports.TokenAmount = TokenAmount;
61
+ //# sourceMappingURL=Token.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Token.js","sourceRoot":"","sources":["../../../src/entities/token/Token.ts"],"names":[],"mappings":";;;AAAA,qEAAuD;AAEvD,wCAAuC;AACvC,+CAA4C;AAE5C,iDAA8C;AAG9C,MAAa,KAAK;IAEE;IACA;IACA;IACA;IACA;IACA;IACA;IAPlB,YACkB,OAAe,EACf,OAAgB,EAChB,QAAgB,EAChB,MAAc,EACd,IAAY,EACZ,OAAgB,EAChB,QAAiB;QANjB,YAAO,GAAP,OAAO,CAAQ;QACf,YAAO,GAAP,OAAO,CAAS;QAChB,aAAQ,GAAR,QAAQ,CAAQ;QAChB,WAAM,GAAN,MAAM,CAAQ;QACd,SAAI,GAAJ,IAAI,CAAQ;QACZ,YAAO,GAAP,OAAO,CAAS;QAChB,aAAQ,GAAR,QAAQ,CAAS;IAChC,CAAC;IAEJ,MAAM,CAAC,cAAc,CAAC,KAAwB;QAC5C,OAAO,IAAI,K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CAAC,OAAO,EAAE,OAAO,CAAC,CAAC;QAC1D,OAAO,IAAI,WAAW,CAAC,IAAI,EAAE,SAAS,CAAC,CAAC;IAC1C,CAAC;CACF;AA9CD,sBA8CC;AAED,MAAa,WAAW;IAEJ;IACA;IAFlB,YACkB,KAAY,EACZ,MAAc;QADd,UAAK,GAAL,KAAK,CAAO;QACZ,WAAM,GAAN,MAAM,CAAQ;IAC7B,CAAC;IAEJ,MAAM,CAAC,cAAc,CAAC,KAAwB,EAAE,MAAc;QAC5D,OAAO,IAAI,WAAW,CAAC,KAAK,CAAC,cAAc,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IACtE,CAAC;IAED,MAAM,CAAC,mBAAmB,CAAC,KAAoB,EAAE,MAAc;QAC7D,OAAO,IAAI,WAAW,CAAC,KAAK,CAAC,mBAAmB,CAAC,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,CAAC,CAAC,CAAC;IAC3E,CAAC;IAED,QAAQ,CAAC,QAAgB;QACvB,OAAO,IAAI,WAAW,CACpB,IAAI,CAAC,KAAK,EACV,8BAAQ,CAAC,YAAY,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,OAAO,CAAC,8BAAQ,CAAC,UAAU,CAAC,CAAC,GAAG,QAAQ,CAAC,CAAC,CAAC,KAAK,CACpF,CAAC;IACJ,CAAC;CACF;AApBD,kCAoBC"}
@@ -0,0 +1 @@
1
+ export * from './Token';
@@ -0,0 +1,18 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ __exportStar(require("./Token"), exports);
18
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entities/token/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
@@ -0,0 +1,7 @@
1
+ export type PendleSdkErrorParams = {
2
+ cause?: unknown;
3
+ };
4
+ export declare class PendleSdkError extends Error {
5
+ cause?: unknown;
6
+ constructor(message: string, params?: PendleSdkErrorParams);
7
+ }
@@ -0,0 +1,15 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.PendleSdkError = void 0;
4
+ class PendleSdkError extends Error {
5
+ cause;
6
+ constructor(message, params) {
7
+ super(message, params);
8
+ const cause = params?.cause;
9
+ if (!this.cause && cause)
10
+ this.cause = cause;
11
+ Object.setPrototypeOf(this, this.constructor.prototype);
12
+ }
13
+ }
14
+ exports.PendleSdkError = PendleSdkError;
15
+ //# sourceMappingURL=PendleSdkError.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"PendleSdkError.js","sourceRoot":"","sources":["../../src/errors/PendleSdkError.ts"],"names":[],"mappings":";;;AAaA,MAAa,cAAe,SAAQ,KAAK;IAM9B,KAAK,CAAW;IAEzB,YAAY,OAAe,EAAE,MAA6B;QACxD,KAAK,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC;QAEvB,MAAM,KAAK,GAAG,MAAM,EAAE,KAAK,CAAC;QAC5B,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,KAAK;YAAE,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;QAI7C,MAAM,CAAC,cAAc,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,SAAS,CAAC,CAAC;IAC1D,CAAC;CACF;AAlBD,wCAkBC"}
@@ -66,6 +66,22 @@ export type ApproveAgentMessage = {
66
66
  expiry: bigint;
67
67
  nonce: bigint;
68
68
  };
69
+ export type DepositFromBoxMessage = {
70
+ root: Address;
71
+ boxId: number;
72
+ tokenSpent: Address;
73
+ maxAmountSpent: bigint;
74
+ accountId: number;
75
+ tokenId: number;
76
+ marketId: number;
77
+ minDepositAmount: bigint;
78
+ payTreasuryAmount: bigint;
79
+ swapExtRouter: Address;
80
+ swapApprove: Address;
81
+ swapCalldata: Hex;
82
+ expiry: bigint;
83
+ salt: bigint;
84
+ };
69
85
  export type SetAccManagerStruct = {
70
86
  root: Address;
71
87
  accountId: number;
@@ -1,3 +1,3 @@
1
1
  export { bulkSignWithAgent, bulkSignWithAgentV2, getAgentSignature, signCancelStopOrderRequest, signCancelStopOrderV2Request, signStopOrderRequest, signUpdateSettings, signWithAgent, type SignedAgentExecution, } from './agent';
2
2
  export { hashStopOrderRequest } from './common';
3
- export { signApproveAgentMessage, signSetAccManagerMessage } from './sensitive';
3
+ export { signApproveAgentMessage, signDepositFromBoxMessage, signSetAccManagerMessage, } from './sensitive';
@@ -1,6 +1,6 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.signSetAccManagerMessage = exports.signApproveAgentMessage = exports.hashStopOrderRequest = exports.signWithAgent = exports.signUpdateSettings = exports.signStopOrderRequest = exports.signCancelStopOrderV2Request = exports.signCancelStopOrderRequest = exports.getAgentSignature = exports.bulkSignWithAgentV2 = exports.bulkSignWithAgent = void 0;
3
+ exports.signSetAccManagerMessage = exports.signDepositFromBoxMessage = exports.signApproveAgentMessage = exports.hashStopOrderRequest = exports.signWithAgent = exports.signUpdateSettings = exports.signStopOrderRequest = exports.signCancelStopOrderV2Request = exports.signCancelStopOrderRequest = exports.getAgentSignature = exports.bulkSignWithAgentV2 = exports.bulkSignWithAgent = void 0;
4
4
  var agent_1 = require("./agent");
5
5
  Object.defineProperty(exports, "bulkSignWithAgent", { enumerable: true, get: function () { return agent_1.bulkSignWithAgent; } });
6
6
  Object.defineProperty(exports, "bulkSignWithAgentV2", { enumerable: true, get: function () { return agent_1.bulkSignWithAgentV2; } });
@@ -14,5 +14,6 @@ var common_1 = require("./common");
14
14
  Object.defineProperty(exports, "hashStopOrderRequest", { enumerable: true, get: function () { return common_1.hashStopOrderRequest; } });
15
15
  var sensitive_1 = require("./sensitive");
16
16
  Object.defineProperty(exports, "signApproveAgentMessage", { enumerable: true, get: function () { return sensitive_1.signApproveAgentMessage; } });
17
+ Object.defineProperty(exports, "signDepositFromBoxMessage", { enumerable: true, get: function () { return sensitive_1.signDepositFromBoxMessage; } });
17
18
  Object.defineProperty(exports, "signSetAccManagerMessage", { enumerable: true, get: function () { return sensitive_1.signSetAccManagerMessage; } });
18
19
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/signing/index.ts"],"names":[],"mappings":";;;AAAA,iCAUiB;AATf,0GAAA,iBAAiB,OAAA;AACjB,4GAAA,mBAAmB,OAAA;AACnB,0GAAA,iBAAiB,OAAA;AACjB,mHAAA,0BAA0B,OAAA;AAC1B,qHAAA,4BAA4B,OAAA;AAC5B,6GAAA,oBAAoB,OAAA;AACpB,2GAAA,kBAAkB,OAAA;AAClB,sGAAA,aAAa,OAAA;AAGf,mCAAgD;AAAvC,8GAAA,oBAAoB,OAAA;AAC7B,yCAAgF;AAAvE,oHAAA,uBAAuB,OAAA;AAAE,qHAAA,wBAAwB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/utils/signing/index.ts"],"names":[],"mappings":";;;AAAA,iCAUiB;AATf,0GAAA,iBAAiB,OAAA;AACjB,4GAAA,mBAAmB,OAAA;AACnB,0GAAA,iBAAiB,OAAA;AACjB,mHAAA,0BAA0B,OAAA;AAC1B,qHAAA,4BAA4B,OAAA;AAC5B,6GAAA,oBAAoB,OAAA;AACpB,2GAAA,kBAAkB,OAAA;AAClB,sGAAA,aAAa,OAAA;AAGf,mCAAgD;AAAvC,8GAAA,oBAAoB,OAAA;AAC7B,yCAIqB;AAHnB,oHAAA,uBAAuB,OAAA;AACvB,sHAAA,yBAAyB,OAAA;AACzB,qHAAA,wBAAwB,OAAA"}
@@ -1,4 +1,5 @@
1
1
  import { WalletClient } from 'viem';
2
- import { ApproveAgentMessage, SetAccManagerStruct } from '../../types';
2
+ import { ApproveAgentMessage, DepositFromBoxMessage, SetAccManagerStruct } from '../../types';
3
3
  export declare function signSetAccManagerMessage(wallet: WalletClient, message: SetAccManagerStruct): Promise<`0x${string}`>;
4
4
  export declare function signApproveAgentMessage(wallet: WalletClient, message: ApproveAgentMessage): Promise<`0x${string}`>;
5
+ export declare function signDepositFromBoxMessage(wallet: WalletClient, message: DepositFromBoxMessage): Promise<`0x${string}`>;