Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/fillableBalance filter #167

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
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
4 changes: 4 additions & 0 deletions src/methods/limitOrders/approveForOrder.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@ export type ApproveTokenForLimitOrderFunctions<T> = {
/** @description approving AugustusRFQ as spender for makerAsset */
approveMakerTokenForLimitOrder: ApproveToken<T>;
/** @description approving AugustusSwapper as spender for takerAsset for Limit Orders that will be executed through it */
/** @deprecated for OTC Orders approve directly the contract that the Order will be filled through:
* AugustusSwapper for old P2P orders;
* AugustusRFQ for new P2P orders
*/
approveTakerTokenForLimitOrder: ApproveToken<T>;
};

Expand Down
10 changes: 9 additions & 1 deletion src/methods/limitOrders/getOrders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export type LimitOrdersUserParams = (
export type GetRequiredAllowanceParams = {
maker: Address;
token?: Address;
filter?: { taker?: Address; notTaker?: Address; type?: LimitOrderType };
};

type GetLimitOrderByHash = (
Expand All @@ -57,6 +58,7 @@ export type GetLimitOrdersFunctions = {
* @param userParams - parameters to get allowance for active orders
* @param {string} userParams.maker - user to get required allowances for
* @param {string=} userParams.token - if given `token`, the mapping will contain that token address only
* @param {{taker?:Address;notTaker?:Address;type?:LimitOrderType}=} userParams.filter - extra filter to get balance required for type=P2P or type=LIMIT orders separately
* @param {AbortSignal=} signal - AbortSignal passed to fetcher
* @returns `{Lowercase<Address> => wei number as string}` mapping of token to fillableBalance
*/
Expand Down Expand Up @@ -103,10 +105,16 @@ export const constructGetLimitOrders = ({
const getRequiredBalance: GetRequiredBalance = async (userParams, signal) => {
const baseFetchURL = getBaseFetchURLByEntityType('fillablebalance');
const userURL = `${baseFetchURL}/${userParams.maker}` as const;
const fetchURL = userParams.token
let routeURL = userParams.token
? (`${userURL}/${userParams.token}` as const)
: userURL;

const search = constructSearchString<
NonNullable<GetRequiredAllowanceParams['filter']>
>(userParams.filter || {});

const fetchURL = `${routeURL}${search}` as const;

const response = await fetcher<
Record<string, string>,
GetRequiredBalanceURL
Expand Down
11 changes: 3 additions & 8 deletions src/methods/limitOrders/helpers/buildOrderData.ts
Original file line number Diff line number Diff line change
Expand Up @@ -90,14 +90,9 @@ export function buildOrderData({
taker = ZERO_ADDRESS;
} else {
// otherwise for p2p order ->
if (AppVersion === '6.1') {
// limit taker to EOA for v6 version (no Arbitrary Token Swaps + OTC Fill, or OTC Fill through AugustusSwapper)
taker = takerInNonce;
} else {
// on v5
// -> fill through Augustus only
taker = AugustusAddress;
}
// all new P2P Orders only fillable directly by EOA taker
// not through Augustus, this also disables BUY+FILL Order flow
taker = takerInNonce;
}

const order: OrderData = {
Expand Down
Loading