New:Socket for Asana Is Now Available.Learn more
Get Started

@pear-protocol/utils

Package Overview
Dependencies
Maintainers
4
Versions
37
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@pear-protocol/utils - npm Package Compare versions

Comparing version
0.5.3
to
0.6.0
+18
dist/basket/max-size.d.ts
import type { MaxBasketSizeCalculation, MaxBasketSizeInput, MaxBasketSizeResult, SinglePoolSizingContext } from './basket.types';
/**
* The largest gross notional this basket can reach while every leg stays funded at its weight.
*
* Takes the caller's figures as given — a malformed budget or leverage is the caller's own
* responsibility to keep clean (enforce it with a schema at the boundary if that matters to you),
* not something this function guards against.
*/
export declare function computeMaxBasketSize(input: MaxBasketSizeCalculation): MaxBasketSizeResult;
/**
* Sizes a basket that funds every leg out of one account-wide balance and caps leverage at nothing
* but the caller-supplied max: `effectiveLeverage = min(requested, catalogMax)`.
*
* A leg naming an asset the caller's catalog does not list leaves its ceiling unknown, and sizing
* against the request alone would overstate the basket — so one unknown leg (or no available
* balance at all) reports no size rather than a wrong one.
*/
export declare function sizeSinglePoolBasket(input: MaxBasketSizeInput, context: SinglePoolSizingContext): MaxBasketSizeResult;
+51
-1

@@ -1,2 +0,2 @@

import type { InstrumentId, Side } from '@pear-protocol/types';
import type { HttpTypes, InstrumentId, Side } from '@pear-protocol/types';
export type BasketLeg = {

@@ -7,1 +7,51 @@ symbol: InstrumentId;

};
/**
* Mirrors the shipped basket model (`BasketItem` in the frontend): unsigned `weight`
* with `side` alongside, weights summing to 100. Sizing ignores `side` — margin
* requirement does not depend on direction — and normalises by Σweight.
*/
export type MaxBasketSizeLeg = {
asset: InstrumentId;
side: Side;
/** Unsigned percentage. The set sums to 100. */
weight: number;
};
export type MaxBasketSizeInput = {
legs: MaxBasketSizeLeg[];
/** What the caller is requesting for the whole basket, before each leg's own venue max caps it. */
requestedLeverage: number;
};
export type MaxBasketSizeResult = {
/**
* The whole basket's max GROSS notional in USD — Σ leg notional, not per-side and not per-asset.
* The basket is atomic, so this is one ceiling for the entire structure, not a per-leg maximum.
* Null when the caller could not supply an available balance, or a leg names an asset the
* caller's max-leverage map does not list.
*/
maxNotional: string | null;
/**
* The margin `maxNotional` spends — always the whole `budget`/`availableBalance` the caller
* supplied, since that is exactly the point at which the basket stops growing. Stated explicitly
* rather than left for the caller to infer, and `null` on the same terms as `maxNotional`.
*/
marginRequired: string | null;
};
/** One basket leg with its leverage already capped by the caller. */
export type CappedBasketLeg = {
/** Unsigned, in the caller's own scale — `computeMaxBasketSize` normalises by Σweight. */
weight: number;
effectiveLeverage: string;
};
/** The one margin budget every leg funds out of. */
export type MaxBasketSizeCalculation = {
/** USD-equivalent margin available. Every connector this sizes for funds a basket from one balance. */
budget: string;
legs: CappedBasketLeg[];
};
/** What `sizeSinglePoolBasket` needs beyond the legs: the account's balance and the leverage ceilings. */
export type SinglePoolSizingContext = {
/** The account's whole available margin, or `null` when the caller could not read one. */
availableBalance: string | null;
/** Off the core-sdk instrument catalog — only `id` and `leverage` are read. */
instruments: Pick<HttpTypes.Instrument, 'id' | 'leverage'>[];
};

@@ -0,2 +1,4 @@

export * from './basket.types';
export * from './compute';
export * from './derive-basket-key';
export * from './max-size';
+1
-1
{
"name": "@pear-protocol/utils",
"version": "0.5.3",
"version": "0.6.0",
"description": "Pear Protocol Utility functions",

@@ -5,0 +5,0 @@ "private": false,

Sorry, the diff of this file is too big to display