Socket
Socket
Sign inDemoInstall

handle-sdk-react

Package Overview
Dependencies
Maintainers
1
Versions
58
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

handle-sdk-react - npm Package Compare versions

Comparing version 0.0.19 to 0.0.20

10

dist/src/components/GovernanceLock.d.ts

@@ -12,3 +12,13 @@ import { ethers } from "ethers";

getData: (account: string | undefined, signer: ethers.Signer) => Promise<GovernanceLockData>;
createLock: ({ forexAmount, durationInSeconds }: {
durationInSeconds: number;
forexAmount: ethers.BigNumber;
}, signer: ethers.Signer) => Promise<ethers.ContractTransaction>;
increaseLockedAmount: (forexAmount: ethers.BigNumber, signer: ethers.Signer) => Promise<ethers.ContractTransaction>;
increaseLockDurationBy: ({ increaseDurationByInSeconds, currentUnlocksAt }: {
increaseDurationByInSeconds: number;
currentUnlocksAt: ethers.BigNumber;
}, signer: ethers.Signer) => Promise<ethers.ContractTransaction>;
private getMulticall;
private getContract;
}

67

dist/src/components/GovernanceLock.js

@@ -54,3 +54,5 @@ "use strict";

var config_1 = __importDefault(require("../config"));
var contracts_1 = require("../contracts");
var contract_utils_1 = require("../utils/contract-utils");
var MAX_LOCK_SECONDS = 4 * 365 * 24 * 60 * 60;
var GovernanceLock = /** @class */ (function () {

@@ -60,13 +62,65 @@ function GovernanceLock(c) {

this.getData = function (account, signer) { return __awaiter(_this, void 0, void 0, function () {
var provider, multicall;
var provider, multicall, response;
var _a, _b, _c, _d;
return __generator(this, function (_e) {
switch (_e.label) {
case 0:
provider = (0, contract_utils_1.createMulticallProtocolContracts)(this.config.protocolAddresses, this.config.chainId, signer).provider;
multicall = this.getMulticall(account, signer);
return [4 /*yield*/, (0, contract_utils_1.callMulticallObject)(multicall, provider)];
case 1:
response = _e.sent();
return [2 /*return*/, {
totalForexLocked: response.totalForexLocked,
account: ((_a = response.acountLocked) === null || _a === void 0 ? void 0 : _a.amount) && ((_b = response.acountLocked) === null || _b === void 0 ? void 0 : _b.end) && response.accountBalance
? {
forexLocked: (_c = response.acountLocked) === null || _c === void 0 ? void 0 : _c.amount,
unlocksAt: (_d = response.acountLocked) === null || _d === void 0 ? void 0 : _d.end,
veForexBalance: response.accountBalance
}
: undefined
}];
}
});
}); };
this.createLock = function (_a, signer) {
var forexAmount = _a.forexAmount, durationInSeconds = _a.durationInSeconds;
return __awaiter(_this, void 0, void 0, function () {
var unlockDate, contract;
return __generator(this, function (_b) {
if (durationInSeconds > MAX_LOCK_SECONDS) {
throw new Error("Duration cannot be greater than ".concat(MAX_LOCK_SECONDS, " seconds"));
}
unlockDate = Math.floor(Date.now() / 1000 + durationInSeconds);
contract = this.getContract(signer);
return [2 /*return*/, contract.createLock(forexAmount, unlockDate)];
});
});
};
this.increaseLockedAmount = function (forexAmount, signer) { return __awaiter(_this, void 0, void 0, function () {
var contract;
return __generator(this, function (_a) {
provider = (0, contract_utils_1.createMulticallProtocolContracts)(this.config.protocolAddresses, this.config.chainId, signer).provider;
multicall = this.getMulticall(account, signer);
return [2 /*return*/, (0, contract_utils_1.callMulticallObject)(multicall, provider)];
contract = this.getContract(signer);
return [2 /*return*/, contract.increaseAmount(forexAmount)];
});
}); };
this.increaseLockDurationBy = function (_a, signer) {
var increaseDurationByInSeconds = _a.increaseDurationByInSeconds, currentUnlocksAt = _a.currentUnlocksAt;
return __awaiter(_this, void 0, void 0, function () {
var contract, newUnlocksAt, now;
return __generator(this, function (_b) {
contract = this.getContract(signer);
newUnlocksAt = Math.floor(currentUnlocksAt.toNumber() + increaseDurationByInSeconds);
now = Date.now() / 1000;
if (newUnlocksAt - now > MAX_LOCK_SECONDS) {
throw new Error("Duration cannot be greater than ".concat(MAX_LOCK_SECONDS, " seconds"));
}
return [2 /*return*/, contract.increaseUnlockTime(newUnlocksAt)];
});
});
};
this.getMulticall = function (account, signer) {
var contracts = (0, contract_utils_1.createMulticallProtocolContracts)(_this.config.protocolAddresses, _this.config.chainId, signer).contracts;
var base = {
supply: contracts.governanceLock.supply()
totalForexLocked: contracts.governanceLock.supply()
};

@@ -78,2 +132,5 @@ if (account) {

};
this.getContract = function (signer) {
return contracts_1.GovernanceLock__factory.connect(_this.config.protocolAddresses.governanceLock, signer);
};
this.config = c || {

@@ -80,0 +137,0 @@ protocolAddresses: config_1.default.protocol.arbitrum.protocol,

8

dist/src/components/RewardPool.js

@@ -118,3 +118,3 @@ "use strict";

if (account) {
return __assign(__assign({}, base), { accountBalance: contracts.rewardPool.balanceOf(account) });
return __assign(__assign({}, base), { claimableRewards: contracts.rewardPool.balanceOf(account) });
}

@@ -127,3 +127,7 @@ return base;

forexDistributionRate: multicallResponse.forexDistributionRate,
accountBalance: multicallResponse.accountBalance,
account: multicallResponse.claimableRewards
? {
claimableRewards: multicallResponse.claimableRewards
}
: undefined,
pools: poolNames.reduce(function (progress, pn) {

@@ -130,0 +134,0 @@ var _a;

import { ethers } from "ethers";
export declare type GovernanceLockData = {
supply: ethers.BigNumber;
acountLocked?: {
amount: ethers.BigNumber;
end: ethers.BigNumber;
totalForexLocked: ethers.BigNumber;
account?: {
forexLocked: ethers.BigNumber;
unlocksAt: ethers.BigNumber;
veForexBalance: ethers.BigNumber;
};
accountBalanceOf?: ethers.BigNumber;
};

@@ -16,3 +16,5 @@ import { ethers } from "ethers";

forexDistributionRate: ethers.BigNumber;
accountBalance?: ethers.BigNumber;
account?: {
claimableRewards?: ethers.BigNumber;
};
};

@@ -19,0 +21,0 @@ export declare type RewardPoolPool = {

{
"name": "handle-sdk-react",
"version": "0.0.19",
"version": "0.0.20",
"description": "handle.fi sdk",

@@ -5,0 +5,0 @@ "main": "dist/src/index.js",

import { ethers } from "ethers";
import sdkConfig from "../config";
import { ProtocolAddresses } from "../config";
// import { GovernanceLock__factory } from "../contracts";
import { GovernanceLock__factory } from "../contracts";
import { Promisified } from "../types/general";

@@ -15,3 +15,3 @@ import { GovernanceLockData } from "../types/governanceLock";

type GovernanceLockMulticall = {
supply: ethers.BigNumber;
totalForexLocked: ethers.BigNumber;
acountLocked?: {

@@ -24,2 +24,4 @@ amount: ethers.BigNumber;

const MAX_LOCK_SECONDS = 4 * 365 * 24 * 60 * 60;
export default class GovernanceLock {

@@ -46,5 +48,64 @@ private config: FxKeeperPoolConfig;

const multicall = this.getMulticall(account, signer);
return callMulticallObject(multicall, provider);
const response = await callMulticallObject(multicall, provider);
return {
totalForexLocked: response.totalForexLocked,
account:
response.acountLocked?.amount && response.acountLocked?.end && response.accountBalance
? {
forexLocked: response.acountLocked?.amount,
unlocksAt: response.acountLocked?.end,
veForexBalance: response.accountBalance
}
: undefined
};
};
public createLock = async (
{
forexAmount,
durationInSeconds
}: {
durationInSeconds: number;
forexAmount: ethers.BigNumber;
},
signer: ethers.Signer
) => {
if (durationInSeconds > MAX_LOCK_SECONDS) {
throw new Error(`Duration cannot be greater than ${MAX_LOCK_SECONDS} seconds`);
}
const unlockDate = Math.floor(Date.now() / 1000 + durationInSeconds);
const contract = this.getContract(signer);
return contract.createLock(forexAmount, unlockDate);
};
public increaseLockedAmount = async (forexAmount: ethers.BigNumber, signer: ethers.Signer) => {
const contract = this.getContract(signer);
return contract.increaseAmount(forexAmount);
};
public increaseLockDurationBy = async (
{
increaseDurationByInSeconds,
currentUnlocksAt
}: {
increaseDurationByInSeconds: number;
currentUnlocksAt: ethers.BigNumber;
},
signer: ethers.Signer
) => {
const contract = this.getContract(signer);
const newUnlocksAt = Math.floor(currentUnlocksAt.toNumber() + increaseDurationByInSeconds);
const now = Date.now() / 1000;
if (newUnlocksAt - now > MAX_LOCK_SECONDS) {
throw new Error(`Duration cannot be greater than ${MAX_LOCK_SECONDS} seconds`);
}
return contract.increaseUnlockTime(newUnlocksAt);
};
private getMulticall = (

@@ -61,3 +122,3 @@ account: string | undefined,

const base = {
supply: contracts.governanceLock.supply()
totalForexLocked: contracts.governanceLock.supply()
};

@@ -75,2 +136,6 @@

};
private getContract = (signer: ethers.Signer) => {
return GovernanceLock__factory.connect(this.config.protocolAddresses.governanceLock, signer);
};
}

@@ -29,3 +29,3 @@ import { ethers, Signer } from "ethers";

forexDistributionRate: ethers.BigNumber;
accountBalance?: ethers.BigNumber;
claimableRewards?: ethers.BigNumber;
};

@@ -127,3 +127,3 @@

...base,
accountBalance: contracts.rewardPool.balanceOf(account)
claimableRewards: contracts.rewardPool.balanceOf(account)
};

@@ -140,3 +140,7 @@ }

forexDistributionRate: multicallResponse.forexDistributionRate,
accountBalance: multicallResponse.accountBalance,
account: multicallResponse.claimableRewards
? {
claimableRewards: multicallResponse.claimableRewards
}
: undefined,
pools: poolNames.reduce((progress, pn) => {

@@ -143,0 +147,0 @@ const poolName = pn as RewardPoolName;

import { ethers } from "ethers";
export type GovernanceLockData = {
supply: ethers.BigNumber;
acountLocked?: {
amount: ethers.BigNumber;
end: ethers.BigNumber;
totalForexLocked: ethers.BigNumber;
account?: {
forexLocked: ethers.BigNumber;
unlocksAt: ethers.BigNumber;
veForexBalance: ethers.BigNumber;
};
accountBalanceOf?: ethers.BigNumber;
};

@@ -20,3 +20,5 @@ import { ethers } from "ethers";

forexDistributionRate: ethers.BigNumber;
accountBalance?: ethers.BigNumber;
account?: {
claimableRewards?: ethers.BigNumber;
};
};

@@ -23,0 +25,0 @@

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc