handle-sdk
Advanced tools
Comparing version 0.0.23 to 0.0.24
{ | ||
"name": "handle-sdk", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "handle.fi sdk", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -34,4 +34,4 @@ import { fxToken } from "./fxToken"; | ||
mintWithoutCollateral(tokenAmount: ethers.BigNumber, returnTxData?: boolean, gasLimit?: ethers.BigNumber, gasPrice?: ethers.BigNumber, deadline?: number, referral?: string): Promise<any>; | ||
depositCollateral(amount: ethers.BigNumber, collateralToken: CollateralTokens, returnTxData?: boolean, approveTransfer?: boolean, gasLimit?: ethers.BigNumber, gasPrice?: ethers.BigNumber, referral?: string): Promise<any>; | ||
depositCollateral(amount: ethers.BigNumber, collateralToken: CollateralTokens, returnTxData?: boolean, gasLimit?: ethers.BigNumber, gasPrice?: ethers.BigNumber, referral?: string): Promise<any>; | ||
withdrawCollateral(amount: ethers.BigNumber, collateralToken: CollateralTokens, returnTxData?: boolean, gasLimit?: ethers.BigNumber, gasPrice?: ethers.BigNumber): Promise<any>; | ||
} |
@@ -232,7 +232,6 @@ "use strict"; | ||
}; | ||
Vault.prototype.depositCollateral = function (amount, collateralToken, returnTxData, approveTransfer, gasLimit, gasPrice, referral) { | ||
Vault.prototype.depositCollateral = function (amount, collateralToken, returnTxData, gasLimit, gasPrice, referral) { | ||
if (returnTxData === void 0) { returnTxData = false; } | ||
if (approveTransfer === void 0) { approveTransfer = true; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var func, collateralTokenAddress; | ||
var func, allowance, collateralTokenAddress; | ||
return __generator(this, function (_a) { | ||
@@ -253,9 +252,11 @@ switch (_a.label) { | ||
case 1: return [2 /*return*/, _a.sent()]; | ||
case 2: | ||
if (!approveTransfer) return [3 /*break*/, 4]; | ||
case 2: return [4 /*yield*/, this.sdk.contracts[collateralToken].allowance(this.account, this.sdk.contracts.treasury.address)]; | ||
case 3: | ||
allowance = _a.sent(); | ||
if (!allowance.lt(amount)) return [3 /*break*/, 5]; | ||
return [4 /*yield*/, this.sdk.contracts[collateralToken].approve(this.sdk.contracts.treasury.address, amount)]; | ||
case 3: | ||
case 4: | ||
_a.sent(); | ||
_a.label = 4; | ||
case 4: | ||
_a.label = 5; | ||
case 5: | ||
collateralTokenAddress = this.sdk.protocol.getCollateralTokenBySymbol(collateralToken).address; | ||
@@ -266,3 +267,3 @@ return [4 /*yield*/, func.depositCollateral(this.account, amount, collateralTokenAddress, this.token.address, referral !== null && referral !== void 0 ? referral : ethers_1.ethers.constants.AddressZero, { | ||
})]; | ||
case 5: return [2 /*return*/, _a.sent()]; | ||
case 6: return [2 /*return*/, _a.sent()]; | ||
} | ||
@@ -269,0 +270,0 @@ }); |
@@ -70,3 +70,3 @@ "use strict"; | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, vault.depositCollateral(DEPOSIT_AMOUNT, ProtocolTokens_1.CollateralTokens.WETH, false, false, GAS_PRICE)]; | ||
case 0: return [4 /*yield*/, vault.depositCollateral(DEPOSIT_AMOUNT, ProtocolTokens_1.CollateralTokens.WETH, false, GAS_PRICE)]; | ||
case 1: return [4 /*yield*/, (_a.sent()).wait(1)]; | ||
@@ -82,3 +82,3 @@ case 2: | ||
switch (_a.label) { | ||
case 0: return [4 /*yield*/, vault.depositCollateral(DEPOSIT_AMOUNT, ProtocolTokens_1.CollateralTokens.DAI, false, true, GAS_PRICE)]; | ||
case 0: return [4 /*yield*/, vault.depositCollateral(DEPOSIT_AMOUNT, ProtocolTokens_1.CollateralTokens.DAI, false, GAS_PRICE)]; | ||
case 1: return [4 /*yield*/, (_a.sent()).wait(1)]; | ||
@@ -85,0 +85,0 @@ case 2: |
{ | ||
"name": "handle-sdk", | ||
"version": "0.0.23", | ||
"version": "0.0.24", | ||
"description": "handle.fi sdk", | ||
@@ -5,0 +5,0 @@ "main": "dist/src/index.js", |
@@ -198,3 +198,2 @@ import { fxToken } from "./fxToken"; | ||
returnTxData: boolean = false, | ||
approveTransfer: boolean = true, | ||
gasLimit?: ethers.BigNumber, | ||
@@ -222,3 +221,8 @@ gasPrice?: ethers.BigNumber, | ||
} else { | ||
if (approveTransfer) { | ||
const allowance = await this.sdk.contracts[collateralToken].allowance( | ||
this.account, | ||
this.sdk.contracts.treasury.address | ||
); | ||
if (allowance.lt(amount)) { | ||
await this.sdk.contracts[collateralToken].approve( | ||
@@ -225,0 +229,0 @@ this.sdk.contracts.treasury.address, |
@@ -22,3 +22,3 @@ import { xdescribe, it } from "@jest/globals"; | ||
await ( | ||
await vault.depositCollateral(DEPOSIT_AMOUNT, CollateralTokens.WETH, false, false, GAS_PRICE) | ||
await vault.depositCollateral(DEPOSIT_AMOUNT, CollateralTokens.WETH, false, GAS_PRICE) | ||
).wait(1); | ||
@@ -28,3 +28,3 @@ }); | ||
await ( | ||
await vault.depositCollateral(DEPOSIT_AMOUNT, CollateralTokens.DAI, false, true, GAS_PRICE) | ||
await vault.depositCollateral(DEPOSIT_AMOUNT, CollateralTokens.DAI, false, GAS_PRICE) | ||
).wait(1); | ||
@@ -31,0 +31,0 @@ }); |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1608804
18202
162