@ape.swap/bonds-sdk 1.0.636 → 1.0.638

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -47,7 +47,7 @@ import { isNumber } from '../../../utils/numbers';
47
47
  import { TooltipBubble, Button, Svg, ListTag } from '../../uikit-sdk';
48
48
  import { TooltipText } from '../../../enum/tooltips';
49
49
  import { ethers } from 'ethers';
50
- import convertToTokenValue from "../../../utils/convertToTokenValue";
50
+ import convertToTokenValue, { adjustDecimals } from "../../../utils/convertToTokenValue";
51
51
  import TokenImage from '../../uikit-sdk/TokenImage';
52
52
  import BOND_ABI from '../../../config/abi/bond.json';
53
53
  import ERC_20_ABI from '../../../config/abi/erc20.json';
@@ -80,7 +80,7 @@ var BondModal = function (_a) {
80
80
  //user to buy
81
81
  //Check with Fede if this needs to be temp, if we force approval everytime, isn't this fine?
82
82
  var handleBuy = function () { return __awaiter(void 0, void 0, void 0, function () {
83
- var billAddress, decimals, maxPrice, amount, tx, error_1;
83
+ var billAddress, decimals, maxPrice, rawAmount, amount, tx, error_1;
84
84
  return __generator(this, function (_a) {
85
85
  switch (_a.label) {
86
86
  case 0:
@@ -90,16 +90,18 @@ var BondModal = function (_a) {
90
90
  case 1:
91
91
  _a.trys.push([1, 3, , 4]);
92
92
  console.log('HANDLEBUY CLICKED');
93
- maxPrice = new BigNumber(bondData[0].trueBillPrice).times(102).div(100);
94
- amount = convertToTokenValue(inputValue, decimals);
93
+ maxPrice = new BigNumber(bondData[0].trueBillPrice).times(102).div(100).toFixed(0);
94
+ rawAmount = adjustDecimals(inputValue);
95
+ amount = new BigNumber(rawAmount).times(new BigNumber(10).pow(decimals !== null && decimals !== void 0 ? decimals : 18)).toString();
95
96
  console.log('BillAddress:', billAddress);
96
97
  console.log('Amount:', amount);
97
98
  console.log('MaxPrice:', maxPrice);
99
+ console.log('Price:', bondData[0].trueBillPrice);
98
100
  return [4 /*yield*/, writeContractAsync({
99
101
  address: billAddress,
100
102
  abi: BOND_ABI,
101
103
  functionName: 'deposit',
102
- args: [amount, maxPrice.toFixed(0), account],
104
+ args: [amount, maxPrice, account],
103
105
  })];
104
106
  case 2:
105
107
  tx = _a.sent();
@@ -134,7 +136,7 @@ var BondModal = function (_a) {
134
136
  address: tokenAddress,
135
137
  abi: ERC_20_ABI,
136
138
  functionName: 'approve',
137
- args: [account, amount]
139
+ args: [bondData[0].billAddress, amount]
138
140
  })];
139
141
  case 2:
140
142
  tx = _a.sent();
package/package.json CHANGED
@@ -3,7 +3,7 @@
3
3
  "description": "Ape Bond SDK",
4
4
  "author": "Ape Bond",
5
5
  "license": "MIT",
6
- "version": "1.0.636",
6
+ "version": "1.0.638",
7
7
  "main": "dist/index.js",
8
8
  "module": "dist/index.es.js",
9
9
  "types": "dist/index.d.ts",