"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.getScionRewardsSubgraphUrl = exports.getSectorSubgraphUrl = exports.getSgId = exports.reverseChainId = exports.fixChainId = void 0;
var _a = process.env, _b = _a.PUBLIC_SUBGRAPH, PUBLIC_SUBGRAPH = _b === void 0 ? 'localhost' : _b, _c = _a.PUBLIC_SUBGRAPH_SUFFIX, PUBLIC_SUBGRAPH_SUFFIX = _c === void 0 ? '' : _c, _d = _a.PUBLIC_FORK_CHAIN, PUBLIC_FORK_CHAIN = _d === void 0 ? 'mainnet' : _d, _e = _a.PUBLIC_SUBGRAPH_KEY, PUBLIC_SUBGRAPH_KEY = _e === void 0 ? '' : _e;
function fixChainId(chain) {
    if (chain === 'arbitrum')
        return 'arbitrum-one';
    return chain;
}
exports.fixChainId = fixChainId;
function reverseChainId(chain) {
    if (chain === 'arbitrum-one')
        return 'arbitrum';
    return chain;
}
exports.reverseChainId = reverseChainId;
function getSgId(address, chain) {
    if (chain === 'localhost')
        chain = PUBLIC_SUBGRAPH.split('-')[0];
    return (address === null || address === void 0 ? void 0 : address.toLowerCase()) + fixChainId(chain);
}
exports.getSgId = getSgId;
var vaultSubgraphIds = {
    moonriver: {
        production: '4Zxx74bNdYAuzThNUrEvopgVNHhCzhvqXjoC9RQ9AaPx',
        staging: 'xugUPwfNnTyWwo1da4iJiYnh9itzKAnFYQaUG1MEgU2',
    },
    optimism: {
        production: 'Dt7b98HhHeDXJrH9zTmNQuSZx1VEKatVhprW8rvupvqw',
        staging: '8z1TecQd6mPX5mcF1Lu5zsfgW1jtqKBUmUsThZh5KBrb',
    },
    arbitrum: {
        production: 'GtAF1urLjeMxMR1xxJ1Ngp94fWVz6cw3CgmboCiNTshs',
        staging: '5HZosWGrqEZRqBdQQvc5tR8oepTMG2PGw2LWodh3gCfz',
    },
    mainnet: {
        production: '2S8e4uhydzb3aw3neshBMYoumPXJ1FUXsdjM7J7Sv7yX',
        staging: 'AzYTb3K1Px18XBbXHFwKdZoLoWsAfwQ8RTFpGF4kqYpi',
    },
};
var rewardsSubgraphIds = {
    fantom: 'LGFF8mUj4w2VHg9A3mR2HY3aL6hJUaDq96UkLmvzAcq',
    moonriver: 'DyEcg994ZLMjha5aT6Emg2294x9FhH8rmQNsJ2R7vK5N',
};
function getSubgraphId(chain) {
    var isStaging = PUBLIC_SUBGRAPH_SUFFIX === '-staging';
    if (chain == 'localhost') {
        return vaultSubgraphIds[PUBLIC_FORK_CHAIN][isStaging ? 'staging' : 'production'];
    }
    return vaultSubgraphIds[chain][isStaging ? 'staging' : 'production'];
}
function getSubgraphUrl(id) {
    return "https://gateway-arbitrum.network.thegraph.com/api/".concat(PUBLIC_SUBGRAPH_KEY, "/subgraphs/id/").concat(id);
}
var getSectorSubgraphUrl = function (chain) {
    var subgraphId = getSubgraphId(chain);
    switch (chain) {
        case 'localhost':
            if (PUBLIC_SUBGRAPH === 'localhost') {
                // TODO: outdated local subgraph url
                return "http://localhost:8000/subgraphs/name/sector-fi/sector-".concat(PUBLIC_SUBGRAPH);
            }
            else {
                return getSubgraphUrl(getSubgraphId(PUBLIC_FORK_CHAIN));
            }
        default:
            return getSubgraphUrl(subgraphId);
    }
};
exports.getSectorSubgraphUrl = getSectorSubgraphUrl;
var getScionRewardsSubgraphUrl = function (chain) {
    return getSubgraphUrl(rewardsSubgraphIds[chain]);
};
exports.getScionRewardsSubgraphUrl = getScionRewardsSubgraphUrl;
//# sourceMappingURL=subgraph.js.map