@reyaxyz/common 0.344.3 → 0.346.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +1 -1
- package/dist/incentives-api-types.js.map +1 -1
- package/dist/trading-api-types.js.map +1 -1
- package/dist/transactions/executeTransaction.js +8 -123
- package/dist/transactions/executeTransaction.js.map +1 -1
- package/dist/types/incentives-api-types.d.ts +6 -2
- package/dist/types/incentives-api-types.d.ts.map +1 -1
- package/dist/types/trading-api-types.d.ts +103 -1
- package/dist/types/trading-api-types.d.ts.map +1 -1
- package/dist/types/transactions/executeTransaction.d.ts +2 -15
- package/dist/types/transactions/executeTransaction.d.ts.map +1 -1
- package/dist/types/utils/layerzero.d.ts +22 -0
- package/dist/types/utils/layerzero.d.ts.map +1 -0
- package/dist/types/utils/token/batch-token-getters.d.ts +0 -5
- package/dist/types/utils/token/batch-token-getters.d.ts.map +1 -1
- package/dist/types/utils/token/token-getters.d.ts +0 -2
- package/dist/types/utils/token/token-getters.d.ts.map +1 -1
- package/dist/utils/layerzero.js +31 -0
- package/dist/utils/layerzero.js.map +1 -0
- package/dist/utils/token/batch-token-getters.js +13 -64
- package/dist/utils/token/batch-token-getters.js.map +1 -1
- package/dist/utils/token/token-getters.js +1 -42
- package/dist/utils/token/token-getters.js.map +1 -1
- package/package.json +2 -2
- package/src/incentives-api-types.ts +11 -5
- package/src/trading-api-types.ts +105 -1
- package/src/transactions/executeTransaction.ts +2 -130
- package/src/utils/layerzero.ts +66 -0
- package/src/utils/token/batch-token-getters.ts +0 -28
- package/src/utils/token/token-getters.ts +0 -29
- package/dist/types/utils/layerzero/index.d.ts +0 -3
- package/dist/types/utils/layerzero/index.d.ts.map +0 -1
- package/dist/types/utils/layerzero/oft-config.d.ts +0 -4
- package/dist/types/utils/layerzero/oft-config.d.ts.map +0 -1
- package/dist/types/utils/layerzero/types.d.ts +0 -23
- package/dist/types/utils/layerzero/types.d.ts.map +0 -1
- package/dist/utils/layerzero/index.js +0 -19
- package/dist/utils/layerzero/index.js.map +0 -1
- package/dist/utils/layerzero/oft-config.js +0 -29
- package/dist/utils/layerzero/oft-config.js.map +0 -1
- package/dist/utils/layerzero/types.js +0 -3
- package/dist/utils/layerzero/types.js.map +0 -1
- package/src/utils/layerzero/index.ts +0 -2
- package/src/utils/layerzero/oft-config.ts +0 -32
- package/src/utils/layerzero/types.ts +0 -25
|
@@ -1,25 +1,10 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
JsonRpcProvider,
|
|
4
|
-
JsonRpcSigner,
|
|
5
|
-
Network,
|
|
6
|
-
Signer,
|
|
7
|
-
} from 'ethers';
|
|
8
|
-
import { MoneyInOutChainId, ReyaChainId } from '../types';
|
|
1
|
+
import { JsonRpcSigner, Signer } from 'ethers';
|
|
2
|
+
import { ReyaChainId } from '../types';
|
|
9
3
|
import { ContractType, getAddress } from './contractAddresses';
|
|
10
4
|
import { abi } from './abis/Errors.json';
|
|
11
5
|
import { ErrorDecoder } from 'ethers-decode-error';
|
|
12
6
|
import type { DecodedError } from 'ethers-decode-error';
|
|
13
7
|
import { getGasBuffer } from './txHelpers';
|
|
14
|
-
import { getPublicRpcUrlsOrThrow } from '../utils';
|
|
15
|
-
import { Interface } from 'ethers';
|
|
16
|
-
|
|
17
|
-
const reyaChainIdRPCMapper: { [key: number]: string } = {
|
|
18
|
-
[ReyaChainId.reyaNetwork]:
|
|
19
|
-
'https://rpc.reya.network/263e76b89da84d478fd2b6e8783a1cfe',
|
|
20
|
-
[ReyaChainId.reyaCronos]:
|
|
21
|
-
'https://rpc.reya-cronos.gelato.digital/263e76b89da84d478fd2b6e8783a1cfe',
|
|
22
|
-
};
|
|
23
8
|
|
|
24
9
|
export type Transaction = {
|
|
25
10
|
from: string;
|
|
@@ -29,108 +14,6 @@ export type Transaction = {
|
|
|
29
14
|
};
|
|
30
15
|
const errorDecoder = ErrorDecoder.create([abi]);
|
|
31
16
|
|
|
32
|
-
export async function estimateGas(
|
|
33
|
-
signer: Signer | JsonRpcSigner,
|
|
34
|
-
data: string,
|
|
35
|
-
value: string,
|
|
36
|
-
chainId: number,
|
|
37
|
-
targetContract: ContractType | string,
|
|
38
|
-
): Promise<
|
|
39
|
-
Transaction & {
|
|
40
|
-
gasLimit: bigint;
|
|
41
|
-
maxPriorityFeePerGas?: bigint;
|
|
42
|
-
maxFeePerGas?: bigint;
|
|
43
|
-
}
|
|
44
|
-
> {
|
|
45
|
-
const accountAddress = await signer.getAddress();
|
|
46
|
-
|
|
47
|
-
return estimateGasGivenAddress(
|
|
48
|
-
accountAddress,
|
|
49
|
-
data,
|
|
50
|
-
value,
|
|
51
|
-
chainId,
|
|
52
|
-
targetContract,
|
|
53
|
-
);
|
|
54
|
-
}
|
|
55
|
-
|
|
56
|
-
// TODO: deprecate this when /executeGelato is gone
|
|
57
|
-
export async function estimateGasGivenAddress(
|
|
58
|
-
accountAddress: string,
|
|
59
|
-
data: string,
|
|
60
|
-
value: string,
|
|
61
|
-
chainId: number,
|
|
62
|
-
targetContract: ContractType | string,
|
|
63
|
-
): Promise<
|
|
64
|
-
Transaction & {
|
|
65
|
-
gasLimit: bigint;
|
|
66
|
-
maxPriorityFeePerGas?: bigint;
|
|
67
|
-
maxFeePerGas?: bigint;
|
|
68
|
-
}
|
|
69
|
-
> {
|
|
70
|
-
const contractAddress = Object.values(ContractType).includes(
|
|
71
|
-
targetContract as ContractType,
|
|
72
|
-
)
|
|
73
|
-
? getAddress(chainId, targetContract as ContractType)
|
|
74
|
-
: targetContract;
|
|
75
|
-
|
|
76
|
-
const tx = {
|
|
77
|
-
from: accountAddress, // @todo Update with relayer address
|
|
78
|
-
to: contractAddress,
|
|
79
|
-
data,
|
|
80
|
-
...(value && value !== '0' ? { value: value } : {}),
|
|
81
|
-
};
|
|
82
|
-
|
|
83
|
-
const gasLimit: bigint = BigInt('5000000'); // hardcode to 5m gas limit if fails to get estimate
|
|
84
|
-
|
|
85
|
-
try {
|
|
86
|
-
const network = new Network('Reya', chainId);
|
|
87
|
-
const provider = new JsonRpcProvider(
|
|
88
|
-
reyaChainIdRPCMapper[chainId],
|
|
89
|
-
network,
|
|
90
|
-
{
|
|
91
|
-
staticNetwork: network,
|
|
92
|
-
pollingInterval: 50,
|
|
93
|
-
},
|
|
94
|
-
);
|
|
95
|
-
await provider.call(tx);
|
|
96
|
-
} catch (error) {
|
|
97
|
-
const decodedError = await errorDecoder.decode(error);
|
|
98
|
-
const reason = customReasonMapper(decodedError);
|
|
99
|
-
console.error(
|
|
100
|
-
`Error simulating transaction account address ${accountAddress} reason ${decodedError?.name} ${decodedError} ${error}`,
|
|
101
|
-
);
|
|
102
|
-
throw new Error(reason);
|
|
103
|
-
}
|
|
104
|
-
|
|
105
|
-
if (Object.values(ReyaChainId).includes(chainId as ReyaChainId)) {
|
|
106
|
-
const maxPriorityFeePerGas: bigint = BigInt('0');
|
|
107
|
-
const maxFeePerGas: bigint = BigInt('100000000');
|
|
108
|
-
return { ...tx, gasLimit, maxPriorityFeePerGas, maxFeePerGas };
|
|
109
|
-
}
|
|
110
|
-
|
|
111
|
-
return { ...tx, gasLimit };
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
export async function estimateGasFromTxAndChainId(
|
|
115
|
-
chainId: ReyaChainId | MoneyInOutChainId,
|
|
116
|
-
tx: ethers.TransactionRequest,
|
|
117
|
-
): Promise<bigint> {
|
|
118
|
-
const rpcUrls = getPublicRpcUrlsOrThrow(chainId);
|
|
119
|
-
let lastError = null;
|
|
120
|
-
|
|
121
|
-
for (const url of rpcUrls) {
|
|
122
|
-
try {
|
|
123
|
-
const provider = new ethers.JsonRpcProvider(url);
|
|
124
|
-
const estimation = await provider.estimateGas(tx);
|
|
125
|
-
return addGasBuffer(estimation);
|
|
126
|
-
} catch (error) {
|
|
127
|
-
lastError = error;
|
|
128
|
-
}
|
|
129
|
-
}
|
|
130
|
-
|
|
131
|
-
throw new Error('All RPC URLs failed; last error: ' + lastError);
|
|
132
|
-
}
|
|
133
|
-
|
|
134
17
|
async function estimateGasExternalChains(
|
|
135
18
|
signer: Signer | JsonRpcSigner,
|
|
136
19
|
data: string,
|
|
@@ -224,14 +107,3 @@ const customReasonMapper = ({ name, reason }: DecodedError): string => {
|
|
|
224
107
|
return reason ?? 'Error executing transaction';
|
|
225
108
|
}
|
|
226
109
|
};
|
|
227
|
-
|
|
228
|
-
function addGasBuffer(estimation: bigint): bigint {
|
|
229
|
-
return (estimation * BigInt(120)) / BigInt(100);
|
|
230
|
-
}
|
|
231
|
-
|
|
232
|
-
export async function decodeErrorBytes(returnData: string): Promise<string> {
|
|
233
|
-
const INTERFACE = new Interface(abi);
|
|
234
|
-
const decodedError = INTERFACE.parseError(returnData);
|
|
235
|
-
console.log(decodedError);
|
|
236
|
-
return `${decodedError?.name}: ${decodedError?.args}` || 'Error not found';
|
|
237
|
-
}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
|
|
3
|
+
export type OFTMessagingFee = {
|
|
4
|
+
nativeFee: string;
|
|
5
|
+
lzTokenFee: string;
|
|
6
|
+
};
|
|
7
|
+
|
|
8
|
+
enum LzComposerOperationType {
|
|
9
|
+
NONE = 0,
|
|
10
|
+
DEPOSIT_SPOT_ACCOUNT = 1,
|
|
11
|
+
DEPOSIT_ACCOUNT = 2,
|
|
12
|
+
}
|
|
13
|
+
|
|
14
|
+
export type OFTSendParams = {
|
|
15
|
+
dstEid: number;
|
|
16
|
+
to: string;
|
|
17
|
+
amountLD: bigint;
|
|
18
|
+
minAmountLD: bigint;
|
|
19
|
+
extraOptions: string;
|
|
20
|
+
composeMsg: string;
|
|
21
|
+
oftCmd: string;
|
|
22
|
+
};
|
|
23
|
+
|
|
24
|
+
const buildComposeMsg = (
|
|
25
|
+
accountId: number,
|
|
26
|
+
collateralAddressInReyaPeriphery: string,
|
|
27
|
+
) => {
|
|
28
|
+
const opType = LzComposerOperationType.DEPOSIT_ACCOUNT;
|
|
29
|
+
const opData = ethers.AbiCoder.defaultAbiCoder().encode(
|
|
30
|
+
['uint128', 'address'],
|
|
31
|
+
[accountId, collateralAddressInReyaPeriphery],
|
|
32
|
+
);
|
|
33
|
+
|
|
34
|
+
const composeMsg = ethers.AbiCoder.defaultAbiCoder().encode(
|
|
35
|
+
['uint8', 'bytes'],
|
|
36
|
+
[opType, opData],
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return composeMsg;
|
|
40
|
+
};
|
|
41
|
+
|
|
42
|
+
export const buildOFTSendParamsToDepositInMA = (params: {
|
|
43
|
+
amount: bigint;
|
|
44
|
+
collateralAddressInReyaPeriphery: string;
|
|
45
|
+
dstEid: number;
|
|
46
|
+
extraOptions: string;
|
|
47
|
+
receiverAddress: string;
|
|
48
|
+
marginAccountId: number;
|
|
49
|
+
}): OFTSendParams => {
|
|
50
|
+
const receiverBytes32 = ethers.zeroPadValue(params.receiverAddress, 32);
|
|
51
|
+
|
|
52
|
+
const composeMsg = buildComposeMsg(
|
|
53
|
+
params.marginAccountId,
|
|
54
|
+
params.collateralAddressInReyaPeriphery,
|
|
55
|
+
);
|
|
56
|
+
|
|
57
|
+
return {
|
|
58
|
+
dstEid: params.dstEid,
|
|
59
|
+
to: receiverBytes32,
|
|
60
|
+
amountLD: params.amount,
|
|
61
|
+
minAmountLD: params.amount,
|
|
62
|
+
extraOptions: params.extraOptions,
|
|
63
|
+
composeMsg,
|
|
64
|
+
oftCmd: '0x',
|
|
65
|
+
};
|
|
66
|
+
};
|
|
@@ -1,14 +1,8 @@
|
|
|
1
1
|
import { ethers } from 'ethers';
|
|
2
2
|
import { MoneyInOutChainId, ReyaChainId } from '../../types';
|
|
3
3
|
import { getPublicRpcUrlsOrThrow } from '../network';
|
|
4
|
-
import { exponentialBackoff } from '../retry';
|
|
5
4
|
import { descale, getERC20TokenContract } from './utils';
|
|
6
5
|
|
|
7
|
-
export type GetETHBalanceBatchArgs = {
|
|
8
|
-
walletAddress: string;
|
|
9
|
-
chain: MoneyInOutChainId | ReyaChainId;
|
|
10
|
-
};
|
|
11
|
-
|
|
12
6
|
export type GetERC20BalanceBatchArgs = {
|
|
13
7
|
tokenAddress: string;
|
|
14
8
|
tokenDecimals: number;
|
|
@@ -24,28 +18,6 @@ export type GetERC20AllowanceBatchArgs = {
|
|
|
24
18
|
chain: MoneyInOutChainId | ReyaChainId;
|
|
25
19
|
};
|
|
26
20
|
|
|
27
|
-
export const getETHBalanceBatch = async ({
|
|
28
|
-
walletAddress,
|
|
29
|
-
chain,
|
|
30
|
-
}: GetETHBalanceBatchArgs): Promise<number> => {
|
|
31
|
-
const rpcUrls = getPublicRpcUrlsOrThrow(chain);
|
|
32
|
-
let lastError = null;
|
|
33
|
-
|
|
34
|
-
for (const url of rpcUrls) {
|
|
35
|
-
try {
|
|
36
|
-
const provider = new ethers.JsonRpcProvider(url);
|
|
37
|
-
const currentBalance = await exponentialBackoff(() =>
|
|
38
|
-
provider.getBalance(ethers.getAddress(walletAddress)),
|
|
39
|
-
);
|
|
40
|
-
return descale(18)(currentBalance);
|
|
41
|
-
} catch (error) {
|
|
42
|
-
lastError = error;
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
|
|
46
|
-
throw new Error('All RPC URLs failed; last error: ' + lastError);
|
|
47
|
-
};
|
|
48
|
-
|
|
49
21
|
export const getERC20BalanceBatch = async ({
|
|
50
22
|
tokenAddress,
|
|
51
23
|
tokenDecimals,
|
|
@@ -40,32 +40,3 @@ export const getERC20Allowance = async ({
|
|
|
40
40
|
? Number.MAX_SAFE_INTEGER
|
|
41
41
|
: descale(tokenDecimals)(allowance);
|
|
42
42
|
};
|
|
43
|
-
|
|
44
|
-
export const getERC20Balance = async ({
|
|
45
|
-
tokenAddress,
|
|
46
|
-
tokenDecimals,
|
|
47
|
-
walletAddress,
|
|
48
|
-
subject,
|
|
49
|
-
}: GetERC20BalanceArgs): Promise<number> => {
|
|
50
|
-
const token = getERC20TokenContract(tokenAddress, subject);
|
|
51
|
-
|
|
52
|
-
const currentBalance = await exponentialBackoff(() =>
|
|
53
|
-
token.balanceOf(walletAddress),
|
|
54
|
-
);
|
|
55
|
-
|
|
56
|
-
return descale(tokenDecimals)(currentBalance);
|
|
57
|
-
};
|
|
58
|
-
|
|
59
|
-
export const getETHBalance = async ({
|
|
60
|
-
walletAddress,
|
|
61
|
-
subject,
|
|
62
|
-
}: GetETHBalanceArgs): Promise<number> => {
|
|
63
|
-
const provider = subject.provider;
|
|
64
|
-
if (!provider) throw new Error("User's provider not found");
|
|
65
|
-
|
|
66
|
-
const currentBalance = await exponentialBackoff(() =>
|
|
67
|
-
provider.getBalance(ethers.getAddress(walletAddress)),
|
|
68
|
-
);
|
|
69
|
-
|
|
70
|
-
return descale(18)(currentBalance);
|
|
71
|
-
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"/","sources":["utils/layerzero/index.ts"],"names":[],"mappings":"AAAA,cAAc,SAAS,CAAC;AACxB,cAAc,cAAc,CAAC"}
|
|
@@ -1,4 +0,0 @@
|
|
|
1
|
-
import { MoneyInOutChainId, ReyaChainId, TokenName } from '../../types';
|
|
2
|
-
export declare const getLzEndpointId: (chainId: MoneyInOutChainId | ReyaChainId) => number;
|
|
3
|
-
export declare const getOFTTokenAddress: (tokenName: TokenName, chainId: MoneyInOutChainId | ReyaChainId) => string;
|
|
4
|
-
//# sourceMappingURL=oft-config.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oft-config.d.ts","sourceRoot":"/","sources":["utils/layerzero/oft-config.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AAGxE,eAAO,MAAM,eAAe,YACjB,iBAAiB,GAAG,WAAW,KACvC,MAaF,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAClB,SAAS,WACX,iBAAiB,GAAG,WAAW,KACvC,MAQF,CAAC"}
|
|
@@ -1,23 +0,0 @@
|
|
|
1
|
-
export type OFTSendParam = {
|
|
2
|
-
dstEid: number;
|
|
3
|
-
to: string;
|
|
4
|
-
amountLD: bigint;
|
|
5
|
-
minAmountLD: bigint;
|
|
6
|
-
extraOptions: string;
|
|
7
|
-
composeMsg: string;
|
|
8
|
-
oftCmd: string;
|
|
9
|
-
};
|
|
10
|
-
export type OFTMessagingFee = {
|
|
11
|
-
nativeFee: bigint;
|
|
12
|
-
lzTokenFee: bigint;
|
|
13
|
-
};
|
|
14
|
-
export type OFTMessagingReceipt = {
|
|
15
|
-
guid: string;
|
|
16
|
-
nonce: bigint;
|
|
17
|
-
fee: OFTMessagingFee;
|
|
18
|
-
};
|
|
19
|
-
export type OFTReceipt = {
|
|
20
|
-
amountSentLD: bigint;
|
|
21
|
-
amountReceivedLD: bigint;
|
|
22
|
-
};
|
|
23
|
-
//# sourceMappingURL=types.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"/","sources":["utils/layerzero/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,YAAY,GAAG;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,CAAC;IACrB,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;CAChB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG;IAC5B,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,mBAAmB,GAAG;IAChC,IAAI,EAAE,MAAM,CAAC;IACb,KAAK,EAAE,MAAM,CAAC;IACd,GAAG,EAAE,eAAe,CAAC;CACtB,CAAC;AAEF,MAAM,MAAM,UAAU,GAAG;IACvB,YAAY,EAAE,MAAM,CAAC;IACrB,gBAAgB,EAAE,MAAM,CAAC;CAC1B,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("./types"), exports);
|
|
18
|
-
__exportStar(require("./oft-config"), exports);
|
|
19
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"/","sources":["utils/layerzero/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,0CAAwB;AACxB,+CAA6B","sourcesContent":["export * from './types';\nexport * from './oft-config';\n"]}
|
|
@@ -1,29 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getOFTTokenAddress = exports.getLzEndpointId = void 0;
|
|
4
|
-
var types_1 = require("../../types");
|
|
5
|
-
var token_info_getters_1 = require("../token/token-info-getters");
|
|
6
|
-
var getLzEndpointId = function (chainId) {
|
|
7
|
-
var _a;
|
|
8
|
-
var chainToLzEid = (_a = {},
|
|
9
|
-
_a[types_1.MoneyInOutChainId.ethereumMainnet] = 30101,
|
|
10
|
-
_a[types_1.MoneyInOutChainId.ethereumSepolia] = 40161,
|
|
11
|
-
_a[types_1.ReyaChainId.reyaNetwork] = 30313,
|
|
12
|
-
_a[types_1.ReyaChainId.reyaCronos] = 40319,
|
|
13
|
-
_a);
|
|
14
|
-
var lzEid = chainToLzEid[chainId];
|
|
15
|
-
if (!lzEid) {
|
|
16
|
-
throw new Error("No LayerZero endpoint ID found for chain ".concat(chainId));
|
|
17
|
-
}
|
|
18
|
-
return lzEid;
|
|
19
|
-
};
|
|
20
|
-
exports.getLzEndpointId = getLzEndpointId;
|
|
21
|
-
var getOFTTokenAddress = function (tokenName, chainId) {
|
|
22
|
-
var tokenInfo = (0, token_info_getters_1.getTokenInfoByName)(tokenName, chainId);
|
|
23
|
-
if (!tokenInfo.isOFT) {
|
|
24
|
-
throw new Error("getOFTTokenAddress: token ".concat(tokenName, " on chain ").concat(chainId, " is not an OFT token"));
|
|
25
|
-
}
|
|
26
|
-
return tokenInfo.address;
|
|
27
|
-
};
|
|
28
|
-
exports.getOFTTokenAddress = getOFTTokenAddress;
|
|
29
|
-
//# sourceMappingURL=oft-config.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"oft-config.js","sourceRoot":"/","sources":["utils/layerzero/oft-config.ts"],"names":[],"mappings":";;;AAAA,qCAAwE;AACxE,kEAAiE;AAE1D,IAAM,eAAe,GAAG,UAC7B,OAAwC;;IAExC,IAAM,YAAY;QAChB,GAAC,yBAAiB,CAAC,eAAe,IAAG,KAAK;QAC1C,GAAC,yBAAiB,CAAC,eAAe,IAAG,KAAK;QAC1C,GAAC,mBAAW,CAAC,WAAW,IAAG,KAAK;QAChC,GAAC,mBAAW,CAAC,UAAU,IAAG,KAAK;WAChC,CAAC;IAEF,IAAM,KAAK,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC;IACpC,IAAI,CAAC,KAAK,EAAE,CAAC;QACX,MAAM,IAAI,KAAK,CAAC,mDAA4C,OAAO,CAAE,CAAC,CAAC;IACzE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAfW,QAAA,eAAe,mBAe1B;AAEK,IAAM,kBAAkB,GAAG,UAChC,SAAoB,EACpB,OAAwC;IAExC,IAAM,SAAS,GAAG,IAAA,uCAAkB,EAAC,SAAS,EAAE,OAAO,CAAC,CAAC;IACzD,IAAI,CAAC,SAAS,CAAC,KAAK,EAAE,CAAC;QACrB,MAAM,IAAI,KAAK,CACb,oCAA6B,SAAS,uBAAa,OAAO,yBAAsB,CACjF,CAAC;IACJ,CAAC;IACD,OAAO,SAAS,CAAC,OAAO,CAAC;AAC3B,CAAC,CAAC;AAXW,QAAA,kBAAkB,sBAW7B","sourcesContent":["import { MoneyInOutChainId, ReyaChainId, TokenName } from '../../types';\nimport { getTokenInfoByName } from '../token/token-info-getters';\n\nexport const getLzEndpointId = (\n chainId: MoneyInOutChainId | ReyaChainId,\n): number => {\n const chainToLzEid: Record<number, number> = {\n [MoneyInOutChainId.ethereumMainnet]: 30101,\n [MoneyInOutChainId.ethereumSepolia]: 40161,\n [ReyaChainId.reyaNetwork]: 30313,\n [ReyaChainId.reyaCronos]: 40319,\n };\n\n const lzEid = chainToLzEid[chainId];\n if (!lzEid) {\n throw new Error(`No LayerZero endpoint ID found for chain ${chainId}`);\n }\n return lzEid;\n};\n\nexport const getOFTTokenAddress = (\n tokenName: TokenName,\n chainId: MoneyInOutChainId | ReyaChainId,\n): string => {\n const tokenInfo = getTokenInfoByName(tokenName, chainId);\n if (!tokenInfo.isOFT) {\n throw new Error(\n `getOFTTokenAddress: token ${tokenName} on chain ${chainId} is not an OFT token`,\n );\n }\n return tokenInfo.address;\n};\n"]}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"/","sources":["utils/layerzero/types.ts"],"names":[],"mappings":"","sourcesContent":["export type OFTSendParam = {\n dstEid: number;\n to: string;\n amountLD: bigint;\n minAmountLD: bigint;\n extraOptions: string;\n composeMsg: string;\n oftCmd: string;\n};\n\nexport type OFTMessagingFee = {\n nativeFee: bigint;\n lzTokenFee: bigint;\n};\n\nexport type OFTMessagingReceipt = {\n guid: string;\n nonce: bigint;\n fee: OFTMessagingFee;\n};\n\nexport type OFTReceipt = {\n amountSentLD: bigint;\n amountReceivedLD: bigint;\n};\n"]}
|
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
import { MoneyInOutChainId, ReyaChainId, TokenName } from '../../types';
|
|
2
|
-
import { getTokenInfoByName } from '../token/token-info-getters';
|
|
3
|
-
|
|
4
|
-
export const getLzEndpointId = (
|
|
5
|
-
chainId: MoneyInOutChainId | ReyaChainId,
|
|
6
|
-
): number => {
|
|
7
|
-
const chainToLzEid: Record<number, number> = {
|
|
8
|
-
[MoneyInOutChainId.ethereumMainnet]: 30101,
|
|
9
|
-
[MoneyInOutChainId.ethereumSepolia]: 40161,
|
|
10
|
-
[ReyaChainId.reyaNetwork]: 30313,
|
|
11
|
-
[ReyaChainId.reyaCronos]: 40319,
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
const lzEid = chainToLzEid[chainId];
|
|
15
|
-
if (!lzEid) {
|
|
16
|
-
throw new Error(`No LayerZero endpoint ID found for chain ${chainId}`);
|
|
17
|
-
}
|
|
18
|
-
return lzEid;
|
|
19
|
-
};
|
|
20
|
-
|
|
21
|
-
export const getOFTTokenAddress = (
|
|
22
|
-
tokenName: TokenName,
|
|
23
|
-
chainId: MoneyInOutChainId | ReyaChainId,
|
|
24
|
-
): string => {
|
|
25
|
-
const tokenInfo = getTokenInfoByName(tokenName, chainId);
|
|
26
|
-
if (!tokenInfo.isOFT) {
|
|
27
|
-
throw new Error(
|
|
28
|
-
`getOFTTokenAddress: token ${tokenName} on chain ${chainId} is not an OFT token`,
|
|
29
|
-
);
|
|
30
|
-
}
|
|
31
|
-
return tokenInfo.address;
|
|
32
|
-
};
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
export type OFTSendParam = {
|
|
2
|
-
dstEid: number;
|
|
3
|
-
to: string;
|
|
4
|
-
amountLD: bigint;
|
|
5
|
-
minAmountLD: bigint;
|
|
6
|
-
extraOptions: string;
|
|
7
|
-
composeMsg: string;
|
|
8
|
-
oftCmd: string;
|
|
9
|
-
};
|
|
10
|
-
|
|
11
|
-
export type OFTMessagingFee = {
|
|
12
|
-
nativeFee: bigint;
|
|
13
|
-
lzTokenFee: bigint;
|
|
14
|
-
};
|
|
15
|
-
|
|
16
|
-
export type OFTMessagingReceipt = {
|
|
17
|
-
guid: string;
|
|
18
|
-
nonce: bigint;
|
|
19
|
-
fee: OFTMessagingFee;
|
|
20
|
-
};
|
|
21
|
-
|
|
22
|
-
export type OFTReceipt = {
|
|
23
|
-
amountSentLD: bigint;
|
|
24
|
-
amountReceivedLD: bigint;
|
|
25
|
-
};
|