Skip to content

Commit 8aa928f

Browse files
authored
feat: add offramp sdk methods (#559)
* feat: add offramp sdk methods * ci: fix npm ci * fix: taproot test case * chore: remove console statements * chore: give quote in create order params * feat: add bumpFee and cancelOrder flags * fix: test case * fix: remove offrampregistry address from constructor * fix: use single bumpfee logic for both `getOfframpOrders` & `bumpFeeForOfframpOrder` * chore: rename `RawOrder` to `OfframpRawOrder` * fix: test gateway sdk initialization * fix: test gateway sdk initialization * fix: lowercase alphabet `R` from offramp * fix: Refactor SDK to handle offramp claim delays and registry fetch * fix: Update token address in gateway test mock response * fix: calculate order deadline dynamically on client-side * fix: incorrect type for deadline in gateway client * chore: add todo and update type documentation. * fix: return default values message if fetching the quote fails * fix: edge case for active order * fix: change cancel order -> unlock order * fix: Refactor fee bumping and claim delay logic for clarity * fix: Return error for tokens with undefined decimals * fix: Refactor claim delay logic to use bigint for consistency
1 parent 7b4913e commit 8aa928f

File tree

6 files changed

+633
-170
lines changed

6 files changed

+633
-170
lines changed

assets/bobBTC.svg

Lines changed: 8 additions & 0 deletions
Loading

sdk/src/gateway/abi.ts

Lines changed: 90 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -38,45 +38,40 @@ export const strategyCaller = [
3838
},
3939
] as const;
4040

41-
export const offRampCaller = [
41+
export const offrampCreateOrderCaller = [
4242
{
4343
type: 'function',
44-
name: 'createOffRampRequest',
44+
name: 'createOrder',
4545
inputs: [
4646
{
47-
name: '_offRampRequestArgs',
47+
name: 'offrampOrderArgs',
4848
type: 'tuple',
49-
internalType: 'struct OffRampRequestArgs',
49+
internalType: 'struct OfframpOrderArgs',
5050
components: [
5151
{
52-
name: 'offRampAddress',
53-
type: 'address',
54-
internalType: 'contract IGateway',
52+
name: 'satAmountToLock',
53+
type: 'uint256',
54+
internalType: 'uint256',
5555
},
5656
{
57-
name: 'amountLocked',
57+
name: 'satFeesMax',
5858
type: 'uint256',
5959
internalType: 'uint256',
6060
},
6161
{
62-
name: 'maxFees',
62+
name: 'orderCreationDeadline',
6363
type: 'uint256',
6464
internalType: 'uint256',
6565
},
6666
{
67-
name: 'user',
68-
type: 'address',
69-
internalType: 'address',
67+
name: 'outputScript',
68+
type: 'bytes',
69+
internalType: 'bytes',
7070
},
7171
{
7272
name: 'token',
7373
type: 'address',
74-
internalType: 'contract IERC20Ext',
75-
},
76-
{
77-
name: 'userBtcAddress',
78-
type: 'bytes',
79-
internalType: 'bytes',
74+
internalType: 'address',
8075
},
8176
],
8277
},
@@ -86,9 +81,86 @@ export const offRampCaller = [
8681
},
8782
] as const;
8883

84+
export const offrampBumpFeeCaller = [
85+
{
86+
type: 'function',
87+
name: 'bumpFeeOfExistingOrder',
88+
inputs: [
89+
{
90+
name: 'orderId',
91+
type: 'uint256',
92+
internalType: 'uint256',
93+
},
94+
{
95+
name: 'newFeeSat',
96+
type: 'uint256',
97+
internalType: 'uint256',
98+
},
99+
],
100+
outputs: [],
101+
stateMutability: 'nonpayable',
102+
},
103+
] as const;
104+
105+
export const offrampUnlockFundsCaller = [
106+
{
107+
type: 'function',
108+
name: 'unlockFunds',
109+
inputs: [
110+
{
111+
name: 'orderId',
112+
type: 'uint256',
113+
internalType: 'uint256',
114+
},
115+
{
116+
name: 'receiver',
117+
type: 'address',
118+
internalType: 'address',
119+
},
120+
],
121+
outputs: [],
122+
stateMutability: 'nonpayable',
123+
},
124+
] as const;
125+
89126
export const compoundV2CTokenAbi = parseAbi([
90127
'function exchangeRateCurrent() external returns (uint256)',
91128
'function underlying() external view returns (address)',
92129
]);
93130

94131
export const aaveV2AtokenAbi = parseAbi(['function UNDERLYING_ASSET_ADDRESS() external view returns (address)']);
132+
133+
export const offrampGetOrderCaller = [
134+
{
135+
type: 'function',
136+
name: 'getOfframpOrder',
137+
inputs: [
138+
{
139+
name: 'orderId',
140+
type: 'uint256',
141+
internalType: 'uint256',
142+
},
143+
],
144+
outputs: [
145+
{
146+
name: '',
147+
type: 'tuple',
148+
internalType: 'struct OfframpOrderDetails',
149+
components: [
150+
{ name: 'satAmountLocked', type: 'uint256', internalType: 'uint256' },
151+
{ name: 'satFeesMax', type: 'uint256', internalType: 'uint256' },
152+
{ name: 'sender', type: 'address', internalType: 'address' },
153+
{ name: 'receiver', type: 'address', internalType: 'address' },
154+
{ name: 'outputScript', type: 'bytes', internalType: 'bytes' },
155+
{ name: 'status', type: 'uint8', internalType: 'enum OfframpOrderStatus' },
156+
{ name: 'timestamp', type: 'uint256', internalType: 'uint256' },
157+
{ name: 'token', type: 'address', internalType: 'address' },
158+
{ name: 'owner', type: 'address', internalType: 'address' },
159+
],
160+
},
161+
],
162+
stateMutability: 'view',
163+
},
164+
] as const;
165+
166+
export const claimDelayAbi = parseAbi(['function CLAIM_DELAY() view returns (uint64)']);

0 commit comments

Comments
 (0)