@reyaxyz/common 0.135.2 → 0.137.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/services/getSocketAddresses.js +12 -22
- package/dist/services/getSocketAddresses.js.map +1 -1
- package/dist/transactions/executeTransaction.js +10 -5
- package/dist/transactions/executeTransaction.js.map +1 -1
- package/dist/types/services/getSocketAddresses.d.ts +32 -2
- package/dist/types/services/getSocketAddresses.d.ts.map +1 -1
- package/dist/types/transactions/executeTransaction.d.ts +2 -2
- package/dist/types/transactions/executeTransaction.d.ts.map +1 -1
- package/dist/types/types.d.ts +1 -9
- package/dist/types/types.d.ts.map +1 -1
- package/dist/types/utils/network.d.ts +1 -1
- package/dist/types/utils/network.d.ts.map +1 -1
- package/dist/types/utils/token/batch-token-getters.d.ts +22 -0
- package/dist/types/utils/token/batch-token-getters.d.ts.map +1 -0
- package/dist/types/utils/token/index.d.ts +6 -0
- package/dist/types/utils/token/index.d.ts.map +1 -0
- package/dist/types/utils/token/token-getters.d.ts +23 -0
- package/dist/types/utils/token/token-getters.d.ts.map +1 -0
- package/dist/types/utils/token/token-info-getters.d.ts +6 -0
- package/dist/types/utils/token/token-info-getters.d.ts.map +1 -0
- package/dist/types/utils/token/token-info.d.ts +3 -0
- package/dist/types/utils/token/token-info.d.ts.map +1 -0
- package/dist/types/utils/token/utils.d.ts +7 -0
- package/dist/types/utils/token/utils.d.ts.map +1 -0
- package/dist/types.js.map +1 -1
- package/dist/utils/network.js +2 -0
- package/dist/utils/network.js.map +1 -1
- package/dist/utils/token/batch-token-getters.js +175 -0
- package/dist/utils/token/batch-token-getters.js.map +1 -0
- package/dist/utils/token/index.js +22 -0
- package/dist/utils/token/index.js.map +1 -0
- package/dist/utils/token/token-getters.js +104 -0
- package/dist/utils/token/token-getters.js.map +1 -0
- package/dist/utils/token/token-info-getters.js +49 -0
- package/dist/utils/token/token-info-getters.js.map +1 -0
- package/dist/utils/{token-info.js → token/token-info.js} +1 -1
- package/dist/utils/token/token-info.js.map +1 -0
- package/dist/utils/token/utils.js +46 -0
- package/dist/utils/token/utils.js.map +1 -0
- package/package.json +2 -2
- package/src/services/getSocketAddresses.ts +3 -23
- package/src/transactions/executeTransaction.ts +9 -5
- package/src/types.ts +1 -11
- package/src/utils/network.ts +5 -2
- package/src/utils/token/batch-token-getters.ts +111 -0
- package/src/utils/token/index.ts +5 -0
- package/src/utils/token/token-getters.ts +71 -0
- package/src/utils/token/token-info-getters.ts +84 -0
- package/src/utils/{token-info.ts → token/token-info.ts} +1 -1
- package/src/utils/token/utils.ts +49 -0
- package/dist/types/utils/token-info.d.ts +0 -3
- package/dist/types/utils/token-info.d.ts.map +0 -1
- package/dist/types/utils/token.d.ts +0 -49
- package/dist/types/utils/token.d.ts.map +0 -1
- package/dist/utils/token-info.js.map +0 -1
- package/dist/utils/token.js +0 -340
- package/dist/utils/token.js.map +0 -1
- package/src/utils/token.ts +0 -317
|
@@ -2,7 +2,6 @@ import {
|
|
|
2
2
|
ReyaChainId,
|
|
3
3
|
GetSocketConnectorsParams,
|
|
4
4
|
Address,
|
|
5
|
-
GetSocketControllerParams,
|
|
6
5
|
MoneyInOutChainId,
|
|
7
6
|
GetSocketVaultParams,
|
|
8
7
|
SocketTokenConnectors,
|
|
@@ -12,8 +11,8 @@ import {
|
|
|
12
11
|
import {
|
|
13
12
|
getMoneyInOutNetworksFromReyaChainId,
|
|
14
13
|
getReyaNetworkFromMoneyInOutChainId,
|
|
15
|
-
|
|
16
|
-
|
|
14
|
+
convertToAddress,
|
|
15
|
+
} from '../utils';
|
|
17
16
|
|
|
18
17
|
import * as REYA_CRONOS from '../utils/socket/reyaCronos.json';
|
|
19
18
|
import * as REYA_NETWORK from '../utils/socket/reyaNetwork.json';
|
|
@@ -62,7 +61,7 @@ export type SocketConnectorAddresses = {
|
|
|
62
61
|
['FAST']?: string;
|
|
63
62
|
};
|
|
64
63
|
|
|
65
|
-
const getSocketDeploymentJSON = (
|
|
64
|
+
export const getSocketDeploymentJSON = (
|
|
66
65
|
reyaChainId: ReyaChainId,
|
|
67
66
|
): SocketDeploymentAddresses => {
|
|
68
67
|
switch (reyaChainId) {
|
|
@@ -111,25 +110,6 @@ export const getSocketConnectors = (
|
|
|
111
110
|
};
|
|
112
111
|
};
|
|
113
112
|
|
|
114
|
-
export const getSocketController = (
|
|
115
|
-
params: GetSocketControllerParams,
|
|
116
|
-
): Address => {
|
|
117
|
-
const deploymentJSON = getSocketDeploymentJSON(params.reyaChainId);
|
|
118
|
-
const controller = (
|
|
119
|
-
deploymentJSON?.[params.reyaChainId]?.[
|
|
120
|
-
params.tokenName
|
|
121
|
-
] as SocketAppChainAddresses
|
|
122
|
-
)?.[SocketSuperBridgeContracts.Controller];
|
|
123
|
-
|
|
124
|
-
if (!controller) {
|
|
125
|
-
throw new Error(
|
|
126
|
-
`getSocketController: controller not found ${JSON.stringify(params)}`,
|
|
127
|
-
);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
return convertToAddress(controller);
|
|
131
|
-
};
|
|
132
|
-
|
|
133
113
|
export const getSocketVault = (params: GetSocketVaultParams): Address => {
|
|
134
114
|
const reyaChainId = getReyaNetworkFromMoneyInOutChainId(
|
|
135
115
|
params.moneyInOutChainId,
|
|
@@ -1,11 +1,15 @@
|
|
|
1
|
-
import { JsonRpcSigner, Signer } from 'ethers';
|
|
1
|
+
import { ethers, JsonRpcSigner, Signer } from 'ethers';
|
|
2
2
|
import { ReyaChainId } from '../types';
|
|
3
3
|
import { ContractType, getAddress } from './contractAddresses';
|
|
4
|
-
import { getGasBuffer } from './txHelpers';
|
|
5
4
|
import { abi } from './abis/Errors.json';
|
|
6
5
|
import { ErrorDecoder } from 'ethers-decode-error';
|
|
7
6
|
import type { DecodedError } from 'ethers-decode-error';
|
|
8
7
|
|
|
8
|
+
const reyaChainIdRPCMapper: { [key: number]: string } = {
|
|
9
|
+
[ReyaChainId.reyaNetwork]: 'https://rpc.reya.network',
|
|
10
|
+
[ReyaChainId.reyaCronos]: 'https://rpc.reya-cronos.gelato.digital',
|
|
11
|
+
};
|
|
12
|
+
|
|
9
13
|
export type Transaction = {
|
|
10
14
|
from: string;
|
|
11
15
|
to: string;
|
|
@@ -41,11 +45,11 @@ export async function estimateGas(
|
|
|
41
45
|
...(value && value !== '0' ? { value: value } : {}),
|
|
42
46
|
};
|
|
43
47
|
|
|
44
|
-
|
|
48
|
+
const gasLimit: bigint = BigInt('5000000'); // hardcode to 5m gas limit if fails to get estimate
|
|
45
49
|
|
|
46
50
|
try {
|
|
47
|
-
const
|
|
48
|
-
|
|
51
|
+
const provider = ethers.getDefaultProvider(reyaChainIdRPCMapper[chainId]);
|
|
52
|
+
await provider.call(tx);
|
|
49
53
|
} catch (error) {
|
|
50
54
|
const decodedError = await errorDecoder.decode(error);
|
|
51
55
|
const reason = customReasonMapper(decodedError);
|
package/src/types.ts
CHANGED
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
import { Signer } from 'ethers';
|
|
2
|
-
|
|
3
1
|
export type Address = Lowercase<string>;
|
|
4
2
|
export type TokenName = Uppercase<string>;
|
|
5
3
|
|
|
@@ -279,11 +277,6 @@ export type GetSocketConnectorsParams = {
|
|
|
279
277
|
tokenName: TokenName;
|
|
280
278
|
};
|
|
281
279
|
|
|
282
|
-
export type GetSocketControllerParams = {
|
|
283
|
-
reyaChainId: ReyaChainId;
|
|
284
|
-
tokenName: TokenName;
|
|
285
|
-
};
|
|
286
|
-
|
|
287
280
|
export type GetSocketVaultParams = {
|
|
288
281
|
moneyInOutChainId: MoneyInOutChainId;
|
|
289
282
|
tokenName: TokenName;
|
|
@@ -418,11 +411,8 @@ export type GetFundingRateChartDataResult = {
|
|
|
418
411
|
fundingRate: number;
|
|
419
412
|
};
|
|
420
413
|
|
|
421
|
-
export type
|
|
414
|
+
export type GetBalancesForBridgeArgs = {
|
|
422
415
|
walletAddress: string;
|
|
423
|
-
tokenAddress: LpPoolEntity['tokenAddress'];
|
|
424
|
-
spenderAddress: string;
|
|
425
|
-
subject: Signer;
|
|
426
416
|
};
|
|
427
417
|
|
|
428
418
|
export type DepthSimulationState = {
|
package/src/utils/network.ts
CHANGED
|
@@ -76,7 +76,10 @@ export const chainIdToExplorerURL: {
|
|
|
76
76
|
[ReyaChainId.reyaCronos]: 'https://reya-cronos.blockscout.com',
|
|
77
77
|
};
|
|
78
78
|
|
|
79
|
-
export const ChainRpcUrls: {
|
|
79
|
+
export const ChainRpcUrls: {
|
|
80
|
+
[key in MoneyInOutChainId | ReyaChainId]: string[];
|
|
81
|
+
} = {
|
|
82
|
+
[ReyaChainId.reyaNetwork]: ['https://rpc.reya.network'],
|
|
80
83
|
[MoneyInOutChainId.ethereumMainnet]: [
|
|
81
84
|
'https://mainnet.gateway.tenderly.co',
|
|
82
85
|
'https://eth.llamarpc.com',
|
|
@@ -118,7 +121,7 @@ export const ChainRpcUrls: { [key in MoneyInOutChainId]: string[] } = {
|
|
|
118
121
|
'https://base.gateway.tenderly.co/2LHAD54IBvgXiVQdhE9mIF',
|
|
119
122
|
],
|
|
120
123
|
// Add the rest of the mainnet URLs above
|
|
121
|
-
|
|
124
|
+
[ReyaChainId.reyaCronos]: ['https://rpc.reya-cronos.gelato.digital'],
|
|
122
125
|
[MoneyInOutChainId.polygonMumbai]: [
|
|
123
126
|
'https://polygon-mumbai.gateway.tenderly.co',
|
|
124
127
|
'https://polygon-mumbai-bor-rpc.publicnode.com',
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { MoneyInOutChainId, ReyaChainId } from '../../types';
|
|
3
|
+
import { ChainRpcUrls } from '../network';
|
|
4
|
+
import { exponentialBackoff } from '../retry';
|
|
5
|
+
import { descale, getERC20TokenContract } from './utils';
|
|
6
|
+
|
|
7
|
+
export type GetETHBalanceBatchArgs = {
|
|
8
|
+
walletAddress: string;
|
|
9
|
+
chain: MoneyInOutChainId | ReyaChainId;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export type GetERC20BalanceBatchArgs = {
|
|
13
|
+
tokenAddress: string;
|
|
14
|
+
tokenDecimals: number;
|
|
15
|
+
walletAddress: string;
|
|
16
|
+
chain: MoneyInOutChainId | ReyaChainId;
|
|
17
|
+
};
|
|
18
|
+
|
|
19
|
+
export type GetERC20AllowanceBatchArgs = {
|
|
20
|
+
tokenAddress: string;
|
|
21
|
+
tokenDecimals: number;
|
|
22
|
+
walletAddress: string;
|
|
23
|
+
spenderAddress: string;
|
|
24
|
+
chain: MoneyInOutChainId | ReyaChainId;
|
|
25
|
+
};
|
|
26
|
+
|
|
27
|
+
export const getETHBalanceBatch = async ({
|
|
28
|
+
walletAddress,
|
|
29
|
+
chain,
|
|
30
|
+
}: GetETHBalanceBatchArgs): Promise<number> => {
|
|
31
|
+
const rpcUrls = ChainRpcUrls[chain];
|
|
32
|
+
if (!rpcUrls || rpcUrls.length === 0) {
|
|
33
|
+
throw new Error('No RPC URLs configured for the chain: ' + chain);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
let lastError = null;
|
|
37
|
+
|
|
38
|
+
for (const url of rpcUrls) {
|
|
39
|
+
try {
|
|
40
|
+
const provider = new ethers.JsonRpcProvider(url);
|
|
41
|
+
const currentBalance = await exponentialBackoff(() =>
|
|
42
|
+
provider.getBalance(ethers.getAddress(walletAddress)),
|
|
43
|
+
);
|
|
44
|
+
return descale(18)(currentBalance);
|
|
45
|
+
} catch (error) {
|
|
46
|
+
lastError = error;
|
|
47
|
+
}
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
throw new Error('All RPC URLs failed; last error: ' + lastError);
|
|
51
|
+
};
|
|
52
|
+
|
|
53
|
+
export const getERC20BalanceBatch = async ({
|
|
54
|
+
tokenAddress,
|
|
55
|
+
tokenDecimals,
|
|
56
|
+
walletAddress,
|
|
57
|
+
chain,
|
|
58
|
+
}: GetERC20BalanceBatchArgs): Promise<number> => {
|
|
59
|
+
const rpcUrls = ChainRpcUrls[chain];
|
|
60
|
+
if (!rpcUrls || rpcUrls.length === 0) {
|
|
61
|
+
throw new Error('No RPC URLs configured for the chain: ' + chain);
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
let lastError = null;
|
|
65
|
+
|
|
66
|
+
for (const url of rpcUrls) {
|
|
67
|
+
try {
|
|
68
|
+
const provider = new ethers.JsonRpcProvider(url);
|
|
69
|
+
const token = getERC20TokenContract(tokenAddress, provider);
|
|
70
|
+
const currentBalance = await token.balanceOf(walletAddress);
|
|
71
|
+
|
|
72
|
+
return descale(tokenDecimals)(currentBalance);
|
|
73
|
+
} catch (error) {
|
|
74
|
+
lastError = error;
|
|
75
|
+
}
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
throw new Error('All RPC URLs failed; last error: ' + lastError);
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export const getERC20AllowanceBatch = async ({
|
|
82
|
+
tokenAddress,
|
|
83
|
+
tokenDecimals,
|
|
84
|
+
walletAddress,
|
|
85
|
+
spenderAddress,
|
|
86
|
+
chain,
|
|
87
|
+
}: GetERC20AllowanceBatchArgs): Promise<number> => {
|
|
88
|
+
const rpcUrls = ChainRpcUrls[chain];
|
|
89
|
+
if (!rpcUrls || rpcUrls.length === 0) {
|
|
90
|
+
throw new Error('No RPC URLs configured for the chain: ' + chain);
|
|
91
|
+
}
|
|
92
|
+
|
|
93
|
+
let lastError = null;
|
|
94
|
+
|
|
95
|
+
for (const url of rpcUrls) {
|
|
96
|
+
try {
|
|
97
|
+
const provider = new ethers.JsonRpcProvider(url);
|
|
98
|
+
const token = getERC20TokenContract(tokenAddress, provider);
|
|
99
|
+
const currentBalance = await token.allowance(
|
|
100
|
+
walletAddress,
|
|
101
|
+
spenderAddress,
|
|
102
|
+
);
|
|
103
|
+
|
|
104
|
+
return descale(tokenDecimals)(currentBalance);
|
|
105
|
+
} catch (error) {
|
|
106
|
+
lastError = error;
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
|
|
110
|
+
throw new Error('All RPC URLs failed; last error: ' + lastError);
|
|
111
|
+
};
|
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { exponentialBackoff } from '../retry';
|
|
3
|
+
import { LpPoolEntity } from '../../types';
|
|
4
|
+
import { getERC20TokenContract, scale, descale } from './utils';
|
|
5
|
+
|
|
6
|
+
export type GetERC20BalanceArgs = {
|
|
7
|
+
tokenAddress: string;
|
|
8
|
+
tokenDecimals: number;
|
|
9
|
+
walletAddress: string;
|
|
10
|
+
subject: ethers.Signer | ethers.Provider;
|
|
11
|
+
};
|
|
12
|
+
|
|
13
|
+
export type GetETHBalanceArgs = {
|
|
14
|
+
walletAddress: string;
|
|
15
|
+
subject: ethers.Signer | ethers.Provider;
|
|
16
|
+
};
|
|
17
|
+
|
|
18
|
+
export type GetERC20AllowanceArgs = {
|
|
19
|
+
walletAddress: string;
|
|
20
|
+
tokenAddress: LpPoolEntity['tokenAddress'];
|
|
21
|
+
tokenDecimals: number;
|
|
22
|
+
spenderAddress: string;
|
|
23
|
+
subject: ethers.Signer;
|
|
24
|
+
};
|
|
25
|
+
|
|
26
|
+
export const getERC20Allowance = async ({
|
|
27
|
+
walletAddress,
|
|
28
|
+
tokenAddress,
|
|
29
|
+
tokenDecimals,
|
|
30
|
+
spenderAddress,
|
|
31
|
+
subject,
|
|
32
|
+
}: GetERC20AllowanceArgs): Promise<number> => {
|
|
33
|
+
const tokenContract = getERC20TokenContract(tokenAddress, subject);
|
|
34
|
+
|
|
35
|
+
const allowance = await exponentialBackoff(() =>
|
|
36
|
+
tokenContract.allowance(walletAddress, spenderAddress),
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
return BigInt(allowance) > scale(tokenDecimals)(Number.MAX_SAFE_INTEGER)
|
|
40
|
+
? Number.MAX_SAFE_INTEGER
|
|
41
|
+
: descale(tokenDecimals)(allowance);
|
|
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
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { TOKEN_INFO } from './token-info';
|
|
2
|
+
import {
|
|
3
|
+
Address,
|
|
4
|
+
MoneyInOutChainId,
|
|
5
|
+
ReyaChainId,
|
|
6
|
+
TokenInfo,
|
|
7
|
+
TokenName,
|
|
8
|
+
} from '../../types';
|
|
9
|
+
import { convertToAddress } from './utils';
|
|
10
|
+
|
|
11
|
+
export const getTokenInfoByAddress = (
|
|
12
|
+
tokenAddressParam: Address | string,
|
|
13
|
+
chainId?: ReyaChainId | MoneyInOutChainId,
|
|
14
|
+
): TokenInfo => {
|
|
15
|
+
const tokenAddress =
|
|
16
|
+
typeof tokenAddressParam === 'string'
|
|
17
|
+
? convertToAddress(tokenAddressParam)
|
|
18
|
+
: tokenAddressParam;
|
|
19
|
+
|
|
20
|
+
if (chainId) {
|
|
21
|
+
const tokenInfo = TOKEN_INFO[chainId].find(
|
|
22
|
+
(tokenInfo) => tokenInfo.address === tokenAddress,
|
|
23
|
+
);
|
|
24
|
+
if (!tokenInfo) {
|
|
25
|
+
throw new Error(
|
|
26
|
+
`getTokenInfoByAddress: no token info found [chainId ${chainId}, token address ${tokenAddress}]`,
|
|
27
|
+
);
|
|
28
|
+
}
|
|
29
|
+
return tokenInfo;
|
|
30
|
+
} else {
|
|
31
|
+
for (const chainId in TOKEN_INFO) {
|
|
32
|
+
const tokenInfos =
|
|
33
|
+
TOKEN_INFO[chainId as unknown as keyof typeof TOKEN_INFO];
|
|
34
|
+
const tokenInfo = tokenInfos.find(
|
|
35
|
+
(tokenInfo) => tokenInfo.address === tokenAddress,
|
|
36
|
+
);
|
|
37
|
+
if (tokenInfo) {
|
|
38
|
+
return tokenInfo;
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
throw new Error(
|
|
42
|
+
`getTokenInfoByAddress: no token info found [token address ${tokenAddress}]`,
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const getTokenInfoByName = (
|
|
48
|
+
tokenName: TokenName,
|
|
49
|
+
chainId: ReyaChainId | MoneyInOutChainId,
|
|
50
|
+
): TokenInfo => {
|
|
51
|
+
const tokenInfo = TOKEN_INFO[chainId].find(
|
|
52
|
+
(tokenInfo) => tokenInfo.name === tokenName,
|
|
53
|
+
);
|
|
54
|
+
|
|
55
|
+
if (!tokenInfo) {
|
|
56
|
+
throw new Error(
|
|
57
|
+
`getTokenInfoByName: no token info found [chain id ${chainId}, token name ${tokenName}]`,
|
|
58
|
+
);
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
return tokenInfo;
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
export const getTokenInfosByChain = (
|
|
65
|
+
chainId: ReyaChainId | MoneyInOutChainId,
|
|
66
|
+
): TokenInfo[] => {
|
|
67
|
+
return TOKEN_INFO[chainId];
|
|
68
|
+
};
|
|
69
|
+
|
|
70
|
+
export const getRUSDUnderlyingTokenInfo = (
|
|
71
|
+
chainId: ReyaChainId | MoneyInOutChainId,
|
|
72
|
+
): TokenInfo => {
|
|
73
|
+
const tokenInfo = TOKEN_INFO[chainId].find(
|
|
74
|
+
(tokenInfo) => tokenInfo.isRUSDUnderlying === true,
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
if (!tokenInfo) {
|
|
78
|
+
throw new Error(
|
|
79
|
+
`getRUSDUnderlyingTokenInfo: no token info found [chain id ${chainId}]`,
|
|
80
|
+
);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
return tokenInfo;
|
|
84
|
+
};
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ethers } from 'ethers';
|
|
2
|
+
import { Address } from '../../types';
|
|
3
|
+
|
|
4
|
+
export const descale = (tokenDecimals: number) => {
|
|
5
|
+
const f = (value: bigint) => {
|
|
6
|
+
return Number(ethers.formatUnits(value.toString(), tokenDecimals));
|
|
7
|
+
};
|
|
8
|
+
|
|
9
|
+
return f;
|
|
10
|
+
};
|
|
11
|
+
|
|
12
|
+
export const scale = (tokenDecimals: number): ((value: number) => bigint) => {
|
|
13
|
+
return (value: number): bigint => {
|
|
14
|
+
// Convert the number to a string
|
|
15
|
+
const valueStr = value.toString();
|
|
16
|
+
// Split the string into whole and fractional parts
|
|
17
|
+
// eslint-disable-next-line prefer-const
|
|
18
|
+
let [whole, fractional = ''] = valueStr.split('.');
|
|
19
|
+
// Ensure the fractional part is the correct length, padding with zeros if necessary
|
|
20
|
+
fractional = fractional
|
|
21
|
+
.padEnd(tokenDecimals, '0')
|
|
22
|
+
.substring(0, tokenDecimals);
|
|
23
|
+
// Concatenate the whole part with the correctly length-limited fractional part
|
|
24
|
+
const scaledValueStr = whole + fractional;
|
|
25
|
+
// Convert the concatenated string to a BigInt, assuming it represents a value in wei (or equivalent smallest unit)
|
|
26
|
+
// This is safe as we're not losing precision - just scaling the number to its smallest unit representation
|
|
27
|
+
return BigInt(scaledValueStr);
|
|
28
|
+
};
|
|
29
|
+
};
|
|
30
|
+
|
|
31
|
+
export const getERC20TokenContract = (
|
|
32
|
+
tokenAddress: string,
|
|
33
|
+
subject: ethers.Signer | ethers.Provider,
|
|
34
|
+
): ethers.Contract => {
|
|
35
|
+
const abi: string[] = [
|
|
36
|
+
`function approve(address, uint256) external returns (bool)`,
|
|
37
|
+
`function balanceOf(address) external view returns (uint256)`,
|
|
38
|
+
`function allowance(address,address) external view returns (uint256)`,
|
|
39
|
+
`function approve(address,uint256) external returns (bool)`,
|
|
40
|
+
];
|
|
41
|
+
|
|
42
|
+
const contract = new ethers.Contract(tokenAddress, abi, subject);
|
|
43
|
+
|
|
44
|
+
return contract;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export const convertToAddress = (str: string): Address => {
|
|
48
|
+
return str.toLowerCase() as Address;
|
|
49
|
+
};
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token-info.d.ts","sourceRoot":"/","sources":["utils/token-info.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,UAAU,CAAC;AAWrE,eAAO,MAAM,UAAU,EAAE,MAAM,CAAC,WAAW,GAAG,iBAAiB,EAAE,SAAS,EAAE,CA2VzE,CAAC"}
|
|
@@ -1,49 +0,0 @@
|
|
|
1
|
-
import { Provider } from 'ethers';
|
|
2
|
-
import { Contract, Signer } from 'ethers';
|
|
3
|
-
import { Address, GetERC20AllowanceParams, MoneyInOutChainId, ReyaChainId, TokenInfo, TokenName } from '../types';
|
|
4
|
-
export declare const descale: (tokenDecimals: number) => (value: bigint) => number;
|
|
5
|
-
export declare const scale: (tokenDecimals: number) => (value: number) => bigint;
|
|
6
|
-
export declare const getERC20TokenContract: (tokenAddress: string, subject: Signer | Provider) => Contract;
|
|
7
|
-
export declare const convertToAddress: (str: string) => Address;
|
|
8
|
-
export declare const getTokenInfoByAddress: (tokenAddressParam: Address | string, chainId?: ReyaChainId | MoneyInOutChainId) => TokenInfo;
|
|
9
|
-
export declare const getTokenInfoByName: (tokenName: TokenName, chainId: ReyaChainId | MoneyInOutChainId) => TokenInfo;
|
|
10
|
-
export declare const getTokenInfosByChain: (chainId: ReyaChainId | MoneyInOutChainId) => TokenInfo[];
|
|
11
|
-
export declare const getRUSDUnderlyingTokenInfo: (chainId: ReyaChainId | MoneyInOutChainId) => TokenInfo;
|
|
12
|
-
export declare const getERC20Allowance: ({ walletAddress, tokenAddress, spenderAddress, subject, }: GetERC20AllowanceParams) => Promise<number>;
|
|
13
|
-
export type GetERC20BalanceArgs = {
|
|
14
|
-
tokenAddress: string;
|
|
15
|
-
walletAddress: string;
|
|
16
|
-
subject: Signer | Provider;
|
|
17
|
-
};
|
|
18
|
-
export type GetETHBalanceArgs = {
|
|
19
|
-
walletAddress: string;
|
|
20
|
-
subject: Signer | Provider;
|
|
21
|
-
};
|
|
22
|
-
export type GetETHBalanceBatchArgs = {
|
|
23
|
-
walletAddress: string;
|
|
24
|
-
chain: MoneyInOutChainId;
|
|
25
|
-
};
|
|
26
|
-
export type GetERC20BalanceBatchArgs = {
|
|
27
|
-
tokenAddress: string;
|
|
28
|
-
walletAddress: string;
|
|
29
|
-
chain: MoneyInOutChainId;
|
|
30
|
-
};
|
|
31
|
-
export type GetReyaETHBalanceArgs = {
|
|
32
|
-
walletAddress: string;
|
|
33
|
-
chain: ReyaChainId;
|
|
34
|
-
};
|
|
35
|
-
export type GetReyaERC20BalanceArgs = {
|
|
36
|
-
tokenAddress: string;
|
|
37
|
-
walletAddress: string;
|
|
38
|
-
chain: ReyaChainId;
|
|
39
|
-
};
|
|
40
|
-
export type GetBalancesForBridgeArgs = {
|
|
41
|
-
walletAddress: string;
|
|
42
|
-
};
|
|
43
|
-
export declare const getERC20Balance: ({ tokenAddress, walletAddress, subject, }: GetERC20BalanceArgs) => Promise<number>;
|
|
44
|
-
export declare const getETHBalance: ({ walletAddress, subject, }: GetETHBalanceArgs) => Promise<number>;
|
|
45
|
-
export declare const getETHBalanceBatch: ({ walletAddress, chain, }: GetETHBalanceBatchArgs) => Promise<number>;
|
|
46
|
-
export declare const getERC20BalanceBatch: ({ tokenAddress, walletAddress, chain, }: GetERC20BalanceBatchArgs) => Promise<number>;
|
|
47
|
-
export declare const getReyaETHBalance: ({ walletAddress, chain, }: GetReyaETHBalanceArgs) => Promise<number>;
|
|
48
|
-
export declare const getReyaERC20Balance: ({ tokenAddress, walletAddress, chain, }: GetReyaERC20BalanceArgs) => Promise<number>;
|
|
49
|
-
//# sourceMappingURL=token.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"token.d.ts","sourceRoot":"/","sources":["utils/token.ts"],"names":[],"mappings":"AAAA,OAAO,EAAU,QAAQ,EAAE,MAAM,QAAQ,CAAC;AAE1C,OAAO,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAG1C,OAAO,EACL,OAAO,EACP,uBAAuB,EACvB,iBAAiB,EACjB,WAAW,EACX,SAAS,EACT,SAAS,EACV,MAAM,UAAU,CAAC;AAElB,eAAO,MAAM,OAAO,kBAAmB,MAAM,aACzB,MAAM,WAKzB,CAAC;AAEF,eAAO,MAAM,KAAK,kBAAmB,MAAM,aAAY,MAAM,KAAK,MAiBjE,CAAC;AAEF,eAAO,MAAM,qBAAqB,iBAClB,MAAM,WACX,MAAM,GAAG,QAAQ,KACzB,QAWF,CAAC;AAEF,eAAO,MAAM,gBAAgB,QAAS,MAAM,KAAG,OAE9C,CAAC;AAEF,eAAO,MAAM,qBAAqB,sBACb,OAAO,GAAG,MAAM,YACzB,WAAW,GAAG,iBAAiB,KACxC,SA+BF,CAAC;AAEF,eAAO,MAAM,kBAAkB,cAClB,SAAS,WACX,WAAW,GAAG,iBAAiB,KACvC,SAYF,CAAC;AAEF,eAAO,MAAM,oBAAoB,YACtB,WAAW,GAAG,iBAAiB,KACvC,SAAS,EAEX,CAAC;AAEF,eAAO,MAAM,0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,QAAQ,EAAE,CAAC,EACX,gBAAgB,EAAE,IAAI,IACnB,sBAAsB;mBAGzB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,4CAA4C,EACrD,QAAQ,EAAE,CAAC,EACX,gBAAgB,EAAE,KAAK,IACpB,sBAAsB;mBAGzB,IAAI,EAAE,KAAK,EACX,OAAO,EAAE,4CAA4C,EACrD,QAAQ,EAAE,EAAE,EACZ,gBAAgB,EAAE,KAAK,IACpB,sBAAsB;4BAGzB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,4CAA4C,EACrD,QAAQ,EAAE,EAAE,EACZ,gBAAgB,EAAE,KAAK,IACpB,sBAAsB,KACzB,gBAAgB,EAAE,IAAI,EACtB,iBAAiB,EAAE,IAAI,EACvB,iBAAiB,EAAE,IAAI;mBAGvB,IAAI,EAAE,MAAM,EACZ,OAAO,EAAE,4CAA4C,EACrD,QAAQ,EAAE,CAAC,EACX,gBAAgB,EAAE,KAAK,IACpB,sBAAsB;KAE5B;QACD","sourcesContent":["import { MoneyInOutChainId, ReyaChainId, TokenInfo } from '../types';\n\nconst defaultTokenThresholds: Pick<\n TokenInfo,\n 'minDepositAmount' | 'minWithdrawAmount' | 'minTransferAmount'\n> = {\n minDepositAmount: 10,\n minWithdrawAmount: 10,\n minTransferAmount: 10,\n};\n\nexport const TOKEN_INFO: Record<ReyaChainId | MoneyInOutChainId, TokenInfo[]> =\n {\n /* ------------------------------------------------------ */\n /* MAINNET */\n /* ------------------------------------------------------ */\n [ReyaChainId.reyaNetwork]: [\n {\n name: 'RUSD',\n address: '0xa9f32a851b1800742e47725da54a09a7ef2556a3',\n decimals: 6,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n {\n name: 'USDC',\n address: '0x3b860c0b53f2e8bd5264aa7c3451d41263c933f2',\n decimals: 6,\n isRUSDUnderlying: true,\n ...defaultTokenThresholds,\n },\n {\n name: 'WETH',\n address: '0x6b48c2e6a32077ec17e8ba0d98ffc676dfab1a30',\n decimals: 18,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n minDepositAmount: 0.01,\n minWithdrawAmount: 0.01,\n minTransferAmount: 0.01,\n },\n ],\n [MoneyInOutChainId.ethereumMainnet]: [\n {\n name: 'USDC',\n address: '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48',\n decimals: 6,\n isRUSDUnderlying: true,\n ...defaultTokenThresholds,\n minWithdrawAmount: 28,\n },\n {\n name: 'WETH',\n address: '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2',\n decimals: 18,\n isRUSDUnderlying: false,\n whitelistedWalletOnly: true,\n ...defaultTokenThresholds,\n minDepositAmount: 0.01,\n minWithdrawAmount: 0.01,\n minTransferAmount: 0.01,\n },\n ],\n [MoneyInOutChainId.opMainnet]: [\n {\n name: 'USDC.E',\n address: '0x7f5c764cbc14f9669b88837ca1490cca17c31607',\n decimals: 6,\n isRUSDUnderlying: true,\n ...defaultTokenThresholds,\n minWithdrawAmount: 10,\n },\n {\n name: 'WETH',\n address: '0x4200000000000000000000000000000000000006',\n decimals: 18,\n isRUSDUnderlying: false,\n whitelistedWalletOnly: true,\n ...defaultTokenThresholds,\n minDepositAmount: 0.01,\n minWithdrawAmount: 0.01,\n minTransferAmount: 0.01,\n },\n ],\n [MoneyInOutChainId.polygonMainnet]: [\n {\n name: 'USDC.E',\n address: '0x2791bca1f2de4661ed88a30c99a7a9449aa84174',\n decimals: 6,\n isRUSDUnderlying: true,\n ...defaultTokenThresholds,\n minWithdrawAmount: 10,\n },\n {\n name: 'WETH',\n address: '0x7ceb23fd6bc0add59e62ac25578270cff1b9f619',\n decimals: 18,\n isRUSDUnderlying: false,\n whitelistedWalletOnly: true,\n ...defaultTokenThresholds,\n minDepositAmount: 0.01,\n minWithdrawAmount: 0.01,\n minTransferAmount: 0.01,\n },\n ],\n [MoneyInOutChainId.arbitrumOne]: [\n {\n name: 'USDC.E',\n address: '0xff970a61a04b1ca14834a43f5de4533ebddb5cc8',\n decimals: 6,\n isRUSDUnderlying: true,\n ...defaultTokenThresholds,\n minWithdrawAmount: 10,\n },\n {\n name: 'WETH',\n address: '0x82af49447d8a07e3bd95bd0d56f35241523fbab1',\n decimals: 18,\n isRUSDUnderlying: false,\n whitelistedWalletOnly: true,\n ...defaultTokenThresholds,\n minDepositAmount: 0.01,\n minWithdrawAmount: 0.01,\n minTransferAmount: 0.01,\n },\n ],\n [MoneyInOutChainId.baseMainnet]: [\n {\n name: 'USDC',\n address: '0x833589fcd6edb6e08f4c7c32d4f71b54bda02913',\n decimals: 6,\n isRUSDUnderlying: true,\n ...defaultTokenThresholds,\n minWithdrawAmount: 10,\n },\n {\n name: 'WETH',\n address: '0x4200000000000000000000000000000000000006',\n decimals: 18,\n isRUSDUnderlying: false,\n whitelistedWalletOnly: true,\n ...defaultTokenThresholds,\n minDepositAmount: 0.01,\n minWithdrawAmount: 0.01,\n minTransferAmount: 0.01,\n },\n ],\n\n /* ------------------------------------------------------ */\n /* TESTNET */\n /* ------------------------------------------------------ */\n [ReyaChainId.reyaCronos]: [\n {\n name: 'RUSD',\n address: '0x26ee9dfb27f12990d90ec003af7c5e9c19ea2a4c',\n decimals: 6,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n {\n name: 'USDC',\n address: '0x1b700a40a0707dd5f0bc31cbc57d730558e5714d',\n decimals: 6,\n isRUSDUnderlying: true,\n ...defaultTokenThresholds,\n },\n {\n name: 'USDT',\n address: '0x9ade781dacbd220f0161d98f496a2982b231a9d6',\n decimals: 6,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n {\n name: 'DAI',\n address: '0x733299259c45726ee1bfc9bd0deeba58e48a1853',\n decimals: 18,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n {\n name: 'WETH',\n address: '0xc123b7aeb9d2b2e8a035217d5c29e317c91842e2',\n decimals: 18,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n minDepositAmount: 0.01,\n minWithdrawAmount: 0.01,\n minTransferAmount: 0.01,\n },\n {\n name: 'WBTC',\n address: '0xd382e2f0df859ff9e82f963dcad1aaee939c5e4f',\n decimals: 8,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n ],\n [MoneyInOutChainId.polygonMumbai]: [\n {\n name: 'USDC',\n address: '0xd9edcc943ed9729b08e52bb1e110fe43d1930773',\n decimals: 6,\n isRUSDUnderlying: true,\n ...defaultTokenThresholds,\n },\n {\n name: 'USDT',\n address: '0x4f8ecb190b9ef36113127d97c7f9300875b6563f',\n decimals: 6,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n {\n name: 'DAI',\n address: '0x35479b023e508ee9a7b533dbb5b516bb6875f937',\n decimals: 18,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n {\n name: 'WETH',\n address: '0x6c7a28f6ae2d245b0130520b112fa3544a06d9ae',\n decimals: 18,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n minDepositAmount: 0.01,\n minWithdrawAmount: 0.01,\n minTransferAmount: 0.01,\n },\n {\n name: 'WBTC',\n address: '0x92c7a51bd507736ac0dda48b5f35a4aad0c2bb4d',\n decimals: 8,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n ],\n [MoneyInOutChainId.arbitrumSepolia]: [\n {\n name: 'USDC',\n address: '0x8537307810fc40f4073a12a38554d4ff78efff41',\n decimals: 6,\n isRUSDUnderlying: true,\n ...defaultTokenThresholds,\n },\n {\n name: 'USDT',\n address: '0x66dfb9987c36c4be232156e70b085f664367599a',\n decimals: 6,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n {\n name: 'DAI',\n address: '0x9a573b27d7298c6e2f4d2d4a41c37a0c8af6acca',\n decimals: 18,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n {\n name: 'WETH',\n address: '0x565810cbfa3cf1390963e5afa2fb953795686339',\n decimals: 18,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n minDepositAmount: 0.01,\n minWithdrawAmount: 0.01,\n minTransferAmount: 0.01,\n },\n {\n name: 'WBTC',\n address: '0x1019958c2bd43b882a4e1349337a32ef9563fc4d',\n decimals: 8,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n ],\n [MoneyInOutChainId.opSepolia]: [\n {\n name: 'USDC',\n address: '0x6d290609b3f5f02d52f28d97c75a443ed8564cbf',\n decimals: 6,\n isRUSDUnderlying: true,\n ...defaultTokenThresholds,\n },\n {\n name: 'USDT',\n address: '0x2d1aba6fabae80bf5c1c9ea433aae9030e07cb22',\n decimals: 6,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n {\n name: 'DAI',\n address: '0xdc0258dc3db980090e97ebf4f1fd9cc3c5ad5894',\n decimals: 18,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n {\n name: 'WETH',\n address: '0x2b42affd4b7c14d9b7c2579229495c052672ccd3',\n decimals: 18,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n minDepositAmount: 0.01,\n minWithdrawAmount: 0.01,\n minTransferAmount: 0.01,\n },\n {\n name: 'WBTC',\n address: '0xfc5cc93d85861ac82d89fc2d3e56315540e9c8a7',\n decimals: 8,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n ],\n [MoneyInOutChainId.ethereumSepolia]: [\n {\n name: 'USDC',\n address: '0x565810cbfa3cf1390963e5afa2fb953795686339',\n decimals: 6,\n isRUSDUnderlying: true,\n ...defaultTokenThresholds,\n },\n {\n name: 'USDT',\n address: '0xb4130e87a180b9448286b291331aee8a9c154a3a',\n decimals: 6,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n {\n name: 'DAI',\n address: '0x255745e5c7ae620b7f523f5e4a0ead37660ec5d6',\n decimals: 18,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n {\n name: 'WETH',\n address: '0x771d1ae208377453d478df08bbc38034f72ac833',\n decimals: 18,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n minDepositAmount: 0.01,\n minWithdrawAmount: 0.01,\n minTransferAmount: 0.01,\n },\n {\n name: 'WBTC',\n address: '0x94beff5da6201cb2c8f489196fd970b3df5aa32a',\n decimals: 8,\n isRUSDUnderlying: false,\n ...defaultTokenThresholds,\n },\n ],\n };\n"]}
|