@pendle/sdk-boros 1.0.12-cross-deposit-1 → 1.0.12-cross-deposit-3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/addresses.d.ts +3 -3
- package/dist/addresses.js +3 -3
- package/dist/backend/secrettune/BorosCoreSDK.d.ts +97 -5
- package/dist/backend/secrettune/BorosCoreSDK.js +53 -1
- package/dist/backend/secrettune/BorosCoreSDK.js.map +1 -1
- package/dist/backend/secrettune/BorosSendTxsBotSDK.d.ts +6 -1
- package/dist/backend/secrettune/BorosSendTxsBotSDK.js +1 -1
- package/dist/backend/secrettune/BorosSendTxsBotSDK.js.map +1 -1
- package/dist/entities/crossChainDeposit/AggregatorHelper.d.ts +12 -2
- package/dist/entities/crossChainDeposit/AggregatorHelper.js.map +1 -1
- package/dist/entities/crossChainDeposit/AggregatorHelperErrors.d.ts +6 -3
- package/dist/entities/crossChainDeposit/AggregatorHelperErrors.js.map +1 -1
- package/dist/entities/crossChainDeposit/Depositor.d.ts +1 -0
- package/dist/entities/crossChainDeposit/Depositor.js +3 -0
- package/dist/entities/crossChainDeposit/Depositor.js.map +1 -1
- package/dist/entities/crossChainDeposit/Withdrawer.d.ts +28 -0
- package/dist/entities/crossChainDeposit/Withdrawer.js +59 -0
- package/dist/entities/crossChainDeposit/Withdrawer.js.map +1 -0
- package/dist/entities/crossChainDeposit/aggregators/Boros/BorosHelper.d.ts +53 -0
- package/dist/entities/crossChainDeposit/aggregators/Boros/BorosHelper.js +272 -0
- package/dist/entities/crossChainDeposit/aggregators/Boros/BorosHelper.js.map +1 -0
- package/dist/entities/crossChainDeposit/aggregators/Boros/index.d.ts +2 -36
- package/dist/entities/crossChainDeposit/aggregators/Boros/index.js +15 -187
- package/dist/entities/crossChainDeposit/aggregators/Boros/index.js.map +1 -1
- package/dist/entities/crossChainDeposit/aggregators/Lifi/index.d.ts +18 -1
- package/dist/entities/crossChainDeposit/aggregators/Lifi/index.js +87 -2
- package/dist/entities/crossChainDeposit/aggregators/Lifi/index.js.map +1 -1
- package/dist/entities/crossChainDeposit/aggregators/Pendle/index.d.ts +17 -1
- package/dist/entities/crossChainDeposit/aggregators/Pendle/index.js +80 -1
- package/dist/entities/crossChainDeposit/aggregators/Pendle/index.js.map +1 -1
- package/dist/entities/crossChainDeposit/helpers/TokenHelper.d.ts +6 -0
- package/dist/entities/crossChainDeposit/helpers/TokenHelper.js +49 -0
- package/dist/entities/crossChainDeposit/helpers/TokenHelper.js.map +1 -1
- package/dist/entities/crossChainDeposit/index.d.ts +1 -0
- package/dist/entities/crossChainDeposit/index.js +1 -0
- package/dist/entities/crossChainDeposit/index.js.map +1 -1
- package/dist/entities/token/Token.d.ts +4 -1
- package/dist/entities/token/Token.js +6 -2
- package/dist/entities/token/Token.js.map +1 -1
- package/dist/types/common.d.ts +8 -0
- package/package.json +1 -1
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.Withdrawer = void 0;
|
|
4
|
+
const chains_1 = require("viem/chains");
|
|
5
|
+
const addresses_1 = require("../../addresses");
|
|
6
|
+
const module_1 = require("../../backend/secrettune/module");
|
|
7
|
+
const contracts_factory_1 = require("../../contracts/contracts.factory");
|
|
8
|
+
const AggregatorHelper_1 = require("./AggregatorHelper");
|
|
9
|
+
const Boros_1 = require("./aggregators/Boros");
|
|
10
|
+
const Lifi_1 = require("./aggregators/Lifi");
|
|
11
|
+
const Pendle_1 = require("./aggregators/Pendle");
|
|
12
|
+
const TokenHelper_1 = require("./helpers/TokenHelper");
|
|
13
|
+
class Withdrawer {
|
|
14
|
+
coreSdk;
|
|
15
|
+
contractsFactory;
|
|
16
|
+
depositBoxFactoryContract;
|
|
17
|
+
tokenHelper;
|
|
18
|
+
lifiAggregatorHelper;
|
|
19
|
+
pendleSwapHelper;
|
|
20
|
+
borosLzBridgeHelper;
|
|
21
|
+
constructor(coreSdk, rpcUrls) {
|
|
22
|
+
this.coreSdk = coreSdk;
|
|
23
|
+
this.contractsFactory = new contracts_factory_1.ContractsFactory(rpcUrls);
|
|
24
|
+
this.depositBoxFactoryContract = this.contractsFactory.getDepositBoxFactoryContract((0, addresses_1.getDepositBoxFactoryAddress)());
|
|
25
|
+
this.tokenHelper = new TokenHelper_1.TokenHelper(this.coreSdk);
|
|
26
|
+
this.lifiAggregatorHelper = new Lifi_1.LifiAggregatorHelper(this.contractsFactory.getDepositBoxFactoryContract((0, addresses_1.getDepositBoxFactoryAddress)()));
|
|
27
|
+
this.pendleSwapHelper = new Pendle_1.PendleSwapHelper((0, module_1.getPendleV2Sdk)(), this.coreSdk, this.contractsFactory.getRpcClient(), this.tokenHelper, this.depositBoxFactoryContract);
|
|
28
|
+
this.borosLzBridgeHelper = new Boros_1.BorosLzBridgeHelper(this.coreSdk, this.tokenHelper);
|
|
29
|
+
}
|
|
30
|
+
getAggregatorHelper(toChainId) {
|
|
31
|
+
switch (toChainId) {
|
|
32
|
+
case chains_1.arbitrum.id:
|
|
33
|
+
return this.pendleSwapHelper;
|
|
34
|
+
case chains_1.bsc.id:
|
|
35
|
+
return this.borosLzBridgeHelper;
|
|
36
|
+
default:
|
|
37
|
+
return this.lifiAggregatorHelper;
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
async getRoutes(params) {
|
|
41
|
+
const aggregatorHelper = this.getAggregatorHelper(params.toChainId);
|
|
42
|
+
return aggregatorHelper.quoteWithdraw(params);
|
|
43
|
+
}
|
|
44
|
+
async getTokens(options) {
|
|
45
|
+
return this.tokenHelper.getWithdrawerTokens(options);
|
|
46
|
+
}
|
|
47
|
+
async getRouteStatus(aggregatorName, txHash, options) {
|
|
48
|
+
switch (aggregatorName) {
|
|
49
|
+
case AggregatorHelper_1.AggregatorName.LIFI:
|
|
50
|
+
return this.lifiAggregatorHelper.getRouteStatus(txHash, options);
|
|
51
|
+
case AggregatorHelper_1.AggregatorName.BOROS:
|
|
52
|
+
return this.borosLzBridgeHelper.getRouteStatus(txHash);
|
|
53
|
+
case AggregatorHelper_1.AggregatorName.PENDLE:
|
|
54
|
+
return this.pendleSwapHelper.getRouteStatus(txHash);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.Withdrawer = Withdrawer;
|
|
59
|
+
//# sourceMappingURL=Withdrawer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Withdrawer.js","sourceRoot":"","sources":["../../../src/entities/crossChainDeposit/Withdrawer.ts"],"names":[],"mappings":";;;AACA,wCAA4C;AAC5C,+CAA8D;AAC9D,4DAA+E;AAE/E,yEAAqE;AAIrE,yDAM4B;AAC5B,+CAA0D;AAC1D,6CAA0D;AAC1D,iDAAwD;AACxD,uDAAoD;AAEpD,MAAa,UAAU;IACJ,OAAO,CAAe;IACtB,gBAAgB,CAAmB;IACnC,yBAAyB,CAA4B;IACrD,WAAW,CAAc;IAEjC,oBAAoB,CAAuB;IAC3C,gBAAgB,CAAmB;IACnC,mBAAmB,CAAsB;IAElD,YAAY,OAAqB,EAAE,OAAiB;QAClD,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,gBAAgB,GAAG,IAAI,oCAAgB,CAAC,OAAO,CAAC,CAAC;QACtD,IAAI,CAAC,yBAAyB,GAAG,IAAI,CAAC,gBAAgB,CAAC,4BAA4B,CAAC,IAAA,uCAA2B,GAAE,CAAC,CAAC;QACnH,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,CAAC,IAAI,CAAC,OAAO,CAAC,CAAC;QACjD,IAAI,CAAC,oBAAoB,GAAG,IAAI,2BAAoB,CAClD,IAAI,CAAC,gBAAgB,CAAC,4BAA4B,CAAC,IAAA,uCAA2B,GAAE,CAAC,CAClF,CAAC;QACF,IAAI,CAAC,gBAAgB,GAAG,IAAI,yBAAgB,CAC1C,IAAA,uBAAc,GAAE,EAChB,IAAI,CAAC,OAAO,EACZ,IAAI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gCA8DC"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
import { Hex } from 'viem';
|
|
2
|
+
import { QuoteBscBridgeResponse, QuoteBscBridgeV2Dto, QuoteWithdrawBscResponse } from '../../../../backend/secrettune/BorosCoreSDK';
|
|
3
|
+
import { BorosCoreSdk } from '../../../../backend/secrettune/module';
|
|
4
|
+
import { AggregatorChain, AggregatorHelper, AggregatorName, AggregatorResult, AggregatorRoute, AggregatorRouteStatus, AggregatorSwapData, AggregatorTransferData, QuoteDepositParams, QuoteWithdrawParams } from '../../AggregatorHelper';
|
|
5
|
+
import { TokenHelper, TokenLookupTable } from '../../helpers/TokenHelper';
|
|
6
|
+
export declare const LAYER_ZERO_SCAN_API = "https://scan.layerzero-api.com/v1";
|
|
7
|
+
export declare class BorosLzBridgeResult implements AggregatorResult {
|
|
8
|
+
routes: AggregatorRoute[];
|
|
9
|
+
private rawResult;
|
|
10
|
+
private req;
|
|
11
|
+
private isDeposit;
|
|
12
|
+
constructor(params: {
|
|
13
|
+
isDeposit: boolean;
|
|
14
|
+
req: QuoteBscBridgeV2Dto;
|
|
15
|
+
res: QuoteBscBridgeResponse;
|
|
16
|
+
tokenLookupTable: TokenLookupTable;
|
|
17
|
+
});
|
|
18
|
+
getAggregatorName(): AggregatorName;
|
|
19
|
+
selectRoute(): QuoteBscBridgeResponse | undefined;
|
|
20
|
+
getRouteData(): Promise<{
|
|
21
|
+
transferData: AggregatorTransferData;
|
|
22
|
+
swapData: AggregatorSwapData;
|
|
23
|
+
}>;
|
|
24
|
+
}
|
|
25
|
+
export declare class BorosWithdrawResult implements AggregatorResult {
|
|
26
|
+
routes: AggregatorRoute[];
|
|
27
|
+
private rawResult;
|
|
28
|
+
private req;
|
|
29
|
+
constructor(params: {
|
|
30
|
+
req: QuoteWithdrawParams;
|
|
31
|
+
res: QuoteWithdrawBscResponse;
|
|
32
|
+
tokenLookupTable: TokenLookupTable;
|
|
33
|
+
});
|
|
34
|
+
getAggregatorName(): AggregatorName;
|
|
35
|
+
selectRoute(): QuoteWithdrawBscResponse | undefined;
|
|
36
|
+
getRouteData(_routeId: string): Promise<{
|
|
37
|
+
transferData: AggregatorTransferData;
|
|
38
|
+
}>;
|
|
39
|
+
}
|
|
40
|
+
export declare class BorosLzBridgeHelper implements AggregatorHelper {
|
|
41
|
+
private readonly borosCoreSdk;
|
|
42
|
+
private readonly tokenHelper;
|
|
43
|
+
private readonly layerZeroApiUrl;
|
|
44
|
+
aggregatorName: AggregatorName;
|
|
45
|
+
private readonly axios;
|
|
46
|
+
constructor(borosCoreSdk: BorosCoreSdk, tokenHelper: TokenHelper, layerZeroApiUrl?: string);
|
|
47
|
+
getChains(): Promise<AggregatorChain[]>;
|
|
48
|
+
getTokenLookupTable(): Promise<TokenLookupTable>;
|
|
49
|
+
getRouteStatus(txHash: Hex): Promise<AggregatorRouteStatus>;
|
|
50
|
+
private getLayerZeroStatus;
|
|
51
|
+
quoteDeposit(params: QuoteDepositParams): Promise<AggregatorResult>;
|
|
52
|
+
quoteWithdraw(params: QuoteWithdrawParams): Promise<BorosWithdrawResult>;
|
|
53
|
+
}
|
|
@@ -0,0 +1,272 @@
|
|
|
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
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.BorosLzBridgeHelper = exports.BorosWithdrawResult = exports.BorosLzBridgeResult = exports.LAYER_ZERO_SCAN_API = void 0;
|
|
13
|
+
const axios_1 = __importDefault(require("axios"));
|
|
14
|
+
const viem_1 = require("viem");
|
|
15
|
+
const chains_1 = require("viem/chains");
|
|
16
|
+
const addresses_1 = require("../../../../addresses");
|
|
17
|
+
const cacheDecorators_1 = require("../../../../common/cacheDecorators");
|
|
18
|
+
const constants_1 = require("../../../../multicall/constants");
|
|
19
|
+
const token_1 = require("../../../token");
|
|
20
|
+
const AggregatorHelper_1 = require("../../AggregatorHelper");
|
|
21
|
+
const AggregatorHelperErrors_1 = require("../../AggregatorHelperErrors");
|
|
22
|
+
const utils_1 = require("../../helpers/utils");
|
|
23
|
+
exports.LAYER_ZERO_SCAN_API = 'https://scan.layerzero-api.com/v1';
|
|
24
|
+
class BorosLzBridgeResult {
|
|
25
|
+
routes = [];
|
|
26
|
+
rawResult;
|
|
27
|
+
req;
|
|
28
|
+
isDeposit;
|
|
29
|
+
constructor(params) {
|
|
30
|
+
const { isDeposit, req, res, tokenLookupTable } = params;
|
|
31
|
+
this.isDeposit = isDeposit;
|
|
32
|
+
this.req = req;
|
|
33
|
+
this.rawResult = res;
|
|
34
|
+
const fromToken = tokenLookupTable.lookup(chains_1.bsc.id, res.fromToken, true);
|
|
35
|
+
const toToken = tokenLookupTable.lookup(chains_1.arbitrum.id, res.toToken, true);
|
|
36
|
+
this.routes = [
|
|
37
|
+
{
|
|
38
|
+
id: 'boros',
|
|
39
|
+
inputTokenAmount: new token_1.TokenAmount(fromToken, BigInt(res.fromAmount)),
|
|
40
|
+
outputTokenAmount: new token_1.TokenAmount(toToken, BigInt(res.toAmount)),
|
|
41
|
+
minOutputTokenAmount: new token_1.TokenAmount(toToken, BigInt(res.minToAmount)),
|
|
42
|
+
steps: [
|
|
43
|
+
{
|
|
44
|
+
fromTokenAmount: new token_1.TokenAmount(fromToken, BigInt(res.fromAmount)),
|
|
45
|
+
toTokenAmount: new token_1.TokenAmount(toToken, BigInt(res.toAmount)),
|
|
46
|
+
executionDuration: 20,
|
|
47
|
+
feeCosts: res.feeCosts.map((feeCost) => ({
|
|
48
|
+
name: feeCost.name,
|
|
49
|
+
amountUSD: Number(feeCost.amountUsd),
|
|
50
|
+
})),
|
|
51
|
+
gasCosts: res.gasCosts.flatMap((gasCost) => {
|
|
52
|
+
const token = tokenLookupTable.lookup(gasCost.chainId, gasCost.token);
|
|
53
|
+
if (token == null) {
|
|
54
|
+
return [];
|
|
55
|
+
}
|
|
56
|
+
return {
|
|
57
|
+
tokenAmount: new token_1.TokenAmount(token, BigInt(gasCost.amount)),
|
|
58
|
+
amountUSD: Number(gasCost.amountUsd),
|
|
59
|
+
};
|
|
60
|
+
}),
|
|
61
|
+
tool: {
|
|
62
|
+
key: 'boros',
|
|
63
|
+
name: 'LayerZero',
|
|
64
|
+
logoURI: 'https://storage.googleapis.com/prod-pendle-bucket-a/images/assets/pro/ea33e392-1876-46a5-b7ce-c8434b5a7e71.svg',
|
|
65
|
+
},
|
|
66
|
+
},
|
|
67
|
+
],
|
|
68
|
+
},
|
|
69
|
+
];
|
|
70
|
+
}
|
|
71
|
+
getAggregatorName() {
|
|
72
|
+
return AggregatorHelper_1.AggregatorName.BOROS;
|
|
73
|
+
}
|
|
74
|
+
selectRoute() {
|
|
75
|
+
return this.rawResult;
|
|
76
|
+
}
|
|
77
|
+
async getRouteData() {
|
|
78
|
+
if (this.isDeposit) {
|
|
79
|
+
(0, utils_1.ensureDepositBoxAddress)(this.req.fromAddress, this.req.boxId, this.rawResult.tx.to);
|
|
80
|
+
}
|
|
81
|
+
return {
|
|
82
|
+
transferData: {
|
|
83
|
+
aggregatorName: AggregatorHelper_1.AggregatorName.BOROS,
|
|
84
|
+
approvalAddress: (0, addresses_1.toAddress)(this.rawResult.tx.to),
|
|
85
|
+
calldata: this.rawResult.tx.calldata,
|
|
86
|
+
value: BigInt(this.rawResult.tx.value),
|
|
87
|
+
from: (0, addresses_1.toAddress)(this.rawResult.tx.from),
|
|
88
|
+
to: (0, addresses_1.toAddress)(this.rawResult.tx.to),
|
|
89
|
+
chainId: chains_1.bsc.id,
|
|
90
|
+
},
|
|
91
|
+
swapData: {
|
|
92
|
+
tokenSpent: (0, addresses_1.toAddress)(this.req.toToken),
|
|
93
|
+
amountSpent: BigInt(this.rawResult.toAmount),
|
|
94
|
+
minAmountSpent: BigInt(this.rawResult.minToAmount),
|
|
95
|
+
extRouter: viem_1.zeroAddress,
|
|
96
|
+
extCalldata: '0x',
|
|
97
|
+
},
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
exports.BorosLzBridgeResult = BorosLzBridgeResult;
|
|
102
|
+
class BorosWithdrawResult {
|
|
103
|
+
routes = [];
|
|
104
|
+
rawResult;
|
|
105
|
+
req;
|
|
106
|
+
constructor(params) {
|
|
107
|
+
const { req, res, tokenLookupTable } = params;
|
|
108
|
+
this.req = req;
|
|
109
|
+
this.rawResult = res;
|
|
110
|
+
const fromToken = tokenLookupTable.lookup(chains_1.arbitrum.id, res.fromToken, true);
|
|
111
|
+
const toToken = tokenLookupTable.lookup(chains_1.bsc.id, res.toToken, true);
|
|
112
|
+
this.routes = [
|
|
113
|
+
{
|
|
114
|
+
id: 'boros',
|
|
115
|
+
inputTokenAmount: new token_1.TokenAmount(fromToken, BigInt(res.fromAmount)),
|
|
116
|
+
outputTokenAmount: new token_1.TokenAmount(toToken, BigInt(res.toAmount)),
|
|
117
|
+
minOutputTokenAmount: new token_1.TokenAmount(toToken, BigInt(res.minToAmount)),
|
|
118
|
+
steps: [
|
|
119
|
+
{
|
|
120
|
+
fromTokenAmount: new token_1.TokenAmount(fromToken, BigInt(res.fromAmount)),
|
|
121
|
+
toTokenAmount: new token_1.TokenAmount(toToken, BigInt(res.toAmount)),
|
|
122
|
+
executionDuration: 20,
|
|
123
|
+
feeCosts: res.feeCosts.map((feeCost) => ({
|
|
124
|
+
name: feeCost.name,
|
|
125
|
+
amountUSD: Number(feeCost.amountUsd),
|
|
126
|
+
})),
|
|
127
|
+
gasCosts: res.gasCosts.flatMap((gasCost) => {
|
|
128
|
+
const token = tokenLookupTable.lookup(gasCost.chainId, gasCost.token);
|
|
129
|
+
if (token == null) {
|
|
130
|
+
return [];
|
|
131
|
+
}
|
|
132
|
+
return {
|
|
133
|
+
tokenAmount: new token_1.TokenAmount(token, BigInt(gasCost.amount)),
|
|
134
|
+
amountUSD: Number(gasCost.amountUsd),
|
|
135
|
+
};
|
|
136
|
+
}),
|
|
137
|
+
tool: {
|
|
138
|
+
key: 'boros',
|
|
139
|
+
name: 'LayerZero',
|
|
140
|
+
logoURI: 'https://storage.googleapis.com/prod-pendle-bucket-a/images/assets/pro/ea33e392-1876-46a5-b7ce-c8434b5a7e71.svg',
|
|
141
|
+
},
|
|
142
|
+
},
|
|
143
|
+
],
|
|
144
|
+
},
|
|
145
|
+
];
|
|
146
|
+
}
|
|
147
|
+
getAggregatorName() {
|
|
148
|
+
return AggregatorHelper_1.AggregatorName.BOROS;
|
|
149
|
+
}
|
|
150
|
+
selectRoute() {
|
|
151
|
+
return this.rawResult;
|
|
152
|
+
}
|
|
153
|
+
async getRouteData(_routeId) {
|
|
154
|
+
return {
|
|
155
|
+
transferData: {
|
|
156
|
+
aggregatorName: AggregatorHelper_1.AggregatorName.BOROS,
|
|
157
|
+
approvalAddress: (0, addresses_1.toAddress)(this.rawResult.tx.to),
|
|
158
|
+
calldata: this.rawResult.tx.calldata,
|
|
159
|
+
value: BigInt(this.rawResult.tx.value),
|
|
160
|
+
from: (0, addresses_1.toAddress)(this.rawResult.tx.from),
|
|
161
|
+
to: (0, addresses_1.toAddress)(this.rawResult.tx.to),
|
|
162
|
+
chainId: chains_1.arbitrum.id,
|
|
163
|
+
},
|
|
164
|
+
};
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.BorosWithdrawResult = BorosWithdrawResult;
|
|
168
|
+
class BorosLzBridgeHelper {
|
|
169
|
+
borosCoreSdk;
|
|
170
|
+
tokenHelper;
|
|
171
|
+
layerZeroApiUrl;
|
|
172
|
+
aggregatorName = AggregatorHelper_1.AggregatorName.BOROS;
|
|
173
|
+
axios;
|
|
174
|
+
constructor(borosCoreSdk, tokenHelper, layerZeroApiUrl = exports.LAYER_ZERO_SCAN_API) {
|
|
175
|
+
this.borosCoreSdk = borosCoreSdk;
|
|
176
|
+
this.tokenHelper = tokenHelper;
|
|
177
|
+
this.layerZeroApiUrl = layerZeroApiUrl;
|
|
178
|
+
this.axios = axios_1.default.create();
|
|
179
|
+
}
|
|
180
|
+
async getChains() {
|
|
181
|
+
return [
|
|
182
|
+
{
|
|
183
|
+
chainId: chains_1.bsc.id,
|
|
184
|
+
name: 'Binance Smart Chain',
|
|
185
|
+
key: 'bsc',
|
|
186
|
+
coin: 'BNB',
|
|
187
|
+
logoURI: 'https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/chains/bsc.svg',
|
|
188
|
+
},
|
|
189
|
+
];
|
|
190
|
+
}
|
|
191
|
+
async getTokenLookupTable() {
|
|
192
|
+
return this.tokenHelper.getTokenLookupTable();
|
|
193
|
+
}
|
|
194
|
+
async getRouteStatus(txHash) {
|
|
195
|
+
try {
|
|
196
|
+
let lzData;
|
|
197
|
+
try {
|
|
198
|
+
const response = await this.axios.get(`${this.layerZeroApiUrl}/messages/tx/${txHash}`);
|
|
199
|
+
lzData = response.data;
|
|
200
|
+
}
|
|
201
|
+
catch (lzError) {
|
|
202
|
+
if (axios_1.default.isAxiosError(lzError) && lzError.response?.status === 404) {
|
|
203
|
+
return AggregatorHelper_1.AggregatorRouteStatus.PENDING;
|
|
204
|
+
}
|
|
205
|
+
throw lzError;
|
|
206
|
+
}
|
|
207
|
+
switch (lzData.data[0].status.name) {
|
|
208
|
+
case 'DELIVERED':
|
|
209
|
+
return AggregatorHelper_1.AggregatorRouteStatus.DONE;
|
|
210
|
+
case 'FAILED':
|
|
211
|
+
return AggregatorHelper_1.AggregatorRouteStatus.FAILED;
|
|
212
|
+
case 'UNKNOWN':
|
|
213
|
+
return AggregatorHelper_1.AggregatorRouteStatus.NOT_FOUND;
|
|
214
|
+
case 'PAYLOAD_STORED':
|
|
215
|
+
case 'CONFIRMING':
|
|
216
|
+
case 'INFLIGHT':
|
|
217
|
+
return AggregatorHelper_1.AggregatorRouteStatus.PENDING;
|
|
218
|
+
}
|
|
219
|
+
}
|
|
220
|
+
catch (error) {
|
|
221
|
+
throw (0, AggregatorHelperErrors_1.classifyAggregatorError)(AggregatorHelper_1.AggregatorName.BOROS, error, [500, 502, 503, 504], 'getRouteStatus', txHash, () => undefined);
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
async getLayerZeroStatus(txHash) {
|
|
225
|
+
const response = await this.axios.get(`${this.layerZeroApiUrl}/messages/tx/${txHash}`);
|
|
226
|
+
return response.data;
|
|
227
|
+
}
|
|
228
|
+
async quoteDeposit(params) {
|
|
229
|
+
const req = {
|
|
230
|
+
fromToken: params.fromToken,
|
|
231
|
+
toToken: params.toToken,
|
|
232
|
+
amount: params.fromAmount.toString(),
|
|
233
|
+
fromAddress: params.fromAddress,
|
|
234
|
+
boxId: params.boxId,
|
|
235
|
+
};
|
|
236
|
+
try {
|
|
237
|
+
const [{ data }, tokenLookupTable] = await Promise.all([
|
|
238
|
+
this.borosCoreSdk.depositBox.depositBoxControllerQuoteBscBridgeV2(req),
|
|
239
|
+
this.getTokenLookupTable(),
|
|
240
|
+
]);
|
|
241
|
+
return new BorosLzBridgeResult({ isDeposit: true, req, res: data, tokenLookupTable });
|
|
242
|
+
}
|
|
243
|
+
catch (error) {
|
|
244
|
+
throw (0, AggregatorHelperErrors_1.classifyAggregatorError)(AggregatorHelper_1.AggregatorName.BOROS, error, [500, 502, 503, 504], 'quote', req, () => undefined);
|
|
245
|
+
}
|
|
246
|
+
}
|
|
247
|
+
async quoteWithdraw(params) {
|
|
248
|
+
const tokenLookupTable = await this.getTokenLookupTable();
|
|
249
|
+
const tokenId = tokenLookupTable.lookupTokenId(chains_1.arbitrum.id, params.fromToken);
|
|
250
|
+
const req = {
|
|
251
|
+
fromAddress: params.fromAddress,
|
|
252
|
+
tokenId,
|
|
253
|
+
amount: params.fromAmount.toString(),
|
|
254
|
+
toAddress: params.fromAddress,
|
|
255
|
+
};
|
|
256
|
+
try {
|
|
257
|
+
const { data } = await this.borosCoreSdk.depositBox.depositBoxControllerQuoteWithdrawBsc(req);
|
|
258
|
+
return new BorosWithdrawResult({ req: params, res: data, tokenLookupTable });
|
|
259
|
+
}
|
|
260
|
+
catch (error) {
|
|
261
|
+
throw (0, AggregatorHelperErrors_1.classifyAggregatorError)(AggregatorHelper_1.AggregatorName.BOROS, error, [500, 502, 503, 504], 'quoteWithdraw', req, () => undefined);
|
|
262
|
+
}
|
|
263
|
+
}
|
|
264
|
+
}
|
|
265
|
+
exports.BorosLzBridgeHelper = BorosLzBridgeHelper;
|
|
266
|
+
__decorate([
|
|
267
|
+
(0, cacheDecorators_1.GlobalCache)({
|
|
268
|
+
generateLookupKey: () => 'BorosLzBridgeHelper.getTokenLookupTable',
|
|
269
|
+
ttl_ms: constants_1.MILLISECONDS_IN_A_MINUTE * 10,
|
|
270
|
+
})
|
|
271
|
+
], BorosLzBridgeHelper.prototype, "getTokenLookupTable", null);
|
|
272
|
+
//# sourceMappingURL=BorosHelper.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"BorosHelper.js","sourceRoot":"","sources":["../../../../../src/entities/crossChainDeposit/aggregators/Boros/BorosHelper.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,kDAA6C;AAC7C,+BAAiD;AACjD,wCAA4C;AAC5C,qDAAkD;AAQlD,wEAAiE;AAEjE,+DAA2E;AAC3E,0CAA6C;AAC7C,6DAWgC;AAChC,yEAAuE;AAEvE,+CAA8D;AAGjD,QAAA,mBAAmB,GAAG,mCAAmC,CAAC;AAEvE,MAAa,mBAAmB;IAC9B,MA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ClH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,aAAa,CAAC,MAA2B;QAC7C,MAAM,gBAAgB,GAAG,MAAM,IAAI,CAAC,mBAAmB,EAAE,CAAC;QAC1D,MAAM,OAAO,GAAG,gBAAgB,CAAC,aAAa,CAAC,iBAAQ,CAAC,EAAE,EAAE,MAAM,CAAC,SAAS,CAAC,CAAC;QAE9E,MAAM,GAAG,GAAwB;YAC/B,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,OAAO;YACP,MAAM,EAAE,MAAM,CAAC,UAAU,CAAC,QAAQ,EAAE;YACpC,SAAS,EAAE,MAAM,CAAC,WAAW;SAC9B,CAAC;QAEF,IAAI,CAAC;YACH,MAAM,EAAE,IAAI,EAAE,GAAG,MAAM,IAAI,CAAC,YAAY,CAAC,UAAU,CAAC,oCAAoC,CAAC,GAAG,CAAC,CAAC;YAE9F,OAAO,IAAI,mBAAmB,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE,IAAI,EAAE,gBAAgB,EAAE,CAAC,CAAC;QAC/E,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,eAAe,EACf,GAAG,EACH,GAAG,EAAE,CAAC,SAAS,CAChB,CAAC;QACJ,CAAC;IACH,CAAC;CACF;AA5HD,kDA4HC;AA/FO;IAJL,IAAA,6BAAW,EAA6C;QACvD,iBAAiB,EAAE,GAAG,EAAE,CAAC,yCAAyC;QAClE,MAAM,EAAE,oCAAwB,GAAG,EAAE;KACtC,CAAC;8DAGD"}
|
|
@@ -1,36 +1,2 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
import { BorosCoreSdk } from '../../../../backend/secrettune/module';
|
|
4
|
-
import { AggregatorChain, AggregatorHelper, AggregatorName, AggregatorResult, AggregatorRoute, AggregatorRouteStatus, AggregatorSwapData, AggregatorTransferData, QuoteDepositParams } from '../../AggregatorHelper';
|
|
5
|
-
import { TokenHelper, TokenLookupTable } from '../../helpers/TokenHelper';
|
|
6
|
-
export declare const LAYER_ZERO_SCAN_API = "https://scan.layerzero-api.com/v1";
|
|
7
|
-
export declare class BorosLzBridgeResult implements AggregatorResult {
|
|
8
|
-
routes: AggregatorRoute[];
|
|
9
|
-
private rawResult;
|
|
10
|
-
private req;
|
|
11
|
-
private isDeposit;
|
|
12
|
-
constructor(params: {
|
|
13
|
-
isDeposit: boolean;
|
|
14
|
-
req: QuoteBscBridgeV2Dto;
|
|
15
|
-
res: QuoteBscBridgeResponse;
|
|
16
|
-
tokenLookupTable: TokenLookupTable;
|
|
17
|
-
});
|
|
18
|
-
getAggregatorName(): AggregatorName;
|
|
19
|
-
selectRoute(): QuoteBscBridgeResponse | undefined;
|
|
20
|
-
getRouteData(): Promise<{
|
|
21
|
-
transferData: AggregatorTransferData;
|
|
22
|
-
swapData: AggregatorSwapData;
|
|
23
|
-
}>;
|
|
24
|
-
}
|
|
25
|
-
export declare class BorosLzBridgeHelper implements AggregatorHelper {
|
|
26
|
-
private readonly borosCoreSdk;
|
|
27
|
-
private readonly tokenHelper;
|
|
28
|
-
private readonly layerZeroApiUrl;
|
|
29
|
-
aggregatorName: AggregatorName;
|
|
30
|
-
private readonly axios;
|
|
31
|
-
constructor(borosCoreSdk: BorosCoreSdk, tokenHelper: TokenHelper, layerZeroApiUrl?: string);
|
|
32
|
-
getChains(): Promise<AggregatorChain[]>;
|
|
33
|
-
getTokenLookupTable(): Promise<TokenLookupTable>;
|
|
34
|
-
getRouteStatus(txHash: Hex): Promise<AggregatorRouteStatus>;
|
|
35
|
-
quoteDeposit(params: QuoteDepositParams): Promise<AggregatorResult>;
|
|
36
|
-
}
|
|
1
|
+
export * from './BorosHelper';
|
|
2
|
+
export * from './types';
|
|
@@ -1,191 +1,19 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
|
|
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);
|
|
10
15
|
};
|
|
11
16
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const viem_1 = require("viem");
|
|
15
|
-
const chains_1 = require("viem/chains");
|
|
16
|
-
const addresses_1 = require("../../../../addresses");
|
|
17
|
-
const cacheDecorators_1 = require("../../../../common/cacheDecorators");
|
|
18
|
-
const constants_1 = require("../../../../multicall/constants");
|
|
19
|
-
const token_1 = require("../../../token");
|
|
20
|
-
const AggregatorHelper_1 = require("../../AggregatorHelper");
|
|
21
|
-
const AggregatorHelperErrors_1 = require("../../AggregatorHelperErrors");
|
|
22
|
-
const utils_1 = require("../../helpers/utils");
|
|
23
|
-
exports.LAYER_ZERO_SCAN_API = 'https://scan.layerzero-api.com/v1';
|
|
24
|
-
class BorosLzBridgeResult {
|
|
25
|
-
routes = [];
|
|
26
|
-
rawResult;
|
|
27
|
-
req;
|
|
28
|
-
isDeposit;
|
|
29
|
-
constructor(params) {
|
|
30
|
-
const { isDeposit, req, res, tokenLookupTable } = params;
|
|
31
|
-
this.isDeposit = isDeposit;
|
|
32
|
-
this.req = req;
|
|
33
|
-
this.rawResult = res;
|
|
34
|
-
const fromToken = tokenLookupTable.lookup(chains_1.bsc.id, res.fromToken, true);
|
|
35
|
-
const toToken = tokenLookupTable.lookup(chains_1.arbitrum.id, res.toToken, true);
|
|
36
|
-
this.routes = [
|
|
37
|
-
{
|
|
38
|
-
id: 'boros',
|
|
39
|
-
inputTokenAmount: new token_1.TokenAmount(fromToken, BigInt(res.fromAmount)),
|
|
40
|
-
outputTokenAmount: new token_1.TokenAmount(toToken, BigInt(res.toAmount)),
|
|
41
|
-
minOutputTokenAmount: new token_1.TokenAmount(toToken, BigInt(res.minToAmount)),
|
|
42
|
-
steps: [
|
|
43
|
-
{
|
|
44
|
-
fromTokenAmount: new token_1.TokenAmount(fromToken, BigInt(res.fromAmount)),
|
|
45
|
-
toTokenAmount: new token_1.TokenAmount(toToken, BigInt(res.toAmount)),
|
|
46
|
-
executionDuration: 20,
|
|
47
|
-
feeCosts: res.feeCosts.map((feeCost) => ({
|
|
48
|
-
name: feeCost.name,
|
|
49
|
-
amountUSD: Number(feeCost.amountUsd),
|
|
50
|
-
})),
|
|
51
|
-
gasCosts: res.gasCosts.flatMap((gasCost) => {
|
|
52
|
-
const token = tokenLookupTable.lookup(gasCost.chainId, gasCost.token);
|
|
53
|
-
if (token == null) {
|
|
54
|
-
return [];
|
|
55
|
-
}
|
|
56
|
-
return {
|
|
57
|
-
tokenAmount: new token_1.TokenAmount(token, BigInt(gasCost.amount)),
|
|
58
|
-
amountUSD: Number(gasCost.amountUsd),
|
|
59
|
-
};
|
|
60
|
-
}),
|
|
61
|
-
tool: {
|
|
62
|
-
key: 'boros',
|
|
63
|
-
name: 'LayerZero',
|
|
64
|
-
logoURI: 'https://storage.googleapis.com/prod-pendle-bucket-a/images/assets/pro/ea33e392-1876-46a5-b7ce-c8434b5a7e71.svg',
|
|
65
|
-
},
|
|
66
|
-
},
|
|
67
|
-
],
|
|
68
|
-
},
|
|
69
|
-
];
|
|
70
|
-
}
|
|
71
|
-
getAggregatorName() {
|
|
72
|
-
return AggregatorHelper_1.AggregatorName.BOROS;
|
|
73
|
-
}
|
|
74
|
-
selectRoute() {
|
|
75
|
-
return this.rawResult;
|
|
76
|
-
}
|
|
77
|
-
async getRouteData() {
|
|
78
|
-
if (this.isDeposit) {
|
|
79
|
-
(0, utils_1.ensureDepositBoxAddress)(this.req.fromAddress, this.req.boxId, this.rawResult.tx.to);
|
|
80
|
-
}
|
|
81
|
-
return {
|
|
82
|
-
transferData: {
|
|
83
|
-
aggregatorName: AggregatorHelper_1.AggregatorName.BOROS,
|
|
84
|
-
approvalAddress: (0, addresses_1.toAddress)(this.rawResult.tx.to),
|
|
85
|
-
calldata: this.rawResult.tx.calldata,
|
|
86
|
-
value: BigInt(this.rawResult.tx.value),
|
|
87
|
-
from: (0, addresses_1.toAddress)(this.rawResult.tx.from),
|
|
88
|
-
to: (0, addresses_1.toAddress)(this.rawResult.tx.to),
|
|
89
|
-
chainId: chains_1.bsc.id,
|
|
90
|
-
},
|
|
91
|
-
swapData: {
|
|
92
|
-
tokenSpent: (0, addresses_1.toAddress)(this.req.toToken),
|
|
93
|
-
amountSpent: BigInt(this.rawResult.toAmount),
|
|
94
|
-
extRouter: viem_1.zeroAddress,
|
|
95
|
-
extCalldata: '0x',
|
|
96
|
-
},
|
|
97
|
-
};
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
exports.BorosLzBridgeResult = BorosLzBridgeResult;
|
|
101
|
-
class BorosLzBridgeHelper {
|
|
102
|
-
borosCoreSdk;
|
|
103
|
-
tokenHelper;
|
|
104
|
-
layerZeroApiUrl;
|
|
105
|
-
aggregatorName = AggregatorHelper_1.AggregatorName.BOROS;
|
|
106
|
-
axios;
|
|
107
|
-
constructor(borosCoreSdk, tokenHelper, layerZeroApiUrl = exports.LAYER_ZERO_SCAN_API) {
|
|
108
|
-
this.borosCoreSdk = borosCoreSdk;
|
|
109
|
-
this.tokenHelper = tokenHelper;
|
|
110
|
-
this.layerZeroApiUrl = layerZeroApiUrl;
|
|
111
|
-
this.axios = axios_1.default.create();
|
|
112
|
-
}
|
|
113
|
-
async getChains() {
|
|
114
|
-
return [
|
|
115
|
-
{
|
|
116
|
-
chainId: chains_1.bsc.id,
|
|
117
|
-
name: 'Binance Smart Chain',
|
|
118
|
-
key: 'bsc',
|
|
119
|
-
coin: 'BNB',
|
|
120
|
-
logoURI: 'https://raw.githubusercontent.com/lifinance/types/main/src/assets/icons/chains/bsc.svg',
|
|
121
|
-
},
|
|
122
|
-
];
|
|
123
|
-
}
|
|
124
|
-
async getTokenLookupTable() {
|
|
125
|
-
return this.tokenHelper.getTokenLookupTable();
|
|
126
|
-
}
|
|
127
|
-
async getRouteStatus(txHash) {
|
|
128
|
-
try {
|
|
129
|
-
const data = {
|
|
130
|
-
bridgeTxHash: undefined,
|
|
131
|
-
status: AggregatorHelper_1.AggregatorRouteStatus.PENDING,
|
|
132
|
-
};
|
|
133
|
-
if (data.bridgeTxHash == null) {
|
|
134
|
-
return data.status;
|
|
135
|
-
}
|
|
136
|
-
let lzData;
|
|
137
|
-
try {
|
|
138
|
-
const response = await this.axios.get(`${this.layerZeroApiUrl}/messages/tx/${data.bridgeTxHash}`);
|
|
139
|
-
lzData = response.data;
|
|
140
|
-
}
|
|
141
|
-
catch (lzError) {
|
|
142
|
-
if (axios_1.default.isAxiosError(lzError) && lzError.response?.status === 404) {
|
|
143
|
-
return AggregatorHelper_1.AggregatorRouteStatus.PENDING;
|
|
144
|
-
}
|
|
145
|
-
throw lzError;
|
|
146
|
-
}
|
|
147
|
-
switch (lzData.data[0].status.name) {
|
|
148
|
-
case 'DELIVERED':
|
|
149
|
-
return AggregatorHelper_1.AggregatorRouteStatus.DONE;
|
|
150
|
-
case 'FAILED':
|
|
151
|
-
return AggregatorHelper_1.AggregatorRouteStatus.FAILED;
|
|
152
|
-
case 'UNKNOWN':
|
|
153
|
-
return AggregatorHelper_1.AggregatorRouteStatus.NOT_FOUND;
|
|
154
|
-
case 'PAYLOAD_STORED':
|
|
155
|
-
case 'CONFIRMING':
|
|
156
|
-
case 'INFLIGHT':
|
|
157
|
-
return AggregatorHelper_1.AggregatorRouteStatus.PENDING;
|
|
158
|
-
}
|
|
159
|
-
}
|
|
160
|
-
catch (error) {
|
|
161
|
-
throw (0, AggregatorHelperErrors_1.classifyAggregatorError)(AggregatorHelper_1.AggregatorName.BOROS, error, [500, 502, 503, 504], 'getRouteStatus', txHash, () => undefined);
|
|
162
|
-
}
|
|
163
|
-
}
|
|
164
|
-
async quoteDeposit(params) {
|
|
165
|
-
const req = {
|
|
166
|
-
fromToken: params.fromToken,
|
|
167
|
-
toToken: params.toToken,
|
|
168
|
-
amount: params.fromAmount.toString(),
|
|
169
|
-
fromAddress: params.fromAddress,
|
|
170
|
-
boxId: params.boxId,
|
|
171
|
-
};
|
|
172
|
-
try {
|
|
173
|
-
const [{ data }, tokenLookupTable] = await Promise.all([
|
|
174
|
-
this.borosCoreSdk.depositBox.depositBoxControllerQuoteBscBridgeV2(req),
|
|
175
|
-
this.getTokenLookupTable(),
|
|
176
|
-
]);
|
|
177
|
-
return new BorosLzBridgeResult({ isDeposit: true, req, res: data, tokenLookupTable });
|
|
178
|
-
}
|
|
179
|
-
catch (error) {
|
|
180
|
-
throw (0, AggregatorHelperErrors_1.classifyAggregatorError)(AggregatorHelper_1.AggregatorName.BOROS, error, [500, 502, 503, 504], 'quote', req, () => undefined);
|
|
181
|
-
}
|
|
182
|
-
}
|
|
183
|
-
}
|
|
184
|
-
exports.BorosLzBridgeHelper = BorosLzBridgeHelper;
|
|
185
|
-
__decorate([
|
|
186
|
-
(0, cacheDecorators_1.GlobalCache)({
|
|
187
|
-
generateLookupKey: () => 'BorosLzBridgeHelper.getTokenLookupTable',
|
|
188
|
-
ttl_ms: constants_1.MILLISECONDS_IN_A_MINUTE * 10,
|
|
189
|
-
})
|
|
190
|
-
], BorosLzBridgeHelper.prototype, "getTokenLookupTable", null);
|
|
17
|
+
__exportStar(require("./BorosHelper"), exports);
|
|
18
|
+
__exportStar(require("./types"), exports);
|
|
191
19
|
//# sourceMappingURL=index.js.map
|