@curvefi/api 2.68.15 → 2.68.17
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.
|
@@ -1286,30 +1286,6 @@ export const POOLS_DATA_ETHEREUM = lowerCasePoolDataAddresses({
|
|
|
1286
1286
|
swap_abi: eursusdSwapABI,
|
|
1287
1287
|
gauge_abi: gaugeV4ABI,
|
|
1288
1288
|
},
|
|
1289
|
-
crveth: {
|
|
1290
|
-
name: "crveth",
|
|
1291
|
-
full_name: "crveth",
|
|
1292
|
-
symbol: "crveth",
|
|
1293
|
-
reference_asset: 'CRYPTO',
|
|
1294
|
-
swap_address: '0x8301AE4fc9c624d1D396cbDAa1ed877821D7C511',
|
|
1295
|
-
token_address: '0xEd4064f376cB8d68F770FB1Ff088a3d0F3FF5c4d',
|
|
1296
|
-
gauge_address: '0x1cEBdB0856dd985fAe9b8fEa2262469360B8a3a6',
|
|
1297
|
-
is_crypto: true,
|
|
1298
|
-
underlying_coins: ['ETH', 'CRV'],
|
|
1299
|
-
wrapped_coins: ['WETH', 'CRV'],
|
|
1300
|
-
underlying_coin_addresses: [
|
|
1301
|
-
'0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE',
|
|
1302
|
-
'0xD533a949740bb3306d119CC777fa900bA034cd52',
|
|
1303
|
-
],
|
|
1304
|
-
wrapped_coin_addresses: [
|
|
1305
|
-
'0xC02aaA39b223FE8D0A0e5C4F27eAD9083C756Cc2',
|
|
1306
|
-
'0xD533a949740bb3306d119CC777fa900bA034cd52',
|
|
1307
|
-
],
|
|
1308
|
-
underlying_decimals: [18, 18],
|
|
1309
|
-
wrapped_decimals: [18, 18],
|
|
1310
|
-
swap_abi: crvethSwapABI,
|
|
1311
|
-
gauge_abi: gaugeV4ABI,
|
|
1312
|
-
},
|
|
1313
1289
|
rai: {
|
|
1314
1290
|
name: "rai",
|
|
1315
1291
|
full_name: "rai",
|
|
@@ -32,6 +32,12 @@ export interface IStatsPool {
|
|
|
32
32
|
export declare class StatsPool implements IStatsPool {
|
|
33
33
|
pool: PoolTemplate;
|
|
34
34
|
constructor(pool: PoolTemplate);
|
|
35
|
+
/**
|
|
36
|
+
* Safely fetches admin_fee from contract with fallback logic.
|
|
37
|
+
* This is necessary because for new pools we don't know their ABI in advance,
|
|
38
|
+
* and there's no way to determine it beforehand.
|
|
39
|
+
*/
|
|
40
|
+
private _getAdminFeeSafely;
|
|
35
41
|
parameters: () => Promise<IStatsParameters>;
|
|
36
42
|
wrappedBalances(): Promise<string[]>;
|
|
37
43
|
underlyingBalances(): Promise<string[]>;
|
|
@@ -11,16 +11,17 @@ import { _getPoolsFromApi, _getCrvApyFromApi } from '../../cached.js';
|
|
|
11
11
|
import { _getUsdRate, BN, toBN, _getRewardsFromApi, getVolumeApiController, } from '../../utils.js';
|
|
12
12
|
import { rewardNetworks } from '../../constants/rewardNetworks.js';
|
|
13
13
|
import memoize from "memoizee";
|
|
14
|
+
import { Contract } from "ethers";
|
|
14
15
|
export class StatsPool {
|
|
15
16
|
constructor(pool) {
|
|
16
17
|
this.parameters = () => __awaiter(this, void 0, void 0, function* () {
|
|
17
18
|
const curve = this.pool.curve;
|
|
18
19
|
const multicallContract = curve.contracts[this.pool.address].multicallContract;
|
|
19
20
|
const lpMulticallContract = curve.contracts[this.pool.lpToken].multicallContract;
|
|
21
|
+
const _adminFee = yield this._getAdminFeeSafely();
|
|
20
22
|
const calls = [
|
|
21
23
|
multicallContract.get_virtual_price(),
|
|
22
24
|
multicallContract.fee(),
|
|
23
|
-
"admin_fee" in multicallContract ? multicallContract.admin_fee() : multicallContract.ADMIN_FEE(),
|
|
24
25
|
multicallContract.A(),
|
|
25
26
|
lpMulticallContract.totalSupply(),
|
|
26
27
|
];
|
|
@@ -43,19 +44,19 @@ export class StatsPool {
|
|
|
43
44
|
}
|
|
44
45
|
let _virtualPrice = curve.parseUnits("0");
|
|
45
46
|
let _fee = curve.parseUnits("0");
|
|
46
|
-
let _prices,
|
|
47
|
+
let _prices, _A, _lpTokenSupply, _gamma;
|
|
47
48
|
try {
|
|
48
|
-
[_virtualPrice, _fee,
|
|
49
|
+
[_virtualPrice, _fee, _A, _lpTokenSupply, _gamma, ..._prices] = (yield curve.multicallProvider.all(calls));
|
|
49
50
|
}
|
|
50
51
|
catch ( // Empty pool
|
|
51
52
|
_a) { // Empty pool
|
|
52
53
|
calls.shift();
|
|
53
54
|
if (this.pool.isCrypto) {
|
|
54
55
|
calls.shift();
|
|
55
|
-
[
|
|
56
|
+
[_A, _lpTokenSupply, _gamma, ..._prices] = (yield curve.multicallProvider.all(calls));
|
|
56
57
|
}
|
|
57
58
|
else {
|
|
58
|
-
[_fee,
|
|
59
|
+
[_fee, _A, _lpTokenSupply, _gamma, ..._prices] = (yield curve.multicallProvider.all(calls));
|
|
59
60
|
}
|
|
60
61
|
}
|
|
61
62
|
const [virtualPrice, fee, adminFee, A, lpTokenSupply, gamma] = [
|
|
@@ -221,6 +222,30 @@ export class StatsPool {
|
|
|
221
222
|
});
|
|
222
223
|
this.pool = pool;
|
|
223
224
|
}
|
|
225
|
+
/**
|
|
226
|
+
* Safely fetches admin_fee from contract with fallback logic.
|
|
227
|
+
* This is necessary because for new pools we don't know their ABI in advance,
|
|
228
|
+
* and there's no way to determine it beforehand.
|
|
229
|
+
*/
|
|
230
|
+
_getAdminFeeSafely() {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
232
|
+
const curve = this.pool.curve;
|
|
233
|
+
const contract = curve.contracts[this.pool.address].contract;
|
|
234
|
+
try {
|
|
235
|
+
if ('admin_fee' in contract) {
|
|
236
|
+
return yield contract.admin_fee();
|
|
237
|
+
}
|
|
238
|
+
else {
|
|
239
|
+
return yield contract.ADMIN_FEE();
|
|
240
|
+
}
|
|
241
|
+
}
|
|
242
|
+
catch (_a) {
|
|
243
|
+
const ADMIN_FEE_ABI = { "stateMutability": "view", "type": "function", "name": "admin_fee", "inputs": [], "outputs": [{ "name": "", "type": "uint256" }] };
|
|
244
|
+
const tmpContract = new Contract(this.pool.address, [ADMIN_FEE_ABI], curve.signer || curve.provider);
|
|
245
|
+
return yield tmpContract.admin_fee();
|
|
246
|
+
}
|
|
247
|
+
});
|
|
248
|
+
}
|
|
224
249
|
wrappedBalances() {
|
|
225
250
|
return __awaiter(this, void 0, void 0, function* () {
|
|
226
251
|
const curve = this.pool.curve;
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
[{ "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "previousOwner", "type": "address" }, { "indexed": true, "internalType": "address", "name": "newOwner", "type": "address" }], "name": "OwnershipTransferred", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": false, "internalType": "uint256", "name": "reward", "type": "uint256" }], "name": "RewardAdded", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "user", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "reward", "type": "uint256" }], "name": "RewardPaid", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "user", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "Staked", "type": "event" }, { "anonymous": false, "inputs": [{ "indexed": true, "internalType": "address", "name": "user", "type": "address" }, { "indexed": false, "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "Withdrawn", "type": "event" }, { "constant": true, "inputs": [], "name": "DURATION", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "balanceOf", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [{ "internalType": "address", "name": "account", "type": "address" }], "name": "earned", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [], "name": "exit", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [], "name": "getReward", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "isOwner", "outputs": [{ "internalType": "bool", "name": "", "type": "bool" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "lastTimeRewardApplicable", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "lastUpdateTime", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [{ "internalType": "uint256", "name": "reward", "type": "uint256" }], "name": "notifyRewardAmount", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "owner", "outputs": [{ "internalType": "address", "name": "", "type": "address" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "periodFinish", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [], "name": "renounceOwnership", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "rewardPerToken", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "rewardPerTokenStored", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "rewardRate", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [{ "internalType": "address", "name": "", "type": "address" }], "name": "rewards", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [{ "internalType": "address", "name": "_rewardDistribution", "type": "address" }], "name": "setRewardDistribution", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": false, "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "stake", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "totalSupply", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [{ "internalType": "address", "name": "newOwner", "type": "address" }], "name": "transferOwnership", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [{ "internalType": "address", "name": "", "type": "address" }], "name": "userRewardPerTokenPaid", "outputs": [{ "internalType": "uint256", "name": "", "type": "uint256" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": false, "inputs": [{ "internalType": "uint256", "name": "amount", "type": "uint256" }], "name": "withdraw", "outputs": [], "payable": false, "stateMutability": "nonpayable", "type": "function" }, { "constant": true, "inputs": [], "name": "y", "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], "payable": false, "stateMutability": "view", "type": "function" }, { "constant": true, "inputs": [], "name": "yfi", "outputs": [{ "internalType": "contract IERC20", "name": "", "type": "address" }], "payable": false, "stateMutability": "view", "type": "function" }]
|