fix: fixed WAD Math
This commit is contained in:
parent
122044a1e5
commit
5416bbdd72
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/a5fa4780a59b1f26cae53eb04fc69734.json"
|
"buildInfo": "../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/a5fa4780a59b1f26cae53eb04fc69734.json"
|
"buildInfo": "../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/a5fa4780a59b1f26cae53eb04fc69734.json"
|
"buildInfo": "../../build-info/916d546d680bb337e1c490eb628d93df.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/a5fa4780a59b1f26cae53eb04fc69734.json"
|
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/a5fa4780a59b1f26cae53eb04fc69734.json"
|
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/a5fa4780a59b1f26cae53eb04fc69734.json"
|
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/a5fa4780a59b1f26cae53eb04fc69734.json"
|
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/a5fa4780a59b1f26cae53eb04fc69734.json"
|
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/a5fa4780a59b1f26cae53eb04fc69734.json"
|
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/a5fa4780a59b1f26cae53eb04fc69734.json"
|
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../../../build-info/a5fa4780a59b1f26cae53eb04fc69734.json"
|
"buildInfo": "../../../../build-info/0043b38db58c3ff291cf622f3b61e1a3.json"
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,4 @@
|
|||||||
{
|
{
|
||||||
"_format": "hh-sol-dbg-1",
|
"_format": "hh-sol-dbg-1",
|
||||||
"buildInfo": "../../build-info/afbde6718590f5775bc92171f5c6c7f4.json"
|
"buildInfo": "../../build-info/948b888bf726ea051449ea823f31e46a.json"
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -34,8 +34,11 @@ contract P2PIX is
|
|||||||
IReputation public reputation;
|
IReputation public reputation;
|
||||||
Counters.Counter public depositCount;
|
Counters.Counter public depositCount;
|
||||||
|
|
||||||
|
|
||||||
/// @dev Default blocks that lock will hold tokens.
|
/// @dev Default blocks that lock will hold tokens.
|
||||||
uint256 public defaultLockBlocks;
|
uint256 public defaultLockBlocks;
|
||||||
|
/// @dev The scalar of BRZ token.
|
||||||
|
uint256 constant public WAD = 1e18;
|
||||||
|
|
||||||
/// @dev Stores an relayer's last computed credit.
|
/// @dev Stores an relayer's last computed credit.
|
||||||
mapping(uint256 => uint256) public userRecord;
|
mapping(uint256 => uint256) public userRecord;
|
||||||
@ -199,7 +202,7 @@ contract P2PIX is
|
|||||||
// Halt execution and output `lockID`.
|
// Halt execution and output `lockID`.
|
||||||
return lockID;
|
return lockID;
|
||||||
} else {
|
} else {
|
||||||
if (l.amount <= 100 ether) {
|
if (l.amount <= 1e2 ether) {
|
||||||
_addLock(lockID, l, d);
|
_addLock(lockID, l, d);
|
||||||
// Halt execution and output `lockID`.
|
// Halt execution and output `lockID`.
|
||||||
return lockID;
|
return lockID;
|
||||||
@ -208,9 +211,9 @@ contract P2PIX is
|
|||||||
_castAddrToKey(msg.sender)
|
_castAddrToKey(msg.sender)
|
||||||
];
|
];
|
||||||
uint256 spendLimit;
|
uint256 spendLimit;
|
||||||
(spendLimit) = _limiter(userCredit);
|
(spendLimit) = _limiter(userCredit / WAD);
|
||||||
|
|
||||||
if (l.amount > spendLimit || l.amount > 1e6)
|
if (l.amount > (spendLimit * WAD) || l.amount > 1e6 ether)
|
||||||
revert AmountNotAllowed();
|
revert AmountNotAllowed();
|
||||||
|
|
||||||
_addLock(lockID, l, d);
|
_addLock(lockID, l, d);
|
||||||
@ -350,8 +353,8 @@ contract P2PIX is
|
|||||||
uint256 _newUserRecord = (userRecord[userKey] >>
|
uint256 _newUserRecord = (userRecord[userKey] >>
|
||||||
1);
|
1);
|
||||||
|
|
||||||
if (_newUserRecord <= 1e2) {
|
if (_newUserRecord <= 1e2 ether) {
|
||||||
userRecord[userKey] = 1e2;
|
userRecord[userKey] = 1e2 ether;
|
||||||
} else {
|
} else {
|
||||||
userRecord[userKey] = _newUserRecord;
|
userRecord[userKey] = _newUserRecord;
|
||||||
}
|
}
|
||||||
|
File diff suppressed because one or more lines are too long
@ -29,6 +29,7 @@ import type {
|
|||||||
|
|
||||||
export interface P2PIXInterface extends utils.Interface {
|
export interface P2PIXInterface extends utils.Interface {
|
||||||
functions: {
|
functions: {
|
||||||
|
"WAD()": FunctionFragment;
|
||||||
"_castAddrToKey(address)": FunctionFragment;
|
"_castAddrToKey(address)": FunctionFragment;
|
||||||
"allowedERC20s(address)": FunctionFragment;
|
"allowedERC20s(address)": FunctionFragment;
|
||||||
"cancelDeposit(uint256)": FunctionFragment;
|
"cancelDeposit(uint256)": FunctionFragment;
|
||||||
@ -58,6 +59,7 @@ export interface P2PIXInterface extends utils.Interface {
|
|||||||
|
|
||||||
getFunction(
|
getFunction(
|
||||||
nameOrSignatureOrTopic:
|
nameOrSignatureOrTopic:
|
||||||
|
| "WAD"
|
||||||
| "_castAddrToKey"
|
| "_castAddrToKey"
|
||||||
| "allowedERC20s"
|
| "allowedERC20s"
|
||||||
| "cancelDeposit"
|
| "cancelDeposit"
|
||||||
@ -85,6 +87,7 @@ export interface P2PIXInterface extends utils.Interface {
|
|||||||
| "withdrawBalance"
|
| "withdrawBalance"
|
||||||
): FunctionFragment;
|
): FunctionFragment;
|
||||||
|
|
||||||
|
encodeFunctionData(functionFragment: "WAD", values?: undefined): string;
|
||||||
encodeFunctionData(
|
encodeFunctionData(
|
||||||
functionFragment: "_castAddrToKey",
|
functionFragment: "_castAddrToKey",
|
||||||
values: [PromiseOrValue<string>]
|
values: [PromiseOrValue<string>]
|
||||||
@ -203,6 +206,7 @@ export interface P2PIXInterface extends utils.Interface {
|
|||||||
values?: undefined
|
values?: undefined
|
||||||
): string;
|
): string;
|
||||||
|
|
||||||
|
decodeFunctionResult(functionFragment: "WAD", data: BytesLike): Result;
|
||||||
decodeFunctionResult(
|
decodeFunctionResult(
|
||||||
functionFragment: "_castAddrToKey",
|
functionFragment: "_castAddrToKey",
|
||||||
data: BytesLike
|
data: BytesLike
|
||||||
@ -482,6 +486,8 @@ export interface P2PIX extends BaseContract {
|
|||||||
removeListener: OnEvent<this>;
|
removeListener: OnEvent<this>;
|
||||||
|
|
||||||
functions: {
|
functions: {
|
||||||
|
WAD(overrides?: CallOverrides): Promise<[BigNumber]>;
|
||||||
|
|
||||||
_castAddrToKey(
|
_castAddrToKey(
|
||||||
_addr: PromiseOrValue<string>,
|
_addr: PromiseOrValue<string>,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -632,6 +638,8 @@ export interface P2PIX extends BaseContract {
|
|||||||
): Promise<ContractTransaction>;
|
): Promise<ContractTransaction>;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
WAD(overrides?: CallOverrides): Promise<BigNumber>;
|
||||||
|
|
||||||
_castAddrToKey(
|
_castAddrToKey(
|
||||||
_addr: PromiseOrValue<string>,
|
_addr: PromiseOrValue<string>,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -780,6 +788,8 @@ export interface P2PIX extends BaseContract {
|
|||||||
): Promise<ContractTransaction>;
|
): Promise<ContractTransaction>;
|
||||||
|
|
||||||
callStatic: {
|
callStatic: {
|
||||||
|
WAD(overrides?: CallOverrides): Promise<BigNumber>;
|
||||||
|
|
||||||
_castAddrToKey(
|
_castAddrToKey(
|
||||||
_addr: PromiseOrValue<string>,
|
_addr: PromiseOrValue<string>,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -1036,6 +1046,8 @@ export interface P2PIX extends BaseContract {
|
|||||||
};
|
};
|
||||||
|
|
||||||
estimateGas: {
|
estimateGas: {
|
||||||
|
WAD(overrides?: CallOverrides): Promise<BigNumber>;
|
||||||
|
|
||||||
_castAddrToKey(
|
_castAddrToKey(
|
||||||
_addr: PromiseOrValue<string>,
|
_addr: PromiseOrValue<string>,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
@ -1167,6 +1179,8 @@ export interface P2PIX extends BaseContract {
|
|||||||
};
|
};
|
||||||
|
|
||||||
populateTransaction: {
|
populateTransaction: {
|
||||||
|
WAD(overrides?: CallOverrides): Promise<PopulatedTransaction>;
|
||||||
|
|
||||||
_castAddrToKey(
|
_castAddrToKey(
|
||||||
_addr: PromiseOrValue<string>,
|
_addr: PromiseOrValue<string>,
|
||||||
overrides?: CallOverrides
|
overrides?: CallOverrides
|
||||||
|
@ -36,6 +36,8 @@ describe("Reputation", () => {
|
|||||||
expect(tx2).to.eq(curve(500));
|
expect(tx2).to.eq(curve(500));
|
||||||
expect(tx3).to.eq(curve(444444));
|
expect(tx3).to.eq(curve(444444));
|
||||||
expect(tx4).to.eq(curve(988700));
|
expect(tx4).to.eq(curve(988700));
|
||||||
|
|
||||||
|
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
@ -14,7 +14,7 @@ import {
|
|||||||
import {
|
import {
|
||||||
ethers,
|
ethers,
|
||||||
network,
|
network,
|
||||||
/* , tracer */
|
/* tracer */
|
||||||
} from "hardhat";
|
} from "hardhat";
|
||||||
|
|
||||||
// import keccak256 from "keccak256";
|
// import keccak256 from "keccak256";
|
||||||
@ -1578,7 +1578,7 @@ describe("P2PIX", () => {
|
|||||||
expect(storage.amount).to.eq(ethers.constants.One);
|
expect(storage.amount).to.eq(ethers.constants.One);
|
||||||
expect(storage2.amount).to.eq(ethers.constants.Zero);
|
expect(storage2.amount).to.eq(ethers.constants.Zero);
|
||||||
expect(record1).to.eq(0);
|
expect(record1).to.eq(0);
|
||||||
expect(record2).to.eq(100);
|
expect(record2).to.eq(price);
|
||||||
});
|
});
|
||||||
it("should unlock expired through lock function", async () => {
|
it("should unlock expired through lock function", async () => {
|
||||||
// test method through lock fx
|
// test method through lock fx
|
||||||
|
Loading…
x
Reference in New Issue
Block a user