import { BaseCoreSDK } from "./../mixins/base-core-sdk";
import { AddressZero } from "@ethersproject/constants";
import { withdrawFunds, withdrawAllAvailableFunds, depositFunds } from "./handler";
import { getFundsById, getFunds } from "./subgraph";
export class FundsMixin extends BaseCoreSDK {
    // Implementation
    async depositFunds(entityId, fundsAmount, fundsTokenAddress = AddressZero, overrides = {}) {
        const { returnTxInfo } = overrides;
        const depositArgs = {
            entityId,
            fundsAmount,
            fundsTokenAddress,
            web3Lib: this._web3Lib,
            contractAddress: overrides.contractAddress || this._protocolDiamond
        };
        if (returnTxInfo === true) {
            return depositFunds({
                ...depositArgs,
                returnTxInfo: true
            });
        }
        else {
            return depositFunds({
                ...depositArgs,
                returnTxInfo: false
            });
        }
    }
    // Implementation
    async withdrawFunds(entityId, tokensToWithdraw, amountsToWithdraw, overrides = {}) {
        const { returnTxInfo } = overrides;
        const withdrawArgs = {
            entityId,
            tokensToWithdraw,
            amountsToWithdraw,
            contractAddress: this._protocolDiamond,
            web3Lib: this._web3Lib
        };
        if (returnTxInfo === true) {
            return withdrawFunds({
                ...withdrawArgs,
                returnTxInfo: true
            });
        }
        else {
            return withdrawFunds({
                ...withdrawArgs,
                returnTxInfo: false
            });
        }
    }
    // Implementation
    async withdrawAllAvailableFunds(entityId, overrides = {}) {
        const { returnTxInfo } = overrides;
        const withdrawAllArgs = {
            entityId,
            subgraphUrl: this._subgraphUrl,
            contractAddress: this._protocolDiamond,
            web3Lib: this._web3Lib
        };
        if (returnTxInfo === true) {
            return withdrawAllAvailableFunds({
                ...withdrawAllArgs,
                returnTxInfo: true
            });
        }
        else {
            return withdrawAllAvailableFunds({
                ...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.
     */
    async getFundsById(fundsId, queryVars) {
        return 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.
     */
    async getFunds(queryVars) {
        return getFunds(this._subgraphUrl, queryVars);
    }
}
//# sourceMappingURL=mixin.js.map