@curvefi/api 2.57.2 → 2.57.4
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/lib/curve.js +22 -5
- package/lib/utils.d.ts +4 -1
- package/lib/utils.js +28 -0
- package/package.json +1 -1
package/lib/curve.js
CHANGED
|
@@ -54,8 +54,8 @@ var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
|
54
54
|
}
|
|
55
55
|
return to.concat(ar || Array.prototype.slice.call(from));
|
|
56
56
|
};
|
|
57
|
-
import { ethers,
|
|
58
|
-
import { Provider as MulticallProvider
|
|
57
|
+
import { ethers, AbstractProvider, } from "ethers";
|
|
58
|
+
import { Provider as MulticallProvider } from 'ethcall';
|
|
59
59
|
import { getFactoryPoolData } from "./factory/factory.js";
|
|
60
60
|
import { getFactoryPoolsDataFromApi } from "./factory/factory-api.js";
|
|
61
61
|
import { getCryptoFactoryPoolData } from "./factory/factory-crypto.js";
|
|
@@ -111,6 +111,7 @@ import { lowerCasePoolDataAddresses, extractDecimals, extractGauges } from "./co
|
|
|
111
111
|
import { _getAllGauges, _getHiddenPools } from "./external-api.js";
|
|
112
112
|
import { L2Networks } from "./constants/L2Networks.js";
|
|
113
113
|
import { getTwocryptoFactoryPoolData } from "./factory/factory-twocrypto";
|
|
114
|
+
import { initContract, initMulticallContract } from "./utils.js";
|
|
114
115
|
var _killGauges = function (poolsData) { return __awaiter(void 0, void 0, void 0, function () {
|
|
115
116
|
var gaugeData, isKilled, gaugeStatuses, poolId;
|
|
116
117
|
return __generator(this, function (_a) {
|
|
@@ -1179,10 +1180,26 @@ var Curve = /** @class */ (function () {
|
|
|
1179
1180
|
});
|
|
1180
1181
|
};
|
|
1181
1182
|
Curve.prototype.setContract = function (address, abi) {
|
|
1182
|
-
|
|
1183
|
-
|
|
1184
|
-
|
|
1183
|
+
// eslint-disable-next-line @typescript-eslint/no-this-alias
|
|
1184
|
+
var curveInstance = this;
|
|
1185
|
+
var proxyHandler = {
|
|
1186
|
+
get: function (target, name) {
|
|
1187
|
+
if (name === 'contract') {
|
|
1188
|
+
return initContract(target['address'], target['abi'], curveInstance.signer || curveInstance.provider);
|
|
1189
|
+
}
|
|
1190
|
+
else if (name === 'multicallContract') {
|
|
1191
|
+
return initMulticallContract(target['address'], target['abi']);
|
|
1192
|
+
}
|
|
1193
|
+
else {
|
|
1194
|
+
return target[name];
|
|
1195
|
+
}
|
|
1196
|
+
},
|
|
1197
|
+
};
|
|
1198
|
+
var coreContract = {
|
|
1199
|
+
address: address,
|
|
1200
|
+
abi: abi,
|
|
1185
1201
|
};
|
|
1202
|
+
this.contracts[address] = new Proxy(coreContract, proxyHandler);
|
|
1186
1203
|
};
|
|
1187
1204
|
Curve.prototype._filterHiddenPools = function (pools) {
|
|
1188
1205
|
return __awaiter(this, void 0, void 0, function () {
|
package/lib/utils.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import { Contract } from 'ethers';
|
|
1
|
+
import { BrowserProvider, Contract, JsonRpcProvider, Signer } from 'ethers';
|
|
2
|
+
import { Contract as MulticallContract } from "ethcall";
|
|
2
3
|
import BigNumber from 'bignumber.js';
|
|
3
4
|
import { IBasePoolShortItem, IChainId, IDict, INetworkName, IRewardFromApi, IVolumeAndAPYs, REFERENCE_ASSET } from './interfaces';
|
|
4
5
|
export declare const ETH_ADDRESS = "0xeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeeee";
|
|
@@ -65,3 +66,5 @@ export declare const getPoolName: (name: string) => string;
|
|
|
65
66
|
export declare const isStableNgPool: (name: string) => boolean;
|
|
66
67
|
export declare const assetTypeNameHandler: (assetTypeName: string) => REFERENCE_ASSET;
|
|
67
68
|
export declare const getBasePools: () => Promise<IBasePoolShortItem[]>;
|
|
69
|
+
export declare const initContract: (address: string, abi: any, provider: BrowserProvider | JsonRpcProvider | Signer) => Contract;
|
|
70
|
+
export declare const initMulticallContract: (address: string, abi: any) => MulticallContract;
|
package/lib/utils.js
CHANGED
|
@@ -1004,3 +1004,31 @@ export var getBasePools = function () { return __awaiter(void 0, void 0, void 0,
|
|
|
1004
1004
|
}
|
|
1005
1005
|
});
|
|
1006
1006
|
}); };
|
|
1007
|
+
var memoizedContract = function () {
|
|
1008
|
+
var cache = {};
|
|
1009
|
+
return function (address, abi, provider) {
|
|
1010
|
+
if (address in cache) {
|
|
1011
|
+
return cache[address];
|
|
1012
|
+
}
|
|
1013
|
+
else {
|
|
1014
|
+
var result = new Contract(address, abi, provider);
|
|
1015
|
+
cache[address] = result;
|
|
1016
|
+
return result;
|
|
1017
|
+
}
|
|
1018
|
+
};
|
|
1019
|
+
};
|
|
1020
|
+
var memoizedMulticallContract = function () {
|
|
1021
|
+
var cache = {};
|
|
1022
|
+
return function (address, abi) {
|
|
1023
|
+
if (address in cache) {
|
|
1024
|
+
return cache[address];
|
|
1025
|
+
}
|
|
1026
|
+
else {
|
|
1027
|
+
var result = new MulticallContract(address, abi);
|
|
1028
|
+
cache[address] = result;
|
|
1029
|
+
return result;
|
|
1030
|
+
}
|
|
1031
|
+
};
|
|
1032
|
+
};
|
|
1033
|
+
export var initContract = memoizedContract();
|
|
1034
|
+
export var initMulticallContract = memoizedMulticallContract();
|