@pioneer-platform/uniswap-client 0.0.28 → 0.1.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/CHANGELOG.md +16 -0
- package/lib/constants/chainInfo.d.ts +2 -2
- package/lib/constants/chainInfo.js +40 -43
- package/lib/constants/chains.d.ts +20 -20
- package/lib/constants/chains.js +25 -26
- package/lib/constants/governance.js +13 -14
- package/lib/constants/lists.js +20 -28
- package/lib/constants/misc.d.ts +4 -5
- package/lib/constants/misc.js +2 -2
- package/lib/constants/networks.js +45 -46
- package/lib/constants/proposals/uniswap_grants_proposal_description.js +106 -1
- package/lib/constants/providers.d.ts +16 -15
- package/lib/constants/providers.js +23 -24
- package/lib/constants/routing.js +44 -61
- package/lib/constants/tokens.d.ts +49 -49
- package/lib/constants/tokens.js +133 -170
- package/lib/index.js +556 -877
- package/lib/routing/clientSideSmartOrderRouter.js +72 -121
- package/lib/routing/gas.js +63 -150
- package/lib/routing/types.d.ts +7 -7
- package/lib/routing/types.js +160 -264
- package/lib/routing/utils.js +141 -196
- package/lib/rpc/AppJsonRpcProvider.js +40 -131
- package/lib/rpc/ConfiguredJsonRpcProvider.d.ts +1 -1
- package/lib/rpc/ConfiguredJsonRpcProvider.js +8 -27
- package/lib/utils/contracts/getContract.js +6 -7
- package/lib/utils/transformSwapRouteToGetQuoteResult.js +24 -27
- package/lib/utils/uniswapData.d.ts +6 -6
- package/lib/utils/uniswapData.js +64 -142
- package/package.json +19 -19
- package/tsconfig.json +27 -8
- package/lib/constants/chains.test.d.ts +0 -1
- package/lib/constants/chains.test.js +0 -26
- package/lib/constants/localCurrencies.d.ts +0 -6
- package/lib/constants/localCurrencies.js +0 -94
- package/lib/constants/localCurrencyIcons.d.ts +0 -18
- package/lib/constants/localCurrencyIcons.js +0 -298
- package/lib/constants/routing.test.d.ts +0 -1
- package/lib/constants/routing.test.js +0 -32
- package/lib/constants/tokenLists/broken.tokenlist.json +0 -22
- package/lib/constants/tokenLogoLookup.d.ts +0 -8
- package/lib/constants/tokenLogoLookup.js +0 -48
- package/lib/constants/tokenSafety.js +0 -129
- package/lib/constants/tokenSafetyLookup.d.ts +0 -18
- package/lib/constants/tokenSafetyLookup.js +0 -66
- package/lib/constants/tokenSaftey.test.d.ts +0 -1
- package/lib/constants/tokenSaftey.test.js +0 -31
package/lib/utils/uniswapData.js
CHANGED
|
@@ -1,56 +1,24 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
-
});
|
|
10
|
-
};
|
|
11
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
12
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
13
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
14
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
15
|
-
function step(op) {
|
|
16
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
17
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
18
|
-
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
|
|
19
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
20
|
-
switch (op[0]) {
|
|
21
|
-
case 0: case 1: t = op; break;
|
|
22
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
23
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
24
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
25
|
-
default:
|
|
26
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
27
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
28
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
29
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
30
|
-
if (t[2]) _.ops.pop();
|
|
31
|
-
_.trys.pop(); continue;
|
|
32
|
-
}
|
|
33
|
-
op = body.call(thisArg, _);
|
|
34
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
35
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
36
|
-
}
|
|
37
|
-
};
|
|
38
2
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
39
3
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
40
4
|
};
|
|
41
5
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
42
|
-
exports.
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
6
|
+
exports.FEE_AMOUNT = exports.USDC = exports.DAI = exports.WETH = exports.ETHER = void 0;
|
|
7
|
+
exports.getUniswapPools = getUniswapPools;
|
|
8
|
+
exports.getPair = getPair;
|
|
9
|
+
exports.getPool = getPool;
|
|
10
|
+
exports.buildTrade = buildTrade;
|
|
11
|
+
const jsbi_1 = __importDefault(require("jsbi"));
|
|
12
|
+
const ethers_1 = require("ethers");
|
|
13
|
+
const router_sdk_1 = require("@uniswap/router-sdk");
|
|
14
|
+
const v2_sdk_1 = require("@uniswap/v2-sdk");
|
|
15
|
+
const v3_sdk_1 = require("@uniswap/v3-sdk");
|
|
48
16
|
// import { SwapOptions } from '../../src'
|
|
49
|
-
|
|
50
|
-
|
|
17
|
+
const sdk_core_1 = require("@uniswap/sdk-core");
|
|
18
|
+
const UniswapV3Pool_json_1 = __importDefault(require("@uniswap/v3-core/artifacts/contracts/UniswapV3Pool.sol/UniswapV3Pool.json"));
|
|
51
19
|
// import { TEST_RECIPIENT_ADDRESS } from './addresses'
|
|
52
|
-
|
|
53
|
-
|
|
20
|
+
const V2_FACTORY = '0x5C69bEe701ef814a2B6a3EDD4B1652CB9cc5aA6f';
|
|
21
|
+
const V2_ABI = [
|
|
54
22
|
{
|
|
55
23
|
constant: true,
|
|
56
24
|
inputs: [],
|
|
@@ -77,103 +45,58 @@ var V2_ABI = [
|
|
|
77
45
|
type: 'function',
|
|
78
46
|
},
|
|
79
47
|
];
|
|
80
|
-
|
|
48
|
+
const FORK_BLOCK = 16075500;
|
|
81
49
|
exports.ETHER = sdk_core_1.Ether.onChain(1);
|
|
82
50
|
exports.WETH = new sdk_core_1.Token(1, '0xc02aaa39b223fe8d0a0e5c4f27ead9083c756cc2', 18, 'WETH', 'Wrapped Ether');
|
|
83
51
|
exports.DAI = new sdk_core_1.Token(1, '0x6B175474E89094C44Da98b954EedeAC495271d0F', 18, 'DAI', 'dai');
|
|
84
52
|
exports.USDC = new sdk_core_1.Token(1, '0xa0b86991c6218b36c1d19d4a2e9eb0ce3606eb48', 6, 'USDC', 'USD Coin');
|
|
85
53
|
exports.FEE_AMOUNT = v3_sdk_1.FeeAmount.MEDIUM;
|
|
86
|
-
function getUniswapPools(forkBlock) {
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
case 3:
|
|
101
|
-
WETH_USDC_V3 = _a.sent();
|
|
102
|
-
return [4 /*yield*/, getPool(exports.WETH, exports.USDC, v3_sdk_1.FeeAmount.LOW, fork)];
|
|
103
|
-
case 4:
|
|
104
|
-
WETH_USDC_V3_LOW_FEE = _a.sent();
|
|
105
|
-
return [4 /*yield*/, getPool(exports.USDC, exports.DAI, v3_sdk_1.FeeAmount.LOW, fork)];
|
|
106
|
-
case 5:
|
|
107
|
-
USDC_DAI_V3 = _a.sent();
|
|
108
|
-
return [2 /*return*/, {
|
|
109
|
-
WETH_USDC_V2: WETH_USDC_V2,
|
|
110
|
-
USDC_DAI_V2: USDC_DAI_V2,
|
|
111
|
-
WETH_USDC_V3: WETH_USDC_V3,
|
|
112
|
-
WETH_USDC_V3_LOW_FEE: WETH_USDC_V3_LOW_FEE,
|
|
113
|
-
USDC_DAI_V3: USDC_DAI_V3,
|
|
114
|
-
}];
|
|
115
|
-
}
|
|
116
|
-
});
|
|
117
|
-
});
|
|
54
|
+
async function getUniswapPools(forkBlock) {
|
|
55
|
+
const fork = forkBlock ?? FORK_BLOCK;
|
|
56
|
+
const WETH_USDC_V2 = await getPair(exports.WETH, exports.USDC, fork);
|
|
57
|
+
const USDC_DAI_V2 = await getPair(exports.USDC, exports.DAI, fork);
|
|
58
|
+
const WETH_USDC_V3 = await getPool(exports.WETH, exports.USDC, exports.FEE_AMOUNT, fork);
|
|
59
|
+
const WETH_USDC_V3_LOW_FEE = await getPool(exports.WETH, exports.USDC, v3_sdk_1.FeeAmount.LOW, fork);
|
|
60
|
+
const USDC_DAI_V3 = await getPool(exports.USDC, exports.DAI, v3_sdk_1.FeeAmount.LOW, fork);
|
|
61
|
+
return {
|
|
62
|
+
WETH_USDC_V2,
|
|
63
|
+
USDC_DAI_V2,
|
|
64
|
+
WETH_USDC_V3,
|
|
65
|
+
WETH_USDC_V3_LOW_FEE,
|
|
66
|
+
USDC_DAI_V3,
|
|
67
|
+
};
|
|
118
68
|
}
|
|
119
|
-
exports.getUniswapPools = getUniswapPools;
|
|
120
69
|
function getProvider() {
|
|
121
70
|
return new ethers_1.ethers.providers.JsonRpcProvider(process.env['FORK_URL']);
|
|
122
71
|
}
|
|
123
|
-
function getPair(tokenA, tokenB, blockNumber) {
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
pairAddress = (0, v2_sdk_1.computePairAddress)({ factoryAddress: V2_FACTORY, tokenA: tokenA, tokenB: tokenB });
|
|
130
|
-
contract = new ethers_1.ethers.Contract(pairAddress, V2_ABI, getProvider());
|
|
131
|
-
return [4 /*yield*/, contract.getReserves({ blockTag: blockNumber })];
|
|
132
|
-
case 1:
|
|
133
|
-
_a = _c.sent(), reserve0 = _a.reserve0, reserve1 = _a.reserve1;
|
|
134
|
-
_b = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA] // does safety checks
|
|
135
|
-
, token0 = _b[0], token1 = _b[1];
|
|
136
|
-
return [2 /*return*/, new v2_sdk_1.Pair(sdk_core_1.CurrencyAmount.fromRawAmount(token0, reserve0), sdk_core_1.CurrencyAmount.fromRawAmount(token1, reserve1))];
|
|
137
|
-
}
|
|
138
|
-
});
|
|
139
|
-
});
|
|
72
|
+
async function getPair(tokenA, tokenB, blockNumber) {
|
|
73
|
+
const pairAddress = (0, v2_sdk_1.computePairAddress)({ factoryAddress: V2_FACTORY, tokenA, tokenB });
|
|
74
|
+
const contract = new ethers_1.ethers.Contract(pairAddress, V2_ABI, getProvider());
|
|
75
|
+
const { reserve0, reserve1 } = await contract.getReserves({ blockTag: blockNumber });
|
|
76
|
+
const [token0, token1] = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA]; // does safety checks
|
|
77
|
+
return new v2_sdk_1.Pair(sdk_core_1.CurrencyAmount.fromRawAmount(token0, reserve0), sdk_core_1.CurrencyAmount.fromRawAmount(token1, reserve1));
|
|
140
78
|
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
{
|
|
162
|
-
index: (0, v3_sdk_1.nearestUsableTick)(v3_sdk_1.TickMath.MIN_TICK, v3_sdk_1.TICK_SPACINGS[feeAmount]),
|
|
163
|
-
liquidityNet: liquidity,
|
|
164
|
-
liquidityGross: liquidity,
|
|
165
|
-
},
|
|
166
|
-
{
|
|
167
|
-
index: (0, v3_sdk_1.nearestUsableTick)(v3_sdk_1.TickMath.MAX_TICK, v3_sdk_1.TICK_SPACINGS[feeAmount]),
|
|
168
|
-
liquidityNet: jsbi_1.default.multiply(liquidity, jsbi_1.default.BigInt('-1')),
|
|
169
|
-
liquidityGross: liquidity,
|
|
170
|
-
},
|
|
171
|
-
])];
|
|
172
|
-
}
|
|
173
|
-
});
|
|
174
|
-
});
|
|
79
|
+
async function getPool(tokenA, tokenB, feeAmount, blockNumber) {
|
|
80
|
+
const [token0, token1] = tokenA.sortsBefore(tokenB) ? [tokenA, tokenB] : [tokenB, tokenA]; // does safety checks
|
|
81
|
+
const poolAddress = v3_sdk_1.Pool.getAddress(token0, token1, feeAmount);
|
|
82
|
+
const contract = new ethers_1.ethers.Contract(poolAddress, UniswapV3Pool_json_1.default.abi, getProvider());
|
|
83
|
+
let liquidity = await contract.liquidity({ blockTag: blockNumber });
|
|
84
|
+
let { sqrtPriceX96, tick } = await contract.slot0({ blockTag: blockNumber });
|
|
85
|
+
liquidity = jsbi_1.default.BigInt(liquidity.toString());
|
|
86
|
+
sqrtPriceX96 = jsbi_1.default.BigInt(sqrtPriceX96.toString());
|
|
87
|
+
return new v3_sdk_1.Pool(token0, token1, feeAmount, sqrtPriceX96, liquidity, tick, [
|
|
88
|
+
{
|
|
89
|
+
index: (0, v3_sdk_1.nearestUsableTick)(v3_sdk_1.TickMath.MIN_TICK, v3_sdk_1.TICK_SPACINGS[feeAmount]),
|
|
90
|
+
liquidityNet: liquidity,
|
|
91
|
+
liquidityGross: liquidity,
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
index: (0, v3_sdk_1.nearestUsableTick)(v3_sdk_1.TickMath.MAX_TICK, v3_sdk_1.TICK_SPACINGS[feeAmount]),
|
|
95
|
+
liquidityNet: jsbi_1.default.multiply(liquidity, jsbi_1.default.BigInt('-1')),
|
|
96
|
+
liquidityGross: liquidity,
|
|
97
|
+
},
|
|
98
|
+
]);
|
|
175
99
|
}
|
|
176
|
-
exports.getPool = getPool;
|
|
177
100
|
// use some sane defaults
|
|
178
101
|
// export function swapOptions(options: Partial<SwapOptions>): SwapOptions {
|
|
179
102
|
// // If theres a fee this counts as "slippage" for the amount out, so take it into account
|
|
@@ -191,27 +114,26 @@ exports.getPool = getPool;
|
|
|
191
114
|
function buildTrade(trades) {
|
|
192
115
|
return new router_sdk_1.Trade({
|
|
193
116
|
v2Routes: trades
|
|
194
|
-
.filter(
|
|
195
|
-
.map(
|
|
117
|
+
.filter((trade) => trade instanceof v2_sdk_1.Trade)
|
|
118
|
+
.map((trade) => ({
|
|
196
119
|
routev2: trade.route,
|
|
197
120
|
inputAmount: trade.inputAmount,
|
|
198
121
|
outputAmount: trade.outputAmount,
|
|
199
|
-
})
|
|
122
|
+
})),
|
|
200
123
|
v3Routes: trades
|
|
201
|
-
.filter(
|
|
202
|
-
.map(
|
|
124
|
+
.filter((trade) => trade instanceof v3_sdk_1.Trade)
|
|
125
|
+
.map((trade) => ({
|
|
203
126
|
routev3: trade.route,
|
|
204
127
|
inputAmount: trade.inputAmount,
|
|
205
128
|
outputAmount: trade.outputAmount,
|
|
206
|
-
})
|
|
129
|
+
})),
|
|
207
130
|
mixedRoutes: trades
|
|
208
|
-
.filter(
|
|
209
|
-
.map(
|
|
131
|
+
.filter((trade) => trade instanceof router_sdk_1.MixedRouteTrade)
|
|
132
|
+
.map((trade) => ({
|
|
210
133
|
mixedRoute: trade.route,
|
|
211
134
|
inputAmount: trade.inputAmount,
|
|
212
135
|
outputAmount: trade.outputAmount,
|
|
213
|
-
})
|
|
136
|
+
})),
|
|
214
137
|
tradeType: trades[0].tradeType,
|
|
215
138
|
});
|
|
216
139
|
}
|
|
217
|
-
exports.buildTrade = buildTrade;
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pioneer-platform/uniswap-client",
|
|
3
|
-
"version": "0.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"main": "./lib/index.js",
|
|
5
5
|
"types": "./lib/index.d.ts",
|
|
6
6
|
"dependencies": {
|
|
7
7
|
"@keepkey/keepkey-sdk": "^0.2.57",
|
|
8
|
-
"@pioneer-platform/loggerdog": "^8.
|
|
9
|
-
"@pioneer-platform/maya-network": "^8.
|
|
10
|
-
"@pioneer-platform/pioneer-caip": "^9.
|
|
11
|
-
"@pioneer-platform/pioneer-coins": "^9.
|
|
12
|
-
"@pioneer-platform/pioneer-discovery": "^0.0
|
|
8
|
+
"@pioneer-platform/loggerdog": "^8.4.0",
|
|
9
|
+
"@pioneer-platform/maya-network": "^8.4.0",
|
|
10
|
+
"@pioneer-platform/pioneer-caip": "^9.3.0",
|
|
11
|
+
"@pioneer-platform/pioneer-coins": "^9.4.0",
|
|
12
|
+
"@pioneer-platform/pioneer-discovery": "^0.1.0",
|
|
13
13
|
"@types/ms": "^0.7.34",
|
|
14
14
|
"@types/ms.macro": "^2.0.2",
|
|
15
15
|
"@uniswap/router-sdk": "1.9.0",
|
|
@@ -21,33 +21,33 @@
|
|
|
21
21
|
"@uniswap/universal-router-sdk": "1.8.2",
|
|
22
22
|
"@uniswap/v2-sdk": "4.3.0",
|
|
23
23
|
"@uniswap/v3-sdk": "3.11.0",
|
|
24
|
-
"axios": "^1.
|
|
24
|
+
"axios": "^1.6.0",
|
|
25
25
|
"dayjs": "^1.11.10",
|
|
26
26
|
"dotenv": "^8.2.0",
|
|
27
27
|
"ms": "^2.1.3",
|
|
28
28
|
"ms.macro": "^2.0.0",
|
|
29
29
|
"uuidv4": "^6.2.13"
|
|
30
30
|
},
|
|
31
|
-
"scripts": {
|
|
32
|
-
"npm": "npm i",
|
|
33
|
-
"test": "npm run build && node __tests__/test-module.js",
|
|
34
|
-
"test-sdk": "npm run build && node __tests__/test-module-sdk.js",
|
|
35
|
-
"build": "tsc -p .",
|
|
36
|
-
"prepublish": "npm run build",
|
|
37
|
-
"refresh": "rm -rf ./node_modules ./package-lock.json && npm install"
|
|
38
|
-
},
|
|
39
31
|
"devDependencies": {
|
|
40
32
|
"@types/async-retry": "^1.4.8",
|
|
41
33
|
"@types/bunyan": "^1.8.11",
|
|
42
34
|
"@types/jest": "^25.2.3",
|
|
43
|
-
"@types/node": "^
|
|
35
|
+
"@types/node": "^18.16.0",
|
|
44
36
|
"@types/source-map-support": "^0.5.3",
|
|
45
37
|
"babel-plugin-macros": "^3.1.0",
|
|
46
38
|
"jest": "^26.4.2",
|
|
47
39
|
"onchange": "^7.0.2",
|
|
48
40
|
"serve": "^11.3.2",
|
|
49
41
|
"ts-jest": "^29.0.5",
|
|
50
|
-
"typescript": "^5.0.
|
|
42
|
+
"typescript": "^5.0.4"
|
|
51
43
|
},
|
|
52
|
-
"gitHead": "a76012f6693a12181c4744e53e977a9eaeef0ed3"
|
|
53
|
-
|
|
44
|
+
"gitHead": "a76012f6693a12181c4744e53e977a9eaeef0ed3",
|
|
45
|
+
"scripts": {
|
|
46
|
+
"npm": "pnpm i",
|
|
47
|
+
"test": "pnpm run build && node __tests__/test-module.js",
|
|
48
|
+
"test-sdk": "pnpm run build && node __tests__/test-module-sdk.js",
|
|
49
|
+
"build": "tsc -p .",
|
|
50
|
+
"prepublish": "pnpm run build",
|
|
51
|
+
"refresh": "rm -rf ./node_modules ./package-lock.json && pnpm install"
|
|
52
|
+
}
|
|
53
|
+
}
|
package/tsconfig.json
CHANGED
|
@@ -1,14 +1,33 @@
|
|
|
1
1
|
{
|
|
2
2
|
"compilerOptions": {
|
|
3
|
-
"target": "
|
|
3
|
+
"target": "es2020",
|
|
4
4
|
"module": "commonjs",
|
|
5
|
-
"lib": ["
|
|
5
|
+
"lib": ["es2020", "dom"],
|
|
6
6
|
"declaration": true,
|
|
7
|
-
"outDir": "lib",
|
|
8
|
-
"rootDir": "src",
|
|
9
|
-
"strict":
|
|
10
|
-
"
|
|
7
|
+
"outDir": "./lib",
|
|
8
|
+
"rootDir": "./src",
|
|
9
|
+
"strict": false,
|
|
10
|
+
"noImplicitAny": false,
|
|
11
|
+
"strictNullChecks": false,
|
|
12
|
+
"strictFunctionTypes": false,
|
|
13
|
+
"strictBindCallApply": false,
|
|
14
|
+
"strictPropertyInitialization": false,
|
|
15
|
+
"noImplicitThis": false,
|
|
16
|
+
"alwaysStrict": false,
|
|
11
17
|
"esModuleInterop": true,
|
|
12
|
-
"resolveJsonModule": true
|
|
13
|
-
|
|
18
|
+
"resolveJsonModule": true,
|
|
19
|
+
"skipLibCheck": true,
|
|
20
|
+
"forceConsistentCasingInFileNames": true
|
|
21
|
+
},
|
|
22
|
+
"include": ["src/**/*.ts"],
|
|
23
|
+
"exclude": [
|
|
24
|
+
"node_modules",
|
|
25
|
+
"**/__tests__/*",
|
|
26
|
+
"src/abis/**/*",
|
|
27
|
+
"src/uniswap/**/*",
|
|
28
|
+
"src/utils/**/*",
|
|
29
|
+
"src/routing/**/*",
|
|
30
|
+
"src/constants/**/*",
|
|
31
|
+
"src/rpc/**/*"
|
|
32
|
+
]
|
|
14
33
|
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,26 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
var sdk_core_1 = require("@uniswap/sdk-core");
|
|
4
|
-
var chains_1 = require("./chains");
|
|
5
|
-
// Define an array of test cases with chainId and expected priority
|
|
6
|
-
var chainPriorityTestCases = [
|
|
7
|
-
[sdk_core_1.ChainId.MAINNET, 0],
|
|
8
|
-
[sdk_core_1.ChainId.GOERLI, 0],
|
|
9
|
-
[sdk_core_1.ChainId.SEPOLIA, 0],
|
|
10
|
-
[sdk_core_1.ChainId.ARBITRUM_ONE, 1],
|
|
11
|
-
[sdk_core_1.ChainId.ARBITRUM_GOERLI, 1],
|
|
12
|
-
[sdk_core_1.ChainId.OPTIMISM, 2],
|
|
13
|
-
[sdk_core_1.ChainId.OPTIMISM_GOERLI, 2],
|
|
14
|
-
[sdk_core_1.ChainId.POLYGON, 3],
|
|
15
|
-
[sdk_core_1.ChainId.POLYGON_MUMBAI, 3],
|
|
16
|
-
[sdk_core_1.ChainId.BASE, 4],
|
|
17
|
-
[sdk_core_1.ChainId.BNB, 5],
|
|
18
|
-
[sdk_core_1.ChainId.AVALANCHE, 6],
|
|
19
|
-
[sdk_core_1.ChainId.CELO, 7],
|
|
20
|
-
[sdk_core_1.ChainId.CELO_ALFAJORES, 7],
|
|
21
|
-
[sdk_core_1.ChainId.BLAST, 8],
|
|
22
|
-
];
|
|
23
|
-
test.each(chainPriorityTestCases)('getChainPriority returns expected priority for a given ChainId %O', function (chainId, expectedPriority) {
|
|
24
|
-
var priority = (0, chains_1.getChainPriority)(chainId);
|
|
25
|
-
expect(priority).toBe(expectedPriority);
|
|
26
|
-
});
|
|
@@ -1,6 +0,0 @@
|
|
|
1
|
-
import { ReactNode } from 'react';
|
|
2
|
-
export declare const SUPPORTED_LOCAL_CURRENCIES: readonly [any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any, any];
|
|
3
|
-
export type SupportedLocalCurrency = (typeof SUPPORTED_LOCAL_CURRENCIES)[number];
|
|
4
|
-
export declare const DEFAULT_LOCAL_CURRENCY: SupportedLocalCurrency;
|
|
5
|
-
export declare const LOCAL_CURRENCY_SYMBOL_DISPLAY_TYPE: Record<SupportedLocalCurrency, 'narrowSymbol' | 'symbol'>;
|
|
6
|
-
export declare function getLocalCurrencyIcon(localCurrency: SupportedLocalCurrency, size?: number): ReactNode;
|
|
@@ -1,94 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.getLocalCurrencyIcon = exports.LOCAL_CURRENCY_SYMBOL_DISPLAY_TYPE = exports.DEFAULT_LOCAL_CURRENCY = exports.SUPPORTED_LOCAL_CURRENCIES = void 0;
|
|
4
|
-
var types_and_hooks_1 = require("uniswap/src/data/graphql/uniswap-data-api/__generated__/types-and-hooks");
|
|
5
|
-
var localCurrencyIcons_1 = require("./localCurrencyIcons");
|
|
6
|
-
exports.SUPPORTED_LOCAL_CURRENCIES = [
|
|
7
|
-
types_and_hooks_1.Currency.Usd,
|
|
8
|
-
types_and_hooks_1.Currency.Aud,
|
|
9
|
-
types_and_hooks_1.Currency.Brl,
|
|
10
|
-
types_and_hooks_1.Currency.Cad,
|
|
11
|
-
types_and_hooks_1.Currency.Eur,
|
|
12
|
-
types_and_hooks_1.Currency.Gbp,
|
|
13
|
-
types_and_hooks_1.Currency.Hkd,
|
|
14
|
-
types_and_hooks_1.Currency.Idr,
|
|
15
|
-
types_and_hooks_1.Currency.Inr,
|
|
16
|
-
types_and_hooks_1.Currency.Jpy,
|
|
17
|
-
types_and_hooks_1.Currency.Ngn,
|
|
18
|
-
types_and_hooks_1.Currency.Pkr,
|
|
19
|
-
types_and_hooks_1.Currency.Rub,
|
|
20
|
-
types_and_hooks_1.Currency.Sgd,
|
|
21
|
-
types_and_hooks_1.Currency.Thb,
|
|
22
|
-
types_and_hooks_1.Currency.Try,
|
|
23
|
-
types_and_hooks_1.Currency.Uah,
|
|
24
|
-
types_and_hooks_1.Currency.Vnd,
|
|
25
|
-
];
|
|
26
|
-
exports.DEFAULT_LOCAL_CURRENCY = types_and_hooks_1.Currency.Usd;
|
|
27
|
-
// some currencies need to be forced to use the narrow symbol and others need to be forced to use symbol
|
|
28
|
-
// for example: when CAD is set to narrowSymbol it is displayed as $ which offers no differentiation from USD
|
|
29
|
-
// but when set to symbol it is displayed as CA$ which is correct
|
|
30
|
-
// On the other hand when TBH is set to symbol it is displayed as THB, but when set to narrowSymbol it is ฿ which is correct
|
|
31
|
-
exports.LOCAL_CURRENCY_SYMBOL_DISPLAY_TYPE = {
|
|
32
|
-
USD: 'narrowSymbol',
|
|
33
|
-
EUR: 'narrowSymbol',
|
|
34
|
-
RUB: 'narrowSymbol',
|
|
35
|
-
INR: 'narrowSymbol',
|
|
36
|
-
GBP: 'narrowSymbol',
|
|
37
|
-
JPY: 'narrowSymbol',
|
|
38
|
-
VND: 'narrowSymbol',
|
|
39
|
-
SGD: 'symbol',
|
|
40
|
-
BRL: 'symbol',
|
|
41
|
-
HKD: 'symbol',
|
|
42
|
-
CAD: 'symbol',
|
|
43
|
-
IDR: 'narrowSymbol',
|
|
44
|
-
TRY: 'narrowSymbol',
|
|
45
|
-
NGN: 'narrowSymbol',
|
|
46
|
-
UAH: 'narrowSymbol',
|
|
47
|
-
PKR: 'narrowSymbol',
|
|
48
|
-
AUD: 'symbol',
|
|
49
|
-
THB: 'narrowSymbol',
|
|
50
|
-
};
|
|
51
|
-
function getLocalCurrencyIcon(localCurrency, size) {
|
|
52
|
-
if (size === void 0) { size = 20; }
|
|
53
|
-
switch (localCurrency) {
|
|
54
|
-
case types_and_hooks_1.Currency.Usd:
|
|
55
|
-
return <localCurrencyIcons_1.USD_ICON width={size} height={size}/>;
|
|
56
|
-
case types_and_hooks_1.Currency.Eur:
|
|
57
|
-
return <localCurrencyIcons_1.EUR_ICON width={size} height={size}/>;
|
|
58
|
-
case types_and_hooks_1.Currency.Rub:
|
|
59
|
-
return <localCurrencyIcons_1.RUB_ICON width={size} height={size}/>;
|
|
60
|
-
case types_and_hooks_1.Currency.Inr:
|
|
61
|
-
return <localCurrencyIcons_1.INR_ICON width={size} height={size}/>;
|
|
62
|
-
case types_and_hooks_1.Currency.Gbp:
|
|
63
|
-
return <localCurrencyIcons_1.GBP_ICON width={size} height={size}/>;
|
|
64
|
-
case types_and_hooks_1.Currency.Jpy:
|
|
65
|
-
return <localCurrencyIcons_1.JPY_ICON width={size} height={size}/>;
|
|
66
|
-
case types_and_hooks_1.Currency.Vnd:
|
|
67
|
-
return <localCurrencyIcons_1.VND_ICON width={size} height={size}/>;
|
|
68
|
-
case types_and_hooks_1.Currency.Sgd:
|
|
69
|
-
return <localCurrencyIcons_1.SGD_ICON width={size} height={size}/>;
|
|
70
|
-
case types_and_hooks_1.Currency.Brl:
|
|
71
|
-
return <localCurrencyIcons_1.BRL_ICON width={size} height={size}/>;
|
|
72
|
-
case types_and_hooks_1.Currency.Hkd:
|
|
73
|
-
return <localCurrencyIcons_1.HKD_ICON width={size} height={size}/>;
|
|
74
|
-
case types_and_hooks_1.Currency.Cad:
|
|
75
|
-
return <localCurrencyIcons_1.CAD_ICON width={size} height={size}/>;
|
|
76
|
-
case types_and_hooks_1.Currency.Idr:
|
|
77
|
-
return <localCurrencyIcons_1.IDR_ICON width={size} height={size}/>;
|
|
78
|
-
case types_and_hooks_1.Currency.Try:
|
|
79
|
-
return <localCurrencyIcons_1.TRY_ICON width={size} height={size}/>;
|
|
80
|
-
case types_and_hooks_1.Currency.Ngn:
|
|
81
|
-
return <localCurrencyIcons_1.NGN_ICON width={size} height={size}/>;
|
|
82
|
-
case types_and_hooks_1.Currency.Aud:
|
|
83
|
-
return <localCurrencyIcons_1.AUD_ICON width={size} height={size}/>;
|
|
84
|
-
case types_and_hooks_1.Currency.Pkr:
|
|
85
|
-
return <localCurrencyIcons_1.PKR_ICON width={size} height={size}/>;
|
|
86
|
-
case types_and_hooks_1.Currency.Uah:
|
|
87
|
-
return <localCurrencyIcons_1.UAH_ICON width={size} height={size}/>;
|
|
88
|
-
case types_and_hooks_1.Currency.Thb:
|
|
89
|
-
return <localCurrencyIcons_1.THB_ICON width={size} height={size}/>;
|
|
90
|
-
default:
|
|
91
|
-
return null;
|
|
92
|
-
}
|
|
93
|
-
}
|
|
94
|
-
exports.getLocalCurrencyIcon = getLocalCurrencyIcon;
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
export declare const USD_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
2
|
-
export declare const EUR_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
3
|
-
export declare const RUB_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
4
|
-
export declare const INR_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
5
|
-
export declare const GBP_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
6
|
-
export declare const JPY_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
7
|
-
export declare const VND_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
8
|
-
export declare const SGD_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
9
|
-
export declare const BRL_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
10
|
-
export declare const HKD_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
11
|
-
export declare const CAD_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
12
|
-
export declare const IDR_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
13
|
-
export declare const TRY_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
14
|
-
export declare const NGN_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
15
|
-
export declare const AUD_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
16
|
-
export declare const PKR_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
17
|
-
export declare const UAH_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|
|
18
|
-
export declare const THB_ICON: (props: React.SVGProps<SVGSVGElement>) => any;
|