Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/CNGNManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,15 @@ public JSONObject updateExternalAccounts(UpdateExternalAccountParams updateExter
return ServiceController.makeCalls(UPDATE_EXTERNAL_ACCOUNTS, secrets, updateExternalAccountParams.toJson());
}

public JSONObject getSwapQuote(SwapQuoteParams swapQuoteParams) {
JSONObject payload = new JSONObject();
payload.put("amount", swapQuoteParams.getAmount());
payload.put("destinationAddress", swapQuoteParams.getDestinationAddress());
payload.put("originNetwork", swapQuoteParams.getOriginNetwork().toString().toLowerCase());
payload.put("destinationNetwork", swapQuoteParams.getDestinationNetwork().toString().toLowerCase());
return ServiceController.makeCalls(SWAP_QUOTE, secrets, payload);
}


public static void main(String[] args) {
System.out.println("----------------------BEGIN TEST-------------------------");
Expand Down Expand Up @@ -102,6 +111,16 @@ public static void main(String[] args) {
System.out.println("Swap : " + cngnManager.swap(swapParams));


System.out.println("----------------------SWAP QUOTE-------------------------");
SwapQuoteParams swapQuoteParams = new SwapQuoteParams(
2500,
"0x3d8e2.........................",
Network.BSC,
Network.ETH
);
System.out.println("Swap Quote : " + cngnManager.getSwapQuote(swapQuoteParams));


System.out.println("----------------------CREATE VIRTUAL ACCOUNT-------------------------");
CreateVirtualParams mintParams = new CreateVirtualParams(
"korapay",
Expand Down
52 changes: 52 additions & 0 deletions src/dao/params/SwapQuoteParams.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
package dao.params;

import util.Network;

public class SwapQuoteParams {
private double amount;
private String destinationAddress;
private Network originNetwork;
private Network destinationNetwork;

public SwapQuoteParams(double amount, String destinationAddress, Network originNetwork, Network destinationNetwork) {
this.amount = amount;
this.destinationAddress = destinationAddress;
this.originNetwork = originNetwork;
this.destinationNetwork = destinationNetwork;
}

public SwapQuoteParams() {
}

public double getAmount() {
return amount;
}

public void setAmount(double amount) {
this.amount = amount;
}

public String getDestinationAddress() {
return destinationAddress;
}

public void setDestinationAddress(String destinationAddress) {
this.destinationAddress = destinationAddress;
}

public Network getOriginNetwork() {
return originNetwork;
}

public void setOriginNetwork(Network originNetwork) {
this.originNetwork = originNetwork;
}

public Network getDestinationNetwork() {
return destinationNetwork;
}

public void setDestinationNetwork(Network destinationNetwork) {
this.destinationNetwork = destinationNetwork;
}
}
1 change: 1 addition & 0 deletions src/util/Constants.java
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ public class Constants {
public static String GET_BANKS = BASE_URL+"/banks";
public static String WITHDRAW = BASE_URL+"/withdraw";
public static String VERIFY_WITHDRAWAL = WITHDRAW+"/verify/";
public static String SWAP_QUOTE = BASE_URL+"/swap-quote";

}
Binary file modified target/cngn-java-library-1.0.4.jar
Binary file not shown.