Skip to content

Commit

Permalink
Preview mode
Browse files Browse the repository at this point in the history
  • Loading branch information
mfrager committed Nov 29, 2022
1 parent 6ed41ac commit 1c412bc
Show file tree
Hide file tree
Showing 4 changed files with 791 additions and 684 deletions.
12 changes: 6 additions & 6 deletions js/spl/market_wsol_usdc_1.json
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
{
"tokenMint1": "So11111111111111111111111111111111111111112",
"tokenMint2": "Gh9ZwEmdLJ8DscKNTkTqPbNwLNNBjuSzaG9Vp2KGtKJr",
"market": "9qA4dPEaihjXivkfUb5CiaUeWy74vFVedCoxvh8AJqib",
"marketState": "2n4guTpVBkPhibymVjTx6zKT2NXPhU8JmNw1y1qu5tYp",
"orders": "2A9GA1U9Q2As2vyZFiAFfpSfKkZcmaWvQvGafQ3rVfhH",
"tradeLog": "3kmirxuGAGhK8MMcLRZ7HhEAy4oXqQASo3YKDqEpVbVE",
"settle1": "9HS2nxEcJNZca12dMTywH6cyq5Nybq3j7UyjvyKB16ox",
"settle2": "A1SXFVuCESwsdnX74fiGHkLQDqqbdvzXaAedeFfsBADW"
"market": "AvDmSSw9TBVoUXsdCzFXrZiq5jHyzZwjyesZiHZ3f1jq",
"marketState": "FjuPSYFgeC7Sm48qoTxqYCjvkzaxPSWmPTPaNcZ1xYjF",
"orders": "2aMjGshThEsC4bHvGYo2MsJ52yUnuVuhJD7bhhUUiste",
"tradeLog": "BSeqWAByPuGJ6xekv623uZNwowovuxmLRg9AxB3g1nS1",
"settle1": "BVL7ZWuGBsNXQuuPC7aj8PjRyoCyZMd4atj5957KNJ6b",
"settle2": "47WaF5bdstQAaL2tc7GP8qiUJvPh3z9LY8oKuExDko1u"
}
8 changes: 5 additions & 3 deletions js/spl/orders1.js
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ async function readMarketSpec() {
withdrawResultRent = await provider.connection.getMinimumBalanceForRentExemption(withdrawResultBytes)
}

async function limitOrder(orderType, user, result, qty, price) {
async function limitOrder(orderType, user, result, qty, price, preview) {
var userToken1 = await associatedTokenAddress(user.publicKey, tokenMint1)
var userToken2 = await associatedTokenAddress(user.publicKey, tokenMint2)
var mktState = await aquadex.account.marketState.fetch(marketStatePK)
Expand Down Expand Up @@ -186,6 +186,7 @@ async function limitOrder(orderType, user, result, qty, price) {
true,
false,
new anchor.BN(0), // Order expiry
preview, // Preview
rollover, // Rollover settlement log
params,
))
Expand All @@ -196,6 +197,7 @@ async function limitOrder(orderType, user, result, qty, price) {
true,
false,
new anchor.BN(0), // Order expiry
preview, // Preview
rollover, // Rollover settlement log
params,
))
Expand Down Expand Up @@ -234,8 +236,8 @@ async function main() {
var userWallet = importSecretKey(user.secret)
var userToken1 = await associatedTokenAddress(userWallet.publicKey, tokenMint1)
var userToken2 = await associatedTokenAddress(userWallet.publicKey, tokenMint2)
//console.log(await limitOrder('bid', userWallet, resultData1, 1 * (10**9), 15 * (10**6)))
console.log(await limitOrder('ask', userWallet, resultData1, 1 * (10**9), 15 * (10**6)))
//console.log(await limitOrder('bid', userWallet, resultData1, 1 * (10**9), 15 * (10**6) false))
console.log(await limitOrder('ask', userWallet, resultData1, 1 * (10**9), 7 * (10**6), true))
var res = await aquadex.account.tradeResult.fetch(resultData1.publicKey)
console.log(formatOrder(res))

Expand Down
9 changes: 5 additions & 4 deletions js/spl/spl_orders1.js
Original file line number Diff line number Diff line change
Expand Up @@ -181,13 +181,14 @@ async function main() {
var order1

if (true) {
console.log('Limit Ask 1')
console.log(await aquadex.rpc.limitAsk(
console.log('Limit Bid 1')
console.log(await aquadex.rpc.limitBid(
new anchor.BN(1 * (10**9)), // Quantity
new anchor.BN(7.82 * (10**6)), // Price
true, // Post
false, // Fill
new anchor.BN(0), // Order expiry
false, // Preview mode
false, // Settlement Log Rollover
{
accounts: {
Expand Down Expand Up @@ -216,10 +217,10 @@ async function main() {

if (false) {
console.log('Cancel Order 1')
var orderId = decodeOrderId('00000000vwap00000000000008')
var orderId = decodeOrderId('00000000ex9e1zzzzzzzzzzzzw')
//var orderId = order1
console.log(await aquadex.rpc.cancelOrder(
1, // 0 - Bid, 1 - Ask
0, // 0 - Bid, 1 - Ask
orderId,
{
accounts: {
Expand Down
Loading

0 comments on commit 1c412bc

Please sign in to comment.