@triadxyz/triad-protocol 2.9.7-beta → 2.9.9-beta
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/utils/helpers.d.ts +0 -2
- package/dist/utils/helpers.js +3 -9
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -955,7 +955,7 @@ class TriadProtocolClient {
|
|
|
955
955
|
const maxSharesForPrice = remainingUSDC
|
|
956
956
|
.mul(new bn_js_1.default(Math.pow(10, this.decimals)))
|
|
957
957
|
.div(adjustedPrice);
|
|
958
|
-
const sharesToBuy = bn_js_1.default.min(
|
|
958
|
+
const sharesToBuy = bn_js_1.default.min(maxSharesForPrice, availableShares);
|
|
959
959
|
if (sharesToBuy.lte(new bn_js_1.default(0)))
|
|
960
960
|
continue;
|
|
961
961
|
const usdcAmount = sharesToBuy
|
package/dist/types/index.d.ts
CHANGED
package/dist/utils/helpers.d.ts
CHANGED
|
@@ -3,7 +3,6 @@ import { IdlAccounts } from '@coral-xyz/anchor';
|
|
|
3
3
|
import { Stake, StakeVault, Unstake } from './../types/stake';
|
|
4
4
|
import { Market, Order, OrderDirection, OrderSide, OrderStatus, OrderType, UserTrade, Pool, BookOrder, Refer, Customer } from '../types';
|
|
5
5
|
import { TriadProtocol } from '../types/triad_protocol';
|
|
6
|
-
import { BN } from '@coral-xyz/anchor';
|
|
7
6
|
export declare const encodeString: (value: string, alloc?: number) => number[];
|
|
8
7
|
export declare const decodeString: (bytes: number[]) => string;
|
|
9
8
|
export declare const formatStakeVault: (stakeVault: IdlAccounts<TriadProtocol>['stakeVault']) => StakeVault;
|
|
@@ -48,4 +47,3 @@ export declare const getOrderStatus: (status: {
|
|
|
48
47
|
}) => OrderStatus;
|
|
49
48
|
export declare const formatRefer: (account: IdlAccounts<TriadProtocol>['refer']) => Refer;
|
|
50
49
|
export declare const formatCustomer: (account: IdlAccounts<TriadProtocol>['customer'], publicKey: PublicKey) => Customer;
|
|
51
|
-
export declare const roundUp: (value: BN) => BN;
|
package/dist/utils/helpers.js
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.
|
|
3
|
+
exports.formatCustomer = exports.formatRefer = exports.getOrderStatus = exports.getOrderSide = exports.getOrderType = exports.getOrderSideFromNumber = exports.getOrderDirectionFromNumber = exports.getOrderDirection = exports.getTokenProgram = exports.calculateStakeRewards = exports.formatBookOrder = exports.formatOrder = exports.formatUserTrade = exports.formatMarket = exports.formatPool = exports.formatUnstake = exports.formatStake = exports.formatStakeVault = exports.decodeString = exports.encodeString = void 0;
|
|
4
4
|
const web3_js_1 = require("@solana/web3.js");
|
|
5
5
|
const spl_token_1 = require("@solana/spl-token");
|
|
6
6
|
const types_1 = require("../types");
|
|
7
7
|
const constants_1 = require("./constants");
|
|
8
|
-
const anchor_1 = require("@coral-xyz/anchor");
|
|
9
8
|
const encodeString = (value, alloc = 32) => {
|
|
10
9
|
const buffer = Buffer.alloc(alloc, 32);
|
|
11
10
|
buffer.write(value);
|
|
@@ -130,7 +129,8 @@ const formatOrder = (order, authority) => {
|
|
|
130
129
|
orderSide: (0, exports.getOrderSide)(order.orderSide),
|
|
131
130
|
price: order.price.toString(),
|
|
132
131
|
totalShares: order.totalShares.toString(),
|
|
133
|
-
filledShares: order.filledShares ? order.filledShares.toString() : ''
|
|
132
|
+
filledShares: order.filledShares ? order.filledShares.toString() : '',
|
|
133
|
+
isTrdPayout: order.isTrdPayout
|
|
134
134
|
};
|
|
135
135
|
};
|
|
136
136
|
exports.formatOrder = formatOrder;
|
|
@@ -249,9 +249,3 @@ const formatCustomer = (account, publicKey) => {
|
|
|
249
249
|
};
|
|
250
250
|
};
|
|
251
251
|
exports.formatCustomer = formatCustomer;
|
|
252
|
-
const roundUp = (value) => {
|
|
253
|
-
let decimal = value.toNumber() / 1000000;
|
|
254
|
-
let rounded = Math.round(decimal * 100) / 100;
|
|
255
|
-
return new anchor_1.BN(rounded * 1000000);
|
|
256
|
-
};
|
|
257
|
-
exports.roundUp = roundUp;
|