New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

@fairmint/safe-js

Package Overview
Dependencies
Maintainers
6
Versions
43
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@fairmint/safe-js - npm Package Compare versions

Comparing version 1.4.1 to 1.4.2

2

package.json
{
"name": "@fairmint/safe-js",
"version": "1.4.1",
"version": "1.4.2",
"description": "Safe javascript library.",

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

@@ -125,14 +125,14 @@ const abi = require("@fairmint/cafe-abi/abi.json");

this.data.initTrial = new BigNumber(initTrial).shiftedBy(
this.data.initTrial = contract.toBigNumber(initTrial).shiftedBy(
-this.data.decimals
);
this.data.equityCommitment = new BigNumber(equityCommitment).shiftedBy(-2);
this.data.maxGoal = new BigNumber(maxGoal).shiftedBy(-this.data.decimals);
this.data.shareholdersPool = new BigNumber(shareholdersPool).shiftedBy(
this.data.equityCommitment = contract.toBigNumber(equityCommitment).shiftedBy(-2);
this.data.maxGoal = contract.toBigNumber(maxGoal).shiftedBy(-this.data.decimals);
this.data.shareholdersPool = contract.toBigNumber(shareholdersPool).shiftedBy(
-this.data.decimals
);
this.data.fundraisingGoal = new BigNumber(fundraisingGoal).shiftedBy(
this.data.fundraisingGoal = contract.toBigNumber(fundraisingGoal).shiftedBy(
-this.data.decimals
);
this.data.totalSupply = new BigNumber(totalSupply).shiftedBy(
this.data.totalSupply = contract.toBigNumber(totalSupply).shiftedBy(
-this.data.decimals

@@ -142,18 +142,18 @@ );

this.data.control = control;
this.data.fee = new BigNumber(fee).div(constants.BASIS_POINTS_DEN);
this.data.minInvestment = new BigNumber(minInvestment).shiftedBy(
this.data.fee = contract.toBigNumber(fee).div(constants.BASIS_POINTS_DEN);
this.data.minInvestment = contract.toBigNumber(minInvestment).shiftedBy(
-this.data.currency.decimals
);
this.data.state = constants.STATES[stateId];
this.data.buySlope = new BigNumber(buySlopeNum)
this.data.buySlope = contract.toBigNumber(buySlopeNum)
.shiftedBy(18 + 18 - this.data.currency.decimals)
.div(buySlopeDen);
this.data.stakeholdersIssued = new BigNumber(stakeholdersIssued).shiftedBy(
this.data.stakeholdersIssued = contract.toBigNumber(stakeholdersIssued).shiftedBy(
-this.data.decimals
);
this.data.stakeholdersAuthorized = new BigNumber(
this.data.stakeholdersAuthorized = contract.toBigNumber(
stakeholdersAuthorized
).shiftedBy(-4);
this.data.initGoal = new BigNumber(initGoal).shiftedBy(-this.data.decimals);
this.data.initReserve = new BigNumber(initReserve).shiftedBy(
this.data.initGoal = contract.toBigNumber(initGoal).shiftedBy(-this.data.decimals);
this.data.initReserve = contract.toBigNumber(initReserve).shiftedBy(
-this.data.decimals

@@ -183,3 +183,3 @@ );

this.data.equityCommitment.times(
new BigNumber(1).minus(this.data.stakeholdersAuthorized)
contract.toBigNumber(1).minus(this.data.stakeholdersAuthorized)
)

@@ -195,3 +195,3 @@ );

this.data.equityCommitment.times(
new BigNumber(1).minus(this.data.stakeholdersAuthorized)
contract.toBigNumber(1).minus(this.data.stakeholdersAuthorized)
)

@@ -208,3 +208,3 @@ );

} else {
this.data.redeemPrice = new BigNumber(0);
this.data.redeemPrice = contract.toBigNumber(0);
}

@@ -234,4 +234,4 @@ }

]);
account.ethBalance = new BigNumber(ethBalance).shiftedBy(-18);
account.tokenBalance = new BigNumber(tokenBalance).shiftedBy(
account.ethBalance = contract.toBigNumber(ethBalance).shiftedBy(-18);
account.tokenBalance = contract.toBigNumber(tokenBalance).shiftedBy(
-this.data.decimals

@@ -266,6 +266,6 @@ );

if (currencyBalance) {
account.currencyBalance = new BigNumber(currencyBalance).shiftedBy(
account.currencyBalance = contract.toBigNumber(currencyBalance).shiftedBy(
-this.data.currency.decimals
);
account.allowance = new BigNumber(allowance).shiftedBy(
account.allowance = contract.toBigNumber(allowance).shiftedBy(
-this.data.currency.decimals

@@ -310,6 +310,6 @@ );

balance = await this.currency.balanceOf(accountAddress);
balance = new BigNumber(balance).shiftedBy(-this.data.currency.decimals);
balance = contract.toBigNumber(balance).shiftedBy(-this.data.currency.decimals);
} else {
balance = await this.provider.getBalance(accountAddress);
balance = new BigNumber(balance).shiftedBy(-18);
balance = contract.toBigNumber(balance).shiftedBy(-18);
}

@@ -395,3 +395,3 @@ return balance;

if (!currencyAmount) return 0;
const currencyValue = new BigNumber(currencyAmount).shiftedBy(
const currencyValue = contract.toBigNumber(currencyAmount).shiftedBy(
this.data.currency.decimals

@@ -401,3 +401,3 @@ );

.estimateBuyValue(currencyValue.toFixed());
return new BigNumber(buyValue).shiftedBy(-this.data.decimals);
return contract.toBigNumber(buyValue).shiftedBy(-this.data.decimals);
}

@@ -414,11 +414,11 @@ async buy(currencyAmount, maxSlipPercent, sendToAddress) {

throw new Error("0 expected value");
const currencyValue = new BigNumber(currencyAmount)
const currencyValue = contract.toBigNumber(currencyAmount)
.shiftedBy(this.data.currency.decimals)
.dp(0);
let minBuyValue = estimateBuyValue
.times(new BigNumber(100).minus(maxSlipPercent).div(100))
.times(contract.toBigNumber(100).minus(maxSlipPercent).div(100))
.shiftedBy(this.data.decimals)
.dp(0);
if (minBuyValue.lt(1)) {
minBuyValue = new BigNumber(1);
minBuyValue = contract.toBigNumber(1);
}

@@ -433,17 +433,17 @@

async estimateSellValue(tokenAmount) {
if (!tokenAmount) return new BigNumber(0);
const tokenValue = new BigNumber(tokenAmount).shiftedBy(this.data.decimals);
if (tokenValue.isEqualTo(0)) return new BigNumber(0);
if (!tokenAmount) return contract.toBigNumber(0);
const tokenValue = contract.toBigNumber(tokenAmount).shiftedBy(this.data.decimals);
if (tokenValue.isEqualTo(0)) return contract.toBigNumber(0);
try {
const sellValue = await this.dat
.estimateSellValue(tokenValue.toFixed());
return new BigNumber(sellValue).shiftedBy(-this.data.currency.decimals);
return contract.toBigNumber(sellValue).shiftedBy(-this.data.currency.decimals);
} catch (e) {
console.log(`Error reading sellValue: ${e}`);
// likely > totalSupply
return new BigNumber(0);
return contract.toBigNumber(0);
}
}
async sell(tokenAmount, maxSlipPercent, sendToAddress) {
tokenAmount = new BigNumber(tokenAmount);
tokenAmount = contract.toBigNumber(tokenAmount);
const estimateSellValue = await this.estimateSellValue(

@@ -465,7 +465,7 @@ tokenAmount.toFixed()

let minSellValue = estimateSellValue
.times(new BigNumber(100).minus(maxSlipPercent).div(100))
.times(contract.toBigNumber(100).minus(maxSlipPercent).div(100))
.shiftedBy(this.data.currency.decimals)
.dp(0);
if (minSellValue.lt(1)) {
minSellValue = new BigNumber(1);
minSellValue = contract.toBigNumber(1);
}

@@ -493,3 +493,3 @@ return this.dat.sell(

burn(tokenAmount) {
const tokenValue = new BigNumber(tokenAmount)
const tokenValue = contract.toBigNumber(tokenAmount)
.shiftedBy(this.data.decimals)

@@ -506,3 +506,3 @@ .dp(0);

}
const tokenValue = new BigNumber(tokenAmount)
const tokenValue = contract.toBigNumber(tokenAmount)
.shiftedBy(this.data.decimals)

@@ -513,3 +513,3 @@ .dp(0);

manualBuy(sendToAddress, currencyAmount) {
const buyAmount = new BigNumber(currencyAmount)
const buyAmount = contract.toBigNumber(currencyAmount)
.shiftedBy(this.data.currency.decimals)

@@ -520,7 +520,7 @@ .dp(0);

increaseCommitment(commitment, tokenAmount) {
const tokenValue = new BigNumber(tokenAmount)
const tokenValue = contract.toBigNumber(tokenAmount)
.shiftedBy(this.data.decimals)
.dp(0);
return this.dat.increaseCommitment(
new BigNumber(commitment).shiftedBy(2).toFixed(),
contract.toBigNumber(commitment).shiftedBy(2).toFixed(),
tokenValue.toFixed()

@@ -536,7 +536,7 @@ );

}
const tokenValue = new BigNumber(tokenAmount)
const tokenValue = contract.toBigNumber(tokenAmount)
.shiftedBy(this.data.decimals)
.dp(0);
return this.dat.convertToCafe(
new BigNumber(commitment).shiftedBy(2).toFixed(),
contract.toBigNumber(commitment).shiftedBy(2).toFixed(),
tokenValue.toFixed(),

@@ -724,10 +724,10 @@ sendTo

}
const currencyValue = new BigNumber(currencyAmount)
const currencyValue = contract.toBigNumber(currencyAmount)
.shiftedBy(this.data.currency.decimals)
.dp(0);
let minBuyValue = new BigNumber(minTokensBought)
let minBuyValue = contract.toBigNumber(minTokensBought)
.shiftedBy(this.data.decimals)
.dp(0);
if (minBuyValue.lt(1)) {
minBuyValue = new BigNumber(1);
minBuyValue = contract.toBigNumber(1);
}

@@ -797,10 +797,10 @@

}
const currencyValue = new BigNumber(currencyAmount)
const currencyValue = contract.toBigNumber(currencyAmount)
.shiftedBy(this.data.currency.decimals)
.dp(0);
let minBuyValue = new BigNumber(minTokensBought)
let minBuyValue = contract.toBigNumber(minTokensBought)
.shiftedBy(this.data.decimals)
.dp(0);
if (minBuyValue.lt(1)) {
minBuyValue = new BigNumber(1);
minBuyValue = contract.toBigNumber(1);
}

@@ -844,10 +844,10 @@ const signatureHash = signature.substring(2);

}
const fairValue = new BigNumber(quantityToSell)
const fairValue = contract.toBigNumber(quantityToSell)
.shiftedBy(this.data.decimals)
.dp(0);
let minCurrencyValue = new BigNumber(minCurrencyReturned)
let minCurrencyValue = contract.toBigNumber(minCurrencyReturned)
.shiftedBy(this.data.currency.decimals)
.dp(0);
if (minCurrencyValue.lt(1)) {
minCurrencyValue = new BigNumber(1);
minCurrencyValue = contract.toBigNumber(1);
}

@@ -917,10 +917,10 @@

}
const fairValue = new BigNumber(quantityToSell)
const fairValue = contract.toBigNumber(quantityToSell)
.shiftedBy(this.data.decimals)
.dp(0);
let minCurrencyValue = new BigNumber(minCurrencyReturned)
let minCurrencyValue = contract.toBigNumber(minCurrencyReturned)
.shiftedBy(this.data.currency.decimals)
.dp(0);
if (minCurrencyValue.lt(1)) {
minCurrencyValue = new BigNumber(1);
minCurrencyValue = contract.toBigNumber(1);
}

@@ -927,0 +927,0 @@ const signatureHash = signature.substring(2);

@@ -0,1 +1,2 @@

const BigNumber = require("bignumber.js");
const Ethers = require("ethers");

@@ -9,2 +10,5 @@

},
toBigNumber: (value) => {
return new BigNumber(value.toString())
}
},

@@ -11,0 +15,0 @@ constants: {

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