@triadxyz/triad-protocol 2.9.8-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 +6 -6
- 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
|
@@ -896,11 +896,11 @@ class TriadProtocolClient {
|
|
|
896
896
|
let adjustedPrice = orderPrice;
|
|
897
897
|
if (feeBps > 0) {
|
|
898
898
|
const priceSpread = new bn_js_1.default(1000000).sub(orderPrice);
|
|
899
|
-
const fee =
|
|
899
|
+
const fee = priceSpread
|
|
900
900
|
.mul(orderPrice)
|
|
901
901
|
.mul(new bn_js_1.default(feeBps))
|
|
902
902
|
.div(new bn_js_1.default(10000))
|
|
903
|
-
.div(new bn_js_1.default(1000000))
|
|
903
|
+
.div(new bn_js_1.default(1000000));
|
|
904
904
|
adjustedPrice = orderPrice.add(fee);
|
|
905
905
|
}
|
|
906
906
|
const maxSharesForPrice = tempRemainingUSDC
|
|
@@ -945,11 +945,11 @@ class TriadProtocolClient {
|
|
|
945
945
|
let adjustedPrice = orderPrice;
|
|
946
946
|
if (feeBps > 0) {
|
|
947
947
|
const priceSpread = new bn_js_1.default(1000000).sub(orderPrice);
|
|
948
|
-
const fee =
|
|
948
|
+
const fee = priceSpread
|
|
949
949
|
.mul(orderPrice)
|
|
950
950
|
.mul(new bn_js_1.default(feeBps))
|
|
951
951
|
.div(new bn_js_1.default(10000))
|
|
952
|
-
.div(new bn_js_1.default(1000000))
|
|
952
|
+
.div(new bn_js_1.default(1000000));
|
|
953
953
|
adjustedPrice = orderPrice.add(fee);
|
|
954
954
|
}
|
|
955
955
|
const maxSharesForPrice = remainingUSDC
|
|
@@ -1033,11 +1033,11 @@ class TriadProtocolClient {
|
|
|
1033
1033
|
let adjustedPrice = orderPrice;
|
|
1034
1034
|
if (feeBps > 0) {
|
|
1035
1035
|
const priceSpread = new bn_js_1.default(1000000).sub(orderPrice);
|
|
1036
|
-
const fee =
|
|
1036
|
+
const fee = priceSpread
|
|
1037
1037
|
.mul(orderPrice)
|
|
1038
1038
|
.mul(new bn_js_1.default(feeBps))
|
|
1039
1039
|
.div(new bn_js_1.default(10000))
|
|
1040
|
-
.div(new bn_js_1.default(1000000))
|
|
1040
|
+
.div(new bn_js_1.default(1000000));
|
|
1041
1041
|
adjustedPrice = orderPrice.sub(fee);
|
|
1042
1042
|
}
|
|
1043
1043
|
amountOfUSDC = amountOfUSDC.add(sharesToSell.mul(adjustedPrice).div(new bn_js_1.default(Math.pow(10, this.decimals))));
|
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.ceil(decimal * 100) / 100;
|
|
255
|
-
return new anchor_1.BN(rounded * 1000000);
|
|
256
|
-
};
|
|
257
|
-
exports.roundUp = roundUp;
|