UNPKG

@verified-network/verified-sdk

Version:

An SDK to develop applications on the Verified Network

101 lines (100 loc) 4.29 kB
"use strict"; // SPDX-License-Identifier: BUSL-1.1 // @ts-nocheck Object.defineProperty(exports, "__esModule", { value: true }); const index_1 = require("../../index"); const VerifiedMarkets_json_1 = require("../../../abi/loans/compound/VerifiedMarkets.json"); var FUNCTIONS; (function (FUNCTIONS) { FUNCTIONS["SUBMITNEWRWA"] = "submitNewRWA"; FUNCTIONS["POSTCOLLATERAL"] = "postCollateral"; FUNCTIONS["BORROWBASE"] = "borrowBase"; FUNCTIONS["REPAYBASE"] = "repayBase"; FUNCTIONS["WITHDRAWCOLLATERAL"] = "withdrawCollateral"; FUNCTIONS["REPAYLENDERS"] = "repayLenders"; })(FUNCTIONS || (FUNCTIONS = {})); class Compound extends index_1.VerifiedContract { constructor(signer, contractNetworkAddress) { const address = contractNetworkAddress; super(address, JSON.stringify(VerifiedMarkets_json_1.abi), signer); this.contractAddress = address; } async _getMeeQuote(paymentTokenAddress, functionName, args, apiKey, rpcUrl, isReactNative) { return await this.getQuote(paymentTokenAddress, functionName, args, rpcUrl, apiKey, isReactNative); } async setSigner(_address, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, _address); return this.callContract(FUNCTIONS.SETSIGNER, _address, options); } /** * Submits new RWA to Compound * @params submitNewRWA( address asset, address collateral, address bond, uint256 apy, string memory issuingDocs, uint256 frequency, uint256 faceValue, address factory ) * @returns */ async submitNewRWA(asset, collateral, bond, apy, issuingDocs, frequency, faceValue, factory, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, asset); await this.validateInput(index_1.DATATYPES.ADDRESS, collateral); await this.validateInput(index_1.DATATYPES.ADDRESS, bond); await this.validateInput(index_1.DATATYPES.NUMBER, apy); await this.validateInput(index_1.DATATYPES.STRING, issuingDocs); await this.validateInput(index_1.DATATYPES.NUMBER, frequency); await this.validateInput(index_1.DATATYPES.NUMBER, faceValue); await this.validateInput(index_1.DATATYPES.ADDRESS, factory); return this.callContract(FUNCTIONS.SUBMITNEWRWA, asset, collateral, bond, apy, issuingDocs, frequency, faceValue, factory, options); } /** * Posts collateral to Compound * @params (address bond, address issuer, address factory) * @returns */ async postCollateral(bond, issuer, factory, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, bond); await this.validateInput(index_1.DATATYPES.ADDRESS, issuer); await this.validateInput(index_1.DATATYPES.ADDRESS, factory); return this.callContract(FUNCTIONS.POSTCOLLATERAL, bond, issuer, factory, options); } /** * Borrows from Compound * @params (address bond) * @returns */ async borrowBase(bond, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, bond); return this.callContract(FUNCTIONS.BORROWBASE, bond, options); } /** * Repays to Compound * @params (address bond, uint256 amount) * @returns */ async repayBase(bond, amount, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, bond); await this.validateInput(index_1.DATATYPES.NUMBER, amount); return this.callContract(FUNCTIONS.REPAYBASE, bond, amount, options); } /** * Withdraws collateral * @params (address bond, address issuer) * @returns */ async withdrawCollateral(bond, issuer, factory, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, bond); await this.validateInput(index_1.DATATYPES.ADDRESS, issuer); return this.callContract(FUNCTIONS.WITHDRAWCOLLATERAL, bond, issuer, options); } async repayLenders(bond, collateral, options) { await this.validateInput(index_1.DATATYPES.ADDRESS, bond); await this.validateInput(index_1.DATATYPES.ADDRESS, collateral); return this.callContract(FUNCTIONS.REPAYLENDERS, bond, collateral, options); } } exports.default = Compound;