curvance 4.0.0 → 4.0.2
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/abis/ProtocolReader.json +24 -0
- package/dist/chains/arb-sepolia.json +44 -0
- package/dist/chains/monad-mainnet.json +26 -1
- package/dist/classes/CToken.d.ts.map +1 -1
- package/dist/classes/CToken.js +5 -10
- package/dist/classes/CToken.js.map +1 -1
- package/dist/classes/DexAggregators/KuruMainnet.d.ts +1 -0
- package/dist/classes/DexAggregators/KuruMainnet.d.ts.map +1 -0
- package/dist/classes/DexAggregators/KuruMainnet.js +228 -0
- package/dist/classes/DexAggregators/KuruMainnet.js.map +1 -0
- package/dist/classes/Kuru.d.ts +59 -0
- package/dist/classes/Kuru.d.ts.map +1 -0
- package/dist/classes/Kuru.js +167 -0
- package/dist/classes/Kuru.js.map +1 -0
- package/dist/classes/KuruMainnet.d.ts +59 -0
- package/dist/classes/KuruMainnet.d.ts.map +1 -0
- package/dist/classes/KuruMainnet.js +167 -0
- package/dist/classes/KuruMainnet.js.map +1 -0
- package/dist/classes/ProtocolReader.d.ts +2 -0
- package/dist/classes/ProtocolReader.d.ts.map +1 -1
- package/dist/classes/ProtocolReader.js +3 -0
- package/dist/classes/ProtocolReader.js.map +1 -1
- package/dist/contracts/monad-mainnet.json +1 -1
- package/dist/snapshot.d.ts +53 -0
- package/dist/snapshot.d.ts.map +1 -0
- package/dist/snapshot.js +103 -0
- package/dist/snapshot.js.map +1 -0
- package/package.json +1 -1
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// import Decimal from "decimal.js";
|
|
3
|
+
// import { address, curvance_provider, TokenInput } from "../../types";
|
|
4
|
+
// import { ERC20 } from "../ERC20";
|
|
5
|
+
// import { toBigInt, toDecimal, validateProviderAsSigner, WAD } from "../../helpers";
|
|
6
|
+
// import { ZapToken } from "../CToken";
|
|
7
|
+
// import { Swap } from "../Zapper";
|
|
8
|
+
// interface KuruJWTResponse {
|
|
9
|
+
// token: string;
|
|
10
|
+
// expires_at: number;
|
|
11
|
+
// rate_limit: {
|
|
12
|
+
// rps: number;
|
|
13
|
+
// burst: number;
|
|
14
|
+
// }
|
|
15
|
+
// }
|
|
16
|
+
// interface KuruQuoteResponse {
|
|
17
|
+
// type: string;
|
|
18
|
+
// status: string;
|
|
19
|
+
// output: string;
|
|
20
|
+
// minOut: string;
|
|
21
|
+
// transaction: {
|
|
22
|
+
// calldata: string;
|
|
23
|
+
// value: string;
|
|
24
|
+
// to: string;
|
|
25
|
+
// };
|
|
26
|
+
// gasPrices: {
|
|
27
|
+
// slow: string;
|
|
28
|
+
// standard: string;
|
|
29
|
+
// fast: string;
|
|
30
|
+
// rapid: string;
|
|
31
|
+
// extreme: string;
|
|
32
|
+
// };
|
|
33
|
+
// }
|
|
34
|
+
// const cached_jwt = new Map<string, KuruJWTResponse>();
|
|
35
|
+
// const cached_requests = new Map<string, number[]>();
|
|
36
|
+
// export default class KuruMainnet {
|
|
37
|
+
// static api = "https://ws.kuru.io/api"
|
|
38
|
+
// static router = "0xb3e6778480b2E488385E8205eA05E20060B813cb" as address; // KuruFlowEntrypoint
|
|
39
|
+
// jwt: string | null = null;
|
|
40
|
+
// rps = 1;
|
|
41
|
+
// dao = "0x0Acb7eF4D8733C719d60e0992B489b629bc55C02" as address;
|
|
42
|
+
// async loadJWT(wallet: string) {
|
|
43
|
+
// if(cached_jwt.has(wallet)) {
|
|
44
|
+
// const cached = cached_jwt.get(wallet)!;
|
|
45
|
+
// const currentTime = KuruMainnet.getCurrentTime();
|
|
46
|
+
// if(cached.expires_at > currentTime) {
|
|
47
|
+
// this.jwt = cached.token;
|
|
48
|
+
// this.rps = cached.rate_limit.rps;
|
|
49
|
+
// return;
|
|
50
|
+
// } else {
|
|
51
|
+
// cached_jwt.delete(wallet);
|
|
52
|
+
// }
|
|
53
|
+
// }
|
|
54
|
+
// const resp = await fetch(`${KuruMainnet.api}/generate-token`, {
|
|
55
|
+
// method: "POST",
|
|
56
|
+
// headers: {
|
|
57
|
+
// "Content-Type": "application/json",
|
|
58
|
+
// },
|
|
59
|
+
// body: JSON.stringify({
|
|
60
|
+
// user_address: wallet,
|
|
61
|
+
// }),
|
|
62
|
+
// keepalive: true
|
|
63
|
+
// });
|
|
64
|
+
// if(!resp.ok) {
|
|
65
|
+
// throw new Error(`Failed to fetch JWT: ${resp.status} ${resp.statusText}`);
|
|
66
|
+
// }
|
|
67
|
+
// const data = await resp.json() as KuruJWTResponse;
|
|
68
|
+
// this.jwt = data.token;
|
|
69
|
+
// this.rps = data.rate_limit.rps;
|
|
70
|
+
// cached_jwt.set(wallet, data);
|
|
71
|
+
// }
|
|
72
|
+
// async rateLimitSleep(wallet: string) {
|
|
73
|
+
// const now = KuruMainnet.getCurrentTime();
|
|
74
|
+
// const requests = cached_requests.get(wallet) || [];
|
|
75
|
+
// const windowStart = now - 2;
|
|
76
|
+
// const recentRequests = requests.filter(timestamp => timestamp > windowStart);
|
|
77
|
+
// if(recentRequests.length >= this.rps) {
|
|
78
|
+
// const earliestRequest = Math.min(...recentRequests);
|
|
79
|
+
// const sleepTime = (earliestRequest + 2) - now;
|
|
80
|
+
// await new Promise(resolve => setTimeout(resolve, sleepTime * 2000));
|
|
81
|
+
// }
|
|
82
|
+
// }
|
|
83
|
+
// static async getAvailableTokens(provider: curvance_provider, query: string | null = null) {
|
|
84
|
+
// const signer = validateProviderAsSigner(provider);
|
|
85
|
+
// const userAddress = signer.address;
|
|
86
|
+
// let endpoint = `https://api.kuru.io/api/v2/tokens/search?limit=20&userAddress=${userAddress}`;
|
|
87
|
+
// if(query) {
|
|
88
|
+
// endpoint += `&q=${encodeURIComponent(query)}`;
|
|
89
|
+
// }
|
|
90
|
+
// const resp = await fetch(endpoint, {
|
|
91
|
+
// method: "GET",
|
|
92
|
+
// headers: {
|
|
93
|
+
// "Content-Type": "application/json",
|
|
94
|
+
// }
|
|
95
|
+
// });
|
|
96
|
+
// if(!resp.ok) {
|
|
97
|
+
// throw new Error(`Failed to fetch available tokens: ${resp.status} ${resp.statusText}`);
|
|
98
|
+
// }
|
|
99
|
+
// const list = await resp.json() as {
|
|
100
|
+
// success: boolean;
|
|
101
|
+
// code: number;
|
|
102
|
+
// timestamp: number;
|
|
103
|
+
// data: {
|
|
104
|
+
// data: Array<{
|
|
105
|
+
// address: string;
|
|
106
|
+
// decimals: number;
|
|
107
|
+
// name: string;
|
|
108
|
+
// ticker: string;
|
|
109
|
+
// imageurl: string,
|
|
110
|
+
// twitter: string,
|
|
111
|
+
// website: string,
|
|
112
|
+
// is_verified: boolean,
|
|
113
|
+
// contract_renounced: boolean,
|
|
114
|
+
// is_erc20: boolean,
|
|
115
|
+
// is_mintable: boolean,
|
|
116
|
+
// is_strict: boolean,
|
|
117
|
+
// balance: string,
|
|
118
|
+
// last_price: string,
|
|
119
|
+
// quote_asset: string,
|
|
120
|
+
// market_address: string,
|
|
121
|
+
// total_supply: string,
|
|
122
|
+
// burned_supply: string
|
|
123
|
+
// }>
|
|
124
|
+
// }
|
|
125
|
+
// };
|
|
126
|
+
// let tokens: ZapToken[] = [];
|
|
127
|
+
// for(const token of list.data.data) {
|
|
128
|
+
// const erc20 = new ERC20(
|
|
129
|
+
// provider,
|
|
130
|
+
// token.address as address,
|
|
131
|
+
// {
|
|
132
|
+
// address: token.address as address,
|
|
133
|
+
// name: token.name,
|
|
134
|
+
// symbol: token.ticker,
|
|
135
|
+
// decimals: BigInt(token.decimals ?? 18),
|
|
136
|
+
// totalSupply: BigInt(token.total_supply ?? 0),
|
|
137
|
+
// balance: BigInt(token.balance ?? 0),
|
|
138
|
+
// image: token.imageurl,
|
|
139
|
+
// price: Decimal(token.last_price).div(WAD)
|
|
140
|
+
// },
|
|
141
|
+
// );
|
|
142
|
+
// tokens.push({
|
|
143
|
+
// interface: erc20,
|
|
144
|
+
// type: 'simple',
|
|
145
|
+
// quote: async(tokenIn: string, tokenOut: string, amount: TokenInput, slippageTolerance: bigint | null = null) => {
|
|
146
|
+
// const raw_amount = toBigInt(amount, 18n);
|
|
147
|
+
// const data = await KuruMainnet.quote(signer.address, tokenIn, tokenOut, raw_amount.toString(), slippageTolerance);
|
|
148
|
+
// return {
|
|
149
|
+
// output: toDecimal(BigInt(data.output ?? 0), BigInt(token.decimals ?? 18)),
|
|
150
|
+
// minOut: toDecimal(BigInt(data.minOut ?? 0), BigInt(token.decimals ?? 18)),
|
|
151
|
+
// max_slippage: data.max_slippage
|
|
152
|
+
// };
|
|
153
|
+
// }
|
|
154
|
+
// });
|
|
155
|
+
// }
|
|
156
|
+
// return tokens;
|
|
157
|
+
// }
|
|
158
|
+
// // Get current time in seconds
|
|
159
|
+
// static getCurrentTime() {
|
|
160
|
+
// return Math.floor(Date.now() / 1000);
|
|
161
|
+
// }
|
|
162
|
+
// static async quoteAction(wallet: string, tokenIn: string, tokenOut: string, amount: string, slippageTolerance: bigint | null = null) {
|
|
163
|
+
// const quote = await KuruMainnet.quote(wallet, tokenIn, tokenOut, amount, slippageTolerance);
|
|
164
|
+
// const action = {
|
|
165
|
+
// inputToken: tokenIn,
|
|
166
|
+
// inputAmount: BigInt(amount),
|
|
167
|
+
// outputToken: tokenOut,
|
|
168
|
+
// target: quote.transaction.to,
|
|
169
|
+
// slippage: slippageTolerance ?? 0n,
|
|
170
|
+
// call: `0x${quote.transaction.calldata}`
|
|
171
|
+
// } as Swap;
|
|
172
|
+
// return { action, quote };
|
|
173
|
+
// }
|
|
174
|
+
// static async quoteMin(wallet: string, tokenIn: string, tokenOut: string, amount: string, slippageTolerance: bigint | null = null) {
|
|
175
|
+
// const quote = await KuruMainnet.quote(wallet, tokenIn, tokenOut, amount, slippageTolerance);
|
|
176
|
+
// return quote.minOut;
|
|
177
|
+
// }
|
|
178
|
+
// static async quote(wallet: string, tokenIn: string, tokenOut: string, amount: string, slippageTolerance: bigint | null = null) {
|
|
179
|
+
// const kuru = new this();
|
|
180
|
+
// await kuru.loadJWT(wallet);
|
|
181
|
+
// await kuru.rateLimitSleep(wallet);
|
|
182
|
+
// const payload: {
|
|
183
|
+
// userAddress: string;
|
|
184
|
+
// tokenIn: string;
|
|
185
|
+
// tokenOut: string;
|
|
186
|
+
// amount: string;
|
|
187
|
+
// referrerAddress?: string;
|
|
188
|
+
// referrerFeeBps?: number;
|
|
189
|
+
// slippage_tolerance?: number;
|
|
190
|
+
// autoSlippage?: boolean;
|
|
191
|
+
// } = {
|
|
192
|
+
// userAddress: wallet,
|
|
193
|
+
// tokenIn: tokenIn,
|
|
194
|
+
// tokenOut: tokenOut,
|
|
195
|
+
// amount: amount,
|
|
196
|
+
// referrerAddress: kuru.dao,
|
|
197
|
+
// referrerFeeBps: 10,
|
|
198
|
+
// };
|
|
199
|
+
// if(!slippageTolerance) {
|
|
200
|
+
// payload.autoSlippage = true;
|
|
201
|
+
// } else {
|
|
202
|
+
// payload.slippage_tolerance = Number(slippageTolerance);
|
|
203
|
+
// }
|
|
204
|
+
// cached_requests.set(wallet, (cached_requests.get(wallet) || []).concat(KuruMainnet.getCurrentTime()));
|
|
205
|
+
// const resp = await fetch(`${KuruMainnet.api}/quote`, {
|
|
206
|
+
// method: "POST",
|
|
207
|
+
// headers: {
|
|
208
|
+
// "Content-Type": "application/json",
|
|
209
|
+
// "Authorization": `Bearer ${kuru.jwt}`
|
|
210
|
+
// },
|
|
211
|
+
// body: JSON.stringify(payload),
|
|
212
|
+
// });
|
|
213
|
+
// if(!resp.ok) {
|
|
214
|
+
// throw new Error(`Failed to fetch quote: ${resp.status} ${resp.statusText}`);
|
|
215
|
+
// }
|
|
216
|
+
// const data = await resp.json() as KuruQuoteResponse;
|
|
217
|
+
// return {
|
|
218
|
+
// ...data,
|
|
219
|
+
// max_slippage: KuruMainnet.getSlippage(BigInt(data.output ?? 0), BigInt(data.minOut ?? 0))
|
|
220
|
+
// };
|
|
221
|
+
// }
|
|
222
|
+
// static getSlippage(output: bigint, min_output: bigint) {
|
|
223
|
+
// const diff = output - min_output;
|
|
224
|
+
// const decimal = Decimal(diff).div(output).mul(100);
|
|
225
|
+
// return decimal ?? Decimal(100);
|
|
226
|
+
// }
|
|
227
|
+
// }
|
|
228
|
+
//# sourceMappingURL=KuruMainnet.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KuruMainnet.js","sourceRoot":"","sources":["../../../src/classes/DexAggregators/KuruMainnet.ts"],"names":[],"mappings":";AAAA,oCAAoC;AACpC,wEAAwE;AACxE,oCAAoC;AACpC,sFAAsF;AACtF,wCAAwC;AACxC,oCAAoC;AAEpC,8BAA8B;AAC9B,qBAAqB;AACrB,0BAA0B;AAC1B,oBAAoB;AACpB,uBAAuB;AACvB,yBAAyB;AACzB,QAAQ;AACR,IAAI;AAEJ,gCAAgC;AAChC,oBAAoB;AACpB,sBAAsB;AACtB,sBAAsB;AACtB,sBAAsB;AACtB,qBAAqB;AACrB,4BAA4B;AAC5B,yBAAyB;AACzB,sBAAsB;AACtB,SAAS;AACT,mBAAmB;AACnB,wBAAwB;AACxB,4BAA4B;AAC5B,wBAAwB;AACxB,yBAAyB;AACzB,2BAA2B;AAC3B,SAAS;AACT,IAAI;AAEJ,yDAAyD;AACzD,uDAAuD;AAEvD,qCAAqC;AACrC,4CAA4C;AAC5C,qGAAqG;AACrG,iCAAiC;AACjC,eAAe;AACf,qEAAqE;AAErE,sCAAsC;AACtC,uCAAuC;AACvC,sDAAsD;AACtD,gEAAgE;AAEhE,oDAAoD;AACpD,2CAA2C;AAC3C,oDAAoD;AACpD,0BAA0B;AAC1B,uBAAuB;AACvB,6CAA6C;AAC7C,gBAAgB;AAChB,YAAY;AAEZ,0EAA0E;AAC1E,8BAA8B;AAC9B,yBAAyB;AACzB,sDAAsD;AACtD,iBAAiB;AACjB,qCAAqC;AACrC,wCAAwC;AACxC,kBAAkB;AAClB,8BAA8B;AAC9B,cAAc;AAEd,yBAAyB;AACzB,yFAAyF;AACzF,YAAY;AAEZ,6DAA6D;AAE7D,iCAAiC;AACjC,0CAA0C;AAC1C,w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,kBAAkB;AAClB,YAAY;AAEZ,yBAAyB;AACzB,QAAQ;AAER,qCAAqC;AACrC,gCAAgC;AAChC,gDAAgD;AAChD,QAAQ;AAER,6IAA6I;AAC7I,uGAAuG;AACvG,2BAA2B;AAC3B,mCAAmC;AACnC,2CAA2C;AAC3C,qCAAqC;AACrC,4CAA4C;AAC5C,iDAAiD;AACjD,sDAAsD;AACtD,qBAAqB;AAErB,oCAAoC;AACpC,QAAQ;AAER,0IAA0I;AAC1I,uGAAuG;AACvG,+BAA+B;AAC/B,QAAQ;AAER,uIAAuI;AACvI,mCAAmC;AACnC,sCAAsC;AACtC,6CAA6C;AAE7C,2BAA2B;AAC3B,mCAAmC;AACnC,+BAA+B;AAC/B,gCAAgC;AAChC,8BAA8B;AAC9B,wCAAwC;AACxC,uCAAuC;AACvC,2CAA2C;AAC3C,sCAAsC;AACtC,gBAAgB;AAChB,mCAAmC;AACnC,gCAAgC;AAChC,kCAAkC;AAClC,8BAA8B;AAC9B,yCAAyC;AACzC,kCAAkC;AAClC,aAAa;AAEb,mCAAmC;AACnC,2CAA2C;AAC3C,mBAAmB;AACnB,sEAAsE;AACtE,YAAY;AAEZ,iHAAiH;AACjH,iEAAiE;AACjE,8BAA8B;AAC9B,yBAAyB;AACzB,sDAAsD;AACtD,wDAAwD;AACxD,iBAAiB;AACjB,6CAA6C;AAC7C,cAAc;AAEd,yBAAyB;AACzB,2FAA2F;AAC3F,YAAY;AAEZ,+DAA+D;AAE/D,mBAAmB;AACnB,uBAAuB;AACvB,wGAAwG;AACxG,aAAa;AACb,QAAQ;AAER,+DAA+D;AAC/D,4CAA4C;AAC5C,8DAA8D;AAC9D,0CAA0C;AAC1C,QAAQ;AACR,IAAI"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Decimal from "decimal.js";
|
|
2
|
+
import { address, curvance_provider } from "../types";
|
|
3
|
+
import { ZapToken } from "./CToken";
|
|
4
|
+
import { Swap } from "./Zapper";
|
|
5
|
+
export default class Kuru {
|
|
6
|
+
api: string;
|
|
7
|
+
static router: address;
|
|
8
|
+
jwt: string | null;
|
|
9
|
+
rps: number;
|
|
10
|
+
dao: address;
|
|
11
|
+
loadJWT(wallet: string): Promise<void>;
|
|
12
|
+
rateLimitSleep(wallet: string): Promise<void>;
|
|
13
|
+
static getAvailableTokens(provider: curvance_provider, query?: string | null): Promise<ZapToken[]>;
|
|
14
|
+
static getCurrentTime(): number;
|
|
15
|
+
static quoteAction(wallet: string, tokenIn: string, tokenOut: string, amount: string, slippageTolerance?: bigint | null): Promise<{
|
|
16
|
+
action: Swap;
|
|
17
|
+
quote: {
|
|
18
|
+
max_slippage: Decimal;
|
|
19
|
+
type: string;
|
|
20
|
+
status: string;
|
|
21
|
+
output: string;
|
|
22
|
+
minOut: string;
|
|
23
|
+
transaction: {
|
|
24
|
+
calldata: string;
|
|
25
|
+
value: string;
|
|
26
|
+
to: string;
|
|
27
|
+
};
|
|
28
|
+
gasPrices: {
|
|
29
|
+
slow: string;
|
|
30
|
+
standard: string;
|
|
31
|
+
fast: string;
|
|
32
|
+
rapid: string;
|
|
33
|
+
extreme: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
static quoteMin(wallet: string, tokenIn: string, tokenOut: string, amount: string, slippageTolerance?: bigint | null): Promise<string>;
|
|
38
|
+
static quote(wallet: string, tokenIn: string, tokenOut: string, amount: string, slippageTolerance?: bigint | null): Promise<{
|
|
39
|
+
max_slippage: Decimal;
|
|
40
|
+
type: string;
|
|
41
|
+
status: string;
|
|
42
|
+
output: string;
|
|
43
|
+
minOut: string;
|
|
44
|
+
transaction: {
|
|
45
|
+
calldata: string;
|
|
46
|
+
value: string;
|
|
47
|
+
to: string;
|
|
48
|
+
};
|
|
49
|
+
gasPrices: {
|
|
50
|
+
slow: string;
|
|
51
|
+
standard: string;
|
|
52
|
+
fast: string;
|
|
53
|
+
rapid: string;
|
|
54
|
+
extreme: string;
|
|
55
|
+
};
|
|
56
|
+
}>;
|
|
57
|
+
static getSlippage(output: bigint, min_output: bigint): Decimal;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=Kuru.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Kuru.d.ts","sourceRoot":"","sources":["../../src/classes/Kuru.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAc,MAAM,UAAU,CAAC;AAGlE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAiChC,MAAM,CAAC,OAAO,OAAO,IAAI;IACrB,GAAG,SAAmC;IACtC,MAAM,CAAC,MAAM,EAAmD,OAAO,CAAC;IACxE,GAAG,EAAE,MAAM,GAAG,IAAI,CAAQ;IAC1B,GAAG,SAAK;IACR,GAAG,EAAmD,OAAO,CAAC;IAExD,OAAO,CAAC,MAAM,EAAE,MAAM;IAoCtB,cAAc,CAAC,MAAM,EAAE,MAAM;WAatB,kBAAkB,CAAC,QAAQ,EAAE,iBAAiB,EAAE,KAAK,GAAE,MAAM,GAAG,IAAW;IAoFxF,MAAM,CAAC,cAAc;WAIR,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAE,MAAM,GAAG,IAAW;;;;kBArK7H,MAAM;oBACJ,MAAM;oBACN,MAAM;oBACN,MAAM;yBACD;gBACT,QAAQ,EAAE,MAAM,CAAC;gBACjB,KAAK,EAAE,MAAM,CAAC;gBACd,EAAE,EAAE,MAAM,CAAC;aACd;uBACU;gBACP,IAAI,EAAE,MAAM,CAAC;gBACb,QAAQ,EAAE,MAAM,CAAC;gBACjB,IAAI,EAAE,MAAM,CAAC;gBACb,KAAK,EAAE,MAAM,CAAC;gBACd,OAAO,EAAE,MAAM,CAAC;aACnB;;;WAoKY,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAE,MAAM,GAAG,IAAW;WAKnH,KAAK,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,EAAE,iBAAiB,GAAE,MAAM,GAAG,IAAW;;cAxLvH,MAAM;gBACJ,MAAM;gBACN,MAAM;gBACN,MAAM;qBACD;YACT,QAAQ,EAAE,MAAM,CAAC;YACjB,KAAK,EAAE,MAAM,CAAC;YACd,EAAE,EAAE,MAAM,CAAC;SACd;mBACU;YACP,IAAI,EAAE,MAAM,CAAC;YACb,QAAQ,EAAE,MAAM,CAAC;YACjB,IAAI,EAAE,MAAM,CAAC;YACb,KAAK,EAAE,MAAM,CAAC;YACd,OAAO,EAAE,MAAM,CAAC;SACnB;;IA4ND,MAAM,CAAC,WAAW,CAAC,MAAM,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM;CAKxD"}
|
|
@@ -0,0 +1,167 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
+
};
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
const decimal_js_1 = __importDefault(require("decimal.js"));
|
|
7
|
+
const ERC20_1 = require("./ERC20");
|
|
8
|
+
const helpers_1 = require("../helpers");
|
|
9
|
+
const cached_jwt = new Map();
|
|
10
|
+
const cached_requests = new Map();
|
|
11
|
+
class Kuru {
|
|
12
|
+
api = "https://ws.staging.kuru.io/api";
|
|
13
|
+
static router = "0x96eaC98928437496DdD0Cd2080E54Fe78BaC99b6"; // KuruFlowEntrypoint
|
|
14
|
+
jwt = null;
|
|
15
|
+
rps = 1;
|
|
16
|
+
dao = "0x0Acb7eF4D8733C719d60e0992B489b629bc55C02";
|
|
17
|
+
async loadJWT(wallet) {
|
|
18
|
+
if (cached_jwt.has(wallet)) {
|
|
19
|
+
const cached = cached_jwt.get(wallet);
|
|
20
|
+
const currentTime = Kuru.getCurrentTime();
|
|
21
|
+
if (cached.expires_at > currentTime) {
|
|
22
|
+
this.jwt = cached.token;
|
|
23
|
+
this.rps = cached.rate_limit.rps;
|
|
24
|
+
return;
|
|
25
|
+
}
|
|
26
|
+
else {
|
|
27
|
+
cached_jwt.delete(wallet);
|
|
28
|
+
}
|
|
29
|
+
}
|
|
30
|
+
const resp = await fetch(`${this.api}/generate-token`, {
|
|
31
|
+
method: "POST",
|
|
32
|
+
headers: {
|
|
33
|
+
"Content-Type": "application/json",
|
|
34
|
+
},
|
|
35
|
+
body: JSON.stringify({
|
|
36
|
+
user_address: wallet,
|
|
37
|
+
}),
|
|
38
|
+
keepalive: true
|
|
39
|
+
});
|
|
40
|
+
if (!resp.ok) {
|
|
41
|
+
throw new Error(`Failed to fetch JWT: ${resp.status} ${resp.statusText}`);
|
|
42
|
+
}
|
|
43
|
+
const data = await resp.json();
|
|
44
|
+
this.jwt = data.token;
|
|
45
|
+
this.rps = data.rate_limit.rps;
|
|
46
|
+
cached_jwt.set(wallet, data);
|
|
47
|
+
}
|
|
48
|
+
async rateLimitSleep(wallet) {
|
|
49
|
+
const now = Kuru.getCurrentTime();
|
|
50
|
+
const requests = cached_requests.get(wallet) || [];
|
|
51
|
+
const windowStart = now - 2;
|
|
52
|
+
const recentRequests = requests.filter(timestamp => timestamp > windowStart);
|
|
53
|
+
if (recentRequests.length >= this.rps) {
|
|
54
|
+
const earliestRequest = Math.min(...recentRequests);
|
|
55
|
+
const sleepTime = (earliestRequest + 2) - now;
|
|
56
|
+
await new Promise(resolve => setTimeout(resolve, sleepTime * 2000));
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
static async getAvailableTokens(provider, query = null) {
|
|
60
|
+
const signer = (0, helpers_1.validateProviderAsSigner)(provider);
|
|
61
|
+
const userAddress = signer.address;
|
|
62
|
+
let endpoint = `https://api.kuru.io/api/v2/tokens/search?limit=20&userAddress=${userAddress}`;
|
|
63
|
+
if (query) {
|
|
64
|
+
endpoint += `&q=${encodeURIComponent(query)}`;
|
|
65
|
+
}
|
|
66
|
+
const resp = await fetch(endpoint, {
|
|
67
|
+
method: "GET",
|
|
68
|
+
headers: {
|
|
69
|
+
"Content-Type": "application/json",
|
|
70
|
+
}
|
|
71
|
+
});
|
|
72
|
+
if (!resp.ok) {
|
|
73
|
+
throw new Error(`Failed to fetch available tokens: ${resp.status} ${resp.statusText}`);
|
|
74
|
+
}
|
|
75
|
+
const list = await resp.json();
|
|
76
|
+
let tokens = [];
|
|
77
|
+
for (const token of list.data.data) {
|
|
78
|
+
const erc20 = new ERC20_1.ERC20(provider, token.address, {
|
|
79
|
+
address: token.address,
|
|
80
|
+
name: token.name,
|
|
81
|
+
symbol: token.ticker,
|
|
82
|
+
decimals: BigInt(token.decimals ?? 18),
|
|
83
|
+
totalSupply: BigInt(token.total_supply ?? 0),
|
|
84
|
+
balance: BigInt(token.balance ?? 0),
|
|
85
|
+
image: token.imageurl,
|
|
86
|
+
price: (0, decimal_js_1.default)(token.last_price).div(helpers_1.WAD)
|
|
87
|
+
});
|
|
88
|
+
tokens.push({
|
|
89
|
+
interface: erc20,
|
|
90
|
+
type: 'simple',
|
|
91
|
+
quote: async (tokenIn, tokenOut, amount, slippageTolerance = null) => {
|
|
92
|
+
const raw_amount = (0, helpers_1.toBigInt)(amount, 18n);
|
|
93
|
+
const data = await Kuru.quote(signer.address, tokenIn, tokenOut, raw_amount.toString(), slippageTolerance);
|
|
94
|
+
return {
|
|
95
|
+
output: (0, helpers_1.toDecimal)(BigInt(data.output ?? 0), BigInt(token.decimals ?? 18)),
|
|
96
|
+
minOut: (0, helpers_1.toDecimal)(BigInt(data.minOut ?? 0), BigInt(token.decimals ?? 18)),
|
|
97
|
+
max_slippage: data.max_slippage
|
|
98
|
+
};
|
|
99
|
+
}
|
|
100
|
+
});
|
|
101
|
+
}
|
|
102
|
+
return tokens;
|
|
103
|
+
}
|
|
104
|
+
// Get current time in seconds
|
|
105
|
+
static getCurrentTime() {
|
|
106
|
+
return Math.floor(Date.now() / 1000);
|
|
107
|
+
}
|
|
108
|
+
static async quoteAction(wallet, tokenIn, tokenOut, amount, slippageTolerance = null) {
|
|
109
|
+
const quote = await Kuru.quote(wallet, tokenIn, tokenOut, amount, slippageTolerance);
|
|
110
|
+
const action = {
|
|
111
|
+
inputToken: tokenIn,
|
|
112
|
+
inputAmount: BigInt(amount),
|
|
113
|
+
outputToken: tokenOut,
|
|
114
|
+
target: quote.transaction.to,
|
|
115
|
+
slippage: slippageTolerance ?? 0n,
|
|
116
|
+
call: `0x${quote.transaction.calldata}`
|
|
117
|
+
};
|
|
118
|
+
return { action, quote };
|
|
119
|
+
}
|
|
120
|
+
static async quoteMin(wallet, tokenIn, tokenOut, amount, slippageTolerance = null) {
|
|
121
|
+
const quote = await Kuru.quote(wallet, tokenIn, tokenOut, amount, slippageTolerance);
|
|
122
|
+
return quote.minOut;
|
|
123
|
+
}
|
|
124
|
+
static async quote(wallet, tokenIn, tokenOut, amount, slippageTolerance = null) {
|
|
125
|
+
const kuru = new this();
|
|
126
|
+
await kuru.loadJWT(wallet);
|
|
127
|
+
await kuru.rateLimitSleep(wallet);
|
|
128
|
+
const payload = {
|
|
129
|
+
userAddress: wallet,
|
|
130
|
+
tokenIn: tokenIn,
|
|
131
|
+
tokenOut: tokenOut,
|
|
132
|
+
amount: amount,
|
|
133
|
+
referrerAddress: kuru.dao,
|
|
134
|
+
referrerFeeBps: 10,
|
|
135
|
+
};
|
|
136
|
+
if (!slippageTolerance) {
|
|
137
|
+
payload.autoSlippage = true;
|
|
138
|
+
}
|
|
139
|
+
else {
|
|
140
|
+
payload.slippage_tolerance = Number(slippageTolerance);
|
|
141
|
+
}
|
|
142
|
+
cached_requests.set(wallet, (cached_requests.get(wallet) || []).concat(Kuru.getCurrentTime()));
|
|
143
|
+
const resp = await fetch(`${kuru.api}/quote`, {
|
|
144
|
+
method: "POST",
|
|
145
|
+
headers: {
|
|
146
|
+
"Content-Type": "application/json",
|
|
147
|
+
"Authorization": `Bearer ${kuru.jwt}`
|
|
148
|
+
},
|
|
149
|
+
body: JSON.stringify(payload),
|
|
150
|
+
});
|
|
151
|
+
if (!resp.ok) {
|
|
152
|
+
throw new Error(`Failed to fetch quote: ${resp.status} ${resp.statusText}`);
|
|
153
|
+
}
|
|
154
|
+
const data = await resp.json();
|
|
155
|
+
return {
|
|
156
|
+
...data,
|
|
157
|
+
max_slippage: Kuru.getSlippage(BigInt(data.output ?? 0), BigInt(data.minOut ?? 0))
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
static getSlippage(output, min_output) {
|
|
161
|
+
const diff = output - min_output;
|
|
162
|
+
const decimal = (0, decimal_js_1.default)(diff).div(output).mul(100);
|
|
163
|
+
return decimal ?? (0, decimal_js_1.default)(100);
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
exports.default = Kuru;
|
|
167
|
+
//# sourceMappingURL=Kuru.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Kuru.js","sourceRoot":"","sources":["../../src/classes/Kuru.ts"],"names":[],"mappings":";;;;;AAAA,4DAAiC;AAEjC,mCAAgC;AAChC,wCAAgF;AAgChF,MAAM,UAAU,GAAG,IAAI,GAAG,EAA2B,CAAC;AACtD,MAAM,eAAe,GAAG,IAAI,GAAG,EAAoB,CAAC;AAEpD,MAAqB,IAAI;IACrB,GAAG,GAAG,gCAAgC,CAAA;IACtC,MAAM,CAAC,MAAM,GAAG,4CAAuD,CAAC,CAAC,qBAAqB;IAC9F,GAAG,GAAkB,IAAI,CAAC;IAC1B,GAAG,GAAG,CAAC,CAAC;IACR,GAAG,GAAG,4CAAuD,CAAC;IAE9D,KAAK,CAAC,OAAO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M,IAAI,KAAK,CAAC,0BAA0B,IAAI,CAAC,MAAM,IAAI,IAAI,CAAC,UAAU,EAAE,CAAC,CAAC;QAChF,CAAC;QAED,MAAM,IAAI,GAAG,MAAM,IAAI,CAAC,IAAI,EAAuB,CAAC;QAEpD,OAAO;YACH,GAAG,IAAI;YACP,YAAY,EAAE,IAAI,CAAC,WAAW,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,EAAE,MAAM,CAAC,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC,CAAC;SACrF,CAAC;IACN,CAAC;IAED,MAAM,CAAC,WAAW,CAAC,MAAc,EAAE,UAAkB;QACjD,MAAM,IAAI,GAAG,MAAM,GAAG,UAAU,CAAC;QACjC,MAAM,OAAO,GAAG,IAAA,oBAAO,EAAC,IAAI,CAAC,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACnD,OAAO,OAAO,IAAI,IAAA,oBAAO,EAAC,GAAG,CAAC,CAAC;IACnC,CAAC;;AA1NL,uBA2NC"}
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import Decimal from "decimal.js";
|
|
2
|
+
import { address, curvance_provider } from "../types";
|
|
3
|
+
import { ZapToken } from "./CToken";
|
|
4
|
+
import { Swap } from "./Zapper";
|
|
5
|
+
export default class KuruMainnet {
|
|
6
|
+
static api: string;
|
|
7
|
+
static router: address;
|
|
8
|
+
jwt: string | null;
|
|
9
|
+
rps: number;
|
|
10
|
+
dao: address;
|
|
11
|
+
loadJWT(wallet: string): Promise<void>;
|
|
12
|
+
rateLimitSleep(wallet: string): Promise<void>;
|
|
13
|
+
static getAvailableTokens(provider: curvance_provider, query?: string | null): Promise<ZapToken[]>;
|
|
14
|
+
static getCurrentTime(): number;
|
|
15
|
+
static quoteAction(wallet: string, tokenIn: string, tokenOut: string, amount: string, slippageTolerance?: bigint | null): Promise<{
|
|
16
|
+
action: Swap;
|
|
17
|
+
quote: {
|
|
18
|
+
max_slippage: Decimal;
|
|
19
|
+
type: string;
|
|
20
|
+
status: string;
|
|
21
|
+
output: string;
|
|
22
|
+
minOut: string;
|
|
23
|
+
transaction: {
|
|
24
|
+
calldata: string;
|
|
25
|
+
value: string;
|
|
26
|
+
to: string;
|
|
27
|
+
};
|
|
28
|
+
gasPrices: {
|
|
29
|
+
slow: string;
|
|
30
|
+
standard: string;
|
|
31
|
+
fast: string;
|
|
32
|
+
rapid: string;
|
|
33
|
+
extreme: string;
|
|
34
|
+
};
|
|
35
|
+
};
|
|
36
|
+
}>;
|
|
37
|
+
static quoteMin(wallet: string, tokenIn: string, tokenOut: string, amount: string, slippageTolerance?: bigint | null): Promise<string>;
|
|
38
|
+
static quote(wallet: string, tokenIn: string, tokenOut: string, amount: string, slippageTolerance?: bigint | null): Promise<{
|
|
39
|
+
max_slippage: Decimal;
|
|
40
|
+
type: string;
|
|
41
|
+
status: string;
|
|
42
|
+
output: string;
|
|
43
|
+
minOut: string;
|
|
44
|
+
transaction: {
|
|
45
|
+
calldata: string;
|
|
46
|
+
value: string;
|
|
47
|
+
to: string;
|
|
48
|
+
};
|
|
49
|
+
gasPrices: {
|
|
50
|
+
slow: string;
|
|
51
|
+
standard: string;
|
|
52
|
+
fast: string;
|
|
53
|
+
rapid: string;
|
|
54
|
+
extreme: string;
|
|
55
|
+
};
|
|
56
|
+
}>;
|
|
57
|
+
static getSlippage(output: bigint, min_output: bigint): Decimal;
|
|
58
|
+
}
|
|
59
|
+
//# sourceMappingURL=KuruMainnet.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"KuruMainnet.d.ts","sourceRoot":"","sources":["../../src/classes/KuruMainnet.ts"],"names":[],"mappings":"AAAA,OAAO,OAAO,MAAM,YAAY,CAAC;AACjC,OAAO,EAAE,OAAO,EAAE,iBAAiB,EAAc,MAAM,UAAU,CAAC;AAGlE,OAAO,EAAE,QAAQ,EAAE,MAAM,UAAU,CAAC;AACpC,OAAO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