@snapshot-labs/snapshot.js 0.2.2 → 0.2.6
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/LICENSE +0 -0
- package/README.md +0 -0
- package/dist/index.d.ts +2 -0
- package/dist/plugins/charts/index.d.ts +5 -0
- package/dist/plugins/commentBox/index.d.ts +5 -0
- package/dist/plugins/index.d.ts +4 -0
- package/dist/rollup.cjs.config.dev.js +43 -0
- package/dist/rollup.config.dev.js +75 -0
- package/dist/sign/eip1271.d.ts +1 -1
- package/dist/sign/index.d.ts +2 -2
- package/dist/snapshot.cjs.js +73 -34
- package/dist/snapshot.esm.js +73 -34
- package/dist/snapshot.min.js +1 -1
- package/dist/strategies/aave-governance-power/index.d.ts +3 -0
- package/dist/strategies/aavegotchi/index.d.ts +6 -0
- package/dist/strategies/aavegotchi-agip/index.d.ts +3 -0
- package/dist/strategies/apescape/index.d.ts +6 -0
- package/dist/strategies/api/index.d.ts +6 -0
- package/dist/strategies/avn-balance-of-staked/index.d.ts +3 -0
- package/dist/strategies/badgeth/index.d.ts +3 -0
- package/dist/strategies/balance-of-with-min/index.d.ts +3 -0
- package/dist/strategies/balance-of-with-thresholds/index.d.ts +25 -0
- package/dist/strategies/balancer/index.d.ts +3 -0
- package/dist/strategies/balancer-delegation/index.d.ts +6 -0
- package/dist/strategies/balancer-smart-pool/index.d.ts +6 -0
- package/dist/strategies/balancer-unipool/index.d.ts +6 -0
- package/dist/strategies/brightid/index.d.ts +6 -0
- package/dist/strategies/cake/index.d.ts +3 -0
- package/dist/strategies/celer-sgn-delegation/index.d.ts +3 -0
- package/dist/strategies/comp-like-votes/index.d.ts +6 -0
- package/dist/strategies/contract-call/index.d.ts +6 -0
- package/dist/strategies/cream/index.d.ts +3 -0
- package/dist/strategies/ctoken/index.d.ts +3 -0
- package/dist/strategies/curio-cards-erc20-weighted/index.d.ts +3 -0
- package/dist/strategies/decentraland-estate-size/index.d.ts +3 -0
- package/dist/strategies/defidollar/index.d.ts +3 -0
- package/dist/strategies/delegation/index.d.ts +6 -0
- package/dist/strategies/dittomoney/index.d.ts +3 -0
- package/dist/strategies/ens-domains-owned/index.d.ts +3 -0
- package/dist/strategies/ens-reverse-record/index.d.ts +6 -0
- package/dist/strategies/erc1155-all-balances-of/index.d.ts +6 -0
- package/dist/strategies/erc1155-balance-of/index.d.ts +6 -0
- package/dist/strategies/erc1155-balance-of-cv/index.d.ts +6 -0
- package/dist/strategies/erc20-balance-of/index.d.ts +3 -0
- package/dist/strategies/erc20-balance-of-coeff/index.d.ts +3 -0
- package/dist/strategies/erc20-balance-of-cv/index.d.ts +6 -0
- package/dist/strategies/erc20-balance-of-delegation/index.d.ts +6 -0
- package/dist/strategies/erc20-balance-of-fixed-total/index.d.ts +6 -0
- package/dist/strategies/erc20-balance-of-quadratic-delegation/index.d.ts +6 -0
- package/dist/strategies/erc20-price/index.d.ts +3 -0
- package/dist/strategies/erc20-received/index.d.ts +10 -0
- package/dist/strategies/erc20-with-balance/index.d.ts +3 -0
- package/dist/strategies/erc721/index.d.ts +6 -0
- package/dist/strategies/erc721-enumerable/index.d.ts +3 -0
- package/dist/strategies/erc721-with-multiplier/index.d.ts +6 -0
- package/dist/strategies/erc721-with-tokenid/index.d.ts +21 -0
- package/dist/strategies/esd/index.d.ts +3 -0
- package/dist/strategies/esd-delegation/index.d.ts +6 -0
- package/dist/strategies/eth-balance/index.d.ts +6 -0
- package/dist/strategies/eth-philanthropy/index.d.ts +6 -0
- package/dist/strategies/eth-received/ElasticSearchTxResult.d.ts +71 -0
- package/dist/strategies/eth-received/index.d.ts +7 -0
- package/dist/strategies/eth-wallet-age/index.d.ts +3 -0
- package/dist/strategies/eth-with-balance/index.d.ts +3 -0
- package/dist/strategies/flashstake/index.d.ts +3 -0
- package/dist/strategies/frax-finance/index.d.ts +3 -0
- package/dist/strategies/governor-alpha/index.d.ts +6 -0
- package/dist/strategies/hopr-uni-lp-farm/index.d.ts +3 -0
- package/dist/strategies/ilv/index.d.ts +6 -0
- package/dist/strategies/impossible-finance/index.d.ts +6 -0
- package/dist/strategies/index.d.ts +243 -0
- package/dist/strategies/infinityprotocol-liquidity-pools/index.d.ts +3 -0
- package/dist/strategies/inverse-xinv/index.d.ts +6 -0
- package/dist/strategies/iotex-balance/index.d.ts +3 -0
- package/dist/strategies/iotex-staked-balance/index.d.ts +3 -0
- package/dist/strategies/liftkitchen/index.d.ts +3 -0
- package/dist/strategies/maker-ds-chief/index.d.ts +6 -0
- package/dist/strategies/masterchef/index.d.ts +3 -0
- package/dist/strategies/masterchef-pool-balance/index.d.ts +3 -0
- package/dist/strategies/masterchef-pool-balance-price/index.d.ts +6 -0
- package/dist/strategies/mithcash/index.d.ts +3 -0
- package/dist/strategies/modefi/index.d.ts +6 -0
- package/dist/strategies/modefi-staking/index.d.ts +6 -0
- package/dist/strategies/moloch/index.d.ts +6 -0
- package/dist/strategies/moloch-all/index.d.ts +6 -0
- package/dist/strategies/moloch-loot/index.d.ts +6 -0
- package/dist/strategies/multichain/index.d.ts +3 -0
- package/dist/strategies/multisig-owners/index.d.ts +6 -0
- package/dist/strategies/mushrooms/index.d.ts +6 -0
- package/dist/strategies/niu-staked/index.d.ts +6 -0
- package/dist/strategies/ocean-marketplace/index.d.ts +8 -0
- package/dist/strategies/ocean-marketplace/oceanUtils.d.ts +2 -0
- package/dist/strategies/ogn/index.d.ts +3 -0
- package/dist/strategies/opium/index.d.ts +3 -0
- package/dist/strategies/pagination/index.d.ts +3 -0
- package/dist/strategies/pancake/index.d.ts +6 -0
- package/dist/strategies/pepemon/index.d.ts +6 -0
- package/dist/strategies/piedao/index.d.ts +3 -0
- package/dist/strategies/planet-finance/index.d.ts +4 -0
- package/dist/strategies/pob-hash/index.d.ts +9 -0
- package/dist/strategies/rebased/index.d.ts +3 -0
- package/dist/strategies/ren-nodes/index.d.ts +3 -0
- package/dist/strategies/rnbw-balance/index.d.ts +3 -0
- package/dist/strategies/ruler-staked-lp/index.d.ts +6 -0
- package/dist/strategies/ruler-staked-token/index.d.ts +6 -0
- package/dist/strategies/saffron-finance/index.d.ts +6 -0
- package/dist/strategies/spookyswap/index.d.ts +6 -0
- package/dist/strategies/stablexswap/index.d.ts +6 -0
- package/dist/strategies/staked-keep/index.d.ts +3 -0
- package/dist/strategies/staked-uniswap/index.d.ts +6 -0
- package/dist/strategies/strategiesFull.d.ts +245 -0
- package/dist/strategies/sushiswap/index.d.ts +3 -0
- package/dist/strategies/synthetix/index.d.ts +3 -0
- package/dist/strategies/the-graph/baseStrategy.d.ts +4 -0
- package/dist/strategies/the-graph/graphUtils.d.ts +12 -0
- package/dist/strategies/the-graph/tokenLockWallets.d.ts +9 -0
- package/dist/strategies/the-graph-balance/balances.d.ts +2 -0
- package/dist/strategies/the-graph-balance/index.d.ts +6 -0
- package/dist/strategies/the-graph-delegation/delegators.d.ts +2 -0
- package/dist/strategies/the-graph-delegation/index.d.ts +6 -0
- package/dist/strategies/the-graph-indexing/index.d.ts +6 -0
- package/dist/strategies/the-graph-indexing/indexers.d.ts +2 -0
- package/dist/strategies/ticket/index.d.ts +6 -0
- package/dist/strategies/ticket-validity/index.d.ts +3 -0
- package/dist/strategies/tokenlon/index.d.ts +3 -0
- package/dist/strategies/tomb-finance/index.d.ts +6 -0
- package/dist/strategies/total-axion-shares/index.d.ts +3 -0
- package/dist/strategies/tranche-staking/index.d.ts +6 -0
- package/dist/strategies/tranche-staking-lp/index.d.ts +6 -0
- package/dist/strategies/tranche-staking-slice/index.d.ts +3 -0
- package/dist/strategies/typhoon/index.d.ts +3 -0
- package/dist/strategies/uni/index.d.ts +6 -0
- package/dist/strategies/unipool-same-token/index.d.ts +6 -0
- package/dist/strategies/unipool-univ2-lp/index.d.ts +6 -0
- package/dist/strategies/uniswap/index.d.ts +3 -0
- package/dist/strategies/whitelist/index.d.ts +6 -0
- package/dist/strategies/work/index.d.ts +6 -0
- package/dist/strategies/xcover/index.d.ts +6 -0
- package/dist/strategies/xdai-easy-staking/index.d.ts +3 -0
- package/dist/strategies/xdai-easy-staking/utils.d.ts +3 -0
- package/dist/strategies/xdai-posdao-staking/index.d.ts +3 -0
- package/dist/strategies/xdai-stake-delegation/index.d.ts +6 -0
- package/dist/strategies/xdai-stake-holders/index.d.ts +3 -0
- package/dist/strategies/xdai-stakers-and-holders/index.d.ts +3 -0
- package/dist/strategies/xrc20-balance-of/index.d.ts +3 -0
- package/dist/strategies/xseen/index.d.ts +6 -0
- package/dist/strategies/yearn-vault/index.d.ts +3 -0
- package/dist/strategies/zrx-voting-power/index.d.ts +3 -0
- package/dist/utils/contentHash.d.ts +28 -0
- package/package.json +2 -2
- package/src/client.ts +0 -0
- package/src/dist/index.js +14 -0
- package/src/dist/utils.js +291 -0
- package/src/networks/{fuse.png → 122.png} +0 -0
- package/src/networks/43114.png +0 -0
- package/src/networks.json +2 -2
- package/src/plugins/charts/index.ts +5 -0
- package/src/plugins/charts/logo.png +0 -0
- package/src/plugins/commentBox/index.ts +5 -0
- package/src/plugins/commentBox/logo.png +0 -0
- package/src/plugins/index.ts +5 -1
- package/src/plugins/safeSnap/dist/index.js +585 -0
- package/src/plugins/safeSnap/index.ts +22 -7
- package/src/sign/eip1271.ts +2 -2
- package/src/sign/index.ts +9 -5
- package/src/strategies/aave-governance-power/dist/index.js +110 -0
- package/src/strategies/aavegotchi/dist/index.js +156 -0
- package/src/strategies/aavegotchi-agip/dist/index.js +168 -0
- package/src/strategies/apescape/dist/index.js +164 -0
- package/src/strategies/api/dist/index.js +76 -0
- package/src/strategies/avn-balance-of-staked/dist/index.js +173 -0
- package/src/strategies/badgeth/dist/index.js +86 -0
- package/src/strategies/balance-of-with-min/dist/index.js +64 -0
- package/src/strategies/balance-of-with-thresholds/dist/index.js +73 -0
- package/src/strategies/balancer/dist/index.js +121 -0
- package/src/strategies/balancer-delegation/dist/index.js +62 -0
- package/src/strategies/balancer-smart-pool/dist/index.js +85 -0
- package/src/strategies/balancer-unipool/dist/index.js +141 -0
- package/src/strategies/brightid/dist/index.js +69 -0
- package/src/strategies/cake/dist/index.js +146 -0
- package/src/strategies/celer-sgn-delegation/dist/index.js +199 -0
- package/src/strategies/comp-like-votes/dist/index.js +91 -0
- package/src/strategies/contract-call/dist/index.js +76 -0
- package/src/strategies/cream/dist/index.js +310 -0
- package/src/strategies/ctoken/dist/index.js +145 -0
- package/src/strategies/curio-cards-erc20-weighted/dist/index.js +188 -0
- package/src/strategies/decentraland-estate-size/dist/index.js +101 -0
- package/src/strategies/defidollar/dist/index.js +106 -0
- package/src/strategies/delegation/dist/index.js +71 -0
- package/src/strategies/dist/index.js +248 -0
- package/src/strategies/dist/strategiesFull.js +246 -0
- package/src/strategies/dittomoney/dist/index.js +167 -0
- package/src/strategies/ens-domains-owned/dist/index.js +105 -0
- package/src/strategies/ens-reverse-record/dist/index.js +98 -0
- package/src/strategies/erc1155-all-balances-of/dist/index.js +99 -0
- package/src/strategies/erc1155-balance-of/dist/index.js +94 -0
- package/src/strategies/erc1155-balance-of-cv/dist/index.js +58 -0
- package/src/strategies/erc20-balance-of/dist/index.js +76 -0
- package/src/strategies/erc20-balance-of-delegation/dist/index.js +73 -0
- package/src/strategies/erc20-balance-of-quadratic-delegation/dist/index.js +75 -0
- package/src/strategies/erc20-price/dist/index.js +107 -0
- package/src/strategies/erc20-received/dist/index.js +166 -0
- package/src/strategies/erc20-with-balance/dist/index.js +61 -0
- package/src/strategies/erc721/dist/index.js +69 -0
- package/src/strategies/erc721-enumerable/dist/index.js +57 -0
- package/src/strategies/erc721-with-multiplier/dist/index.js +70 -0
- package/src/strategies/erc721-with-tokenid/dist/index.js +68 -0
- package/src/strategies/esd/dist/index.js +125 -0
- package/src/strategies/esd-delegation/dist/index.js +73 -0
- package/src/strategies/eth-balance/dist/index.js +72 -0
- package/src/strategies/eth-philanthropy/dist/index.js +81 -0
- package/src/strategies/eth-received/dist/index.js +127 -0
- package/src/strategies/eth-wallet-age/dist/index.js +126 -0
- package/src/strategies/eth-with-balance/dist/index.js +63 -0
- package/src/strategies/flashstake/dist/index.js +138 -0
- package/src/strategies/frax-finance/dist/index.js +236 -0
- package/src/strategies/governor-alpha/dist/index.js +71 -0
- package/src/strategies/hopr-uni-lp-farm/dist/index.js +232 -0
- package/src/strategies/ilv/dist/index.js +58 -0
- package/src/strategies/impossible-finance/dist/index.js +126 -0
- package/src/strategies/infinityprotocol-liquidity-pools/dist/index.js +120 -0
- package/src/strategies/inverse-xinv/dist/index.js +76 -0
- package/src/strategies/iotex-balance/dist/index.js +82 -0
- package/src/strategies/iotex-staked-balance/dist/index.js +79 -0
- package/src/strategies/liftkitchen/dist/index.js +167 -0
- package/src/strategies/masterchef/dist/index.js +183 -0
- package/src/strategies/masterchef-pool-balance/dist/index.js +190 -0
- package/src/strategies/masterchef-pool-balance-price/dist/index.js +442 -0
- package/src/strategies/mithcash/dist/index.js +133 -0
- package/src/strategies/modefi/dist/index.js +120 -0
- package/src/strategies/modefi-staking/dist/index.js +115 -0
- package/src/strategies/moloch-all/dist/index.js +154 -0
- package/src/strategies/moloch-loot/dist/index.js +153 -0
- package/src/strategies/multichain/dist/index.js +149 -0
- package/src/strategies/multisig-owners/dist/index.js +85 -0
- package/src/strategies/mushrooms/dist/index.js +202 -0
- package/src/strategies/niu-staked/dist/index.js +83 -0
- package/src/strategies/ocean-marketplace/dist/index.js +155 -0
- package/src/strategies/ogn/dist/index.js +105 -0
- package/src/strategies/opium/dist/index.js +153 -0
- package/src/strategies/pagination/dist/index.js +78 -0
- package/src/strategies/pancake/dist/index.js +140 -0
- package/src/strategies/pepemon/dist/index.js +177 -0
- package/src/strategies/piedao/dist/index.js +156 -0
- package/src/strategies/planet-finance/dist/index.js +190 -0
- package/src/strategies/pob-hash/dist/index.js +95 -0
- package/src/strategies/rebased/dist/index.js +134 -0
- package/src/strategies/ren-nodes/dist/index.js +148 -0
- package/src/strategies/rnbw-balance/dist/index.js +107 -0
- package/src/strategies/ruler-staked-lp/dist/index.js +156 -0
- package/src/strategies/ruler-staked-token/dist/index.js +100 -0
- package/src/strategies/saffron-finance/dist/index.js +293 -0
- package/src/strategies/spookyswap/dist/index.js +161 -0
- package/src/strategies/stablexswap/dist/index.js +153 -0
- package/src/strategies/staked-keep/dist/index.js +90 -0
- package/src/strategies/staked-uniswap/dist/index.js +112 -0
- package/src/strategies/sushiswap/dist/index.js +120 -0
- package/src/strategies/synthetix/dist/index.js +233 -0
- package/src/strategies/the-graph-balance/dist/index.js +55 -0
- package/src/strategies/the-graph-delegation/dist/index.js +55 -0
- package/src/strategies/the-graph-indexing/dist/index.js +55 -0
- package/src/strategies/ticket/dist/index.js +51 -0
- package/src/strategies/ticket-validity/dist/index.js +63 -0
- package/src/strategies/tokenlon/dist/index.js +211 -0
- package/src/strategies/tomb-finance/dist/index.js +130 -0
- package/src/strategies/total-axion-shares/dist/index.js +93 -0
- package/src/strategies/tranche-staking/dist/index.js +96 -0
- package/src/strategies/tranche-staking-lp/dist/index.js +133 -0
- package/src/strategies/tranche-staking-slice/dist/index.js +164 -0
- package/src/strategies/typhoon/dist/index.js +124 -0
- package/src/strategies/uni/dist/index.js +93 -0
- package/src/strategies/unipool-same-token/dist/index.js +98 -0
- package/src/strategies/unipool-univ2-lp/dist/index.js +105 -0
- package/src/strategies/uniswap/dist/index.js +120 -0
- package/src/strategies/whitelist/dist/index.js +56 -0
- package/src/strategies/work/dist/index.js +90 -0
- package/src/strategies/xcover/dist/index.js +95 -0
- package/src/strategies/xdai-easy-staking/dist/index.js +193 -0
- package/src/strategies/xdai-posdao-staking/dist/index.js +63 -0
- package/src/strategies/xdai-stake-delegation/dist/index.js +93 -0
- package/src/strategies/xdai-stake-holders/dist/index.js +63 -0
- package/src/strategies/xdai-stakers-and-holders/dist/index.js +137 -0
- package/src/strategies/xrc20-balance-of/dist/index.js +83 -0
- package/src/strategies/xseen/dist/index.js +121 -0
- package/src/strategies/zrx-voting-power/dist/index.js +104 -0
- package/src/utils/dist/provider.js +12 -0
- package/src/utils/dist/web3.js +73 -0
|
@@ -0,0 +1,94 @@
|
|
|
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 (_) 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
|
+
exports.__esModule = true;
|
|
39
|
+
exports.strategy = exports.examples = exports.version = exports.author = void 0;
|
|
40
|
+
var units_1 = require("@ethersproject/units");
|
|
41
|
+
var utils_1 = require("../../utils");
|
|
42
|
+
var examples_json_1 = require("./examples.json");
|
|
43
|
+
exports.author = 'dave4506';
|
|
44
|
+
exports.version = '0.1.0';
|
|
45
|
+
exports.examples = examples_json_1["default"];
|
|
46
|
+
var abi = [
|
|
47
|
+
{
|
|
48
|
+
inputs: [
|
|
49
|
+
{
|
|
50
|
+
internalType: 'address',
|
|
51
|
+
name: 'owner',
|
|
52
|
+
type: 'address'
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
internalType: 'uint256',
|
|
56
|
+
name: 'id',
|
|
57
|
+
type: 'uint256'
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
name: 'balanceOf',
|
|
61
|
+
outputs: [
|
|
62
|
+
{
|
|
63
|
+
internalType: 'uint256',
|
|
64
|
+
name: '',
|
|
65
|
+
type: 'uint256'
|
|
66
|
+
}
|
|
67
|
+
],
|
|
68
|
+
stateMutability: 'view',
|
|
69
|
+
type: 'function'
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
function strategy(space, network, provider, addresses, options, snapshot) {
|
|
73
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
74
|
+
var blockTag, response;
|
|
75
|
+
return __generator(this, function (_a) {
|
|
76
|
+
switch (_a.label) {
|
|
77
|
+
case 0:
|
|
78
|
+
blockTag = typeof snapshot === 'number' ? snapshot : 'latest';
|
|
79
|
+
return [4 /*yield*/, utils_1.multicall(network, provider, abi, addresses.map(function (address) { return [
|
|
80
|
+
options.address,
|
|
81
|
+
'balanceOf',
|
|
82
|
+
[address, options.tokenId]
|
|
83
|
+
]; }), { blockTag: blockTag })];
|
|
84
|
+
case 1:
|
|
85
|
+
response = _a.sent();
|
|
86
|
+
return [2 /*return*/, Object.fromEntries(response.map(function (value, i) { return [
|
|
87
|
+
addresses[i],
|
|
88
|
+
parseFloat(units_1.formatUnits(value.toString(), options.decimals))
|
|
89
|
+
]; }))];
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
});
|
|
93
|
+
}
|
|
94
|
+
exports.strategy = strategy;
|
|
@@ -0,0 +1,58 @@
|
|
|
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 (_) 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
|
+
exports.__esModule = true;
|
|
39
|
+
exports.strategy = exports.examples = exports.version = exports.author = void 0;
|
|
40
|
+
var erc1155_balance_of_1 = require("../erc1155-balance-of");
|
|
41
|
+
var examples_json_1 = require("./examples.json");
|
|
42
|
+
exports.author = 'dave4506';
|
|
43
|
+
exports.version = '0.1.0';
|
|
44
|
+
exports.examples = examples_json_1["default"];
|
|
45
|
+
function strategy(space, network, provider, addresses, options, snapshot) {
|
|
46
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
47
|
+
var score;
|
|
48
|
+
return __generator(this, function (_a) {
|
|
49
|
+
switch (_a.label) {
|
|
50
|
+
case 0: return [4 /*yield*/, erc1155_balance_of_1.strategy(space, network, provider, addresses, options, snapshot)];
|
|
51
|
+
case 1:
|
|
52
|
+
score = _a.sent();
|
|
53
|
+
return [2 /*return*/, Object.fromEntries(Object.entries(score).map(function (address) { return [address[0], Math.sqrt(address[1])]; }))];
|
|
54
|
+
}
|
|
55
|
+
});
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
exports.strategy = strategy;
|
|
@@ -0,0 +1,76 @@
|
|
|
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 (_) 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
|
+
exports.__esModule = true;
|
|
39
|
+
exports.strategy = exports.about = exports.examples = exports.version = exports.author = void 0;
|
|
40
|
+
var units_1 = require("@ethersproject/units");
|
|
41
|
+
var multicaller_1 = require("../../utils/multicaller");
|
|
42
|
+
var examples_json_1 = require("./examples.json");
|
|
43
|
+
var README_md_1 = require("./README.md");
|
|
44
|
+
exports.author = 'bonustrack';
|
|
45
|
+
exports.version = '0.1.1';
|
|
46
|
+
exports.examples = examples_json_1["default"];
|
|
47
|
+
exports.about = README_md_1["default"];
|
|
48
|
+
var abi = [
|
|
49
|
+
'function balanceOf(address account) external view returns (uint256)'
|
|
50
|
+
];
|
|
51
|
+
function strategy(space, network, provider, addresses, options, snapshot) {
|
|
52
|
+
return __awaiter(this, void 0, Promise, function () {
|
|
53
|
+
var blockTag, multi, result;
|
|
54
|
+
return __generator(this, function (_a) {
|
|
55
|
+
switch (_a.label) {
|
|
56
|
+
case 0:
|
|
57
|
+
blockTag = typeof snapshot === 'number' ? snapshot : 'latest';
|
|
58
|
+
multi = new multicaller_1["default"](network, provider, abi, { blockTag: blockTag });
|
|
59
|
+
addresses.forEach(function (address) {
|
|
60
|
+
return multi.call(address, options.address, 'balanceOf', [address]);
|
|
61
|
+
});
|
|
62
|
+
return [4 /*yield*/, multi.execute()];
|
|
63
|
+
case 1:
|
|
64
|
+
result = _a.sent();
|
|
65
|
+
return [2 /*return*/, Object.fromEntries(Object.entries(result).map(function (_a) {
|
|
66
|
+
var address = _a[0], balance = _a[1];
|
|
67
|
+
return [
|
|
68
|
+
address,
|
|
69
|
+
parseFloat(units_1.formatUnits(balance, options.decimals))
|
|
70
|
+
];
|
|
71
|
+
}))];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
exports.strategy = strategy;
|
|
@@ -0,0 +1,73 @@
|
|
|
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 (_) 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
|
+
exports.__esModule = true;
|
|
39
|
+
exports.strategy = exports.examples = exports.version = exports.author = void 0;
|
|
40
|
+
var erc20_balance_of_1 = require("../erc20-balance-of");
|
|
41
|
+
var utils_1 = require("../../plugins/delegation/utils");
|
|
42
|
+
var examples_json_1 = require("./examples.json");
|
|
43
|
+
exports.author = 'bonustrack';
|
|
44
|
+
exports.version = '0.1.0';
|
|
45
|
+
exports.examples = examples_json_1["default"];
|
|
46
|
+
function strategy(space, network, provider, addresses, options, snapshot) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
48
|
+
var delegations, score;
|
|
49
|
+
return __generator(this, function (_a) {
|
|
50
|
+
switch (_a.label) {
|
|
51
|
+
case 0: return [4 /*yield*/, utils_1.getDelegations(space, network, provider, addresses, options, snapshot)];
|
|
52
|
+
case 1:
|
|
53
|
+
delegations = _a.sent();
|
|
54
|
+
if (Object.keys(delegations).length === 0)
|
|
55
|
+
return [2 /*return*/, {}];
|
|
56
|
+
console.debug('Delegations', delegations);
|
|
57
|
+
return [4 /*yield*/, erc20_balance_of_1.strategy(space, network, provider, Object.values(delegations).reduce(function (a, b) {
|
|
58
|
+
return a.concat(b);
|
|
59
|
+
}), options, snapshot)];
|
|
60
|
+
case 2:
|
|
61
|
+
score = _a.sent();
|
|
62
|
+
console.debug('Delegators score', score);
|
|
63
|
+
return [2 /*return*/, Object.fromEntries(addresses.map(function (address) {
|
|
64
|
+
var addressScore = delegations[address]
|
|
65
|
+
? delegations[address].reduce(function (a, b) { return a + score[b]; }, 0)
|
|
66
|
+
: 0;
|
|
67
|
+
return [address, addressScore];
|
|
68
|
+
}))];
|
|
69
|
+
}
|
|
70
|
+
});
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
exports.strategy = strategy;
|
|
@@ -0,0 +1,75 @@
|
|
|
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 (_) 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
|
+
exports.__esModule = true;
|
|
39
|
+
exports.strategy = exports.about = exports.examples = exports.version = exports.author = void 0;
|
|
40
|
+
var erc20_balance_of_1 = require("../erc20-balance-of");
|
|
41
|
+
var utils_1 = require("../../plugins/delegation/utils");
|
|
42
|
+
var examples_json_1 = require("./examples.json");
|
|
43
|
+
var README_md_1 = require("./README.md");
|
|
44
|
+
exports.author = 'ferittuncer';
|
|
45
|
+
exports.version = '1.0.0';
|
|
46
|
+
exports.examples = examples_json_1["default"];
|
|
47
|
+
exports.about = README_md_1["default"];
|
|
48
|
+
function strategy(space, network, provider, addresses, options, snapshot) {
|
|
49
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
50
|
+
var delegations, score;
|
|
51
|
+
return __generator(this, function (_a) {
|
|
52
|
+
switch (_a.label) {
|
|
53
|
+
case 0: return [4 /*yield*/, utils_1.getDelegations(space, network, provider, addresses, options, snapshot)];
|
|
54
|
+
case 1:
|
|
55
|
+
delegations = _a.sent();
|
|
56
|
+
if (Object.keys(delegations).length === 0)
|
|
57
|
+
return [2 /*return*/, {}];
|
|
58
|
+
console.debug('Delegations', delegations);
|
|
59
|
+
return [4 /*yield*/, erc20_balance_of_1.strategy(space, network, provider, Object.values(delegations).reduce(function (a, b) {
|
|
60
|
+
return a.concat(b);
|
|
61
|
+
}), options, snapshot)];
|
|
62
|
+
case 2:
|
|
63
|
+
score = _a.sent();
|
|
64
|
+
console.debug('Delegators score', score);
|
|
65
|
+
return [2 /*return*/, Object.fromEntries(addresses.map(function (address) {
|
|
66
|
+
var addressScore = delegations[address]
|
|
67
|
+
? delegations[address].reduce(function (a, b) { return (Math.sqrt(a) + Math.sqrt(score[b])) ^ 2; }, 0)
|
|
68
|
+
: 0;
|
|
69
|
+
return [address, addressScore];
|
|
70
|
+
}))];
|
|
71
|
+
}
|
|
72
|
+
});
|
|
73
|
+
});
|
|
74
|
+
}
|
|
75
|
+
exports.strategy = strategy;
|
|
@@ -0,0 +1,107 @@
|
|
|
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 (_) 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
|
+
exports.__esModule = true;
|
|
39
|
+
exports.strategy = exports.about = exports.examples = exports.version = exports.author = void 0;
|
|
40
|
+
var cross_fetch_1 = require("cross-fetch");
|
|
41
|
+
var erc20_balance_of_1 = require("../erc20-balance-of");
|
|
42
|
+
var examples_json_1 = require("./examples.json");
|
|
43
|
+
var README_md_1 = require("./README.md");
|
|
44
|
+
exports.author = 'snapshot-labs';
|
|
45
|
+
exports.version = '0.0.1';
|
|
46
|
+
exports.examples = examples_json_1["default"];
|
|
47
|
+
exports.about = README_md_1["default"];
|
|
48
|
+
var networksWithPlatforms = {
|
|
49
|
+
1: 'ethereum',
|
|
50
|
+
56: 'binance-smart-chain',
|
|
51
|
+
66: 'okex-chain',
|
|
52
|
+
88: 'tomochain',
|
|
53
|
+
100: 'xdai',
|
|
54
|
+
128: 'huobi-token',
|
|
55
|
+
137: 'polygon-pos',
|
|
56
|
+
250: 'fantom',
|
|
57
|
+
42220: 'celo',
|
|
58
|
+
43114: 'avalanche',
|
|
59
|
+
1666600000: 'harmony-shard-0'
|
|
60
|
+
};
|
|
61
|
+
function strategy(space, network, provider, addresses, options, snapshot) {
|
|
62
|
+
var _a, _b;
|
|
63
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
64
|
+
var blockTag, block, platform, address, _c, currency, coingeckoApiURL, coingeckoData, latestPriceFromBlock, score;
|
|
65
|
+
var _this = this;
|
|
66
|
+
return __generator(this, function (_d) {
|
|
67
|
+
switch (_d.label) {
|
|
68
|
+
case 0:
|
|
69
|
+
blockTag = typeof snapshot === 'number' ? snapshot : 'latest';
|
|
70
|
+
return [4 /*yield*/, provider.getBlock(blockTag)];
|
|
71
|
+
case 1:
|
|
72
|
+
block = _d.sent();
|
|
73
|
+
platform = options.platform
|
|
74
|
+
? options.platform
|
|
75
|
+
: networksWithPlatforms[network];
|
|
76
|
+
address = options.address, _c = options.currency, currency = _c === void 0 ? 'usd' : _c;
|
|
77
|
+
coingeckoApiURL = "https://api.coingecko.com/api/v3/coins/" + platform + "/contract/" + address + "/market_chart/range?vs_currency=" + currency + "&from=" + (block.timestamp - 100000) + "&to=" + block.timestamp;
|
|
78
|
+
return [4 /*yield*/, cross_fetch_1["default"](coingeckoApiURL)
|
|
79
|
+
.then(function (r) { return __awaiter(_this, void 0, void 0, function () {
|
|
80
|
+
var json;
|
|
81
|
+
return __generator(this, function (_a) {
|
|
82
|
+
switch (_a.label) {
|
|
83
|
+
case 0: return [4 /*yield*/, r.json()];
|
|
84
|
+
case 1:
|
|
85
|
+
json = _a.sent();
|
|
86
|
+
return [2 /*return*/, json];
|
|
87
|
+
}
|
|
88
|
+
});
|
|
89
|
+
}); })["catch"](function (e) {
|
|
90
|
+
console.error(e);
|
|
91
|
+
throw new Error('Strategy er20-price: coingecko api failed');
|
|
92
|
+
})];
|
|
93
|
+
case 2:
|
|
94
|
+
coingeckoData = _d.sent();
|
|
95
|
+
latestPriceFromBlock = ((_b = (_a = coingeckoData.prices) === null || _a === void 0 ? void 0 : _a.pop()) === null || _b === void 0 ? void 0 : _b.pop()) || 0;
|
|
96
|
+
return [4 /*yield*/, erc20_balance_of_1.strategy(space, network, provider, addresses, options, snapshot)];
|
|
97
|
+
case 3:
|
|
98
|
+
score = _d.sent();
|
|
99
|
+
return [2 /*return*/, Object.fromEntries(Object.entries(score).map(function (address) { return [
|
|
100
|
+
address[0],
|
|
101
|
+
address[1] * latestPriceFromBlock
|
|
102
|
+
]; }))];
|
|
103
|
+
}
|
|
104
|
+
});
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
exports.strategy = strategy;
|