How does crypto exchange take a cut from trades? - cryptocurrency

Say I have ETH & other person has ZETH and we trade them.
My ETH is sent to his wallet & his ZETH is sent to my wallet. Who pays the 8$ ETH transfer fee & 2$ ZETH transfer fee? I mean in order to send eth to another wallet you pay a fee to miners. Also the exchange takes a cut. So it means 8$ is paid twice because my eth is sent to two wallets, to other person wallet & exchange cut fee is sent to exchange wallet. This makes no sense, exchange will be broke in no time if it pays the fees, how is it possible?
I want to understand the principle.

Crypto exchanges makes money 2 ways:
First one is of course by charging transaction fee for each of the transaction.
Second is giving you the exchange price, which makes profit for them as they take off-setting positions if you are buying crypto from them and not a brokered transactions.

Related

Data consumption while transmitting data to a cloud

considering that the car will connect to the database, how much data will be consumed each time to send to or receive from the could?
It depends on the protocol (HTTP, MQTT, ...), the average message size, the number of recorded properties, and the update rate. To be more specific, for example, consider the case that a car connects through MQTT protocol with 1000 B for its message size for each property (there could be numerous properties recorded in a connected car) where three times per minute a transaction between the car and the could happen.
Are there any relevant details for ObjectBox? where can I find them? is there any estimation about the data consumption?
I went through the details but could not find any table of properties or the protocol and message size.

How can I estimate gas fees before sending a transaction?

I would like to estimate the gas fees for a particular transaction on behalf of my users before sending it.
If I know the current going rate for gas on the Chainweb blockchain, and I know how many units of gas a transaction will consume, then I can multiply them together to provide an estimate of how much it will cost to send a particular transaction.
How do I get those two pieces of information?
First, how can I get the current going rate for gas on Chainweb?
Second, is there a rough way to estimate the number of units of gas a transaction will consume? For example, it costs 21,000 units of gas to transfer Ether from one address to another. How do I determine how many units of gas it will take to transfer KDA from one wallet to another? Or how many units of gas it will take to execute N steps of my contract?
For the going rate I am only certain how to get at the current minimum gas price. It is set in the default config of the Kadena node. Currently: 0.00000001. That has always allowed me to do transactions.
For estimating the gas amount you can use the Pact gas log functionality. Load your contract on a local pact executable and use a .repl file with tests to get a simulation of the gas units cost of the specific contract calls your will perform.
In your repl test script you enclose the contract calls you need to measure with
(env-gas 0)(env-gaslog)
to reset the gas log and start, and
(env-gaslog)
To display the gas units consumed since last reset.
Before you can start logging you need to set the gas model to table and a sufficiently high gas limit.
Assume you are working on the coin contract and you need to know how much units of gas the transaction will consume you can use a test as below:
(env-gasmodel "table")
(env-gaslimit 150000)
(load "fungible-v2.pact")
(load "coin.pact")
(env-gas 0) (env-gaslog)
(create-table coin.coin-table)
(env-gaslog)
If you want to run the above you need to copy the source code of the coin contract (coin.pact) and fungible-v2 standard (fungible-v2.pact) together in a folder with this repl. You can run the above:
$ pact -t test.repl
For full reference: https://pact-language.readthedocs.io/en/stable/pact-functions.html#env-gas

How to handle massive transaction on huge service(like amazon)?

Let's assume there is an item.
It is sold by 100 users every second.
Describe one cycle transaction.
Amazon checks its stock. (10ms)
If an available request to card company for payment. (50ms)
Update item's stock. (50ms)
110ms(I decided arbitrarily) was consumed on one purchase.
How to handle this on amazon?
Is there one database on large services?
Is there a queue?
Just curiosity, Short answers or keywords are fine. thank you.

How to handle cash advance travel expenses in database?

I'm implementing a software solution for a company. As part of its business processes they give cash advances to its employees when they get on a business trip, let's say 1000 dollars. Those 1000 dollars are withdrawn from one of the cash registers available and the transaction is registered to the database as an expense so at the end of their turns cashiers are able to justify the 1k missing.
Then, sometimes the employee who travels spends just part of the money he was given, let's say 500 on gas, 200 on hotel and 100 on meals, so 800 out of the 1000 he was given.
So here's the situation I'm dealing with: those three expenses (gas, hotel and meals) need also to be registered individually when the employee comes back from his trip for two reasons:
To store the expense under the right expense concept so we can then query the database and see how much the company spends on every concept.
To match the money given to the employee as cash advance for his travel expenses with his actual expenses. So a total of four transactions would be performed: three expenses and one income, the 200 the employee didn't used, to match the original 1K.
Up to this point everything is fine regarding the cash advance transaction: 1000 dollars were given and 1000 dollars where justified, 800 in expenses and 200 as the money back. The problem is, the original 1000K still exist as an expense, so the total balance would be -600: 1800 spent and 200 income, which is obviously not correct.
I've thought of two alternatives:
Subtract the travel expenses (800) from the original cash advance expense (1000). This way, the final balance is right (0). But that would mean modifying an old expense entry which in turn will affect that days cash closing if for some reason it needs to be consulted in the future. I'm not sure if this is actually a bad thing to do since the final balance will match the actual money, it just feels wrong to mess with an old entry that will no longer represent what actually happened that day.
Treat cash advances as a special entity, not as an actual expense. This new entity will have the following fields: withdrawn_money, money_back and spent_money. When calculating the cash closing for that day the outcomes would be the sum of expenses plus the sum of cash advances withdrawn_money thus leaving the cash closing intact. Later when the actual expenses are presented they will go directly to the expenses table but at the same time being registered as a cash_advance spent_money new entry. This way we can keep under control how much of the withdrawn money is returned and at the same time save the actual expenses under the right expense concepts for future querying.
Cash advances not being considered as actual expenses make sense to me since the money is in employees hands so technically is not an expense yet.
Alternative 2 sounds better to me but I'm still trying to find the most appropriate implementation. It would be of great help to get opinions of more experienced developers and database designers on subjects like this.
Thanks in advance for your time and I would gladly clarify anything if I wasn't clear enough.
If you are familiar with the double-entry accounting this situation looks like this:
there is a transaction from account 501 (which refers to the money in cash) using the currency as a reference/article to account 422 (which refers to the company staff) using the employee as a reference/article
when the employee comes back:
if he has paid with credit card only and has not used the cash - you make a reverse transaction (from account 422 to account 501)
otherwise for each receipt/invoice he brings back - you make a transaction from account 422 (using the employee as a reference/article) to account 609 (which is for other expenses - and then referencing the appropriate expense)
if the employee does not have a receipt/invoice for some of the money - it stays in account 422 and on the next salary payment you make a smaller transaction for his salary and compensate with a transaction from account 422 to account 604 (which is the payroll) to clear the remainder

How can we check whether sufficient amount is available in a customer's credit card in Authorize.Net?

I am Working in Authorize.Net, here I have to check the customer's credit card has sufficient amount before a transaction. Please help me.
Thanks in advance
Do a pre-authorization for the amount you need to charge. If it comes back approved the card has enough to cover the transaction. Just keep in mind that you'll be freezing those funds on that card so unless you release it immediately you will be causing harm to the user.
Pretty easy - set the transaction amount to the amount you need to clear.
Set the transaction-type to 'auth' - if you get an approval, they have the funds. Save the auth code in your database - you'll need it later when you capture the transaction to actually get the cash
Be sure to do a capture transaction later (like when you actually ship the order) to collect the cash on the auth you did earlier. You will need to furnish the transaction code and the auth code so they can map the capture back onto the earlier auth transaction and fund it for you.

Resources