"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.FundsMixin = void 0;
const base_core_sdk_1 = require("./../mixins/base-core-sdk");
const constants_1 = require("@ethersproject/constants");
const handler_1 = require("./handler");
const subgraph_1 = require("./subgraph");
class FundsMixin extends base_core_sdk_1.BaseCoreSDK {
    // Implementation
    depositFunds(entityId_1, fundsAmount_1) {
        return __awaiter(this, arguments, void 0, function* (entityId, fundsAmount, fundsTokenAddress = constants_1.AddressZero, overrides = {}) {
            const { returnTxInfo } = overrides;
            const depositArgs = {
                entityId,
                fundsAmount,
                fundsTokenAddress,
                web3Lib: this._web3Lib,
                contractAddress: overrides.contractAddress || this._protocolDiamond
            };
            if (returnTxInfo === true) {
                return (0, handler_1.depositFunds)(Object.assign(Object.assign({}, depositArgs), { returnTxInfo: true }));
            }
            else {
                return (0, handler_1.depositFunds)(Object.assign(Object.assign({}, depositArgs), { returnTxInfo: false }));
            }
        });
    }
    // Implementation
    withdrawFunds(entityId_1, tokensToWithdraw_1, amountsToWithdraw_1) {
        return __awaiter(this, arguments, void 0, function* (entityId, tokensToWithdraw, amountsToWithdraw, overrides = {}) {
            const { returnTxInfo } = overrides;
            const withdrawArgs = {
                entityId,
                tokensToWithdraw,
                amountsToWithdraw,
                contractAddress: this._protocolDiamond,
                web3Lib: this._web3Lib
            };
            if (returnTxInfo === true) {
                return (0, handler_1.withdrawFunds)(Object.assign(Object.assign({}, withdrawArgs), { returnTxInfo: true }));
            }
            else {
                return (0, handler_1.withdrawFunds)(Object.assign(Object.assign({}, withdrawArgs), { returnTxInfo: false }));
            }
        });
    }
    // Implementation
    withdrawAllAvailableFunds(entityId_1) {
        return __awaiter(this, arguments, void 0, function* (entityId, overrides = {}) {
            const { returnTxInfo } = overrides;
            const withdrawAllArgs = {
                entityId,
                subgraphUrl: this._subgraphUrl,
                contractAddress: this._protocolDiamond,
                web3Lib: this._web3Lib
            };
            if (returnTxInfo === true) {
                return (0, handler_1.withdrawAllAvailableFunds)(Object.assign(Object.assign({}, withdrawAllArgs), { returnTxInfo: true }));
            }
            else {
                return (0, handler_1.withdrawAllAvailableFunds)(Object.assign(Object.assign({}, withdrawAllArgs), { returnTxInfo: false }));
            }
        });
    }
    /**
     * Returns funds entity from subgraph.
     * @param fundsId - ID of funds entity.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Funds entity from subgraph.
     */
    getFundsById(fundsId, queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return (0, subgraph_1.getFundsById)(this._subgraphUrl, fundsId, queryVars);
        });
    }
    /**
     * Returns funds entities from subgraph.
     * @param queryVars - Optional query variables to skip, order or filter.
     * @returns Funds entities from subgraph.
     */
    getFunds(queryVars) {
        return __awaiter(this, void 0, void 0, function* () {
            return (0, subgraph_1.getFunds)(this._subgraphUrl, queryVars);
        });
    }
}
exports.FundsMixin = FundsMixin;
//# sourceMappingURL=mixin.js.map