Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

allow empty pool for sushi-swap graph reading. #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions docs/asset-manifest.json
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
{
"files": {
"main.css": "/web3-snippets/static/css/main.534a6974.chunk.css",
"main.js": "/web3-snippets/static/js/main.0500f203.chunk.js",
"main.js.map": "/web3-snippets/static/js/main.0500f203.chunk.js.map",
"main.js": "/web3-snippets/static/js/main.09e4141f.chunk.js",
"main.js.map": "/web3-snippets/static/js/main.09e4141f.chunk.js.map",
"runtime-main.js": "/web3-snippets/static/js/runtime-main.e9f1977e.js",
"runtime-main.js.map": "/web3-snippets/static/js/runtime-main.e9f1977e.js.map",
"static/css/2.181a3cb8.chunk.css": "/web3-snippets/static/css/2.181a3cb8.chunk.css",
"static/js/2.d58a128c.chunk.js": "/web3-snippets/static/js/2.d58a128c.chunk.js",
"static/js/2.d58a128c.chunk.js.map": "/web3-snippets/static/js/2.d58a128c.chunk.js.map",
"index.html": "/web3-snippets/index.html",
"precache-manifest.2fb3d4d88dab1dc8887a3980a3ccc046.js": "/web3-snippets/precache-manifest.2fb3d4d88dab1dc8887a3980a3ccc046.js",
"precache-manifest.af1528e5c5b787ed8e50f59d3dbbe872.js": "/web3-snippets/precache-manifest.af1528e5c5b787ed8e50f59d3dbbe872.js",
"service-worker.js": "/web3-snippets/service-worker.js",
"static/css/2.181a3cb8.chunk.css.map": "/web3-snippets/static/css/2.181a3cb8.chunk.css.map",
"static/css/main.534a6974.chunk.css.map": "/web3-snippets/static/css/main.534a6974.chunk.css.map",
Expand All @@ -21,6 +21,6 @@
"static/css/2.181a3cb8.chunk.css",
"static/js/2.d58a128c.chunk.js",
"static/css/main.534a6974.chunk.css",
"static/js/main.0500f203.chunk.js"
"static/js/main.09e4141f.chunk.js"
]
}
2 changes: 1 addition & 1 deletion docs/index.html
Original file line number Diff line number Diff line change
@@ -1 +1 @@
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/web3-snippets/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/web3-snippets/logo192.png"/><link rel="manifest" href="/web3-snippets/manifest.json"/><title>React App</title><link href="/web3-snippets/static/css/2.181a3cb8.chunk.css" rel="stylesheet"><link href="/web3-snippets/static/css/main.534a6974.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,l,i=r[0],p=r[1],f=r[2],c=0,s=[];c<i.length;c++)l=i[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in p)Object.prototype.hasOwnProperty.call(p,n)&&(e[n]=p[n]);for(a&&a(r);s.length;)s.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var p=t[i];0!==o[p]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="/web3-snippets/";var i=this.webpackJsonpwww=this.webpackJsonpwww||[],p=i.push.bind(i);i.push=r,i=i.slice();for(var f=0;f<i.length;f++)r(i[f]);var a=p;t()}([])</script><script src="/web3-snippets/static/js/2.d58a128c.chunk.js"></script><script src="/web3-snippets/static/js/main.0500f203.chunk.js"></script></body></html>
<!doctype html><html lang="en"><head><meta charset="utf-8"/><link rel="icon" href="/web3-snippets/favicon.ico"/><meta name="viewport" content="width=device-width,initial-scale=1"/><meta name="theme-color" content="#000000"/><meta name="description" content="Web site created using create-react-app"/><link rel="apple-touch-icon" href="/web3-snippets/logo192.png"/><link rel="manifest" href="/web3-snippets/manifest.json"/><title>React App</title><link href="/web3-snippets/static/css/2.181a3cb8.chunk.css" rel="stylesheet"><link href="/web3-snippets/static/css/main.534a6974.chunk.css" rel="stylesheet"></head><body><noscript>You need to enable JavaScript to run this app.</noscript><div id="root"></div><script>!function(e){function r(r){for(var n,l,i=r[0],p=r[1],f=r[2],c=0,s=[];c<i.length;c++)l=i[c],Object.prototype.hasOwnProperty.call(o,l)&&o[l]&&s.push(o[l][0]),o[l]=0;for(n in p)Object.prototype.hasOwnProperty.call(p,n)&&(e[n]=p[n]);for(a&&a(r);s.length;)s.shift()();return u.push.apply(u,f||[]),t()}function t(){for(var e,r=0;r<u.length;r++){for(var t=u[r],n=!0,i=1;i<t.length;i++){var p=t[i];0!==o[p]&&(n=!1)}n&&(u.splice(r--,1),e=l(l.s=t[0]))}return e}var n={},o={1:0},u=[];function l(r){if(n[r])return n[r].exports;var t=n[r]={i:r,l:!1,exports:{}};return e[r].call(t.exports,t,t.exports,l),t.l=!0,t.exports}l.m=e,l.c=n,l.d=function(e,r,t){l.o(e,r)||Object.defineProperty(e,r,{enumerable:!0,get:t})},l.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},l.t=function(e,r){if(1&r&&(e=l(e)),8&r)return e;if(4&r&&"object"==typeof e&&e&&e.__esModule)return e;var t=Object.create(null);if(l.r(t),Object.defineProperty(t,"default",{enumerable:!0,value:e}),2&r&&"string"!=typeof e)for(var n in e)l.d(t,n,function(r){return e[r]}.bind(null,n));return t},l.n=function(e){var r=e&&e.__esModule?function(){return e.default}:function(){return e};return l.d(r,"a",r),r},l.o=function(e,r){return Object.prototype.hasOwnProperty.call(e,r)},l.p="/web3-snippets/";var i=this.webpackJsonpwww=this.webpackJsonpwww||[],p=i.push.bind(i);i.push=r,i=i.slice();for(var f=0;f<i.length;f++)r(i[f]);var a=p;t()}([])</script><script src="/web3-snippets/static/js/2.d58a128c.chunk.js"></script><script src="/web3-snippets/static/js/main.09e4141f.chunk.js"></script></body></html>
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
self.__precacheManifest = (self.__precacheManifest || []).concat([
{
"revision": "846a9730367a494f6fb2190555e889a5",
"revision": "5938d3b28f9da6aa353884e038f523ad",
"url": "/web3-snippets/index.html"
},
{
"revision": "47a267cdeaa8e41cef20",
"url": "/web3-snippets/static/css/2.181a3cb8.chunk.css"
},
{
"revision": "0e189896282c930ce790",
"revision": "97fe755d54a87b852041",
"url": "/web3-snippets/static/css/main.534a6974.chunk.css"
},
{
Expand All @@ -20,8 +20,8 @@ self.__precacheManifest = (self.__precacheManifest || []).concat([
"url": "/web3-snippets/static/js/2.d58a128c.chunk.js.LICENSE.txt"
},
{
"revision": "0e189896282c930ce790",
"url": "/web3-snippets/static/js/main.0500f203.chunk.js"
"revision": "97fe755d54a87b852041",
"url": "/web3-snippets/static/js/main.09e4141f.chunk.js"
},
{
"revision": "55dd424de1c313764148",
Expand Down
2 changes: 1 addition & 1 deletion docs/service-worker.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
importScripts("https://storage.googleapis.com/workbox-cdn/releases/4.3.1/workbox-sw.js");

importScripts(
"/web3-snippets/precache-manifest.2fb3d4d88dab1dc8887a3980a3ccc046.js"
"/web3-snippets/precache-manifest.af1528e5c5b787ed8e50f59d3dbbe872.js"
);

self.addEventListener('message', (event) => {
Expand Down
1 change: 0 additions & 1 deletion docs/static/js/main.0500f203.chunk.js.map

This file was deleted.

Large diffs are not rendered by default.

1 change: 1 addition & 0 deletions docs/static/js/main.09e4141f.chunk.js.map

Large diffs are not rendered by default.

6 changes: 5 additions & 1 deletion lib/pool-position.js
Original file line number Diff line number Diff line change
Expand Up @@ -177,15 +177,19 @@ async function sushiCalculateLocked(holderAddress, farmPoolId) {
throw new Error(`Graph query error: ${response.errors[0].message}`);
}

console.log(JSON.stringify(response.data.users, null, 2))
for(const user of response.data.users) {
if (user.pool.id === farmPoolId) {
console.log(JSON.stringify(user, null, 2))
if (user.pool && user.pool.id === farmPoolId) {
const sushiPerShare = new BigNumber(user.pool.accSushiPerShare).dividedBy('1e12');
const sushiDebt = new BigNumber(user.rewardDebt).dividedBy('1e18');
const pending = new BigNumber(user.amount).dividedBy('1e18').multipliedBy(sushiPerShare).minus(sushiDebt);

const harvested = new BigNumber(user.sushiHarvested);
const locked = pending.plus(harvested).multipliedBy(2);
return locked;
} else {
return new BigNumber(user.sushiHarvested).multipliedBy(2);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

there is no locked sushi program afaik, ended months ago

}
}
throw new Error(`Liquidity Provider Wallet Address ${holderAddress} with MasterChef Farm Pool Id ${farmPoolId} not found`)
Expand Down