Skip to content

Instantly share code, notes, and snippets.

@WPSmartContracts
Last active November 29, 2022 14:07
Show Gist options
  • Save WPSmartContracts/3cea79cdd6f9330f1eb079474f953389 to your computer and use it in GitHub Desktop.
Save WPSmartContracts/3cea79cdd6f9330f1eb079474f953389 to your computer and use it in GitHub Desktop.
> hardhat test "test/stake/test-eve-otc-option.js"
Contract: EVE OTC / Oracle
addOffer
pre conditions
✓ Positive offer (70ms)
✓ Erroring transfer sale funds (61ms)
Token for sale not enabled
✓ when token does not exists (38ms)
✓ when token exists but is not enabled (40ms)
✓ when is not a token
Token for payments not enabled
✓ when token does not exists
✓ when token exists but is not enabled
✓ when is not a token
events
✓ New Offer (131ms)
Option Trades
When the seller have no stake
add offers with system tokens
Should Behave Like An Option Trade
Cancel Trade
✓ only owner can cancel the trade
✓ offer should be inactive (78ms)
✓ should return all funds if no buying has happened (50ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Premium
Paying premium
✓ estimatePremiumAmount
✓ Should create the order if the premium is paid (142ms)
✓ Should close the offer if the buyer buys all (123ms)
✓ Should not close the offer if the buyer don't buys it all (146ms)
✓ Emits a NewPremium event (147ms)
Exceptions
✓ When the offer does not exists (43ms)
✓ When the offer is not an option trade (218ms)
✓ When there is not approved amount (114ms)
Paying an option trade
Paying an option trade with the same token as premium
✓ Estimate option trade (132ms)
✓ Should sell the tokens if the premium is paid (489ms)
Exceptions
✓ Paying an option trade with another token
✓ When the offer does not exists
✓ When the buy does not exists
✓ When the offer is not an option trade
✓ When there is not approved amount
✓ When the caller is not the buyer
✓ When the buy is already paid
✓ When the payment is out of the payment window
Cancelling an option trade
✓ After creation
✓ After sellings
Should Behave Like An Option Trade
Cancel Trade
✓ only owner can cancel the trade
✓ offer should be inactive (64ms)
✓ should return all funds if no buying has happened (104ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Premium
Paying premium
✓ estimatePremiumAmount
✓ Should create the order if the premium is paid (137ms)
✓ Should close the offer if the buyer buys all (139ms)
✓ Should not close the offer if the buyer don't buys it all (108ms)
✓ Emits a NewPremium event (106ms)
Exceptions
✓ When the offer does not exists (79ms)
✓ When the offer is not an option trade (176ms)
✓ When there is not approved amount
Paying an option trade
Paying an option trade with the same token as premium
✓ Estimate option trade (129ms)
✓ Should sell the tokens if the premium is paid (438ms)
Exceptions
✓ Paying an option trade with another token
✓ When the offer does not exists
✓ When the buy does not exists
✓ When the offer is not an option trade
✓ When there is not approved amount
✓ When the caller is not the buyer
✓ When the buy is already paid
✓ When the payment is out of the payment window
Cancelling an option trade
✓ After creation
✓ After sellings
Should Behave Like An Option Trade
Cancel Trade
✓ only owner can cancel the trade
✓ offer should be inactive (92ms)
✓ should return all funds if no buying has happened (99ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Premium
Paying premium
✓ estimatePremiumAmount
✓ Should create the order if the premium is paid (130ms)
✓ Should close the offer if the buyer buys all (115ms)
✓ Should not close the offer if the buyer don't buys it all (177ms)
✓ Emits a NewPremium event (122ms)
Exceptions
✓ When the offer does not exists (99ms)
✓ When the offer is not an option trade (134ms)
✓ When there is not approved amount
Paying an option trade
Paying an option trade with the same token as premium
✓ Estimate option trade (139ms)
✓ Should sell the tokens if the premium is paid (625ms)
Exceptions
✓ Paying an option trade with another token
✓ When the offer does not exists
✓ When the buy does not exists
✓ When the offer is not an option trade
✓ When there is not approved amount
✓ When the caller is not the buyer
✓ When the buy is already paid
✓ When the payment is out of the payment window
Cancelling an option trade
✓ After creation
✓ After sellings
Should Behave Like An Option Trade
Cancel Trade
✓ only owner can cancel the trade
✓ offer should be inactive (142ms)
✓ should return all funds if no buying has happened (89ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Premium
Paying premium
✓ estimatePremiumAmount
✓ Should create the order if the premium is paid (129ms)
✓ Should close the offer if the buyer buys all (119ms)
✓ Should not close the offer if the buyer don't buys it all (146ms)
✓ Emits a NewPremium event (92ms)
Exceptions
✓ When the offer does not exists (59ms)
✓ When the offer is not an option trade (172ms)
✓ When there is not approved amount (64ms)
Paying an option trade
Paying an option trade with the same token as premium
✓ Estimate option trade (135ms)
✓ Should sell the tokens if the premium is paid (373ms)
Exceptions
✓ Paying an option trade with another token
✓ When the offer does not exists
✓ When the buy does not exists
✓ When the offer is not an option trade
✓ When there is not approved amount
✓ When the caller is not the buyer
✓ When the buy is already paid
✓ When the payment is out of the payment window
Cancelling an option trade
✓ After creation
✓ After sellings
Should Behave Like An Option Trade
Cancel Trade
✓ only owner can cancel the trade
✓ offer should be inactive (87ms)
✓ should return all funds if no buying has happened (49ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Premium
Paying premium
✓ estimatePremiumAmount
✓ Should create the order if the premium is paid (130ms)
✓ Should close the offer if the buyer buys all (108ms)
✓ Should not close the offer if the buyer don't buys it all (143ms)
✓ Emits a NewPremium event (152ms)
Exceptions
✓ When the offer does not exists (92ms)
✓ When the offer is not an option trade (402ms)
✓ When there is not approved amount (47ms)
Paying an option trade
Paying an option trade with the same token as premium
✓ Estimate option trade (133ms)
✓ Should sell the tokens if the premium is paid (407ms)
Exceptions
✓ Paying an option trade with another token
✓ When the offer does not exists
✓ When the buy does not exists
✓ When the offer is not an option trade
✓ When there is not approved amount
✓ When the caller is not the buyer
✓ When the buy is already paid
✓ When the payment is out of the payment window
Cancelling an option trade
✓ After creation
✓ After sellings
Should Behave Like An Option Trade
Cancel Trade
✓ only owner can cancel the trade
✓ offer should be inactive (52ms)
✓ should return all funds if no buying has happened (72ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Premium
Paying premium
✓ estimatePremiumAmount
✓ Should create the order if the premium is paid (149ms)
✓ Should close the offer if the buyer buys all (112ms)
✓ Should not close the offer if the buyer don't buys it all (162ms)
✓ Emits a NewPremium event (111ms)
Exceptions
✓ When the offer does not exists (53ms)
✓ When the offer is not an option trade (190ms)
✓ When there is not approved amount
Paying an option trade
Paying an option trade with the same token as premium
✓ Estimate option trade (133ms)
✓ Should sell the tokens if the premium is paid (499ms)
Exceptions
✓ Paying an option trade with another token
✓ When the offer does not exists
✓ When the buy does not exists
✓ When the offer is not an option trade
✓ When there is not approved amount
✓ When the caller is not the buyer
✓ When the buy is already paid
✓ When the payment is out of the payment window
Cancelling an option trade
✓ After creation
✓ After sellings
Should Behave Like An Option Trade
Cancel Trade
✓ only owner can cancel the trade
✓ offer should be inactive (61ms)
✓ should return all funds if no buying has happened (63ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Premium
Paying premium
✓ estimatePremiumAmount
✓ Should create the order if the premium is paid (182ms)
✓ Should close the offer if the buyer buys all (115ms)
✓ Should not close the offer if the buyer don't buys it all (125ms)
✓ Emits a NewPremium event (110ms)
Exceptions
✓ When the offer does not exists (63ms)
✓ When the offer is not an option trade (148ms)
✓ When there is not approved amount
Paying an option trade
Paying an option trade with the same token as premium
✓ Estimate option trade (162ms)
✓ Should sell the tokens if the premium is paid (604ms)
Exceptions
✓ Paying an option trade with another token
✓ When the offer does not exists
✓ When the buy does not exists
✓ When the offer is not an option trade
✓ When there is not approved amount
✓ When the caller is not the buyer
✓ When the buy is already paid
✓ When the payment is out of the payment window
Cancelling an option trade
✓ After creation
✓ After sellings
Should Behave Like An Option Trade
Cancel Trade
✓ only owner can cancel the trade
✓ offer should be inactive (78ms)
✓ should return all funds if no buying has happened (87ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Premium
Paying premium
✓ estimatePremiumAmount
✓ Should create the order if the premium is paid (177ms)
✓ Should close the offer if the buyer buys all (152ms)
✓ Should not close the offer if the buyer don't buys it all (159ms)
✓ Emits a NewPremium event (102ms)
Exceptions
✓ When the offer does not exists (66ms)
✓ When the offer is not an option trade (200ms)
✓ When there is not approved amount
Paying an option trade
Paying an option trade with the same token as premium
✓ Estimate option trade (162ms)
✓ Should sell the tokens if the premium is paid (408ms)
Exceptions
✓ Paying an option trade with another token
✓ When the offer does not exists
✓ When the buy does not exists
✓ When the offer is not an option trade
✓ When there is not approved amount
✓ When the caller is not the buyer
✓ When the buy is already paid
✓ When the payment is out of the payment window
Cancelling an option trade
✓ After creation
✓ After sellings
When the seller add a stake
✓ Should not affect old trades, they have to keep the old commission system
210 passing (5m)
> hardhat test "test/stake/test-eve-otc-oracle.js"
Contract: EVE OTC / Oracle
Decimals
✓ 8
✓ 12
Deploy
✓ oracle deployed
✓ EVE deployed
✓ Oracle properly set in EVE
Custom API tests
✓ Deployer is an authorized caller
Others
✓ Other is not an authorized caller (63ms)
✓ Other can not authorize caller
✓ Other is an authorized caller if added (59ms)
✓ Owner is not authorized caller if removed (44ms)
OTC EVE
Authorization
✓ EVE is not an authorized caller by default (71ms)
✓ EVE is an authorized caller if added (76ms)
Tokens
add token
✓ add zero address should fail
by owner
✓ should add the token enabled
✓ should add a CMC token
✓ should add an aggregator token
✓ should add a manual entry token
✓ change token length
change tokens paramenters
✓ token 1 is now a custom price token
✓ token 2 is now a cmc index
✓ token 3 is now an aggregator
✓ should not add more tokens to list
by others
✓ should fail (96ms)
disable token
✓ admin can disable token (142ms)
✓ others cannot disable token (92ms)
✓ if added again the token will be set as enabled (215ms)
re-enable token
✓ admin can re-enable the token (141ms)
✓ others cannot re-enable the token (115ms)
add user token
✓ add zero address should fail
when adding the token for the first time
✓ the token has the data
✓ the user should be the owner of the new token
✓ change user token length
✓ the user can change the price of the token (73ms)
✓ others cannot change the price of the token (74ms)
✓ others cannot add the same token (51ms)
admin can change the owner of one token
✓ the new owner can change the token price (197ms)
✓ others cannot change the token price (69ms)
user token status
✓ the token should be disabled by default
admin can enable token
✓ the token should be enabled
✓ if added again by the owner the token will stay as disabled
admin can re-enable token
✓ the token should be enabled (44ms)
Price in USD
System Tokens
When using CMC API
when getting price
when token enabled
✓ should emit a USDPriceCustomAPI event
should update the last_update time
✓ in eve contract
when token disabled
✓ should fail
when token re-enabled
✓ should succed
When using Chainlink aggregator
when getting price
when token enabled
✓ should emit a USDPriceAggregator event
✓ should update the last_update time
✓ should update the price
when token disabled
✓ should fail (52ms)
when token re-enabled
✓ should succed (47ms)
When using manual price
when setting price
✓ should emit a USDPriceManualEntry event
✓ should return a different price than before (55ms)
✓ should update the last_update time
when getting price
when token enabled
✓ should update the price
when token disabled
✓ get price should fail (45ms)
when token re-enabled
✓ get price should succed
User Tokens
tokens are created
✓ get price and token data is ok
✓ user_token_length is ok
when setting price
✓ not owner cannot set the price
owner can set the price
✓ should emit a USDPriceManualEntry event
✓ should return a different price than before
✓ should update the last_update time
when getting price
when token enabled
when price is not set
✓ price should be zero
when price is set
✓ price should be > 0
when token disabled
✓ should fail (38ms)
unknown tokens
✓ should fail (47ms)
When User Tokens coexist with system tokens
✓ price should be take from system tokens (108ms)
67 passing (30s)
> hardhat test "test/stake/test-eve-otc-stakes.js"
Contract: EVE OTC
Basic data
✓ asset
✓ interest_rate
✓ modify value
✓ Verify permission for modify with a non-admin user (58ms)
Lock options
When the admin user has approved enough funds to pay interest
✓ should fail if the user doesnt have funds
✓ should fail if the user doesnt have funds, even if he approves (61ms)
✓ query the locked funds
✓ query funds in the contract
one more lock
✓ query the locked funds
✓ query funds in the contract
✓ The user already has locked funds
unlock
inmediatly
0 gains
✓ get_gains for user 1, should be 0
✓ get_gains for user 2, should be 0
first user unlocks
✓ No locked funds found
✓ user 1 did not get interest, but recover the funds in EVE
✓ query the locked funds for user 1
✓ query the locked funds for user 2
✓ query funds in the contract
second user unlocks
✓ user 2 did not get interest, but recover the funds in EVE
✓ query the locked funds for user 1
✓ query funds in the contract
+1y
1y gains
✓ get_gains for user 1, should be 30% of 100
✓ get_gains for user 2, should be 30% of 200
first user unlocks
✓ user 1 get 1y interest
✓ query the locked funds for user 1
✓ query the locked funds for user 2
✓ query funds in the contract
second user unlocks
✓ user 2 get 1y interest
✓ query the locked funds for user 1
✓ query funds in the contract
When the admin user has NOT approved enough funds to pay interest
✓ should fail if the user doesnt have funds
✓ should fail if the user doesnt have funds, even if he approves (47ms)
✓ query the locked funds
✓ query funds in the contract
one more lock
✓ query the locked funds
✓ query funds in the contract
unlock
inmediatly
0 gains
✓ get_gains for user 1, should be 0
✓ get_gains for user 2, should be 0
first user unlocks
✓ user 1 did not get interest, but recover the funds in EVE
✓ query the locked funds for user 1
✓ query the locked funds for user 2
✓ query funds in the contract
second user unlocks
✓ user 2 did not get interest, but recover the funds in EVE
✓ query the locked funds for user 1
✓ query funds in the contract
+1y
1y gains
✓ get_gains for user 1, should be 30% of 100
✓ get_gains for user 2, should be 30% of 200
first user unlocks
✓ user 1 get no interest
✓ query the locked funds for user 1
✓ query the locked funds for user 2
✓ query funds in the contract
second user unlocks
✓ user 2 get no interest
✓ query the locked funds for user 1
✓ query funds in the contract
New features
✓ can add a plan (41ms)
✓ data of the plan can be querable (73ms)
✓ plan not active (69ms)
✓ can unlock funds right on time (599ms)
✓ discounts (100ms)
✓ can unlock funds after a while (249ms)
Exceptions
✓ add plan with a non-admin user
✓ only owner can deactivate plan (53ms)
✓ zero values (299ms)
✓ Cannot unlock funds, these funds are locked permanently (221ms)
✓ plan not active (101ms)
✓ cannot unlock funds (113ms)
66 passing (24s)
> hardhat test "test/stake/test-eve-otc-trades-commissions-nft.js"
Contract: EVE OTC / NFT
✓ only owner can add NFT (76ms)
✓ add NFT (138ms)
✓ only owner can add NFT
✓ remove NFT (115ms)
discounts
when discount is not set
when NFT is not set
✓ should be 0
when NFT is set
when the user have NFTs
✓ should be 0
when the user does not have NFTs
✓ should be 0
when the NFT is removed
when the user have NFTs
✓ should be 0
when the user does not have NFTs
✓ should be 0
when discount is set
when NFT is not set
✓ should be 0
when NFT is set
when the user have NFTs
✓ should be positive
when the user does not have NFTs
✓ should be 0
when the NFT is removed
when the user have NFTs
✓ should be 0
when the user does not have NFTs
✓ should be 0
14 passing (3s)
> hardhat test "test/stake/test-eve-otc-trades-commissions.js"
Contract: EVE OTC / Oracle
New commissions scheme
When commissions are greater than 1
shouldBehaveLikeBuyAndSell
When the commission are unchanged during the process
Sellers
✓ The seller commission is locked in advance (446ms)
✓ The contract pays the commission to admin when a trader buys an offer (750ms)
When canceling trades
When there is no trade in the middle
✓ Should return all funds including the surplus (472ms)
When there are trades in the middle
✓ Should return the remaining funds including the surplus (1013ms)
Buyers
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (234ms)
✓ second partial withdrawal (699ms)
✓ total withdrawal (358ms)
When the commission change during the process
Sellers
✓ Old trades are charged with the old commission (1052ms)
✓ New trades are charged with the new commission (1157ms)
Buyers
✓ Old trades are charged with the old commission (1373ms)
✓ New trades are charged with the new commission (1635ms)
Discounts
trades are done with no discount
with no stake
✓ The seller commission is locked in advance (676ms)
✓ The contract pays the commission to admin when a trader buys an offer (1852ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (276ms)
✓ second partial withdrawal (884ms)
✓ total withdrawal (318ms)
with stake with no discount
✓ The seller commission is locked in advance (435ms)
✓ The contract pays the commission to admin when a trader buys an offer (1297ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (261ms)
✓ second partial withdrawal (520ms)
✓ total withdrawal (260ms)
Discounts is applied in the window time
30%
seller only
✓ The seller commission is locked in advance (380ms)
✓ The contract pays the commission to admin when a trader buys an offer (1615ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (375ms)
✓ second partial withdrawal (547ms)
✓ total withdrawal (288ms)
buyer only
✓ The seller commission is locked in advance (554ms)
✓ The contract pays the commission to admin when a trader buys an offer (1626ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (606ms)
✓ second partial withdrawal (538ms)
✓ total withdrawal (204ms)
both
✓ The seller commission is locked in advance (520ms)
✓ The contract pays the commission to admin when a trader buys an offer (1173ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (458ms)
✓ second partial withdrawal (853ms)
✓ total withdrawal (375ms)
100%
seller only
✓ The seller commission is locked in advance (629ms)
✓ The contract pays the commission to admin when a trader buys an offer (1086ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (290ms)
✓ second partial withdrawal (660ms)
✓ total withdrawal (272ms)
buyer only
✓ The seller commission is locked in advance (442ms)
✓ The contract pays the commission to admin when a trader buys an offer (1248ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (239ms)
✓ second partial withdrawal (530ms)
✓ total withdrawal (317ms)
both
✓ The seller commission is locked in advance (634ms)
✓ The contract pays the commission to admin when a trader buys an offer (1100ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (337ms)
✓ second partial withdrawal (615ms)
✓ total withdrawal (287ms)
Discounts expires
with stake with no discount
✓ The seller commission is locked in advance (774ms)
✓ The contract pays the commission to admin when a trader buys an offer (1663ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (897ms)
✓ second partial withdrawal (648ms)
✓ total withdrawal (735ms)
Discounts are replaced
✓ The seller commission is locked in advance (581ms)
✓ The contract pays the commission to admin when a trader buys an offer (1146ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (686ms)
✓ second partial withdrawal (793ms)
✓ total withdrawal (352ms)
NFT Discounts is applied
30%
seller only
✓ The seller commission is locked in advance (476ms)
✓ The contract pays the commission to admin when a trader buys an offer (1237ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (294ms)
✓ second partial withdrawal (730ms)
✓ total withdrawal (411ms)
buyer only
✓ The seller commission is locked in advance (549ms)
✓ The contract pays the commission to admin when a trader buys an offer (1188ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (296ms)
✓ second partial withdrawal (547ms)
✓ total withdrawal (395ms)
both
✓ The seller commission is locked in advance (1649ms)
✓ The contract pays the commission to admin when a trader buys an offer (1771ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (349ms)
✓ second partial withdrawal (565ms)
✓ total withdrawal (389ms)
100%
seller only
✓ The seller commission is locked in advance (442ms)
✓ The contract pays the commission to admin when a trader buys an offer (1145ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (294ms)
✓ second partial withdrawal (662ms)
✓ total withdrawal (394ms)
buyer only
✓ The seller commission is locked in advance (505ms)
✓ The contract pays the commission to admin when a trader buys an offer (1312ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (310ms)
✓ second partial withdrawal (1025ms)
✓ total withdrawal (317ms)
both
✓ The seller commission is locked in advance (887ms)
✓ The contract pays the commission to admin when a trader buys an offer (1555ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (379ms)
✓ second partial withdrawal (579ms)
✓ total withdrawal (373ms)
When commissions are lower than 1
shouldBehaveLikeBuyAndSell
When the commission are unchanged during the process
Sellers
✓ The seller commission is locked in advance (454ms)
✓ The contract pays the commission to admin when a trader buys an offer (1541ms)
When canceling trades
When there is no trade in the middle
✓ Should return all funds including the surplus (924ms)
When there are trades in the middle
✓ Should return the remaining funds including the surplus (1975ms)
Buyers
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (287ms)
✓ second partial withdrawal (821ms)
✓ total withdrawal (639ms)
When the commission change during the process
Sellers
✓ Old trades are charged with the old commission (1404ms)
✓ New trades are charged with the new commission (1388ms)
Buyers
✓ Old trades are charged with the old commission (1565ms)
✓ New trades are charged with the new commission (1512ms)
Discounts
trades are done with no discount
with no stake
✓ The seller commission is locked in advance (461ms)
✓ The contract pays the commission to admin when a trader buys an offer (1145ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (341ms)
✓ second partial withdrawal (1048ms)
✓ total withdrawal (404ms)
with stake with no discount
✓ The seller commission is locked in advance (500ms)
✓ The contract pays the commission to admin when a trader buys an offer (1591ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (293ms)
✓ second partial withdrawal (866ms)
✓ total withdrawal (236ms)
Discounts is applied in the window time
30%
seller only
✓ The seller commission is locked in advance (551ms)
✓ The contract pays the commission to admin when a trader buys an offer (1569ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (256ms)
✓ second partial withdrawal (631ms)
✓ total withdrawal (1038ms)
buyer only
✓ The seller commission is locked in advance (487ms)
✓ The contract pays the commission to admin when a trader buys an offer (1391ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (448ms)
✓ second partial withdrawal (553ms)
✓ total withdrawal (593ms)
both
✓ The seller commission is locked in advance (686ms)
✓ The contract pays the commission to admin when a trader buys an offer (1641ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (565ms)
✓ second partial withdrawal (550ms)
✓ total withdrawal (552ms)
100%
seller only
✓ The seller commission is locked in advance (523ms)
✓ The contract pays the commission to admin when a trader buys an offer (1202ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (297ms)
✓ second partial withdrawal (817ms)
✓ total withdrawal (698ms)
buyer only
✓ The seller commission is locked in advance (1606ms)
✓ The contract pays the commission to admin when a trader buys an offer (1456ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (246ms)
✓ second partial withdrawal (544ms)
✓ total withdrawal (749ms)
both
✓ The seller commission is locked in advance (1354ms)
✓ The contract pays the commission to admin when a trader buys an offer (2649ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (420ms)
✓ second partial withdrawal (568ms)
✓ total withdrawal (261ms)
Discounts expires
with stake with no discount
✓ The seller commission is locked in advance (406ms)
✓ The contract pays the commission to admin when a trader buys an offer (1034ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (417ms)
✓ second partial withdrawal (828ms)
✓ total withdrawal (453ms)
Discounts are replaced
✓ The seller commission is locked in advance (529ms)
✓ The contract pays the commission to admin when a trader buys an offer (1241ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (353ms)
✓ second partial withdrawal (649ms)
✓ total withdrawal (516ms)
NFT Discounts is applied
30%
seller only
✓ The seller commission is locked in advance (748ms)
✓ The contract pays the commission to admin when a trader buys an offer (1452ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (484ms)
✓ second partial withdrawal (921ms)
✓ total withdrawal (348ms)
buyer only
✓ The seller commission is locked in advance (657ms)
✓ The contract pays the commission to admin when a trader buys an offer (1339ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (320ms)
✓ second partial withdrawal (617ms)
✓ total withdrawal (495ms)
both
✓ The seller commission is locked in advance (562ms)
✓ The contract pays the commission to admin when a trader buys an offer (1403ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (351ms)
✓ second partial withdrawal (754ms)
✓ total withdrawal (434ms)
100%
seller only
✓ The seller commission is locked in advance (742ms)
✓ The contract pays the commission to admin when a trader buys an offer (1237ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (527ms)
✓ second partial withdrawal (797ms)
✓ total withdrawal (410ms)
buyer only
✓ The seller commission is locked in advance (891ms)
✓ The contract pays the commission to admin when a trader buys an offer (1385ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (378ms)
✓ second partial withdrawal (793ms)
✓ total withdrawal (272ms)
both
✓ The seller commission is locked in advance (592ms)
✓ The contract pays the commission to admin when a trader buys an offer (1524ms)
The buyer receives the amount of token minus admin commission on
✓ first partial withdrawal (300ms)
✓ second partial withdrawal (703ms)
✓ total withdrawal (453ms)
182 passing (10m)
> hardhat test "test/stake/test-eve-otc-trades-discount-premium.js"
Contract: EVE OTC / Discount / Premium
addOffer
buySmartTrade
when there are no discounts on admin fees
basic data
✓ the offers parameters are set with discount or premium (53ms)
estimate price
✓ estimate the offers with discount / premium (128ms)
buy smart trade
to_buyer_diff 360000000
to_seller_diff 360000000
from_buyer_diff 92000
from_owner_diff 8000
✓ buy the offer 0 (304ms)
to_buyer_diff 440000000
to_seller_diff 440000000
from_buyer_diff 92000
from_owner_diff 8000
✓ buy the offer 1 (273ms)
to_buyer_diff 360000000
to_seller_diff 360000000
from_buyer_diff 92000
from_owner_diff 8000
✓ buy the offer 2 (283ms)
to_buyer_diff 400000000
to_seller_diff 400000000
from_buyer_diff 92000
from_owner_diff 8000
✓ buy the offer 3 (419ms)
when 50% discount on admin fees
basic data
✓ the offers parameters are set with discount or premium
estimate price
✓ estimate the offers with discount / premium (95ms)
buy smart trade
to_buyer_diff 360000000
to_seller_diff 360000000
from_buyer_diff 96000
from_owner_diff 4000
✓ buy the offer 0 (443ms)
to_buyer_diff 440000000
to_seller_diff 440000000
from_buyer_diff 96000
from_owner_diff 4000
✓ buy the offer 1 (420ms)
to_buyer_diff 360000000
to_seller_diff 360000000
from_buyer_diff 96000
from_owner_diff 4000
✓ buy the offer 2 (549ms)
to_buyer_diff 400000000
to_seller_diff 400000000
from_buyer_diff 96000
from_owner_diff 4000
✓ buy the offer 3 (352ms)
12 passing (19s)
> hardhat test "test/stake/test-eve-otc-trades.js"
Contract: EVE OTC / Oracle
addOffer
pre conditions
✓ Positive offer (68ms)
✓ Discount lower than 100
✓ Erroring transfer sale funds (58ms)
Token for sale not enabled
✓ when token does not exists
✓ when token exists but is not enabled (39ms)
✓ when is not a token
Token for payments not enabled
✓ when token does not exists
✓ when token exists but is not enabled (50ms)
✓ when is not a token
events
✓ New Offer (110ms)
Smart Trades
When the seller have no stake
add offers with system tokens
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade
✓ offer should be inactive (79ms)
✓ should return all funds if no buying has happened (83ms)
✓ should return remaining funds if a buying has happened (152ms)
✓ reiterative cancel trades (419ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_chainlink_oracle
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (46ms)
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade (47ms)
✓ offer should be inactive (126ms)
✓ should return all funds if no buying has happened (74ms)
✓ should return remaining funds if a buying has happened (217ms)
✓ reiterative cancel trades (498ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_chainlink_oracle
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (87ms)
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade
✓ offer should be inactive (91ms)
✓ should return all funds if no buying has happened (76ms)
✓ should return remaining funds if a buying has happened (336ms)
✓ reiterative cancel trades (440ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_custom_oracle
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (47ms)
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade (44ms)
✓ offer should be inactive (80ms)
✓ should return all funds if no buying has happened (69ms)
✓ should return remaining funds if a buying has happened (162ms)
✓ reiterative cancel trades (527ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_custom_oracle
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (51ms)
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade (60ms)
✓ offer should be inactive (96ms)
✓ should return all funds if no buying has happened (55ms)
✓ should return remaining funds if a buying has happened (197ms)
✓ reiterative cancel trades (673ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_custom_price
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (53ms)
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade (45ms)
✓ offer should be inactive (92ms)
✓ should return all funds if no buying has happened (41ms)
✓ should return remaining funds if a buying has happened (181ms)
✓ reiterative cancel trades (469ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_custom_price
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (58ms)
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade
✓ offer should be inactive (95ms)
✓ should return all funds if no buying has happened (94ms)
✓ should return remaining funds if a buying has happened (184ms)
✓ reiterative cancel trades (616ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_user_token
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (49ms)
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade (42ms)
✓ offer should be inactive (75ms)
✓ should return all funds if no buying has happened (42ms)
✓ should return remaining funds if a buying has happened (166ms)
✓ reiterative cancel trades (870ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_user_token
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (43ms)
When the seller add a stake
✓ Should not affect old trades, they have to keep the old commission system (199ms)
When the seller have a stake
add offers with system tokens
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade (55ms)
✓ offer should be inactive (79ms)
✓ should return all funds if no buying has happened (61ms)
✓ should return remaining funds if a buying has happened (158ms)
✓ reiterative cancel trades (476ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_chainlink_oracle
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (49ms)
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade (43ms)
✓ offer should be inactive (80ms)
✓ should return all funds if no buying has happened (90ms)
✓ should return remaining funds if a buying has happened (101ms)
✓ reiterative cancel trades (467ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_chainlink_oracle
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (43ms)
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade (44ms)
✓ offer should be inactive (78ms)
✓ should return all funds if no buying has happened (42ms)
✓ should return remaining funds if a buying has happened (196ms)
✓ reiterative cancel trades (465ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_custom_oracle
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (59ms)
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade (67ms)
✓ offer should be inactive (77ms)
✓ should return all funds if no buying has happened (68ms)
✓ should return remaining funds if a buying has happened (145ms)
✓ reiterative cancel trades (581ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_custom_oracle
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (54ms)
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade (93ms)
✓ offer should be inactive (86ms)
✓ should return all funds if no buying has happened (60ms)
✓ should return remaining funds if a buying has happened (144ms)
✓ reiterative cancel trades (471ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_custom_price
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (49ms)
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade
✓ offer should be inactive (88ms)
✓ should return all funds if no buying has happened (78ms)
✓ should return remaining funds if a buying has happened (206ms)
✓ reiterative cancel trades (493ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_custom_price
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (45ms)
add offers with user tokens
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade (41ms)
✓ offer should be inactive (87ms)
✓ should return all funds if no buying has happened (82ms)
✓ should return remaining funds if a buying has happened (243ms)
✓ reiterative cancel trades (471ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_user_token
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (46ms)
Should Behave Like A Smart Trade
Cancel Trade
✓ only owner can cancel the trade
✓ offer should be inactive (87ms)
✓ should return all funds if no buying has happened (55ms)
✓ should return remaining funds if a buying has happened (183ms)
✓ reiterative cancel trades (488ms)
Check Funds
✓ The amount available should be exact to the one added
Changing commissions
✓ The amount available should be exact to the one added
Should Behave Like A Smart Trade
ⓘ token_user_token
✓ trades length is ok
✓ trades are ok
✓ smart_trades_owners is ok
✓ smart_trades_from
✓ smart_trades_to (51ms)
When the seller ends the stake
✓ Should not affect old trades, they have to keep the old commission system (207ms)
buySmartTrade
when the seller has no stakes
buy tokens
✓ the contract should have anough balance from seller to sell and pay commissions
shouldBehaveLikeBuying
✓ Buy 1000000000 token_custom_price with 450 token_chainlink_oracle (227ms)
✓ Estimate Buying Price 1000000000 token_custom_price with 450 token_chainlink_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (62ms)
✓ should succeed to withdraw the buyer (64ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (99ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (167ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (276ms)
arrays
✓ check arrays (52ms)
others
✓ check multiple buys successful (423ms)
exceptions
✓ OTC: token not found in the selected offer (39ms)
✓ OTC: this is not a smart trade (174ms)
✓ OTC: not enough amount in the offer (62ms)
shouldBehaveLikeBuying
✓ Buy 5000000000 token_custom_price with 2250 token_chainlink_oracle (218ms)
✓ Estimate Buying Price 5000000000 token_custom_price with 2250 token_chainlink_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (68ms)
✓ should succeed to withdraw the buyer (120ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (78ms)
after expiration time
✓ should fail to withdraw other than buyer (40ms)
✓ should succeed to withdraw the buyer (147ms)
during time, three times
✓ should fail to withdraw other than buyer (64ms)
✓ should succeed to withdraw the buyer (375ms)
arrays
✓ check arrays (53ms)
others
✓ check multiple buys successful (516ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (86ms)
✓ OTC: not enough amount in the offer
shouldBehaveLikeBuying
✓ Buy 100000000000 token_custom_price with 45000 token_chainlink_oracle (233ms)
✓ Estimate Buying Price 100000000000 token_custom_price with 45000 token_chainlink_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (107ms)
at expiring
✓ should fail to withdraw other than buyer (50ms)
✓ should succeed to withdraw the buyer (60ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (156ms)
during time, three times
✓ should fail to withdraw other than buyer (54ms)
✓ should succeed to withdraw the buyer (253ms)
arrays
✓ check arrays (50ms)
others
✓ check multiple buys successful (432ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (145ms)
✓ OTC: not enough amount in the offer (64ms)
shouldBehaveLikeBuying
✓ Buy 1000 token_chainlink_oracle with 1800000000 token_custom_price (232ms)
✓ Estimate Buying Price 1000 token_chainlink_oracle with 1800000000 token_custom_price
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (60ms)
at expiring
✓ should fail to withdraw other than buyer (163ms)
✓ should succeed to withdraw the buyer (224ms)
after expiration time
✓ should fail to withdraw other than buyer (216ms)
✓ should succeed to withdraw the buyer (118ms)
during time, three times
✓ should fail to withdraw other than buyer (76ms)
✓ should succeed to withdraw the buyer (335ms)
arrays
✓ check arrays (55ms)
others
✓ check multiple buys successful (594ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (120ms)
✓ OTC: not enough amount in the offer (42ms)
shouldBehaveLikeBuying
✓ Buy 5000 token_chainlink_oracle with 9000000000 token_custom_price (199ms)
✓ Estimate Buying Price 5000 token_chainlink_oracle with 9000000000 token_custom_price
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (51ms)
✓ should succeed to withdraw the buyer (89ms)
at expiring
✓ should fail to withdraw other than buyer (43ms)
✓ should succeed to withdraw the buyer (85ms)
after expiration time
✓ should fail to withdraw other than buyer (38ms)
✓ should succeed to withdraw the buyer (124ms)
during time, three times
✓ should fail to withdraw other than buyer (41ms)
✓ should succeed to withdraw the buyer (273ms)
arrays
✓ check arrays (62ms)
others
✓ check multiple buys successful (340ms)
exceptions
✓ OTC: token not found in the selected offer (44ms)
✓ OTC: this is not a smart trade (128ms)
✓ OTC: not enough amount in the offer (81ms)
shouldBehaveLikeBuying
✓ Buy 100000 token_chainlink_oracle with 180000000000 token_custom_price (193ms)
✓ Estimate Buying Price 100000 token_chainlink_oracle with 180000000000 token_custom_price
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (39ms)
✓ should succeed to withdraw the buyer (118ms)
at expiring
✓ should fail to withdraw other than buyer (45ms)
✓ should succeed to withdraw the buyer (90ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (107ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (161ms)
arrays
✓ check arrays (49ms)
others
✓ check multiple buys successful (444ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (124ms)
✓ OTC: not enough amount in the offer
shouldBehaveLikeBuying
✓ Buy 1000000000000000000 token_user_token with 2700000 token_custom_oracle (189ms)
✓ Estimate Buying Price 1000000000000000000 token_user_token with 2700000 token_custom_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (40ms)
✓ should succeed to withdraw the buyer (58ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (46ms)
after expiration time
✓ should fail to withdraw other than buyer (139ms)
✓ should succeed to withdraw the buyer (235ms)
during time, three times
✓ should fail to withdraw other than buyer (66ms)
✓ should succeed to withdraw the buyer (152ms)
arrays
✓ check arrays (75ms)
others
✓ check multiple buys successful (382ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (76ms)
✓ OTC: not enough amount in the offer (50ms)
shouldBehaveLikeBuying
✓ Buy 5000000000000000000 token_user_token with 13500000 token_custom_oracle (191ms)
✓ Estimate Buying Price 5000000000000000000 token_user_token with 13500000 token_custom_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (78ms)
at expiring
✓ should fail to withdraw other than buyer (39ms)
✓ should succeed to withdraw the buyer (69ms)
after expiration time
✓ should fail to withdraw other than buyer (47ms)
✓ should succeed to withdraw the buyer (121ms)
during time, three times
✓ should fail to withdraw other than buyer (72ms)
✓ should succeed to withdraw the buyer (281ms)
arrays
✓ check arrays (50ms)
others
✓ check multiple buys successful (505ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (232ms)
✓ OTC: not enough amount in the offer (129ms)
shouldBehaveLikeBuying
✓ Buy 100000000000000000000 token_user_token with 270000000 token_custom_oracle (198ms)
✓ Estimate Buying Price 100000000000000000000 token_user_token with 270000000 token_custom_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (39ms)
✓ should succeed to withdraw the buyer (101ms)
at expiring
✓ should fail to withdraw other than buyer (277ms)
✓ should succeed to withdraw the buyer (101ms)
after expiration time
✓ should fail to withdraw other than buyer (38ms)
✓ should succeed to withdraw the buyer (116ms)
during time, three times
✓ should fail to withdraw other than buyer (50ms)
✓ should succeed to withdraw the buyer (229ms)
arrays
✓ check arrays (54ms)
others
✓ check multiple buys successful (492ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (70ms)
✓ OTC: not enough amount in the offer (59ms)
shouldBehaveLikeBuying
✓ Buy 1000000 token_custom_oracle with 300000000000000000 token_user_token (148ms)
✓ Estimate Buying Price 1000000 token_custom_oracle with 300000000000000000 token_user_token
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (57ms)
at expiring
✓ should fail to withdraw other than buyer (64ms)
✓ should succeed to withdraw the buyer (127ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (103ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (197ms)
arrays
✓ check arrays (51ms)
others
✓ check multiple buys successful (349ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (134ms)
✓ OTC: not enough amount in the offer (44ms)
shouldBehaveLikeBuying
✓ Buy 5000000 token_custom_oracle with 1500000000000000000 token_user_token (282ms)
✓ Estimate Buying Price 5000000 token_custom_oracle with 1500000000000000000 token_user_token
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (56ms)
✓ should succeed to withdraw the buyer (78ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (68ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (120ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (239ms)
arrays
✓ check arrays (55ms)
others
✓ check multiple buys successful (215ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (141ms)
✓ OTC: not enough amount in the offer
shouldBehaveLikeBuying
✓ Buy 100000000 token_custom_oracle with 30000000000000000000 token_user_token (186ms)
✓ Estimate Buying Price 100000000 token_custom_oracle with 30000000000000000000 token_user_token
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (97ms)
at expiring
✓ should fail to withdraw other than buyer (53ms)
✓ should succeed to withdraw the buyer (74ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (162ms)
during time, three times
✓ should fail to withdraw other than buyer (101ms)
✓ should succeed to withdraw the buyer (194ms)
arrays
✓ check arrays (48ms)
others
✓ check multiple buys successful (461ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (118ms)
✓ OTC: not enough amount in the offer (103ms)
when the seller has stakes
get an estimation of tokens to receive
✓ When no buy have been done
✓ When buys are done
buy tokens
✓ the contract should have anough balance from seller to sell and pay commissions
shouldBehaveLikeBuying
✓ Buy 1000000000 token_custom_price with 450 token_chainlink_oracle (168ms)
✓ Estimate Buying Price 1000000000 token_custom_price with 450 token_chainlink_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (53ms)
at expiring
✓ should fail to withdraw other than buyer (38ms)
✓ should succeed to withdraw the buyer (88ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (100ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (230ms)
arrays
✓ check arrays (56ms)
others
✓ check multiple buys successful (455ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (123ms)
✓ OTC: not enough amount in the offer (52ms)
shouldBehaveLikeBuying
✓ Buy 5000000000 token_custom_price with 2250 token_chainlink_oracle (193ms)
✓ Estimate Buying Price 5000000000 token_custom_price with 2250 token_chainlink_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (52ms)
✓ should succeed to withdraw the buyer (59ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (89ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (132ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (200ms)
arrays
✓ check arrays (83ms)
others
✓ check multiple buys successful (393ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (136ms)
✓ OTC: not enough amount in the offer
shouldBehaveLikeBuying
✓ Buy 100000000000 token_custom_price with 45000 token_chainlink_oracle (201ms)
✓ Estimate Buying Price 100000000000 token_custom_price with 45000 token_chainlink_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (84ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (119ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (189ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (241ms)
arrays
✓ check arrays (62ms)
others
✓ check multiple buys successful (424ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (159ms)
✓ OTC: not enough amount in the offer (55ms)
shouldBehaveLikeBuying
✓ Buy 1000 token_chainlink_oracle with 1800000000 token_custom_price (289ms)
✓ Estimate Buying Price 1000 token_chainlink_oracle with 1800000000 token_custom_price
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (44ms)
✓ should succeed to withdraw the buyer (68ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (95ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (138ms)
during time, three times
✓ should fail to withdraw other than buyer (71ms)
✓ should succeed to withdraw the buyer (236ms)
arrays
✓ check arrays (48ms)
others
✓ check multiple buys successful (382ms)
exceptions
✓ OTC: token not found in the selected offer (117ms)
✓ OTC: this is not a smart trade (113ms)
✓ OTC: not enough amount in the offer (75ms)
shouldBehaveLikeBuying
✓ Buy 5000 token_chainlink_oracle with 9000000000 token_custom_price (449ms)
✓ Estimate Buying Price 5000 token_chainlink_oracle with 9000000000 token_custom_price
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (66ms)
at expiring
✓ should fail to withdraw other than buyer (47ms)
✓ should succeed to withdraw the buyer (87ms)
after expiration time
✓ should fail to withdraw other than buyer (70ms)
✓ should succeed to withdraw the buyer (188ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (286ms)
arrays
✓ check arrays (47ms)
others
✓ check multiple buys successful (429ms)
exceptions
✓ OTC: token not found in the selected offer (168ms)
✓ OTC: this is not a smart trade (182ms)
✓ OTC: not enough amount in the offer (130ms)
shouldBehaveLikeBuying
✓ Buy 100000 token_chainlink_oracle with 180000000000 token_custom_price (295ms)
✓ Estimate Buying Price 100000 token_chainlink_oracle with 180000000000 token_custom_price
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (172ms)
✓ should succeed to withdraw the buyer (68ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (107ms)
after expiration time
✓ should fail to withdraw other than buyer (54ms)
✓ should succeed to withdraw the buyer (108ms)
during time, three times
✓ should fail to withdraw other than buyer (405ms)
✓ should succeed to withdraw the buyer (133ms)
arrays
✓ check arrays (55ms)
others
✓ check multiple buys successful (685ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (141ms)
✓ OTC: not enough amount in the offer (65ms)
shouldBehaveLikeBuying
✓ Buy 1000000000000000000 token_user_token with 2700000 token_custom_oracle (211ms)
✓ Estimate Buying Price 1000000000000000000 token_user_token with 2700000 token_custom_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (71ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (74ms)
after expiration time
✓ should fail to withdraw other than buyer (45ms)
✓ should succeed to withdraw the buyer (100ms)
during time, three times
✓ should fail to withdraw other than buyer (73ms)
✓ should succeed to withdraw the buyer (332ms)
arrays
✓ check arrays (61ms)
others
✓ check multiple buys successful (378ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (161ms)
✓ OTC: not enough amount in the offer (38ms)
shouldBehaveLikeBuying
✓ Buy 5000000000000000000 token_user_token with 13500000 token_custom_oracle (217ms)
✓ Estimate Buying Price 5000000000000000000 token_user_token with 13500000 token_custom_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (109ms)
at expiring
✓ should fail to withdraw other than buyer (66ms)
✓ should succeed to withdraw the buyer (98ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (188ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (215ms)
arrays
✓ check arrays (62ms)
others
✓ check multiple buys successful (642ms)
exceptions
✓ OTC: token not found in the selected offer (54ms)
✓ OTC: this is not a smart trade (115ms)
✓ OTC: not enough amount in the offer (69ms)
shouldBehaveLikeBuying
✓ Buy 100000000000000000000 token_user_token with 270000000 token_custom_oracle (205ms)
✓ Estimate Buying Price 100000000000000000000 token_user_token with 270000000 token_custom_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (151ms)
✓ should succeed to withdraw the buyer (85ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (67ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (177ms)
during time, three times
✓ should fail to withdraw other than buyer (52ms)
✓ should succeed to withdraw the buyer (394ms)
arrays
✓ check arrays (56ms)
others
✓ check multiple buys successful (444ms)
exceptions
✓ OTC: token not found in the selected offer (45ms)
✓ OTC: this is not a smart trade (201ms)
✓ OTC: not enough amount in the offer (47ms)
shouldBehaveLikeBuying
✓ Buy 1000000 token_custom_oracle with 300000000000000000 token_user_token (242ms)
✓ Estimate Buying Price 1000000 token_custom_oracle with 300000000000000000 token_user_token
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (196ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (63ms)
after expiration time
✓ should fail to withdraw other than buyer (90ms)
✓ should succeed to withdraw the buyer (88ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (332ms)
arrays
✓ check arrays (75ms)
others
✓ check multiple buys successful (422ms)
exceptions
✓ OTC: token not found in the selected offer (86ms)
✓ OTC: this is not a smart trade (119ms)
✓ OTC: not enough amount in the offer (38ms)
shouldBehaveLikeBuying
✓ Buy 5000000 token_custom_oracle with 1500000000000000000 token_user_token (279ms)
✓ Estimate Buying Price 5000000 token_custom_oracle with 1500000000000000000 token_user_token
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (124ms)
at expiring
✓ should fail to withdraw other than buyer (44ms)
✓ should succeed to withdraw the buyer (89ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (185ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (192ms)
arrays
✓ check arrays (77ms)
others
✓ check multiple buys successful (386ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (106ms)
✓ OTC: not enough amount in the offer (68ms)
shouldBehaveLikeBuying
✓ Buy 100000000 token_custom_oracle with 30000000000000000000 token_user_token (358ms)
✓ Estimate Buying Price 100000000 token_custom_oracle with 30000000000000000000 token_user_token
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (55ms)
✓ should succeed to withdraw the buyer (114ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (94ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (145ms)
during time, three times
✓ should fail to withdraw other than buyer (103ms)
✓ should succeed to withdraw the buyer (336ms)
arrays
✓ check arrays (66ms)
others
✓ check multiple buys successful (508ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (215ms)
✓ OTC: not enough amount in the offer (66ms)
buySmartTrade
when the seller has stakes with less than 100% discount
buy tokens
shouldBehaveLikeBuying
✓ Buy 1000000000 token_custom_price with 450 token_chainlink_oracle (277ms)
✓ Estimate Buying Price 1000000000 token_custom_price with 450 token_chainlink_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (112ms)
at expiring
✓ should fail to withdraw other than buyer (48ms)
✓ should succeed to withdraw the buyer (86ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (179ms)
during time, three times
✓ should fail to withdraw other than buyer (71ms)
✓ should succeed to withdraw the buyer (512ms)
arrays
✓ check arrays (73ms)
others
✓ check multiple buys successful (654ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (212ms)
✓ OTC: not enough amount in the offer (63ms)
shouldBehaveLikeBuying
✓ Buy 5000000000 token_custom_price with 2250 token_chainlink_oracle (346ms)
✓ Estimate Buying Price 5000000000 token_custom_price with 2250 token_chainlink_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (115ms)
✓ should succeed to withdraw the buyer (114ms)
at expiring
✓ should fail to withdraw other than buyer (42ms)
✓ should succeed to withdraw the buyer (94ms)
after expiration time
✓ should fail to withdraw other than buyer (124ms)
✓ should succeed to withdraw the buyer (294ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (267ms)
arrays
✓ check arrays (93ms)
others
✓ check multiple buys successful (570ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (283ms)
✓ OTC: not enough amount in the offer (151ms)
shouldBehaveLikeBuying
✓ Buy 100000000000 token_custom_price with 45000 token_chainlink_oracle (265ms)
✓ Estimate Buying Price 100000000000 token_custom_price with 45000 token_chainlink_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (136ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (112ms)
after expiration time
✓ should fail to withdraw other than buyer (112ms)
✓ should succeed to withdraw the buyer (164ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (363ms)
arrays
✓ check arrays (59ms)
others
✓ check multiple buys successful (644ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (118ms)
✓ OTC: not enough amount in the offer (122ms)
shouldBehaveLikeBuying
✓ Buy 1000 token_chainlink_oracle with 1800000000 token_custom_price (414ms)
✓ Estimate Buying Price 1000 token_chainlink_oracle with 1800000000 token_custom_price
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (126ms)
at expiring
✓ should fail to withdraw other than buyer (48ms)
✓ should succeed to withdraw the buyer (80ms)
after expiration time
✓ should fail to withdraw other than buyer (49ms)
✓ should succeed to withdraw the buyer (312ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (166ms)
arrays
✓ check arrays (92ms)
others
✓ check multiple buys successful (678ms)
exceptions
✓ OTC: token not found in the selected offer (95ms)
✓ OTC: this is not a smart trade (136ms)
✓ OTC: not enough amount in the offer (59ms)
shouldBehaveLikeBuying
✓ Buy 5000 token_chainlink_oracle with 9000000000 token_custom_price (298ms)
✓ Estimate Buying Price 5000 token_chainlink_oracle with 9000000000 token_custom_price
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (91ms)
✓ should succeed to withdraw the buyer (329ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (117ms)
after expiration time
✓ should fail to withdraw other than buyer (41ms)
✓ should succeed to withdraw the buyer (297ms)
during time, three times
✓ should fail to withdraw other than buyer (68ms)
✓ should succeed to withdraw the buyer (315ms)
arrays
✓ check arrays (89ms)
others
✓ check multiple buys successful (564ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (315ms)
✓ OTC: not enough amount in the offer (277ms)
shouldBehaveLikeBuying
✓ Buy 100000 token_chainlink_oracle with 180000000000 token_custom_price (445ms)
✓ Estimate Buying Price 100000 token_chainlink_oracle with 180000000000 token_custom_price
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (292ms)
✓ should succeed to withdraw the buyer (229ms)
at expiring
✓ should fail to withdraw other than buyer (105ms)
✓ should succeed to withdraw the buyer (122ms)
after expiration time
✓ should fail to withdraw other than buyer (123ms)
✓ should succeed to withdraw the buyer (214ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (283ms)
arrays
✓ check arrays (90ms)
others
✓ check multiple buys successful (687ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (99ms)
✓ OTC: not enough amount in the offer (50ms)
shouldBehaveLikeBuying
✓ Buy 1000000000000000000 token_user_token with 2700000 token_custom_oracle (269ms)
✓ Estimate Buying Price 1000000000000000000 token_user_token with 2700000 token_custom_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer (41ms)
✓ should succeed to withdraw the buyer (88ms)
at expiring
✓ should fail to withdraw other than buyer (52ms)
✓ should succeed to withdraw the buyer (83ms)
after expiration time
✓ should fail to withdraw other than buyer (50ms)
✓ should succeed to withdraw the buyer (161ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (203ms)
arrays
✓ check arrays (67ms)
others
✓ check multiple buys successful (553ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (88ms)
✓ OTC: not enough amount in the offer (140ms)
shouldBehaveLikeBuying
✓ Buy 5000000000000000000 token_user_token with 13500000 token_custom_oracle (178ms)
✓ Estimate Buying Price 5000000000000000000 token_user_token with 13500000 token_custom_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (218ms)
at expiring
✓ should fail to withdraw other than buyer (90ms)
✓ should succeed to withdraw the buyer (118ms)
after expiration time
✓ should fail to withdraw other than buyer (44ms)
✓ should succeed to withdraw the buyer (240ms)
during time, three times
✓ should fail to withdraw other than buyer (184ms)
✓ should succeed to withdraw the buyer (267ms)
arrays
✓ check arrays (71ms)
others
✓ check multiple buys successful (597ms)
exceptions
✓ OTC: token not found in the selected offer (71ms)
✓ OTC: this is not a smart trade (245ms)
✓ OTC: not enough amount in the offer (181ms)
shouldBehaveLikeBuying
✓ Buy 100000000000000000000 token_user_token with 270000000 token_custom_oracle (792ms)
✓ Estimate Buying Price 100000000000000000000 token_user_token with 270000000 token_custom_oracle
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (147ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (62ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (119ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (280ms)
arrays
✓ check arrays (64ms)
others
✓ check multiple buys successful (601ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (122ms)
✓ OTC: not enough amount in the offer (47ms)
shouldBehaveLikeBuying
✓ Buy 1000000 token_custom_oracle with 300000000000000000 token_user_token (265ms)
✓ Estimate Buying Price 1000000 token_custom_oracle with 300000000000000000 token_user_token
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (65ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (85ms)
after expiration time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (205ms)
during time, three times
✓ should fail to withdraw other than buyer (43ms)
✓ should succeed to withdraw the buyer (240ms)
arrays
✓ check arrays (55ms)
others
✓ check multiple buys successful (442ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (191ms)
✓ OTC: not enough amount in the offer (119ms)
shouldBehaveLikeBuying
✓ Buy 5000000 token_custom_oracle with 1500000000000000000 token_user_token (141ms)
✓ Estimate Buying Price 5000000 token_custom_oracle with 1500000000000000000 token_user_token
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (106ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (120ms)
after expiration time
✓ should fail to withdraw other than buyer (66ms)
✓ should succeed to withdraw the buyer (77ms)
during time, three times
✓ should fail to withdraw other than buyer (47ms)
✓ should succeed to withdraw the buyer (378ms)
arrays
✓ check arrays (72ms)
others
✓ check multiple buys successful (430ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (76ms)
✓ OTC: not enough amount in the offer (61ms)
shouldBehaveLikeBuying
✓ Buy 100000000 token_custom_oracle with 30000000000000000000 token_user_token (322ms)
✓ Estimate Buying Price 100000000 token_custom_oracle with 30000000000000000000 token_user_token
withdraw
query getPurchasedWithdrawableTokens
✓ at the moment of buying, should be 0
✓ before expiring
✓ at expiring
✓ after expiring
getPurchasedTokens
during time
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (54ms)
at expiring
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (93ms)
after expiration time
✓ should fail to withdraw other than buyer (46ms)
✓ should succeed to withdraw the buyer (231ms)
during time, three times
✓ should fail to withdraw other than buyer
✓ should succeed to withdraw the buyer (263ms)
arrays
✓ check arrays (56ms)
others
✓ check multiple buys successful (403ms)
exceptions
✓ OTC: token not found in the selected offer
✓ OTC: this is not a smart trade (111ms)
✓ OTC: not enough amount in the offer (85ms)
892 passing (29m)
> hardhat test "test/stake/test-eve-otc.js"
Contract: EVE OTC
Basic data
✓ commission (62ms)
✓ modify value (46ms)
✓ Verify permission for modify with a non-admin user (69ms)
3 passing (2s)
> hardhat test "test/stake/test-eve-otc-emergency.js"
Contract: EVE OTC / Emergency Functions
Pausing the contract
✓ Only owner can pause the contract (93ms)
When commissions are greater than 1
shouldBehaveLikeBuyAndSell
Sellers
✓ Should not add offers if paused (192ms)
✓ Should not buy offers if paused (345ms)
✓ Emergency withdraw (130ms)
✓ Only owner can do an emergency withdraw (136ms)
Buyers
Should not cancel trades if paused
✓ Should not withdraw funds if paused (151ms)
When commissions are lower than 1
shouldBehaveLikeBuyAndSell
Sellers
✓ Should not add offers if paused (188ms)
✓ Should not buy offers if paused (253ms)
✓ Emergency withdraw (98ms)
✓ Only owner can do an emergency withdraw (91ms)
Buyers
Should not cancel trades if paused
✓ Should not withdraw funds if paused (109ms)
11 passing (16s)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment