@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,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 utils_1 = require("../../utils");
|
|
42
|
+
var examples_json_1 = require("./examples.json");
|
|
43
|
+
var README_md_1 = require("./README.md");
|
|
44
|
+
exports.author = 'in19farkt';
|
|
45
|
+
exports.version = '0.1.0';
|
|
46
|
+
exports.examples = examples_json_1["default"];
|
|
47
|
+
exports.about = README_md_1["default"];
|
|
48
|
+
function getArgs(options, address) {
|
|
49
|
+
var args = options.args || ['%{address}'];
|
|
50
|
+
return args.map(function (arg) {
|
|
51
|
+
return typeof arg === 'string' ? arg.replace(/%{address}/g, address) : arg;
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
function strategy(space, network, provider, addresses, options, snapshot) {
|
|
55
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
56
|
+
var blockTag, response;
|
|
57
|
+
return __generator(this, function (_a) {
|
|
58
|
+
switch (_a.label) {
|
|
59
|
+
case 0:
|
|
60
|
+
blockTag = typeof snapshot === 'number' ? snapshot : 'latest';
|
|
61
|
+
return [4 /*yield*/, utils_1.multicall(network, provider, [options.methodABI], addresses.map(function (address) { return [
|
|
62
|
+
options.address,
|
|
63
|
+
options.methodABI.name,
|
|
64
|
+
getArgs(options, address)
|
|
65
|
+
]; }), { blockTag: blockTag })];
|
|
66
|
+
case 1:
|
|
67
|
+
response = _a.sent();
|
|
68
|
+
return [2 /*return*/, Object.fromEntries(response.map(function (value, i) { return [
|
|
69
|
+
addresses[i],
|
|
70
|
+
parseFloat(units_1.formatUnits(value.toString(), options.decimals))
|
|
71
|
+
]; }))];
|
|
72
|
+
}
|
|
73
|
+
});
|
|
74
|
+
});
|
|
75
|
+
}
|
|
76
|
+
exports.strategy = strategy;
|
|
@@ -0,0 +1,310 @@
|
|
|
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
|
+
var __spreadArrays = (this && this.__spreadArrays) || function () {
|
|
39
|
+
for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
|
|
40
|
+
for (var r = Array(s), k = 0, i = 0; i < il; i++)
|
|
41
|
+
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
|
|
42
|
+
r[k] = a[j];
|
|
43
|
+
return r;
|
|
44
|
+
};
|
|
45
|
+
exports.__esModule = true;
|
|
46
|
+
exports.strategy = exports.examples = exports.version = exports.author = void 0;
|
|
47
|
+
var bignumber_1 = require("@ethersproject/bignumber");
|
|
48
|
+
var units_1 = require("@ethersproject/units");
|
|
49
|
+
var erc20_balance_of_1 = require("../erc20-balance-of");
|
|
50
|
+
var web3_1 = require("../../utils/web3");
|
|
51
|
+
var multicaller_1 = require("../../utils/multicaller");
|
|
52
|
+
var examples_json_1 = require("./examples.json");
|
|
53
|
+
exports.author = 'jeremyHD';
|
|
54
|
+
exports.version = '0.2.1';
|
|
55
|
+
exports.examples = examples_json_1["default"];
|
|
56
|
+
var ONE_E18 = units_1.parseUnits('1', 18);
|
|
57
|
+
var abi = [
|
|
58
|
+
{
|
|
59
|
+
constant: true,
|
|
60
|
+
inputs: [
|
|
61
|
+
{
|
|
62
|
+
internalType: 'address',
|
|
63
|
+
name: '',
|
|
64
|
+
type: 'address'
|
|
65
|
+
}
|
|
66
|
+
],
|
|
67
|
+
name: 'balanceOf',
|
|
68
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
69
|
+
payable: false,
|
|
70
|
+
stateMutability: 'view',
|
|
71
|
+
type: 'function'
|
|
72
|
+
},
|
|
73
|
+
{
|
|
74
|
+
inputs: [],
|
|
75
|
+
name: 'totalSupply',
|
|
76
|
+
outputs: [
|
|
77
|
+
{
|
|
78
|
+
internalType: 'uint256',
|
|
79
|
+
name: '',
|
|
80
|
+
type: 'uint256'
|
|
81
|
+
}
|
|
82
|
+
],
|
|
83
|
+
stateMutability: 'view',
|
|
84
|
+
type: 'function'
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
inputs: [
|
|
88
|
+
{
|
|
89
|
+
internalType: 'uint256',
|
|
90
|
+
name: '',
|
|
91
|
+
type: 'uint256'
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
internalType: 'address',
|
|
95
|
+
name: '',
|
|
96
|
+
type: 'address'
|
|
97
|
+
}
|
|
98
|
+
],
|
|
99
|
+
name: 'userInfo',
|
|
100
|
+
outputs: [
|
|
101
|
+
{
|
|
102
|
+
internalType: 'uint256',
|
|
103
|
+
name: 'amount',
|
|
104
|
+
type: 'uint256'
|
|
105
|
+
},
|
|
106
|
+
{
|
|
107
|
+
internalType: 'uint256',
|
|
108
|
+
name: 'rewardDebt',
|
|
109
|
+
type: 'uint256'
|
|
110
|
+
}
|
|
111
|
+
],
|
|
112
|
+
stateMutability: 'view',
|
|
113
|
+
type: 'function'
|
|
114
|
+
},
|
|
115
|
+
{
|
|
116
|
+
constant: true,
|
|
117
|
+
inputs: [],
|
|
118
|
+
name: 'exchangeRateStored',
|
|
119
|
+
outputs: [
|
|
120
|
+
{
|
|
121
|
+
internalType: 'uint256',
|
|
122
|
+
name: '',
|
|
123
|
+
type: 'uint256'
|
|
124
|
+
}
|
|
125
|
+
],
|
|
126
|
+
payable: false,
|
|
127
|
+
stateMutability: 'view',
|
|
128
|
+
type: 'function'
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
constant: true,
|
|
132
|
+
inputs: [
|
|
133
|
+
{
|
|
134
|
+
internalType: 'address',
|
|
135
|
+
name: 'account',
|
|
136
|
+
type: 'address'
|
|
137
|
+
}
|
|
138
|
+
],
|
|
139
|
+
name: 'borrowBalanceStored',
|
|
140
|
+
outputs: [
|
|
141
|
+
{
|
|
142
|
+
internalType: 'uint256',
|
|
143
|
+
name: '',
|
|
144
|
+
type: 'uint256'
|
|
145
|
+
}
|
|
146
|
+
],
|
|
147
|
+
payable: false,
|
|
148
|
+
stateMutability: 'view',
|
|
149
|
+
type: 'function'
|
|
150
|
+
}
|
|
151
|
+
];
|
|
152
|
+
var CREAM_VOTING_POWER = '0xb146BF59f30a54750209EF529a766D952720D0f9';
|
|
153
|
+
var CREAM_VOTING_POWER_DEPLOY_BLOCK = 12315028;
|
|
154
|
+
function strategy(space, network, provider, addresses, options, snapshot) {
|
|
155
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
156
|
+
var snapshotBlock, _a, snapshotBlocks, i, blocksPerPeriod, blockTag, scores, averageScore;
|
|
157
|
+
return __generator(this, function (_b) {
|
|
158
|
+
switch (_b.label) {
|
|
159
|
+
case 0:
|
|
160
|
+
if (!(typeof snapshot === 'number')) return [3 /*break*/, 1];
|
|
161
|
+
_a = snapshot;
|
|
162
|
+
return [3 /*break*/, 3];
|
|
163
|
+
case 1: return [4 /*yield*/, web3_1.getBlockNumber(provider)];
|
|
164
|
+
case 2:
|
|
165
|
+
_a = _b.sent();
|
|
166
|
+
_b.label = 3;
|
|
167
|
+
case 3:
|
|
168
|
+
snapshotBlock = _a;
|
|
169
|
+
snapshotBlocks = [];
|
|
170
|
+
for (i = 0; i < options.periods; i++) {
|
|
171
|
+
blocksPerPeriod = 80640;
|
|
172
|
+
blockTag = snapshotBlock > blocksPerPeriod * i
|
|
173
|
+
? snapshotBlock - blocksPerPeriod * i
|
|
174
|
+
: snapshotBlock;
|
|
175
|
+
snapshotBlocks.push(blockTag);
|
|
176
|
+
}
|
|
177
|
+
return [4 /*yield*/, Promise.all(__spreadArrays(snapshotBlocks.map(function (blockTag) {
|
|
178
|
+
return blockTag > CREAM_VOTING_POWER_DEPLOY_BLOCK
|
|
179
|
+
? getScores(provider, addresses, options, blockTag)
|
|
180
|
+
: getLegacyScores(provider, addresses, options, blockTag);
|
|
181
|
+
})))];
|
|
182
|
+
case 4:
|
|
183
|
+
scores = _b.sent();
|
|
184
|
+
averageScore = {};
|
|
185
|
+
addresses.forEach(function (address) {
|
|
186
|
+
var userScore = scores
|
|
187
|
+
.map(function (score) { return score[address]; })
|
|
188
|
+
.reduce(function (accumulator, score) { return (accumulator += score); }, 0);
|
|
189
|
+
averageScore[address] = userScore / options.periods;
|
|
190
|
+
});
|
|
191
|
+
return [2 /*return*/, Object.fromEntries(Array(addresses.length)
|
|
192
|
+
.fill('')
|
|
193
|
+
.map(function (_, i) {
|
|
194
|
+
var score = averageScore[addresses[i]];
|
|
195
|
+
// ignore score < minimum voting amount
|
|
196
|
+
if (score < options.minVote) {
|
|
197
|
+
return [addresses[i], 0];
|
|
198
|
+
}
|
|
199
|
+
return [addresses[i], score];
|
|
200
|
+
}))];
|
|
201
|
+
}
|
|
202
|
+
});
|
|
203
|
+
});
|
|
204
|
+
}
|
|
205
|
+
exports.strategy = strategy;
|
|
206
|
+
function getScores(provider, addresses, options, blockTag) {
|
|
207
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
208
|
+
return __generator(this, function (_a) {
|
|
209
|
+
return [2 /*return*/, erc20_balance_of_1.strategy('cream', '1', provider, addresses, {
|
|
210
|
+
address: CREAM_VOTING_POWER,
|
|
211
|
+
decimals: 18
|
|
212
|
+
}, blockTag)];
|
|
213
|
+
});
|
|
214
|
+
});
|
|
215
|
+
}
|
|
216
|
+
function getLegacyScores(provider, addresses, options, blockTag) {
|
|
217
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
218
|
+
var score, multi1, multi2, multi3, multi4, results, result, creamPerSushiswapLP, creamPerUniswapLP, creamPerBalancerLP;
|
|
219
|
+
return __generator(this, function (_a) {
|
|
220
|
+
switch (_a.label) {
|
|
221
|
+
case 0:
|
|
222
|
+
score = {};
|
|
223
|
+
multi1 = new multicaller_1["default"]('1', provider, abi, { blockTag: blockTag });
|
|
224
|
+
multi1.call('sushiswap.cream', options.token, 'balanceOf', [
|
|
225
|
+
options.sushiswap
|
|
226
|
+
]);
|
|
227
|
+
multi1.call('sushiswap.totalSupply', options.sushiswap, 'totalSupply');
|
|
228
|
+
addresses.forEach(function (address) {
|
|
229
|
+
multi1.call("sushiswap." + address + ".balanceOf", options.sushiswap, 'balanceOf', [address]);
|
|
230
|
+
multi1.call("sushiswap." + address + ".userInfo", options.masterChef, 'userInfo', [options.pid, address]);
|
|
231
|
+
});
|
|
232
|
+
multi2 = new multicaller_1["default"]('1', provider, abi, { blockTag: blockTag });
|
|
233
|
+
multi2.call('uniswap.cream', options.token, 'balanceOf', [options.uniswap]);
|
|
234
|
+
multi2.call('uniswap.totalSupply', options.uniswap, 'totalSupply');
|
|
235
|
+
multi2.call('balancer.cream', options.token, 'balanceOf', [options.balancer]);
|
|
236
|
+
multi2.call('balancer.totalSupply', options.balancer, 'totalSupply');
|
|
237
|
+
addresses.forEach(function (address) {
|
|
238
|
+
multi2.call("uniswap." + address + ".balanceOf", options.uniswap, 'balanceOf', [
|
|
239
|
+
address
|
|
240
|
+
]);
|
|
241
|
+
multi2.call("balancer." + address + ".balanceOf", options.balancer, 'balanceOf', [address]);
|
|
242
|
+
});
|
|
243
|
+
multi3 = new multicaller_1["default"]('1', provider, abi, { blockTag: blockTag });
|
|
244
|
+
multi3.call('crCREAM.exchangeRate', options.crCREAM, 'exchangeRateStored');
|
|
245
|
+
addresses.forEach(function (address) {
|
|
246
|
+
multi3.call("crCREAM." + address + ".balanceOf", options.crCREAM, 'balanceOf', [
|
|
247
|
+
address
|
|
248
|
+
]);
|
|
249
|
+
multi3.call("crCREAM." + address + ".borrow", options.crCREAM, 'borrowBalanceStored', [address]);
|
|
250
|
+
});
|
|
251
|
+
multi4 = new multicaller_1["default"]('1', provider, abi, { blockTag: blockTag });
|
|
252
|
+
addresses.forEach(function (address) {
|
|
253
|
+
options.pools.forEach(function (pool) {
|
|
254
|
+
multi4.call("pool." + address + "." + pool.name, pool.address, 'balanceOf', [
|
|
255
|
+
address
|
|
256
|
+
]);
|
|
257
|
+
});
|
|
258
|
+
});
|
|
259
|
+
return [4 /*yield*/, Promise.all([
|
|
260
|
+
multi1.execute(),
|
|
261
|
+
multi2.execute(),
|
|
262
|
+
multi3.execute(),
|
|
263
|
+
multi4.execute()
|
|
264
|
+
])];
|
|
265
|
+
case 1:
|
|
266
|
+
results = _a.sent();
|
|
267
|
+
result = results.reduce(function (sumResult, partialResult) {
|
|
268
|
+
Object.entries(partialResult).forEach(function (_a) {
|
|
269
|
+
var key = _a[0], value = _a[1];
|
|
270
|
+
sumResult[key] = value;
|
|
271
|
+
});
|
|
272
|
+
return sumResult;
|
|
273
|
+
}, {});
|
|
274
|
+
creamPerSushiswapLP = units_1.parseUnits(result.sushiswap.cream.toString(), 18).div(result.sushiswap.totalSupply);
|
|
275
|
+
creamPerUniswapLP = units_1.parseUnits(result.uniswap.cream.toString(), 18).div(result.uniswap.totalSupply);
|
|
276
|
+
creamPerBalancerLP = units_1.parseUnits(result.balancer.cream.toString(), 18).div(result.balancer.totalSupply);
|
|
277
|
+
addresses.forEach(function (address) {
|
|
278
|
+
var userScore = score[address] || bignumber_1.BigNumber.from(0);
|
|
279
|
+
var sushi = result.sushiswap[address].balanceOf
|
|
280
|
+
.add(result.sushiswap[address].userInfo.amount)
|
|
281
|
+
.mul(creamPerSushiswapLP)
|
|
282
|
+
.div(ONE_E18);
|
|
283
|
+
var uniswap = result.uniswap[address].balanceOf
|
|
284
|
+
.mul(creamPerUniswapLP)
|
|
285
|
+
.div(ONE_E18);
|
|
286
|
+
var balancer = result.balancer[address].balanceOf
|
|
287
|
+
.mul(creamPerBalancerLP)
|
|
288
|
+
.div(ONE_E18);
|
|
289
|
+
var crCREAM = result.crCREAM[address].balanceOf
|
|
290
|
+
.mul(result.crCREAM.exchangeRate)
|
|
291
|
+
.div(ONE_E18)
|
|
292
|
+
.sub(result.crCREAM[address].borrow);
|
|
293
|
+
var pools = Object.values(result.pool[address]).reduce(function (accumulator, poolBalance) {
|
|
294
|
+
return accumulator.add(poolBalance);
|
|
295
|
+
}, bignumber_1.BigNumber.from(0));
|
|
296
|
+
score[address] = userScore
|
|
297
|
+
.add(sushi)
|
|
298
|
+
.add(uniswap)
|
|
299
|
+
.add(balancer)
|
|
300
|
+
.add(crCREAM)
|
|
301
|
+
.add(pools);
|
|
302
|
+
});
|
|
303
|
+
Object.keys(score).map(function (address) {
|
|
304
|
+
score[address] = parseFloat(units_1.formatUnits(score[address], 18));
|
|
305
|
+
});
|
|
306
|
+
return [2 /*return*/, score];
|
|
307
|
+
}
|
|
308
|
+
});
|
|
309
|
+
});
|
|
310
|
+
}
|
|
@@ -0,0 +1,145 @@
|
|
|
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.version = exports.author = void 0;
|
|
40
|
+
var units_1 = require("@ethersproject/units");
|
|
41
|
+
var utils_1 = require("../../utils");
|
|
42
|
+
var README_md_1 = require("./README.md");
|
|
43
|
+
exports.author = 'arr00';
|
|
44
|
+
exports.version = '0.1.0';
|
|
45
|
+
exports.about = README_md_1["default"];
|
|
46
|
+
var abi = [
|
|
47
|
+
{
|
|
48
|
+
constant: true,
|
|
49
|
+
inputs: [
|
|
50
|
+
{
|
|
51
|
+
internalType: 'address',
|
|
52
|
+
name: 'account',
|
|
53
|
+
type: 'address'
|
|
54
|
+
}
|
|
55
|
+
],
|
|
56
|
+
name: 'balanceOf',
|
|
57
|
+
outputs: [
|
|
58
|
+
{
|
|
59
|
+
internalType: 'uint256',
|
|
60
|
+
name: '',
|
|
61
|
+
type: 'uint256'
|
|
62
|
+
}
|
|
63
|
+
],
|
|
64
|
+
payable: false,
|
|
65
|
+
stateMutability: 'view',
|
|
66
|
+
type: 'function'
|
|
67
|
+
},
|
|
68
|
+
{
|
|
69
|
+
constant: true,
|
|
70
|
+
inputs: [
|
|
71
|
+
{
|
|
72
|
+
internalType: 'address',
|
|
73
|
+
name: 'account',
|
|
74
|
+
type: 'address'
|
|
75
|
+
}
|
|
76
|
+
],
|
|
77
|
+
name: 'borrowBalanceStored',
|
|
78
|
+
outputs: [
|
|
79
|
+
{
|
|
80
|
+
internalType: 'uint256',
|
|
81
|
+
name: '',
|
|
82
|
+
type: 'uint256'
|
|
83
|
+
}
|
|
84
|
+
],
|
|
85
|
+
payable: false,
|
|
86
|
+
stateMutability: 'view',
|
|
87
|
+
type: 'function'
|
|
88
|
+
}
|
|
89
|
+
];
|
|
90
|
+
function strategy(space, network, provider, addresses, options, snapshot) {
|
|
91
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
92
|
+
var blockTag, oldBlockTag, _a, balanceOfCalls, borrowBalanceCalls, calls, _b, response, balancesOldResponse, balancesNowResponse, borrowsNowResponse, resultData, i, noBorrow, balanceNow, balanceOld;
|
|
93
|
+
return __generator(this, function (_c) {
|
|
94
|
+
switch (_c.label) {
|
|
95
|
+
case 0:
|
|
96
|
+
blockTag = typeof snapshot === 'number' ? snapshot : 'latest';
|
|
97
|
+
if (!(typeof snapshot === 'number')) return [3 /*break*/, 1];
|
|
98
|
+
_a = snapshot - options.offsetCheck;
|
|
99
|
+
return [3 /*break*/, 3];
|
|
100
|
+
case 1: return [4 /*yield*/, provider.getBlockNumber()];
|
|
101
|
+
case 2:
|
|
102
|
+
_a = (_c.sent()) - options.offsetCheck;
|
|
103
|
+
_c.label = 3;
|
|
104
|
+
case 3:
|
|
105
|
+
oldBlockTag = _a;
|
|
106
|
+
balanceOfCalls = addresses.map(function (address) { return [
|
|
107
|
+
options.address,
|
|
108
|
+
'balanceOf',
|
|
109
|
+
[address]
|
|
110
|
+
]; });
|
|
111
|
+
borrowBalanceCalls = addresses.map(function (address) { return [
|
|
112
|
+
options.address,
|
|
113
|
+
'borrowBalanceStored',
|
|
114
|
+
[address]
|
|
115
|
+
]; });
|
|
116
|
+
calls = balanceOfCalls.concat(borrowBalanceCalls);
|
|
117
|
+
return [4 /*yield*/, Promise.all([
|
|
118
|
+
utils_1.multicall(network, provider, abi, calls, { blockTag: blockTag }),
|
|
119
|
+
utils_1.multicall(network, provider, abi, addresses.map(function (address) { return [
|
|
120
|
+
options.address,
|
|
121
|
+
'balanceOf',
|
|
122
|
+
[address]
|
|
123
|
+
]; }), { blockTag: oldBlockTag })
|
|
124
|
+
])];
|
|
125
|
+
case 4:
|
|
126
|
+
_b = _c.sent(), response = _b[0], balancesOldResponse = _b[1];
|
|
127
|
+
balancesNowResponse = response.slice(0, addresses.length);
|
|
128
|
+
borrowsNowResponse = response.slice(addresses.length);
|
|
129
|
+
resultData = {};
|
|
130
|
+
for (i = 0; i < balancesNowResponse.length; i++) {
|
|
131
|
+
noBorrow = 1;
|
|
132
|
+
if (options.borrowingRestricted) {
|
|
133
|
+
noBorrow =
|
|
134
|
+
borrowsNowResponse[i].toString().localeCompare('0') == 0 ? 1 : 0;
|
|
135
|
+
}
|
|
136
|
+
balanceNow = parseFloat(units_1.formatUnits(balancesNowResponse[i].toString(), options.decimals));
|
|
137
|
+
balanceOld = parseFloat(units_1.formatUnits(balancesOldResponse[i].toString(), options.decimals));
|
|
138
|
+
resultData[addresses[i]] = Math.min(balanceNow, balanceOld) * noBorrow;
|
|
139
|
+
}
|
|
140
|
+
return [2 /*return*/, resultData];
|
|
141
|
+
}
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
}
|
|
145
|
+
exports.strategy = strategy;
|