This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
version: '2' | |
services: | |
db: | |
image: mariadb | |
restart: always | |
volumes: | |
- c:/Users/talfc/DockerVolumes/nextcloud/mysql:/var/lib/mysql | |
environment: | |
- MYSQL_ROOT_PASSWORD=gugus |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public void run1(String endPoint) { | |
WsProvider wsProvider = new WsProvider(endPoint); | |
Promise<ApiPromise> ready = ApiPromise.create(wsProvider); | |
IRpcFunction.Unsubscribe<Promise> unsubscribeHandler = null; | |
ready.then( (ApiPromise api) -> { | |
Promise<IRpcFunction.Unsubscribe<Promise>> invoke = api.rpc().chain().function("subscribeNewHead").invoke( | |
(IRpcFunction.SubscribeCallback<Header>) (Header header) -> | |
{ | |
System.out.println("Chain is at block: " + header.getBlockNumber()+" trigger "+count); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void token2token(String tokenSymbolFrom, String tokenSymbolTo, String tokenQuantity) { | |
//Suppose we want to convert 100 BAT to DAI tokens, which is a token to token conversion. | |
// Note that ETH is used as the base pair i.e. BAT -> ETH -> DAI. | |
Kyber3j kyber3j = Kyber3j.build(new KyberService(KyberService.KYBER_ROPSTEN)); | |
log.info("Connected to Kyber Network: "+KyberService.KYBER_ROPSTEN); | |
try { | |
Currencies currencies = kyber3j.currencies().send(); | |
if (!checkForError(currencies) && currencies.existsCurreny(tokenSymbolFrom) | |
&& currencies.existsCurreny(tokenSymbolTo) ) { | |
EnabledTokensForWallet tokens = kyber3j.enabledTokensForWallet(credentials.getAddress()).send(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void token2eth(String tokenSymbol, String tokenQuantity){ | |
Kyber3j kyber3j = Kyber3j.build(new KyberService(KyberService.KYBER_ROPSTEN)); | |
log.info("Connected to Kyber Network: "+KyberService.KYBER_ROPSTEN); | |
try { | |
// Check if token is supported | |
Currencies currencies = kyber3j.currencies().send(); | |
if (!checkForError(currencies) && currencies.existsCurreny(tokenSymbol)) { | |
EnabledTokensForWallet tokens = kyber3j.enabledTokensForWallet(credentials.getAddress()).send(); | |
if (!checkForError(tokens)){ | |
// Check if wallet is enabled for token |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void eth2token(String tokenSymbol, String tokenQuantity) { | |
Kyber3j kyber3j = Kyber3j.build(new KyberService(KyberService.KYBER_ROPSTEN)); | |
log.info("Connected to Kyber Network: "+KyberService.KYBER_ROPSTEN); | |
// ETH2<Token> Swap | |
try { | |
// Check if token is supported | |
Currencies currencies = kyber3j.currencies().send(); | |
log.info("Exists Currency"+tokenSymbol+": " + currencies.existsCurreny(tokenSymbol)); | |
if (!checkForError(currencies) && currencies.existsCurreny(tokenSymbol)) { | |
// Get buy rates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package net.cloudburo.kyber.tutorial.protocol; | |
import net.cloudburo.kyber.tutorial.methods.request.GasPriceRange; | |
import net.cloudburo.kyber.tutorial.methods.request.SingleRate; | |
import net.cloudburo.kyber.tutorial.methods.response.*; | |
import org.web3j.protocol.core.Request; | |
import java.math.BigInteger; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public static void main(String[] args) throws Exception { | |
Application app = new Application(); | |
log.info(">>> SCENARIO: ETH2TOKEN"); | |
Thread.sleep(3000); | |
app.eth2token("DAI","2"); | |
log.info(">>> SCENARIO: TOKEN2ETH"); | |
Thread.sleep(3000); | |
app.token2eth("DAI","1"); | |
log.info(">>> SCENARIO: TOKEN2TOKEN"); | |
Thread.sleep(3000); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void token2eth(String tokenSymbol, String tokenQuantity){ | |
Kyber3j kyber3j = Kyber3j.build(new KyberService(KyberService.KYBER_ROPSTEN)); | |
log.info("Connected to Kyber Network: "+KyberService.KYBER_ROPSTEN); | |
try { | |
// Check if token is supported | |
Currencies currencies = kyber3j.currencies().send(); | |
if (!checkForError(currencies) && currencies.existsCurreny(tokenSymbol)) { | |
EnabledTokensForWallet tokens = kyber3j.enabledTokensForWallet(credentials.getAddress()).send(); | |
// Check if wallet is enabled for token | |
String tokenId = currencies.getCurrency(tokenSymbol).getId(); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
private void eth2knc() { | |
Kyber3j kyber3j = Kyber3j.build(new KyberService(KyberService.KYBER_ROPSTEN)); | |
log.info("Connected to Kyber Network: "+KyberService.KYBER_ROPSTEN); | |
// Buy KNC from ETH | |
try { | |
// Check if token is supported | |
Currencies currencies = kyber3j.currencies().send(); | |
log.info("Exists Currency KNC: " + currencies.existsCurreny("KNC")); | |
if (!checkForError(currencies) && currencies.existsCurreny("KNC")) { | |
// Get buy rates |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@SpringBootApplication | |
public class DemoApplication { | |
Logger logger = LoggerFactory.getLogger(DemoApplication.class); | |
public static void main(String[] args) { | |
SpringApplication.run(DemoApplication.class, args); | |
} | |
@Bean |