You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Now, as there is a CoW Python client, we should be able to use it for auto-deposit/withdraw.
Currently, it works by using native contract methods. Each agent starts with N xDai in his wallet and then:
If it's betting on wxDai market, it uses wxDai contract's deposit function to get them.
If it's betting on the sDai market, it first needs to get some wxDai as in (1) and then use sDai contract's deposit function to further convert wxDai into sDai.
After the market is closed, agent keeps the funds in wxDai (so on wxDai markets, it will do nothing, on sDai markets, it will withdraw sDai into wxDai).
This logic is fine as far as there are only wxDai and sDai markets, but fails on other tokens (as xDai can not be just deposited into wETH for example).
To fix it, we could just use CoW swap.
Agent would keep all his funds in xDai, and when betting on some market, it will use CoW to get that market's tokens. After the market is closed, it can use CoW again to convert it back to xDai.
This way, we can support any collateral token if it's available on CoW.
Good property of this is that we can keep the bet amount-logic in xDai. E.g. we can decide how many xDai we want to bet, then CoW will get us an equivalent amount of the other token, and then we can just bet it.
This should simplify auto_deposit and auto_withdraw functions a lot.
One thing to keep in mind is that we should have some token whitelist to prevent attackers stealing of agent's funds by creating markets in fake tokens, and then forcing the agents to buy them with a real-valued xDai.
The text was updated successfully, but these errors were encountered:
Now, as there is a CoW Python client, we should be able to use it for auto-deposit/withdraw.
Currently, it works by using native contract methods. Each agent starts with N xDai in his wallet and then:
After the market is closed, agent keeps the funds in wxDai (so on wxDai markets, it will do nothing, on sDai markets, it will withdraw sDai into wxDai).
This logic is fine as far as there are only wxDai and sDai markets, but fails on other tokens (as xDai can not be just deposited into wETH for example).
To fix it, we could just use CoW swap.
Agent would keep all his funds in xDai, and when betting on some market, it will use CoW to get that market's tokens. After the market is closed, it can use CoW again to convert it back to xDai.
This way, we can support any collateral token if it's available on CoW.
Good property of this is that we can keep the
bet amount
-logic in xDai. E.g. we can decide how many xDai we want to bet, then CoW will get us an equivalent amount of the other token, and then we can just bet it.This should simplify auto_deposit and auto_withdraw functions a lot.
One thing to keep in mind is that we should have some
token whitelist
to prevent attackers stealing of agent's funds by creating markets in fake tokens, and then forcing the agents to buy them with a real-valued xDai.The text was updated successfully, but these errors were encountered: