@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
|
@@ -43,7 +43,8 @@ const ModuleAbi = [
|
|
|
43
43
|
'event ProposalQuestionCreated(bytes32 indexed questionId, string indexed proposalId)',
|
|
44
44
|
|
|
45
45
|
// Read functions
|
|
46
|
-
'function
|
|
46
|
+
'function avatar() view returns (address)', // Reality Module
|
|
47
|
+
'function executor() view returns (address)', // Dao Module
|
|
47
48
|
'function oracle() view returns (address)',
|
|
48
49
|
'function questionCooldown() view returns (uint32)',
|
|
49
50
|
'function buildQuestion(string proposalId, bytes32[] txHashes) view returns (string)',
|
|
@@ -179,12 +180,26 @@ const getModuleDetails = async (
|
|
|
179
180
|
cooldown: number;
|
|
180
181
|
minimumBond: number;
|
|
181
182
|
}> => {
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
183
|
+
let moduleDetails;
|
|
184
|
+
try {
|
|
185
|
+
// Assume module is Reality Module
|
|
186
|
+
moduleDetails = await multicall(network, provider, ModuleAbi, [
|
|
187
|
+
[moduleAddress, 'avatar'],
|
|
188
|
+
[moduleAddress, 'oracle'],
|
|
189
|
+
[moduleAddress, 'questionCooldown'],
|
|
190
|
+
[moduleAddress, 'minimumBond']
|
|
191
|
+
]);
|
|
192
|
+
} catch (err) {
|
|
193
|
+
// The Reality Module doesn't have an avatar field, causing tx to fails.
|
|
194
|
+
// Assume module is Dao Module (old version)
|
|
195
|
+
moduleDetails = await multicall(network, provider, ModuleAbi, [
|
|
196
|
+
[moduleAddress, 'executor'],
|
|
197
|
+
[moduleAddress, 'oracle'],
|
|
198
|
+
[moduleAddress, 'questionCooldown'],
|
|
199
|
+
[moduleAddress, 'minimumBond']
|
|
200
|
+
]);
|
|
201
|
+
}
|
|
202
|
+
|
|
188
203
|
return {
|
|
189
204
|
dao: moduleDetails[0][0],
|
|
190
205
|
oracle: moduleDetails[1][0],
|
package/src/sign/eip1271.ts
CHANGED
|
@@ -49,8 +49,8 @@ export async function verifyOldVersion(
|
|
|
49
49
|
return returnValue.toLowerCase() === magicValue.toLowerCase();
|
|
50
50
|
}
|
|
51
51
|
|
|
52
|
-
export async function verify(address, sig, hash) {
|
|
53
|
-
const provider = getProvider(
|
|
52
|
+
export async function verify(address, sig, hash, network = '1') {
|
|
53
|
+
const provider = getProvider(network);
|
|
54
54
|
if (await verifyDefault(address, sig, hash, provider)) return true;
|
|
55
55
|
return await verifyOldVersion(address, sig, hash, provider);
|
|
56
56
|
}
|
package/src/sign/index.ts
CHANGED
|
@@ -42,12 +42,12 @@ export default class Client {
|
|
|
42
42
|
}
|
|
43
43
|
|
|
44
44
|
async sign(web3: Web3Provider | Wallet, address: string, message, types) {
|
|
45
|
-
if (!message.from) message.from = address;
|
|
46
|
-
if (!message.timestamp) message.timestamp = ~~(Date.now() / 1e3);
|
|
47
|
-
const data: any = { domain, types, message };
|
|
48
45
|
let signer;
|
|
49
46
|
if (web3 instanceof Wallet) signer = web3;
|
|
50
47
|
if (web3 instanceof Web3Provider) signer = web3.getSigner();
|
|
48
|
+
if (!message.from) message.from = address;
|
|
49
|
+
if (!message.timestamp) message.timestamp = ~~(Date.now() / 1e3);
|
|
50
|
+
const data: any = { domain, types, message };
|
|
51
51
|
const sig = await signer._signTypedData(domain, data.types, message);
|
|
52
52
|
console.log('Sign', { address, sig, data });
|
|
53
53
|
return await this.send({ address, sig, data });
|
|
@@ -109,11 +109,15 @@ export default class Client {
|
|
|
109
109
|
return await this.sign(web3, address, message, type);
|
|
110
110
|
}
|
|
111
111
|
|
|
112
|
-
async follow(web3: Wallet, address: string, message: Follow) {
|
|
112
|
+
async follow(web3: Web3Provider | Wallet, address: string, message: Follow) {
|
|
113
113
|
return await this.sign(web3, address, message, followTypes);
|
|
114
114
|
}
|
|
115
115
|
|
|
116
|
-
async unfollow(
|
|
116
|
+
async unfollow(
|
|
117
|
+
web3: Web3Provider | Wallet,
|
|
118
|
+
address: string,
|
|
119
|
+
message: Unfollow
|
|
120
|
+
) {
|
|
117
121
|
return await this.sign(web3, address, message, unfollowTypes);
|
|
118
122
|
}
|
|
119
123
|
|
|
@@ -0,0 +1,110 @@
|
|
|
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
|
+
exports.author = 'kartojal';
|
|
44
|
+
exports.version = '0.1.0';
|
|
45
|
+
exports.examples = examples_json_1["default"];
|
|
46
|
+
exports.about = '';
|
|
47
|
+
/**
|
|
48
|
+
* Aave Governance strategy to measure voting or
|
|
49
|
+
*/
|
|
50
|
+
var abi = [
|
|
51
|
+
{
|
|
52
|
+
inputs: [
|
|
53
|
+
{ internalType: 'address', name: 'user', type: 'address' },
|
|
54
|
+
{ internalType: 'uint256', name: 'blockNumber', type: 'uint256' }
|
|
55
|
+
],
|
|
56
|
+
name: 'getPropositionPowerAt',
|
|
57
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
58
|
+
stateMutability: 'view',
|
|
59
|
+
type: 'function'
|
|
60
|
+
},
|
|
61
|
+
{
|
|
62
|
+
inputs: [
|
|
63
|
+
{ internalType: 'address', name: 'user', type: 'address' },
|
|
64
|
+
{ internalType: 'uint256', name: 'blockNumber', type: 'uint256' }
|
|
65
|
+
],
|
|
66
|
+
name: 'getVotingPowerAt',
|
|
67
|
+
outputs: [{ internalType: 'uint256', name: '', type: 'uint256' }],
|
|
68
|
+
stateMutability: 'view',
|
|
69
|
+
type: 'function'
|
|
70
|
+
}
|
|
71
|
+
];
|
|
72
|
+
var powerTypesToMethod = {
|
|
73
|
+
vote: 'getVotingPowerAt',
|
|
74
|
+
proposition: 'getPropositionPowerAt'
|
|
75
|
+
};
|
|
76
|
+
function strategy(space, network, provider, addresses, options, snapshot) {
|
|
77
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
78
|
+
var blockTag, _a, response;
|
|
79
|
+
return __generator(this, function (_b) {
|
|
80
|
+
switch (_b.label) {
|
|
81
|
+
case 0:
|
|
82
|
+
if (!(typeof snapshot === 'number')) return [3 /*break*/, 1];
|
|
83
|
+
_a = snapshot;
|
|
84
|
+
return [3 /*break*/, 3];
|
|
85
|
+
case 1: return [4 /*yield*/, provider.getBlockNumber(snapshot)];
|
|
86
|
+
case 2:
|
|
87
|
+
_a = _b.sent();
|
|
88
|
+
_b.label = 3;
|
|
89
|
+
case 3:
|
|
90
|
+
blockTag = _a;
|
|
91
|
+
// Early return 0 voting power if governanceStrategy or powerType is not correctly set
|
|
92
|
+
if (!options.governanceStrategy || !powerTypesToMethod[options.powerType]) {
|
|
93
|
+
return [2 /*return*/, Object.fromEntries(addresses.map(function (address) { return [address, '0']; }))];
|
|
94
|
+
}
|
|
95
|
+
return [4 /*yield*/, utils_1.multicall(network, provider, abi, addresses.map(function (address) { return [
|
|
96
|
+
options.governanceStrategy,
|
|
97
|
+
powerTypesToMethod[options.powerType],
|
|
98
|
+
[address.toLowerCase(), blockTag]
|
|
99
|
+
]; }), { blockTag: blockTag })];
|
|
100
|
+
case 4:
|
|
101
|
+
response = _b.sent();
|
|
102
|
+
return [2 /*return*/, Object.fromEntries(response.map(function (value, i) { return [
|
|
103
|
+
addresses[i],
|
|
104
|
+
parseFloat(units_1.formatUnits(value.toString(), options.decimals))
|
|
105
|
+
]; }))];
|
|
106
|
+
}
|
|
107
|
+
});
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
exports.strategy = strategy;
|
|
@@ -0,0 +1,156 @@
|
|
|
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 utils_1 = require("../../utils");
|
|
41
|
+
var examples_json_1 = require("./examples.json");
|
|
42
|
+
exports.author = 'vfatouros';
|
|
43
|
+
exports.version = '0.1.0';
|
|
44
|
+
exports.examples = examples_json_1["default"];
|
|
45
|
+
var tokenAbi = [
|
|
46
|
+
{
|
|
47
|
+
constant: true,
|
|
48
|
+
inputs: [
|
|
49
|
+
{
|
|
50
|
+
internalType: 'address',
|
|
51
|
+
name: 'account',
|
|
52
|
+
type: 'address'
|
|
53
|
+
}
|
|
54
|
+
],
|
|
55
|
+
name: 'balanceOf',
|
|
56
|
+
outputs: [
|
|
57
|
+
{
|
|
58
|
+
internalType: 'uint256',
|
|
59
|
+
name: '',
|
|
60
|
+
type: 'uint256'
|
|
61
|
+
}
|
|
62
|
+
],
|
|
63
|
+
payable: false,
|
|
64
|
+
stateMutability: 'view',
|
|
65
|
+
type: 'function'
|
|
66
|
+
},
|
|
67
|
+
{
|
|
68
|
+
constant: true,
|
|
69
|
+
inputs: [],
|
|
70
|
+
name: 'totalSupply',
|
|
71
|
+
outputs: [
|
|
72
|
+
{
|
|
73
|
+
internalType: 'uint256',
|
|
74
|
+
name: '',
|
|
75
|
+
type: 'uint256'
|
|
76
|
+
}
|
|
77
|
+
],
|
|
78
|
+
payable: false,
|
|
79
|
+
stateMutability: 'view',
|
|
80
|
+
type: 'function'
|
|
81
|
+
},
|
|
82
|
+
{
|
|
83
|
+
constant: true,
|
|
84
|
+
inputs: [
|
|
85
|
+
{
|
|
86
|
+
internalType: 'address',
|
|
87
|
+
name: '_account',
|
|
88
|
+
type: 'address'
|
|
89
|
+
}
|
|
90
|
+
],
|
|
91
|
+
name: 'staked',
|
|
92
|
+
outputs: [
|
|
93
|
+
{
|
|
94
|
+
internalType: 'uint256',
|
|
95
|
+
name: 'ghst_',
|
|
96
|
+
type: 'uint256'
|
|
97
|
+
},
|
|
98
|
+
{
|
|
99
|
+
internalType: 'uint256',
|
|
100
|
+
name: 'poolTokens_',
|
|
101
|
+
type: 'uint256'
|
|
102
|
+
},
|
|
103
|
+
{
|
|
104
|
+
internalType: 'uint256',
|
|
105
|
+
name: 'ghstUsdcPoolToken_',
|
|
106
|
+
type: 'uint256'
|
|
107
|
+
}
|
|
108
|
+
],
|
|
109
|
+
payable: false,
|
|
110
|
+
stateMutability: 'view',
|
|
111
|
+
type: 'function'
|
|
112
|
+
}
|
|
113
|
+
];
|
|
114
|
+
function strategy(_space, network, provider, addresses, options, snapshot) {
|
|
115
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
116
|
+
var blockTag, res, ghstQuickTotalSupply, ghstQuickTokenBalanceInUni, ghstQuickTokensPerUni, ghstUsdcTotalSupply, ghstUsdcTokenBalanceInUni, ghstUsdcTokensPerUni, response;
|
|
117
|
+
return __generator(this, function (_a) {
|
|
118
|
+
switch (_a.label) {
|
|
119
|
+
case 0:
|
|
120
|
+
options.ghstWethAddress =
|
|
121
|
+
options.ghstWethAddress || '0xccb9d2100037f1253e6c1682adf7dc9944498aff';
|
|
122
|
+
blockTag = typeof snapshot === 'number' ? snapshot : 'latest';
|
|
123
|
+
return [4 /*yield*/, utils_1.multicall(network, provider, tokenAbi, [
|
|
124
|
+
[options.ghstQuickAddress, 'totalSupply', []],
|
|
125
|
+
[options.tokenAddress, 'balanceOf', [options.ghstQuickAddress]],
|
|
126
|
+
[options.ghstUsdcAddress, 'totalSupply', []],
|
|
127
|
+
[options.tokenAddress, 'balanceOf', [options.ghstUsdcAddress]]
|
|
128
|
+
].concat(addresses.map(function (address) { return [
|
|
129
|
+
options.stakingAddress,
|
|
130
|
+
'staked',
|
|
131
|
+
[address]
|
|
132
|
+
]; })), { blockTag: blockTag })];
|
|
133
|
+
case 1:
|
|
134
|
+
res = _a.sent();
|
|
135
|
+
ghstQuickTotalSupply = res[0];
|
|
136
|
+
ghstQuickTokenBalanceInUni = res[1];
|
|
137
|
+
ghstQuickTokensPerUni = ghstQuickTokenBalanceInUni /
|
|
138
|
+
Math.pow(10, options.decimals) /
|
|
139
|
+
(ghstQuickTotalSupply / 1e18);
|
|
140
|
+
ghstUsdcTotalSupply = res[2];
|
|
141
|
+
ghstUsdcTokenBalanceInUni = res[3];
|
|
142
|
+
ghstUsdcTokensPerUni = ghstUsdcTokenBalanceInUni /
|
|
143
|
+
Math.pow(10, options.decimals) /
|
|
144
|
+
(ghstUsdcTotalSupply / 1e18);
|
|
145
|
+
response = res.slice(4);
|
|
146
|
+
return [2 /*return*/, Object.fromEntries(response.map(function (values, i) { return [
|
|
147
|
+
addresses[i],
|
|
148
|
+
values[0] / 1e18 + //ghst_
|
|
149
|
+
(values[1] / Math.pow(10, options.decimals)) * ghstQuickTokensPerUni + //poolTokens_
|
|
150
|
+
(values[2] / Math.pow(10, options.decimals)) * ghstUsdcTokensPerUni //ghstUsdcPoolToken_
|
|
151
|
+
]; }))];
|
|
152
|
+
}
|
|
153
|
+
});
|
|
154
|
+
});
|
|
155
|
+
}
|
|
156
|
+
exports.strategy = strategy;
|
|
@@ -0,0 +1,168 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __assign = (this && this.__assign) || function () {
|
|
3
|
+
__assign = Object.assign || function(t) {
|
|
4
|
+
for (var s, i = 1, n = arguments.length; i < n; i++) {
|
|
5
|
+
s = arguments[i];
|
|
6
|
+
for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
|
|
7
|
+
t[p] = s[p];
|
|
8
|
+
}
|
|
9
|
+
return t;
|
|
10
|
+
};
|
|
11
|
+
return __assign.apply(this, arguments);
|
|
12
|
+
};
|
|
13
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
14
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
15
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
16
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
17
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
18
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
19
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
20
|
+
});
|
|
21
|
+
};
|
|
22
|
+
var __generator = (this && this.__generator) || function (thisArg, body) {
|
|
23
|
+
var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
|
|
24
|
+
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
|
|
25
|
+
function verb(n) { return function (v) { return step([n, v]); }; }
|
|
26
|
+
function step(op) {
|
|
27
|
+
if (f) throw new TypeError("Generator is already executing.");
|
|
28
|
+
while (_) try {
|
|
29
|
+
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;
|
|
30
|
+
if (y = 0, t) op = [op[0] & 2, t.value];
|
|
31
|
+
switch (op[0]) {
|
|
32
|
+
case 0: case 1: t = op; break;
|
|
33
|
+
case 4: _.label++; return { value: op[1], done: false };
|
|
34
|
+
case 5: _.label++; y = op[1]; op = [0]; continue;
|
|
35
|
+
case 7: op = _.ops.pop(); _.trys.pop(); continue;
|
|
36
|
+
default:
|
|
37
|
+
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
|
|
38
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
|
|
39
|
+
if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
|
|
40
|
+
if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
|
|
41
|
+
if (t[2]) _.ops.pop();
|
|
42
|
+
_.trys.pop(); continue;
|
|
43
|
+
}
|
|
44
|
+
op = body.call(thisArg, _);
|
|
45
|
+
} catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
|
|
46
|
+
if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
|
|
47
|
+
}
|
|
48
|
+
};
|
|
49
|
+
exports.__esModule = true;
|
|
50
|
+
exports.strategy = exports.examples = exports.version = exports.author = void 0;
|
|
51
|
+
var units_1 = require("@ethersproject/units");
|
|
52
|
+
var multicaller_1 = require("../../utils/multicaller");
|
|
53
|
+
var utils_1 = require("../../utils");
|
|
54
|
+
var examples_json_1 = require("./examples.json");
|
|
55
|
+
exports.author = 'candoizo';
|
|
56
|
+
exports.version = '0.1.0';
|
|
57
|
+
exports.examples = examples_json_1["default"];
|
|
58
|
+
var AAVEGOTCHI_SUBGRAPH_URL = {
|
|
59
|
+
137: 'https://api.thegraph.com/subgraphs/name/aavegotchi/aavegotchi-core-matic'
|
|
60
|
+
};
|
|
61
|
+
var tokenAbi = [
|
|
62
|
+
{
|
|
63
|
+
inputs: [{ internalType: 'address', name: '_account', type: 'address' }],
|
|
64
|
+
name: 'itemBalances',
|
|
65
|
+
outputs: [
|
|
66
|
+
{
|
|
67
|
+
components: [
|
|
68
|
+
{ internalType: 'uint256', name: 'itemId', type: 'uint256' },
|
|
69
|
+
{ internalType: 'uint256', name: 'balance', type: 'uint256' }
|
|
70
|
+
],
|
|
71
|
+
internalType: 'struct ItemsFacet.ItemIdIO[]',
|
|
72
|
+
name: 'bals_',
|
|
73
|
+
type: 'tuple[]'
|
|
74
|
+
}
|
|
75
|
+
],
|
|
76
|
+
stateMutability: 'view',
|
|
77
|
+
type: 'function'
|
|
78
|
+
}
|
|
79
|
+
];
|
|
80
|
+
var itemPriceParams = {
|
|
81
|
+
itemTypes: {
|
|
82
|
+
__args: {
|
|
83
|
+
first: 1000
|
|
84
|
+
},
|
|
85
|
+
svgId: true,
|
|
86
|
+
ghstPrice: true
|
|
87
|
+
}
|
|
88
|
+
};
|
|
89
|
+
function strategy(_space, network, provider, addresses, options, snapshot) {
|
|
90
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
91
|
+
var blockTag, multi, multiRes, walletQueryParams, result, prices, walletScores;
|
|
92
|
+
return __generator(this, function (_a) {
|
|
93
|
+
switch (_a.label) {
|
|
94
|
+
case 0:
|
|
95
|
+
blockTag = typeof snapshot === 'number' ? snapshot : 'latest';
|
|
96
|
+
multi = new multicaller_1["default"](network, provider, tokenAbi, { blockTag: blockTag });
|
|
97
|
+
addresses.map(function (addr) {
|
|
98
|
+
return multi.call(options.tokenAddress + "." + addr.toLowerCase(), options.tokenAddress, 'itemBalances', [addr]);
|
|
99
|
+
});
|
|
100
|
+
return [4 /*yield*/, multi.execute()];
|
|
101
|
+
case 1:
|
|
102
|
+
multiRes = _a.sent();
|
|
103
|
+
walletQueryParams = {
|
|
104
|
+
users: {
|
|
105
|
+
__args: {
|
|
106
|
+
where: {
|
|
107
|
+
id_in: addresses.map(function (addr) { return addr.toLowerCase(); })
|
|
108
|
+
},
|
|
109
|
+
first: 1000
|
|
110
|
+
},
|
|
111
|
+
id: true,
|
|
112
|
+
gotchisOwned: {
|
|
113
|
+
baseRarityScore: true,
|
|
114
|
+
equippedWearables: true
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
};
|
|
118
|
+
return [4 /*yield*/, utils_1.subgraphRequest(AAVEGOTCHI_SUBGRAPH_URL[network], __assign(__assign({}, itemPriceParams), walletQueryParams))];
|
|
119
|
+
case 2:
|
|
120
|
+
result = _a.sent();
|
|
121
|
+
prices = {};
|
|
122
|
+
result.itemTypes.map(function (itemInfo) {
|
|
123
|
+
var itemValue = parseFloat(units_1.formatUnits(itemInfo.ghstPrice, 18));
|
|
124
|
+
if (itemValue > 0)
|
|
125
|
+
prices[parseInt(itemInfo.svgId)] = itemValue;
|
|
126
|
+
});
|
|
127
|
+
walletScores = {};
|
|
128
|
+
result.users.map(function (addrInfo) {
|
|
129
|
+
var id = addrInfo.id, gotchisOwned = addrInfo.gotchisOwned;
|
|
130
|
+
var gotchisBrsEquipValue = 0;
|
|
131
|
+
if (gotchisOwned.length > 0)
|
|
132
|
+
gotchisOwned.map(function (gotchi) {
|
|
133
|
+
var brs = parseInt(gotchi.baseRarityScore);
|
|
134
|
+
gotchisBrsEquipValue += brs;
|
|
135
|
+
gotchi.equippedWearables
|
|
136
|
+
.filter(function (itemId) { return itemId != 0; })
|
|
137
|
+
.map(function (itemId) {
|
|
138
|
+
var shopCost = prices[itemId];
|
|
139
|
+
if (isNaN(shopCost))
|
|
140
|
+
shopCost = 0;
|
|
141
|
+
gotchisBrsEquipValue += shopCost;
|
|
142
|
+
});
|
|
143
|
+
});
|
|
144
|
+
var ownerItemValue = 0;
|
|
145
|
+
var ownerItemInfo = multiRes[options.tokenAddress][id];
|
|
146
|
+
if (ownerItemInfo.length > 0)
|
|
147
|
+
ownerItemInfo.map(function (itemInfo) {
|
|
148
|
+
var amountOwned = parseInt(itemInfo.balance.toString());
|
|
149
|
+
var itemId = parseInt(itemInfo.itemId.toString());
|
|
150
|
+
var pricetag = parseFloat(prices[itemId]);
|
|
151
|
+
var cost = pricetag * amountOwned;
|
|
152
|
+
if (isNaN(cost))
|
|
153
|
+
cost = 0;
|
|
154
|
+
ownerItemValue += cost;
|
|
155
|
+
});
|
|
156
|
+
var addr = addresses.find(function (addrOption) { return addrOption.toLowerCase() === id; });
|
|
157
|
+
walletScores[addr] = ownerItemValue + gotchisBrsEquipValue;
|
|
158
|
+
});
|
|
159
|
+
addresses.map(function (addr) {
|
|
160
|
+
if (!walletScores[addr])
|
|
161
|
+
walletScores[addr] = 0;
|
|
162
|
+
});
|
|
163
|
+
return [2 /*return*/, walletScores];
|
|
164
|
+
}
|
|
165
|
+
});
|
|
166
|
+
});
|
|
167
|
+
}
|
|
168
|
+
exports.strategy = strategy;
|