"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.VaultTemplateTokenFetcher = void 0;
const app_token_template_position_fetcher_1 = require("../../position/template/app-token.template.position-fetcher");
class VaultTemplateTokenFetcher extends app_token_template_position_fetcher_1.AppTokenTemplatePositionFetcher {
    getContract(address) {
        return this.appToolkit.globalContracts.erc20({ address, network: this.network });
    }
    getAddresses() {
        return __awaiter(this, void 0, void 0, function* () {
            return [this.vaultAddress];
        });
    }
    getUnderlyingTokenDefinitions(_params) {
        return __awaiter(this, void 0, void 0, function* () {
            return [{ address: this.underlyingTokenAddress, network: this.network }];
        });
    }
    getPricePerShare({ multicall, appToken }) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const underlying = multicall.wrap(this.appToolkit.globalContracts.erc20(appToken.tokens[0]));
            const reserveRaw = yield underlying.balanceOf((_a = this.reserveAddress) !== null && _a !== void 0 ? _a : this.vaultAddress);
            const reserve = Number(reserveRaw) / Math.pow(10, appToken.tokens[0].decimals);
            const pricePerShare = reserve / appToken.supply;
            return [pricePerShare];
        });
    }
    getLiquidity({ multicall, appToken }) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const underlying = multicall.wrap(this.appToolkit.globalContracts.erc20(appToken.tokens[0]));
            const reserveRaw = yield underlying.balanceOf((_a = this.reserveAddress) !== null && _a !== void 0 ? _a : this.vaultAddress);
            const reserve = Number(reserveRaw) / Math.pow(10, appToken.tokens[0].decimals);
            const liquidity = reserve * appToken.tokens[0].price;
            return liquidity;
        });
    }
    getReserves({ multicall, appToken }) {
        var _a;
        return __awaiter(this, void 0, void 0, function* () {
            const underlying = multicall.wrap(this.appToolkit.globalContracts.erc20(appToken.tokens[0]));
            const reserveRaw = yield underlying.balanceOf((_a = this.reserveAddress) !== null && _a !== void 0 ? _a : this.vaultAddress);
            const reserve = Number(reserveRaw) / Math.pow(10, appToken.tokens[0].decimals);
            return [reserve];
        });
    }
    getApy(_params) {
        return __awaiter(this, void 0, void 0, function* () {
            return 0;
        });
    }
}
exports.VaultTemplateTokenFetcher = VaultTemplateTokenFetcher;
//# sourceMappingURL=vault.template.token-fetcher.js.map