@ape.swap/bonds-sdk 1.0.553 → 1.0.555
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/package.json +1 -1
- package/dist/config/abi/bondNft.json +0 -424
- package/dist/config/abi/ens-public-resolver.json +0 -816
- package/dist/config/abi/ens-registrar.json +0 -422
- package/dist/config/abi/erc20_bytes32.json +0 -30
- package/dist/config/abi/jungleChef.json +0 -291
- package/dist/config/abi/launchBonds.json +0 -2014
- package/dist/config/abi/lockVeAbond.json +0 -2198
- package/dist/config/abi/migrationBond.json +0 -1639
- package/dist/config/abi/migrationFveAbond.json +0 -160
- package/dist/config/abi/multicallv3.json +0 -92
- package/dist/config/abi/price-getter-linea.json +0 -1448
- package/dist/config/abi/price-getter.json +0 -1309
- package/dist/config/abi/sousChef.json +0 -649
- package/dist/config/abi/weth.json +0 -279
- package/dist/hooks/PriceGetter/dexFactories.d.ts +0 -11
- package/dist/hooks/PriceGetter/dexFactories.js +0 -2
- package/dist/hooks/PriceGetter/usePricesFromPriceGetter.d.ts +0 -17
- package/dist/hooks/PriceGetter/usePricesFromPriceGetter.js +0 -205
- package/dist/hooks/useClaimBill.d.ts +0 -4
- package/dist/hooks/useClaimBill.js +0 -59
- package/dist/hooks/useContract.d.ts +0 -25
- package/dist/hooks/useContract.js +0 -107
- package/dist/state/tokenPrices/fetchTokenPricesForMultipleChains.d.ts +0 -4
- package/dist/state/tokenPrices/fetchTokenPricesForMultipleChains.js +0 -81
- package/dist/state/tokenPrices/getAllTokenPrices.d.ts +0 -5
- package/dist/state/tokenPrices/getAllTokenPrices.js +0 -288
- package/dist/state/tokenPrices/useTokenPricesNew.d.ts +0 -11
- package/dist/state/tokenPrices/useTokenPricesNew.js +0 -72
|
@@ -1,279 +0,0 @@
|
|
|
1
|
-
[
|
|
2
|
-
{
|
|
3
|
-
"constant": true,
|
|
4
|
-
"inputs": [],
|
|
5
|
-
"name": "name",
|
|
6
|
-
"outputs": [
|
|
7
|
-
{
|
|
8
|
-
"name": "",
|
|
9
|
-
"type": "string"
|
|
10
|
-
}
|
|
11
|
-
],
|
|
12
|
-
"payable": false,
|
|
13
|
-
"stateMutability": "view",
|
|
14
|
-
"type": "function"
|
|
15
|
-
},
|
|
16
|
-
{
|
|
17
|
-
"constant": false,
|
|
18
|
-
"inputs": [
|
|
19
|
-
{
|
|
20
|
-
"name": "guy",
|
|
21
|
-
"type": "address"
|
|
22
|
-
},
|
|
23
|
-
{
|
|
24
|
-
"name": "wad",
|
|
25
|
-
"type": "uint256"
|
|
26
|
-
}
|
|
27
|
-
],
|
|
28
|
-
"name": "approve",
|
|
29
|
-
"outputs": [
|
|
30
|
-
{
|
|
31
|
-
"name": "",
|
|
32
|
-
"type": "bool"
|
|
33
|
-
}
|
|
34
|
-
],
|
|
35
|
-
"payable": false,
|
|
36
|
-
"stateMutability": "nonpayable",
|
|
37
|
-
"type": "function"
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"constant": true,
|
|
41
|
-
"inputs": [],
|
|
42
|
-
"name": "totalSupply",
|
|
43
|
-
"outputs": [
|
|
44
|
-
{
|
|
45
|
-
"name": "",
|
|
46
|
-
"type": "uint256"
|
|
47
|
-
}
|
|
48
|
-
],
|
|
49
|
-
"payable": false,
|
|
50
|
-
"stateMutability": "view",
|
|
51
|
-
"type": "function"
|
|
52
|
-
},
|
|
53
|
-
{
|
|
54
|
-
"constant": false,
|
|
55
|
-
"inputs": [
|
|
56
|
-
{
|
|
57
|
-
"name": "src",
|
|
58
|
-
"type": "address"
|
|
59
|
-
},
|
|
60
|
-
{
|
|
61
|
-
"name": "dst",
|
|
62
|
-
"type": "address"
|
|
63
|
-
},
|
|
64
|
-
{
|
|
65
|
-
"name": "wad",
|
|
66
|
-
"type": "uint256"
|
|
67
|
-
}
|
|
68
|
-
],
|
|
69
|
-
"name": "transferFrom",
|
|
70
|
-
"outputs": [
|
|
71
|
-
{
|
|
72
|
-
"name": "",
|
|
73
|
-
"type": "bool"
|
|
74
|
-
}
|
|
75
|
-
],
|
|
76
|
-
"payable": false,
|
|
77
|
-
"stateMutability": "nonpayable",
|
|
78
|
-
"type": "function"
|
|
79
|
-
},
|
|
80
|
-
{
|
|
81
|
-
"constant": false,
|
|
82
|
-
"inputs": [
|
|
83
|
-
{
|
|
84
|
-
"name": "wad",
|
|
85
|
-
"type": "uint256"
|
|
86
|
-
}
|
|
87
|
-
],
|
|
88
|
-
"name": "withdraw",
|
|
89
|
-
"outputs": [],
|
|
90
|
-
"payable": false,
|
|
91
|
-
"stateMutability": "nonpayable",
|
|
92
|
-
"type": "function"
|
|
93
|
-
},
|
|
94
|
-
{
|
|
95
|
-
"constant": true,
|
|
96
|
-
"inputs": [],
|
|
97
|
-
"name": "decimals",
|
|
98
|
-
"outputs": [
|
|
99
|
-
{
|
|
100
|
-
"name": "",
|
|
101
|
-
"type": "uint8"
|
|
102
|
-
}
|
|
103
|
-
],
|
|
104
|
-
"payable": false,
|
|
105
|
-
"stateMutability": "view",
|
|
106
|
-
"type": "function"
|
|
107
|
-
},
|
|
108
|
-
{
|
|
109
|
-
"constant": true,
|
|
110
|
-
"inputs": [
|
|
111
|
-
{
|
|
112
|
-
"name": "",
|
|
113
|
-
"type": "address"
|
|
114
|
-
}
|
|
115
|
-
],
|
|
116
|
-
"name": "balanceOf",
|
|
117
|
-
"outputs": [
|
|
118
|
-
{
|
|
119
|
-
"name": "",
|
|
120
|
-
"type": "uint256"
|
|
121
|
-
}
|
|
122
|
-
],
|
|
123
|
-
"payable": false,
|
|
124
|
-
"stateMutability": "view",
|
|
125
|
-
"type": "function"
|
|
126
|
-
},
|
|
127
|
-
{
|
|
128
|
-
"constant": true,
|
|
129
|
-
"inputs": [],
|
|
130
|
-
"name": "symbol",
|
|
131
|
-
"outputs": [
|
|
132
|
-
{
|
|
133
|
-
"name": "",
|
|
134
|
-
"type": "string"
|
|
135
|
-
}
|
|
136
|
-
],
|
|
137
|
-
"payable": false,
|
|
138
|
-
"stateMutability": "view",
|
|
139
|
-
"type": "function"
|
|
140
|
-
},
|
|
141
|
-
{
|
|
142
|
-
"constant": false,
|
|
143
|
-
"inputs": [
|
|
144
|
-
{
|
|
145
|
-
"name": "dst",
|
|
146
|
-
"type": "address"
|
|
147
|
-
},
|
|
148
|
-
{
|
|
149
|
-
"name": "wad",
|
|
150
|
-
"type": "uint256"
|
|
151
|
-
}
|
|
152
|
-
],
|
|
153
|
-
"name": "transfer",
|
|
154
|
-
"outputs": [
|
|
155
|
-
{
|
|
156
|
-
"name": "",
|
|
157
|
-
"type": "bool"
|
|
158
|
-
}
|
|
159
|
-
],
|
|
160
|
-
"payable": false,
|
|
161
|
-
"stateMutability": "nonpayable",
|
|
162
|
-
"type": "function"
|
|
163
|
-
},
|
|
164
|
-
{
|
|
165
|
-
"constant": false,
|
|
166
|
-
"inputs": [],
|
|
167
|
-
"name": "deposit",
|
|
168
|
-
"outputs": [],
|
|
169
|
-
"payable": true,
|
|
170
|
-
"stateMutability": "payable",
|
|
171
|
-
"type": "function"
|
|
172
|
-
},
|
|
173
|
-
{
|
|
174
|
-
"constant": true,
|
|
175
|
-
"inputs": [
|
|
176
|
-
{
|
|
177
|
-
"name": "",
|
|
178
|
-
"type": "address"
|
|
179
|
-
},
|
|
180
|
-
{
|
|
181
|
-
"name": "",
|
|
182
|
-
"type": "address"
|
|
183
|
-
}
|
|
184
|
-
],
|
|
185
|
-
"name": "allowance",
|
|
186
|
-
"outputs": [
|
|
187
|
-
{
|
|
188
|
-
"name": "",
|
|
189
|
-
"type": "uint256"
|
|
190
|
-
}
|
|
191
|
-
],
|
|
192
|
-
"payable": false,
|
|
193
|
-
"stateMutability": "view",
|
|
194
|
-
"type": "function"
|
|
195
|
-
},
|
|
196
|
-
{
|
|
197
|
-
"payable": true,
|
|
198
|
-
"stateMutability": "payable",
|
|
199
|
-
"type": "fallback"
|
|
200
|
-
},
|
|
201
|
-
{
|
|
202
|
-
"anonymous": false,
|
|
203
|
-
"inputs": [
|
|
204
|
-
{
|
|
205
|
-
"indexed": true,
|
|
206
|
-
"name": "src",
|
|
207
|
-
"type": "address"
|
|
208
|
-
},
|
|
209
|
-
{
|
|
210
|
-
"indexed": true,
|
|
211
|
-
"name": "guy",
|
|
212
|
-
"type": "address"
|
|
213
|
-
},
|
|
214
|
-
{
|
|
215
|
-
"indexed": false,
|
|
216
|
-
"name": "wad",
|
|
217
|
-
"type": "uint256"
|
|
218
|
-
}
|
|
219
|
-
],
|
|
220
|
-
"name": "Approval",
|
|
221
|
-
"type": "event"
|
|
222
|
-
},
|
|
223
|
-
{
|
|
224
|
-
"anonymous": false,
|
|
225
|
-
"inputs": [
|
|
226
|
-
{
|
|
227
|
-
"indexed": true,
|
|
228
|
-
"name": "src",
|
|
229
|
-
"type": "address"
|
|
230
|
-
},
|
|
231
|
-
{
|
|
232
|
-
"indexed": true,
|
|
233
|
-
"name": "dst",
|
|
234
|
-
"type": "address"
|
|
235
|
-
},
|
|
236
|
-
{
|
|
237
|
-
"indexed": false,
|
|
238
|
-
"name": "wad",
|
|
239
|
-
"type": "uint256"
|
|
240
|
-
}
|
|
241
|
-
],
|
|
242
|
-
"name": "Transfer",
|
|
243
|
-
"type": "event"
|
|
244
|
-
},
|
|
245
|
-
{
|
|
246
|
-
"anonymous": false,
|
|
247
|
-
"inputs": [
|
|
248
|
-
{
|
|
249
|
-
"indexed": true,
|
|
250
|
-
"name": "dst",
|
|
251
|
-
"type": "address"
|
|
252
|
-
},
|
|
253
|
-
{
|
|
254
|
-
"indexed": false,
|
|
255
|
-
"name": "wad",
|
|
256
|
-
"type": "uint256"
|
|
257
|
-
}
|
|
258
|
-
],
|
|
259
|
-
"name": "Deposit",
|
|
260
|
-
"type": "event"
|
|
261
|
-
},
|
|
262
|
-
{
|
|
263
|
-
"anonymous": false,
|
|
264
|
-
"inputs": [
|
|
265
|
-
{
|
|
266
|
-
"indexed": true,
|
|
267
|
-
"name": "src",
|
|
268
|
-
"type": "address"
|
|
269
|
-
},
|
|
270
|
-
{
|
|
271
|
-
"indexed": false,
|
|
272
|
-
"name": "wad",
|
|
273
|
-
"type": "uint256"
|
|
274
|
-
}
|
|
275
|
-
],
|
|
276
|
-
"name": "Withdrawal",
|
|
277
|
-
"type": "event"
|
|
278
|
-
}
|
|
279
|
-
]
|
|
@@ -1,11 +0,0 @@
|
|
|
1
|
-
import { ChainId, LiquidityDex, Protocols } from "../../enum/apeswaplists";
|
|
2
|
-
type DexInfo = {
|
|
3
|
-
factory: string;
|
|
4
|
-
router?: string;
|
|
5
|
-
protocol: Protocols;
|
|
6
|
-
};
|
|
7
|
-
type dexFactories = Partial<Record<ChainId, Partial<Record<LiquidityDex, DexInfo>>>>;
|
|
8
|
-
type defaultDexFactories = Partial<Record<ChainId, Partial<Record<Protocols, string>>>>;
|
|
9
|
-
export declare const dexFactories: dexFactories;
|
|
10
|
-
export declare const defaultDexFactories: defaultDexFactories;
|
|
11
|
-
export {};
|
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import { ChainId, Token as Token_ApeSwapLists } from '../../enum/apeswaplists';
|
|
2
|
-
type TokenRecord = {
|
|
3
|
-
[k: string]: Token_ApeSwapLists;
|
|
4
|
-
};
|
|
5
|
-
export declare function getTokenPricesV2FromPriceGetter(tokensToCall: TokenRecord, chain: ChainId, lpTokens?: boolean): Promise<any>;
|
|
6
|
-
/**
|
|
7
|
-
* Custom hook to get price getter data.
|
|
8
|
-
*
|
|
9
|
-
* @param tokens - Tokens to build tx data for.
|
|
10
|
-
* @param supportedChainId - The chain ID.
|
|
11
|
-
* @returns The token price calls.
|
|
12
|
-
*/
|
|
13
|
-
export declare function usePriceGetterData(tokensToCall: TokenRecord, // replace 'any' with the actual type
|
|
14
|
-
supportedChainId: ChainId, lpTokens: boolean): (string | number | undefined)[][];
|
|
15
|
-
export declare function getPriceGetterCallData(tokensToCall: TokenRecord, // replace 'any' with the actual type
|
|
16
|
-
supportedChainId: ChainId, lpTokens: boolean): (string | number | undefined)[][];
|
|
17
|
-
export {};
|
|
@@ -1,205 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { ZERO_ADDRESS } from '../../config/constants/misc';
|
|
38
|
-
import { useMemo } from 'react';
|
|
39
|
-
import multicall from '../../utils/multicall';
|
|
40
|
-
import { PRICE_GETTER_ADDRESSES } from '../../config/constants/addresses';
|
|
41
|
-
import PRICE_GETTER_ABI from '../../config/abi/price-getter.json';
|
|
42
|
-
import PRICE_GETTER_ABI_LINEA from '../../config/abi/price-getter-linea.json';
|
|
43
|
-
import { ChainId, Protocols } from '../../enum/apeswaplists';
|
|
44
|
-
import { defaultDexFactories, dexFactories } from './dexFactories';
|
|
45
|
-
export function getTokenPricesV2FromPriceGetter(tokensToCall_1, chain_1) {
|
|
46
|
-
return __awaiter(this, arguments, void 0, function (tokensToCall, chain, lpTokens) {
|
|
47
|
-
var tokenCalls, calls, tokenResults;
|
|
48
|
-
if (lpTokens === void 0) { lpTokens = false; }
|
|
49
|
-
return __generator(this, function (_a) {
|
|
50
|
-
switch (_a.label) {
|
|
51
|
-
case 0:
|
|
52
|
-
tokenCalls = getPriceGetterCallData(tokensToCall, chain, lpTokens);
|
|
53
|
-
calls = tokenCalls.map(function (t) { return ({
|
|
54
|
-
address: PRICE_GETTER_ADDRESSES[chain],
|
|
55
|
-
name: lpTokens ? 'getLPPriceFromFactory' : 'getPriceFromFactory',
|
|
56
|
-
params: t,
|
|
57
|
-
}); });
|
|
58
|
-
return [4 /*yield*/, multicall(+chain, [ChainId.LINEA, ChainId.LIGHTLINK, ChainId.IOTA, ChainId.BASE].includes(chain)
|
|
59
|
-
? PRICE_GETTER_ABI_LINEA
|
|
60
|
-
: PRICE_GETTER_ABI, calls)];
|
|
61
|
-
case 1:
|
|
62
|
-
tokenResults = _a.sent();
|
|
63
|
-
return [2 /*return*/, tokenResults];
|
|
64
|
-
}
|
|
65
|
-
});
|
|
66
|
-
});
|
|
67
|
-
}
|
|
68
|
-
/**
|
|
69
|
-
* Custom hook to get price getter data.
|
|
70
|
-
*
|
|
71
|
-
* @param tokens - Tokens to build tx data for.
|
|
72
|
-
* @param supportedChainId - The chain ID.
|
|
73
|
-
* @returns The token price calls.
|
|
74
|
-
*/
|
|
75
|
-
export function usePriceGetterData(tokensToCall, // replace 'any' with the actual type
|
|
76
|
-
supportedChainId, lpTokens) {
|
|
77
|
-
return useMemo(function () {
|
|
78
|
-
return Object.values(tokensToCall).map(function (token) {
|
|
79
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q;
|
|
80
|
-
var liquidityDex = (_a = token.liquidityDex) === null || _a === void 0 ? void 0 : _a[supportedChainId];
|
|
81
|
-
var dexFactory;
|
|
82
|
-
var protocol = 2;
|
|
83
|
-
var factoryV2 = (_c = (_b = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _b === void 0 ? void 0 : _b[2]) !== null && _c !== void 0 ? _c : ZERO_ADDRESS;
|
|
84
|
-
var factoryV3 = (_e = (_d = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _d === void 0 ? void 0 : _d[3]) !== null && _e !== void 0 ? _e : ZERO_ADDRESS;
|
|
85
|
-
var factoryAlgebra = (_g = (_f = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _f === void 0 ? void 0 : _f[4]) !== null && _g !== void 0 ? _g : ZERO_ADDRESS;
|
|
86
|
-
var factorySolidly = (_j = (_h = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _h === void 0 ? void 0 : _h[7]) !== null && _j !== void 0 ? _j : ZERO_ADDRESS;
|
|
87
|
-
if (liquidityDex) {
|
|
88
|
-
dexFactory = (_k = dexFactories[supportedChainId]) === null || _k === void 0 ? void 0 : _k[liquidityDex];
|
|
89
|
-
protocol = (_l = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.protocol) !== null && _l !== void 0 ? _l : Protocols.V2;
|
|
90
|
-
switch (protocol) {
|
|
91
|
-
case Protocols.V2:
|
|
92
|
-
factoryV2 = (_m = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _m !== void 0 ? _m : factoryV2;
|
|
93
|
-
break;
|
|
94
|
-
case Protocols.V3:
|
|
95
|
-
factoryV3 = (_o = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _o !== void 0 ? _o : factoryV3;
|
|
96
|
-
break;
|
|
97
|
-
case Protocols.Algebra:
|
|
98
|
-
factoryAlgebra = (_p = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _p !== void 0 ? _p : factoryAlgebra;
|
|
99
|
-
break;
|
|
100
|
-
case Protocols.Solidly:
|
|
101
|
-
factorySolidly = (_q = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _q !== void 0 ? _q : factorySolidly;
|
|
102
|
-
break;
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
var errMsg = "No default dex factory found for retrieving price. For Protocol: ".concat(protocol, ".");
|
|
106
|
-
switch (protocol) {
|
|
107
|
-
case Protocols.Both:
|
|
108
|
-
if (factoryV2 === ZERO_ADDRESS || factoryV3 === ZERO_ADDRESS) {
|
|
109
|
-
throw new Error(errMsg);
|
|
110
|
-
}
|
|
111
|
-
break;
|
|
112
|
-
case Protocols.V2:
|
|
113
|
-
if (factoryV2 === ZERO_ADDRESS) {
|
|
114
|
-
throw new Error(errMsg);
|
|
115
|
-
}
|
|
116
|
-
break;
|
|
117
|
-
case Protocols.V3:
|
|
118
|
-
if (factoryV3 === ZERO_ADDRESS) {
|
|
119
|
-
throw new Error(errMsg);
|
|
120
|
-
}
|
|
121
|
-
break;
|
|
122
|
-
}
|
|
123
|
-
// Not sure if this is the best way to handle this. It requires all tokens to be either LP or not
|
|
124
|
-
if (lpTokens && protocol == Protocols.Algebra) {
|
|
125
|
-
protocol = Protocols.Gamma;
|
|
126
|
-
}
|
|
127
|
-
if (lpTokens && protocol == Protocols.V3) {
|
|
128
|
-
protocol = Protocols.Steer;
|
|
129
|
-
}
|
|
130
|
-
return [token.address[supportedChainId], protocol, factoryV2, factoryV3, factoryAlgebra, factorySolidly];
|
|
131
|
-
});
|
|
132
|
-
}, [tokensToCall, supportedChainId, lpTokens]);
|
|
133
|
-
}
|
|
134
|
-
export function getPriceGetterCallData(tokensToCall, // replace 'any' with the actual type
|
|
135
|
-
supportedChainId, lpTokens) {
|
|
136
|
-
return Object.values(tokensToCall).map(function (token) {
|
|
137
|
-
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
|
|
138
|
-
var liquidityDex = (_a = token.liquidityDex) === null || _a === void 0 ? void 0 : _a[supportedChainId];
|
|
139
|
-
var dexFactory;
|
|
140
|
-
var protocol = 2;
|
|
141
|
-
var factoryV2 = (_c = (_b = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _b === void 0 ? void 0 : _b[2]) !== null && _c !== void 0 ? _c : ZERO_ADDRESS;
|
|
142
|
-
var factoryV3 = (_e = (_d = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _d === void 0 ? void 0 : _d[3]) !== null && _e !== void 0 ? _e : ZERO_ADDRESS;
|
|
143
|
-
var factoryAlgebra = (_g = (_f = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _f === void 0 ? void 0 : _f[4]) !== null && _g !== void 0 ? _g : ZERO_ADDRESS;
|
|
144
|
-
var factorySolidly = (_j = (_h = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _h === void 0 ? void 0 : _h[7]) !== null && _j !== void 0 ? _j : ZERO_ADDRESS;
|
|
145
|
-
var factoryXFAI = (_l = (_k = defaultDexFactories === null || defaultDexFactories === void 0 ? void 0 : defaultDexFactories[supportedChainId]) === null || _k === void 0 ? void 0 : _k[8]) !== null && _l !== void 0 ? _l : ZERO_ADDRESS;
|
|
146
|
-
if (liquidityDex) {
|
|
147
|
-
dexFactory = (_m = dexFactories[supportedChainId]) === null || _m === void 0 ? void 0 : _m[liquidityDex];
|
|
148
|
-
protocol = (_o = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.protocol) !== null && _o !== void 0 ? _o : Protocols.V2;
|
|
149
|
-
switch (protocol) {
|
|
150
|
-
case Protocols.V2:
|
|
151
|
-
factoryV2 = (_p = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _p !== void 0 ? _p : factoryV2;
|
|
152
|
-
break;
|
|
153
|
-
case Protocols.V3:
|
|
154
|
-
factoryV3 = (_q = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _q !== void 0 ? _q : factoryV3;
|
|
155
|
-
break;
|
|
156
|
-
case Protocols.Algebra:
|
|
157
|
-
factoryAlgebra = (_r = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _r !== void 0 ? _r : factoryAlgebra;
|
|
158
|
-
break;
|
|
159
|
-
case Protocols.Solidly:
|
|
160
|
-
factorySolidly = (_s = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _s !== void 0 ? _s : factorySolidly;
|
|
161
|
-
break;
|
|
162
|
-
case Protocols.XFAI:
|
|
163
|
-
factoryXFAI = (_t = dexFactory === null || dexFactory === void 0 ? void 0 : dexFactory.factory) !== null && _t !== void 0 ? _t : factoryXFAI;
|
|
164
|
-
}
|
|
165
|
-
}
|
|
166
|
-
var errMsg = "No default dex factory found for retrieving price. For Protocol: ".concat(protocol, ".");
|
|
167
|
-
switch (protocol) {
|
|
168
|
-
case Protocols.Both:
|
|
169
|
-
if (factoryV2 === ZERO_ADDRESS || factoryV3 === ZERO_ADDRESS) {
|
|
170
|
-
throw new Error(errMsg);
|
|
171
|
-
}
|
|
172
|
-
break;
|
|
173
|
-
case Protocols.V2:
|
|
174
|
-
if (factoryV2 === ZERO_ADDRESS) {
|
|
175
|
-
throw new Error(errMsg);
|
|
176
|
-
}
|
|
177
|
-
break;
|
|
178
|
-
case Protocols.V3:
|
|
179
|
-
if (factoryV3 === ZERO_ADDRESS) {
|
|
180
|
-
throw new Error(errMsg);
|
|
181
|
-
}
|
|
182
|
-
break;
|
|
183
|
-
}
|
|
184
|
-
// TODO: Not sure if this is the best way to handle this. It requires all tokens to be either LP or not
|
|
185
|
-
if (lpTokens && protocol == Protocols.Algebra) {
|
|
186
|
-
protocol = Protocols.Gamma;
|
|
187
|
-
}
|
|
188
|
-
if (lpTokens && protocol == Protocols.V3) {
|
|
189
|
-
protocol = Protocols.Steer;
|
|
190
|
-
}
|
|
191
|
-
if ([ChainId.LINEA, ChainId.LIGHTLINK, ChainId.IOTA, ChainId.BASE].includes(supportedChainId) && !token.lpToken) {
|
|
192
|
-
return [
|
|
193
|
-
token.address[supportedChainId],
|
|
194
|
-
protocol,
|
|
195
|
-
factoryV2,
|
|
196
|
-
factoryV3,
|
|
197
|
-
factoryAlgebra,
|
|
198
|
-
factorySolidly,
|
|
199
|
-
factoryXFAI,
|
|
200
|
-
];
|
|
201
|
-
}
|
|
202
|
-
else
|
|
203
|
-
return [token.address[supportedChainId], protocol, factoryV2, factoryV3, factoryAlgebra, factorySolidly];
|
|
204
|
-
});
|
|
205
|
-
}
|
|
@@ -1,59 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
11
|
-
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
12
|
-
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
13
|
-
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
14
|
-
function step(op) {
|
|
15
|
-
if (f) throw new TypeError("Generator is already executing.");
|
|
16
|
-
while (g && (g = 0, op[0] && (_ = 0)), _) try {
|
|
17
|
-
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;
|
|
18
|
-
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
19
|
-
switch (op[0]) {
|
|
20
|
-
case 0: case 1: t = op; break;
|
|
21
|
-
case 4: _.label++; return { value: op[1], done: false };
|
|
22
|
-
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
23
|
-
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
24
|
-
default:
|
|
25
|
-
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
26
|
-
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
27
|
-
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
28
|
-
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
29
|
-
if (t[2]) _.ops.pop();
|
|
30
|
-
_.trys.pop(); continue;
|
|
31
|
-
}
|
|
32
|
-
op = body.call(thisArg, _);
|
|
33
|
-
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
34
|
-
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
35
|
-
}
|
|
36
|
-
};
|
|
37
|
-
import { useCallback } from 'react';
|
|
38
|
-
import { useBondContract } from '../hooks/useContract';
|
|
39
|
-
// Claim a Bill
|
|
40
|
-
var useClaimBill = function (billAddress, billIds, chainId) {
|
|
41
|
-
//const { chainId } = useWeb3React()
|
|
42
|
-
var bondContract = useBondContract(billAddress);
|
|
43
|
-
// const billType = useBillType(billAddress)
|
|
44
|
-
var handleClaimBill = useCallback(function () { return __awaiter(void 0, void 0, void 0, function () {
|
|
45
|
-
var tx;
|
|
46
|
-
return __generator(this, function (_a) {
|
|
47
|
-
switch (_a.label) {
|
|
48
|
-
case 0: return [4 /*yield*/, bondContract.batchRedeem(billIds)];
|
|
49
|
-
case 1:
|
|
50
|
-
tx = _a.sent();
|
|
51
|
-
console.log('HANDLECLAIMBILL TX');
|
|
52
|
-
console.log(tx);
|
|
53
|
-
return [2 /*return*/, tx];
|
|
54
|
-
}
|
|
55
|
-
});
|
|
56
|
-
}); }, [bondContract, billIds, chainId]);
|
|
57
|
-
return { onClaimBill: handleClaimBill };
|
|
58
|
-
};
|
|
59
|
-
export default useClaimBill;
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
import { Contract } from '@ethersproject/contracts';
|
|
2
|
-
import { Bond, BondNft, JungleChef, Multicallv3, MigrationBond, LaunchBonds, LockVeAbond, MigrationFveAbond } from '../config/abi/types';
|
|
3
|
-
import { Erc20 } from '../config/abi/types/Erc20';
|
|
4
|
-
import { EnsRegistrar } from '../config/abi/types/EnsRegistrar';
|
|
5
|
-
import { EnsPublicResolver } from '../config/abi/types/EnsPublicResolver';
|
|
6
|
-
import { PriceGetter } from '../config/abi/types/PriceGetter';
|
|
7
|
-
import { Weth } from '../config/abi/types/Weth';
|
|
8
|
-
import { ChainId } from '@ape.swap/apeswap-lists';
|
|
9
|
-
export declare function useContract<T extends Contract = Contract>(addressOrAddressMap: string | {
|
|
10
|
-
[chainId: number]: string;
|
|
11
|
-
} | undefined, ABI: any, withSignerIfPossible?: boolean): T | null;
|
|
12
|
-
export declare function useInterfaceMulticall(): Multicallv3 | null;
|
|
13
|
-
export declare function useTokenContract(tokenAddress?: string, withSignerIfPossible?: boolean): Erc20 | null;
|
|
14
|
-
export declare function useBytes32TokenContract(tokenAddress?: string, withSignerIfPossible?: boolean): Contract | null;
|
|
15
|
-
export declare function useENSRegistrarContract(withSignerIfPossible?: boolean): EnsRegistrar | null;
|
|
16
|
-
export declare function useENSResolverContract(address: string | undefined, withSignerIfPossible?: boolean): EnsPublicResolver | null;
|
|
17
|
-
export declare function usePriceGetter(chain?: ChainId): PriceGetter | null;
|
|
18
|
-
export declare const useBondContract: (address: string) => Bond;
|
|
19
|
-
export declare const useLaunchBondContract: (address: string) => LaunchBonds;
|
|
20
|
-
export declare const useMigrationBondContract: (address: string) => MigrationBond;
|
|
21
|
-
export declare const useBondNftContract: (address: string) => BondNft;
|
|
22
|
-
export declare const useJungleFarmContract: (address: string) => JungleChef | null;
|
|
23
|
-
export declare function useWETHContract(withSignerIfPossible?: boolean): Weth | null;
|
|
24
|
-
export declare const useLockAbondContract: (address: string) => LockVeAbond;
|
|
25
|
-
export declare const useMigrationFveAbondContract: (address: string) => MigrationFveAbond;
|