@pendle/sdk-boros 1.0.12-cross-deposit-1 → 1.0.12
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 +1 -11
- package/dist/addresses.js +1 -23
- package/dist/addresses.js.map +1 -1
- package/dist/backend/secrettune/BorosCoreSDK.d.ts +21 -165
- package/dist/backend/secrettune/BorosCoreSDK.js +6 -72
- package/dist/backend/secrettune/BorosCoreSDK.js.map +1 -1
- package/dist/backend/secrettune/BorosSendTxsBotSDK.d.ts +3 -4
- package/dist/backend/secrettune/BorosSendTxsBotSDK.js.map +1 -1
- package/dist/backend/secrettune/module.d.ts +0 -6
- package/dist/backend/secrettune/module.js +0 -25
- package/dist/backend/secrettune/module.js.map +1 -1
- package/dist/contracts/contracts.factory.d.ts +3 -9
- package/dist/contracts/contracts.factory.js +4 -16
- package/dist/contracts/contracts.factory.js.map +1 -1
- package/dist/entities/index.d.ts +0 -2
- package/dist/entities/index.js +0 -2
- package/dist/entities/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/types/common.d.ts +0 -16
- package/dist/utils/signing/index.d.ts +1 -1
- package/dist/utils/signing/index.js +1 -2
- package/dist/utils/signing/index.js.map +1 -1
- package/dist/utils/signing/sensitive.d.ts +1 -2
- package/dist/utils/signing/sensitive.js +0 -29
- package/dist/utils/signing/sensitive.js.map +1 -1
- package/package.json +1 -1
- package/dist/backend/secrettune/PendleV2SDK.d.ts +0 -2281
- package/dist/backend/secrettune/PendleV2SDK.js +0 -970
- package/dist/backend/secrettune/PendleV2SDK.js.map +0 -1
- package/dist/common/chainId.d.ts +0 -12
- package/dist/common/chainId.js +0 -17
- package/dist/common/chainId.js.map +0 -1
- package/dist/contracts/abis/viemAbiDepositBoxFactory.d.ts +0 -75
- package/dist/contracts/abis/viemAbiDepositBoxFactory.js +0 -103
- package/dist/contracts/abis/viemAbiDepositBoxFactory.js.map +0 -1
- package/dist/contracts/abis/viemAbiRouter.d.ts +0 -1983
- package/dist/contracts/abis/viemAbiRouter.js +0 -2549
- package/dist/contracts/abis/viemAbiRouter.js.map +0 -1
- package/dist/contracts/deposit-box-factory.d.ts +0 -86
- package/dist/contracts/deposit-box-factory.js +0 -16
- package/dist/contracts/deposit-box-factory.js.map +0 -1
- package/dist/contracts/erc20.d.ts +0 -158
- package/dist/contracts/erc20.js +0 -52
- package/dist/contracts/erc20.js.map +0 -1
- package/dist/contracts/router.d.ts +0 -1987
- package/dist/contracts/router.js +0 -12
- package/dist/contracts/router.js.map +0 -1
- package/dist/entities/crossChainDeposit/AggregatorHelper.d.ts +0 -109
- package/dist/entities/crossChainDeposit/AggregatorHelper.js +0 -26
- package/dist/entities/crossChainDeposit/AggregatorHelper.js.map +0 -1
- package/dist/entities/crossChainDeposit/AggregatorHelperErrors.d.ts +0 -80
- package/dist/entities/crossChainDeposit/AggregatorHelperErrors.js +0 -116
- package/dist/entities/crossChainDeposit/AggregatorHelperErrors.js.map +0 -1
- package/dist/entities/crossChainDeposit/Depositor.d.ts +0 -31
- package/dist/entities/crossChainDeposit/Depositor.js +0 -64
- package/dist/entities/crossChainDeposit/Depositor.js.map +0 -1
- package/dist/entities/crossChainDeposit/aggregators/Boros/index.d.ts +0 -36
- package/dist/entities/crossChainDeposit/aggregators/Boros/index.js +0 -191
- package/dist/entities/crossChainDeposit/aggregators/Boros/index.js.map +0 -1
- package/dist/entities/crossChainDeposit/aggregators/Boros/types.d.ts +0 -10
- package/dist/entities/crossChainDeposit/aggregators/Boros/types.js +0 -3
- package/dist/entities/crossChainDeposit/aggregators/Boros/types.js.map +0 -1
- package/dist/entities/crossChainDeposit/aggregators/Lifi/index.d.ts +0 -39
- package/dist/entities/crossChainDeposit/aggregators/Lifi/index.js +0 -159
- package/dist/entities/crossChainDeposit/aggregators/Lifi/index.js.map +0 -1
- package/dist/entities/crossChainDeposit/aggregators/Lifi/types.d.ts +0 -186
- package/dist/entities/crossChainDeposit/aggregators/Lifi/types.js +0 -28
- package/dist/entities/crossChainDeposit/aggregators/Lifi/types.js.map +0 -1
- package/dist/entities/crossChainDeposit/aggregators/Pendle/index.d.ts +0 -38
- package/dist/entities/crossChainDeposit/aggregators/Pendle/index.js +0 -171
- package/dist/entities/crossChainDeposit/aggregators/Pendle/index.js.map +0 -1
- package/dist/entities/crossChainDeposit/helpers/TokenHelper.d.ts +0 -23
- package/dist/entities/crossChainDeposit/helpers/TokenHelper.js +0 -67
- package/dist/entities/crossChainDeposit/helpers/TokenHelper.js.map +0 -1
- package/dist/entities/crossChainDeposit/helpers/utils.d.ts +0 -4
- package/dist/entities/crossChainDeposit/helpers/utils.js +0 -25
- package/dist/entities/crossChainDeposit/helpers/utils.js.map +0 -1
- package/dist/entities/crossChainDeposit/index.d.ts +0 -2
- package/dist/entities/crossChainDeposit/index.js +0 -19
- package/dist/entities/crossChainDeposit/index.js.map +0 -1
- package/dist/entities/token/Token.d.ts +0 -31
- package/dist/entities/token/Token.js +0 -61
- package/dist/entities/token/Token.js.map +0 -1
- package/dist/entities/token/index.d.ts +0 -1
- package/dist/entities/token/index.js +0 -18
- package/dist/entities/token/index.js.map +0 -1
- package/dist/errors/PendleSdkError.d.ts +0 -7
- package/dist/errors/PendleSdkError.js +0 -15
- package/dist/errors/PendleSdkError.js.map +0 -1
|
@@ -1,38 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,171 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../../../src/entities/crossChainDeposit/aggregators/Pendle/index.ts"],"names":[],"mappings":";;;;;;;;;AAAA,+BAAgG;AAChG,wCAAuC;AACvC,qDAAkD;AAGlD,wEAAiE;AAEjE,+DAA2E;AAC3E,gDAAmD;AACnD,6DAUgC;AAChC,yEAAuE;AAEvE,+CAA8D;AAE9D,MAAa,gBAAgB;IAC3B,MAAM,GAAsB,EAAE,CAAC;IACvB,SAAS,CAAqB;IAC9B,GAAG,CAAqB;IACxB,MAAM,CAAmB;IAEjC,YAAY,MAKX;QACC,MAAM,EAAE,GAAG,EAAE,GAAG,EAAE,gBAAgB,EAAE,MAAM,EAAE,GAAG,MAAM,CAAC;QACtD,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;QACrB,IAAI,CAAC,GAAG,GAAG,GAAG,CAAC;QACf,MAAM,SAAS,GAAG,gBAAgB,CAAC,MAAM,CAAC,iBAAQ,CAAC,EAAE,EAAE,GAAG,CAAC,SAAoB,EAAE,IAAI,CAAC,CAAC;QACvF,MAAM,OAAO,GAAG,gBAAgB,CAAC,MAAM,CAAC,i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,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"}
|
|
@@ -1,23 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,67 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,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AU,IAAI,MAAM,EAAE,UAAU,EAAE;QACvG,MAAM,EAAE,oCAAwB,GAAG,EAAE;KACtC,CAAC;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"}
|
|
@@ -1,4 +0,0 @@
|
|
|
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;
|
|
@@ -1,25 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|
|
@@ -1,19 +0,0 @@
|
|
|
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("./Depositor"), exports);
|
|
18
|
-
__exportStar(require("./AggregatorHelper"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entities/crossChainDeposit/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,8CAA4B;AAC5B,qDAAmC"}
|
|
@@ -1,31 +0,0 @@
|
|
|
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
|
-
}
|
|
@@ -1,61 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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,E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@
|
|
|
1
|
-
export * from './Token';
|
|
@@ -1,18 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/entities/token/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB"}
|
|
@@ -1,15 +0,0 @@
|
|
|
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
|
|
@@ -1 +0,0 @@
|
|
|
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"}
|