@eco-incorp/sauce 0.99.5 → 0.99.6

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.
Files changed (81) hide show
  1. package/docs/concepts/architecture.md +4 -2
  2. package/docs/concepts/saucescript.md +19 -2
  3. package/docs/guides/builders-and-actions.md +4 -1
  4. package/docs/guides/compiling.md +5 -3
  5. package/docs/guides/intents.md +32 -2
  6. package/docs/guides/protocols-and-tokens.md +21 -1
  7. package/package.json +1 -1
  8. package/sdk/dist/embedded/skills.generated.js +6 -6
  9. package/sdk/dist/embedded/skills.generated.js.map +1 -1
  10. package/sdk/dist/embedded/sources.generated.js +2 -2
  11. package/sdk/dist/embedded/sources.generated.js.map +1 -1
  12. package/sdk/dist/plugin/index.d.ts +3 -2
  13. package/sdk/dist/plugin/index.d.ts.map +1 -1
  14. package/sdk/dist/plugin/index.js.map +1 -1
  15. package/sdk/dist/protocols/cbeth/functions.d.ts +2 -2
  16. package/sdk/dist/protocols/cbeth/functions.d.ts.map +1 -1
  17. package/sdk/dist/protocols/cbeth/functions.js +4 -6
  18. package/sdk/dist/protocols/cbeth/functions.js.map +1 -1
  19. package/sdk/dist/protocols/crvusd/functions.d.ts +2 -2
  20. package/sdk/dist/protocols/crvusd/functions.d.ts.map +1 -1
  21. package/sdk/dist/protocols/crvusd/functions.js +6 -6
  22. package/sdk/dist/protocols/erc20/functions.d.ts +3 -3
  23. package/sdk/dist/protocols/erc20/functions.d.ts.map +1 -1
  24. package/sdk/dist/protocols/erc20/functions.js +6 -9
  25. package/sdk/dist/protocols/erc20/functions.js.map +1 -1
  26. package/sdk/dist/protocols/frax/functions.d.ts +2 -2
  27. package/sdk/dist/protocols/frax/functions.d.ts.map +1 -1
  28. package/sdk/dist/protocols/frax/functions.js +6 -6
  29. package/sdk/dist/protocols/gho/functions.d.ts +2 -2
  30. package/sdk/dist/protocols/gho/functions.d.ts.map +1 -1
  31. package/sdk/dist/protocols/gho/functions.js +4 -6
  32. package/sdk/dist/protocols/gho/functions.js.map +1 -1
  33. package/sdk/dist/protocols/liquity-v2/functions.d.ts +2 -2
  34. package/sdk/dist/protocols/liquity-v2/functions.d.ts.map +1 -1
  35. package/sdk/dist/protocols/liquity-v2/functions.js +4 -6
  36. package/sdk/dist/protocols/liquity-v2/functions.js.map +1 -1
  37. package/sdk/dist/recipes/cctp-split.sauce.ts +3 -1
  38. package/sdk/dist/recipes/plain-transfer.sauce.ts +3 -0
  39. package/sdk/dist/routes/ast-walk.d.ts +4 -0
  40. package/sdk/dist/routes/ast-walk.d.ts.map +1 -1
  41. package/sdk/dist/routes/ast-walk.js +9 -2
  42. package/sdk/dist/routes/ast-walk.js.map +1 -1
  43. package/sdk/dist/routes/chain-exports.generated.d.ts.map +1 -1
  44. package/sdk/dist/routes/chain-exports.generated.js.map +1 -1
  45. package/sdk/dist/routes/index.d.ts +2 -2
  46. package/sdk/dist/routes/index.d.ts.map +1 -1
  47. package/sdk/dist/routes/index.js +1 -1
  48. package/sdk/dist/routes/index.js.map +1 -1
  49. package/sdk/dist/routes/intent-sugar.d.ts.map +1 -1
  50. package/sdk/dist/routes/intent-sugar.js +40 -23
  51. package/sdk/dist/routes/intent-sugar.js.map +1 -1
  52. package/sdk/dist/routes/sauce-route.d.ts.map +1 -1
  53. package/sdk/dist/routes/sauce-route.js +26 -23
  54. package/sdk/dist/routes/sauce-route.js.map +1 -1
  55. package/sdk/dist/routes/source-globals.generated.d.ts +7 -3
  56. package/sdk/dist/routes/source-globals.generated.d.ts.map +1 -1
  57. package/sdk/dist/routes/token-registry.d.ts.map +1 -1
  58. package/sdk/dist/routes/token-registry.js +6 -1
  59. package/sdk/dist/routes/token-registry.js.map +1 -1
  60. package/sdk/dist/routes/token-rewrite.d.ts +63 -28
  61. package/sdk/dist/routes/token-rewrite.d.ts.map +1 -1
  62. package/sdk/dist/routes/token-rewrite.js +390 -122
  63. package/sdk/dist/routes/token-rewrite.js.map +1 -1
  64. package/sdk/dist/token/api.d.ts +7 -4
  65. package/sdk/dist/token/api.d.ts.map +1 -1
  66. package/sdk/dist/token/api.js.map +1 -1
  67. package/sdk/dist/token/evm.js +2 -2
  68. package/sdk/dist/token/index.d.ts +3 -3
  69. package/sdk/dist/token/index.js +3 -3
  70. package/sdk/src/protocols/cbeth/functions.ts +4 -6
  71. package/sdk/src/protocols/crvusd/functions.ts +6 -6
  72. package/sdk/src/protocols/erc20/functions.ts +6 -9
  73. package/sdk/src/protocols/frax/functions.ts +6 -6
  74. package/sdk/src/protocols/gho/functions.ts +4 -6
  75. package/sdk/src/protocols/liquity-v2/functions.ts +4 -6
  76. package/sdk/src/skills/cbeth.md +4 -6
  77. package/sdk/src/skills/crvusd.md +6 -6
  78. package/sdk/src/skills/erc20.md +8 -10
  79. package/sdk/src/skills/frax.md +6 -6
  80. package/sdk/src/skills/gho.md +4 -6
  81. package/sdk/src/skills/liquity-v2.md +4 -6
@@ -37,13 +37,16 @@ export interface TokenCall {
37
37
  *
38
38
  * Route-body calls are positional (`Token(a).approve(spender, amt)`) where the runtime
39
39
  * [`TokenApi`] takes a spec object, because the body is compiled to Sauce bytecode rather than
40
- * executed: `token-rewrite.ts#rewriteTokenFactory` replaces the callee with `IERC20.at` before the
41
- * compiler sees it, and these signatures are what let a **typed closure** body typecheck on the way
42
- * there. Nothing calls these at run time, which is why they live here rather than on `TokenApi`.
40
+ * executed: `token-rewrite.ts#rewriteTokenFactory` lowers each write to `@sauce/token`'s function
41
+ * of the same name, which has OpenZeppelin `SafeERC20` semantics, and each read to `IERC20.at`,
42
+ * before the compiler sees it. These signatures are what let a **typed closure** body typecheck on
43
+ * the way there. The writes return nothing: they revert the program unless the token accepted
44
+ * them. Nothing calls these at run time, which is why they live here rather than on `TokenApi`.
43
45
  */
44
46
  export interface TokenBinding {
45
47
  transfer(to: AddressInput, amount: bigint): void;
46
48
  approve(spender: AddressInput, amount: bigint): void;
49
+ transferFrom(from: AddressInput, to: AddressInput, amount: bigint): void;
47
50
  balanceOf(owner: AddressInput): bigint;
48
51
  }
49
52
  /**
@@ -52,7 +55,7 @@ export interface TokenBinding {
52
55
  *
53
56
  * Deliberately NOT on `TokenApi` itself: the runtime `Token` value is a frozen object and is not
54
57
  * callable, so typing it as callable would promise something that throws. It describes what is
55
- * legal in a route BODY, where the call is rewritten to `IERC20.at(...)` and never survives to run.
58
+ * legal in a route BODY, where the call is rewritten before compiling and never survives to run.
56
59
  */
57
60
  export interface TokenFactory {
58
61
  (address: AddressInput): TokenBinding;
@@ -1 +1 @@
1
- {"version":3,"file":"api.d.ts","sourceRoot":"","sources":["../../src/token/api.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAsB,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAEpD,OAAO,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AACtD,OAAO,EAAE,GAAG,EAAE,MAAM,+BAA+B,CAAC;AAgBpD,OAAO,EAKL,KAAK,YAAY,EACjB,KAAK,gBAAgB,EACrB,KAAK,gBAAgB,EACrB,KAAK,SAAS,EACd,KAAK,WAAW,EAChB,KAAK,iBAAiB,EACvB,MAAM,YAAY,CAAC;AAEpB,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,CAAC,OAAO,EAAE,SAAS,MAAM,EAAE,CAAC;IACpC,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,WAAW,CAAC,EAAE,SAAS,MAAM,EAAE,CAAC;CAC1C;AAED,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC;IACzB,uEAAuE;IACvE,MAAM,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC;IACpC,yGAAyG;IACzG,SAAS,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC;IACvC,yEAAyE;IACzE,UAAU,CAAC,MAAM,EAAE,WAAW,GAAG,MAAM,CAAC;IACx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,MAAM,CAAC,MAAM,KAAK,GAAa,MAAM,CAAC,MAAM,CAAC;IAC3C,QAAQ,EAAE,CAAC,IAAuB,EAAa,EAAE,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,UAAU,EAAE,GAAG,IAAI,EAAE,CAAC;IAC5F,OAAO,EAAE,CAAC,IAAsB,EAAa,EAAE,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,SAAS,EAAE,GAAG,IAAI,EAAE,CAAC;IACzF,SAAS,EAAE,CAAC,IAAsB,EAAa,EAAE,CAAC,aAAa,CAAC,EAAE,EAAE,EAAE,WAAW,EAAE,GAAG,IAAI,EAAE,CAAC;IAC7F,OAAO,EAAE,CAAC,KAA2B,EAAE,IAA6B,EAAU,EAAE,CAC9E,WAAW,CAAC,KAAK,EAAE,IAAI,CAAC,MAAM,CAAC;IACjC,GAAG;IACH,aAAa,EAAE,oBAAoB;IACnC,kBAAkB,EAAE,yBAAyB;IAC7C,QAAQ;IACR,oBAAoB;IACpB,mBAAmB;IACnB,iBAAiB;IACjB,oBAAoB;CACrB,CAAC,CAAC"}
@@ -1,7 +1,7 @@
1
1
  /**
2
2
  * The ERC20 arm — statement/expression builders for the universal token interface's EVM lowering.
3
- * Typed-binding call against the engine-vendored `IERC20` artifact, the exact shape
4
- * `swap/source.ts`/`deposit/source.ts` already emit — nothing new reaches the compiler.
3
+ * The writes go through `safe.ts` (OpenZeppelin `SafeERC20`); the read is a typed call against the
4
+ * engine-vendored `IERC20` artifact, the shape `swap/source.ts`/`deposit/source.ts` already emit.
5
5
  */
6
6
  import { formatAddressField } from "../deposit/format.js";
7
7
  import { toAddressBigint, toAmountBigint } from "./params.js";
@@ -12,9 +12,9 @@
12
12
  * `sdk/src/token/source.ts` for the per-target emission seam and `sdk/src/token/api.ts` for the
13
13
  * `Token`/`TokenCall` builder shape.
14
14
  *
15
- * Two arms, chosen per call (not per accessor): the ERC20 arm (`evm.ts`) emits a typed-binding
16
- * `IERC20.at(token).transfer(...)` call, identical to how `swap/source.ts`/`deposit/source.ts`
17
- * already call protocol contracts; the SPL arm (`svm.ts`) emits `svm.call(program, accounts,
15
+ * Two arms, chosen per call (not per accessor): the ERC20 arm (`evm.ts`) emits the writes with
16
+ * OpenZeppelin `SafeERC20` semantics through `safe.ts`, and the `balanceOf` read as a typed
17
+ * `IERC20.at(token).balanceOf(...)` binding; the SPL arm (`svm.ts`) emits `svm.call(program, accounts,
18
18
  * accounts)` against the SPL Token program, reusing the `svmSettleSource` idiom
19
19
  * (`accountData`/`accountUint`, the `le8` u64 byteswap helper, `TransferChecked`/`ApproveChecked`).
20
20
  * The two arms are NOT interchangeable at compile time — the compiler rejects a contract binding on
@@ -12,9 +12,9 @@
12
12
  * `sdk/src/token/source.ts` for the per-target emission seam and `sdk/src/token/api.ts` for the
13
13
  * `Token`/`TokenCall` builder shape.
14
14
  *
15
- * Two arms, chosen per call (not per accessor): the ERC20 arm (`evm.ts`) emits a typed-binding
16
- * `IERC20.at(token).transfer(...)` call, identical to how `swap/source.ts`/`deposit/source.ts`
17
- * already call protocol contracts; the SPL arm (`svm.ts`) emits `svm.call(program, accounts,
15
+ * Two arms, chosen per call (not per accessor): the ERC20 arm (`evm.ts`) emits the writes with
16
+ * OpenZeppelin `SafeERC20` semantics through `safe.ts`, and the `balanceOf` read as a typed
17
+ * `IERC20.at(token).balanceOf(...)` binding; the SPL arm (`svm.ts`) emits `svm.call(program, accounts,
18
18
  * accounts)` against the SPL Token program, reusing the `svmSettleSource` idiom
19
19
  * (`accountData`/`accountUint`, the `le8` u64 byteswap helper, `TransferChecked`/`ApproveChecked`).
20
20
  * The two arms are NOT interchangeable at compile time — the compiler rejects a contract binding on
@@ -1,19 +1,17 @@
1
1
  export const transfer = `
2
- import { CbETHABI as ICbETH } from "./abis";
2
+ import { transfer } from "@sauce/token";
3
3
 
4
4
  function main(cbethAddress: Address, to: Address, amount: Uint256): Uint256 {
5
- const cbeth = ICbETH.at(cbethAddress);
6
- cbeth.transfer(to, amount);
5
+ transfer(cbethAddress, to, amount);
7
6
  return 1;
8
7
  }
9
8
  `;
10
9
 
11
10
  export const approve = `
12
- import { CbETHABI as ICbETH } from "./abis";
11
+ import { approve } from "@sauce/token";
13
12
 
14
13
  function main(cbethAddress: Address, spender: Address, amount: Uint256): Uint256 {
15
- const cbeth = ICbETH.at(cbethAddress);
16
- cbeth.approve(spender, amount);
14
+ approve(cbethAddress, spender, amount);
17
15
  return 1;
18
16
  }
19
17
  `;
@@ -1,17 +1,17 @@
1
1
  export const transfer = `
2
- import { CrvUSDERC20ABI as ICrvUSD } from "./abis";
2
+ import { transfer } from "@sauce/token";
3
3
 
4
4
  function main(crvusdAddress: Address, to: Address, amount: Uint256): Uint256 {
5
- const crvusd = ICrvUSD.at(crvusdAddress);
6
- return crvusd.transfer(to, amount);
5
+ transfer(crvusdAddress, to, amount);
6
+ return 1;
7
7
  }
8
8
  `;
9
9
 
10
10
  export const approve = `
11
- import { CrvUSDERC20ABI as ICrvUSD } from "./abis";
11
+ import { approve } from "@sauce/token";
12
12
 
13
13
  function main(crvusdAddress: Address, spender: Address, amount: Uint256): Uint256 {
14
- const crvusd = ICrvUSD.at(crvusdAddress);
15
- return crvusd.approve(spender, amount);
14
+ approve(crvusdAddress, spender, amount);
15
+ return 1;
16
16
  }
17
17
  `;
@@ -1,29 +1,26 @@
1
1
  export const transfer = `
2
- import { ERC20ABI as IERC20 } from "./abis";
2
+ import { transfer } from "@sauce/token";
3
3
 
4
4
  function main(token: Address, to: Address, amount: Uint256): Uint256 {
5
- const t = IERC20.at(token);
6
- t.transfer(to, amount);
5
+ transfer(token, to, amount);
7
6
  return 1;
8
7
  }
9
8
  `;
10
9
 
11
10
  export const approve = `
12
- import { ERC20ABI as IERC20 } from "./abis";
11
+ import { approve } from "@sauce/token";
13
12
 
14
13
  function main(token: Address, spender: Address, amount: Uint256): Uint256 {
15
- const t = IERC20.at(token);
16
- t.approve(spender, amount);
14
+ approve(token, spender, amount);
17
15
  return 1;
18
16
  }
19
17
  `;
20
18
 
21
19
  export const transferFrom = `
22
- import { ERC20ABI as IERC20 } from "./abis";
20
+ import { transferFrom } from "@sauce/token";
23
21
 
24
22
  function main(token: Address, from: Address, to: Address, amount: Uint256): Uint256 {
25
- const t = IERC20.at(token);
26
- t.transferFrom(from, to, amount);
23
+ transferFrom(token, from, to, amount);
27
24
  return 1;
28
25
  }
29
26
  `;
@@ -1,17 +1,17 @@
1
1
  export const transfer = `
2
- import { FraxERC20ABI as IFRAX } from "./abis";
2
+ import { transfer } from "@sauce/token";
3
3
 
4
4
  function main(fraxAddress: Address, to: Address, amount: Uint256): Uint256 {
5
- const frax = IFRAX.at(fraxAddress);
6
- return frax.transfer(to, amount);
5
+ transfer(fraxAddress, to, amount);
6
+ return 1;
7
7
  }
8
8
  `;
9
9
 
10
10
  export const approve = `
11
- import { FraxERC20ABI as IFRAX } from "./abis";
11
+ import { approve } from "@sauce/token";
12
12
 
13
13
  function main(fraxAddress: Address, spender: Address, amount: Uint256): Uint256 {
14
- const frax = IFRAX.at(fraxAddress);
15
- return frax.approve(spender, amount);
14
+ approve(fraxAddress, spender, amount);
15
+ return 1;
16
16
  }
17
17
  `;
@@ -1,19 +1,17 @@
1
1
  export const transfer = `
2
- import { GhoTokenABI as IGhoToken } from "./abis";
2
+ import { transfer } from "@sauce/token";
3
3
 
4
4
  function main(ghoAddress: Address, to: Address, amount: Uint256): Uint256 {
5
- const gho = IGhoToken.at(ghoAddress);
6
- gho.transfer(to, amount);
5
+ transfer(ghoAddress, to, amount);
7
6
  return 1;
8
7
  }
9
8
  `;
10
9
 
11
10
  export const approve = `
12
- import { GhoTokenABI as IGhoToken } from "./abis";
11
+ import { approve } from "@sauce/token";
13
12
 
14
13
  function main(ghoAddress: Address, spender: Address, amount: Uint256): Uint256 {
15
- const gho = IGhoToken.at(ghoAddress);
16
- gho.approve(spender, amount);
14
+ approve(ghoAddress, spender, amount);
17
15
  return 1;
18
16
  }
19
17
  `;
@@ -1,19 +1,17 @@
1
1
  export const transfer = `
2
- import { BoldTokenABI as IBoldToken } from "./abis";
2
+ import { transfer } from "@sauce/token";
3
3
 
4
4
  function main(boldAddress: Address, to: Address, amount: Uint256): Uint256 {
5
- const bold = IBoldToken.at(boldAddress);
6
- bold.transfer(to, amount);
5
+ transfer(boldAddress, to, amount);
7
6
  return 1;
8
7
  }
9
8
  `;
10
9
 
11
10
  export const approve = `
12
- import { BoldTokenABI as IBoldToken } from "./abis";
11
+ import { approve } from "@sauce/token";
13
12
 
14
13
  function main(boldAddress: Address, spender: Address, amount: Uint256): Uint256 {
15
- const bold = IBoldToken.at(boldAddress);
16
- bold.approve(spender, amount);
14
+ approve(boldAddress, spender, amount);
17
15
  return 1;
18
16
  }
19
17
  `;
@@ -21,18 +21,16 @@ import { protocolInfo, deployments, sauceFunctions } from "@eco-incorp/sauce/pro
21
21
 
22
22
  ```typescript
23
23
  // Transfer cbETH
24
- import { CbETHABI as ICbETH } from "./abis";
24
+ import { transfer } from "@sauce/token";
25
25
  function main(cbethAddress: Address, to: Address, amount: Uint256): Uint256 {
26
- const cbeth = ICbETH.at(cbethAddress);
27
- cbeth.transfer(to, amount);
26
+ transfer(cbethAddress, to, amount);
28
27
  return 1;
29
28
  }
30
29
 
31
30
  // Approve cbETH
32
- import { CbETHABI as ICbETH } from "./abis";
31
+ import { approve } from "@sauce/token";
33
32
  function main(cbethAddress: Address, spender: Address, amount: Uint256): Uint256 {
34
- const cbeth = ICbETH.at(cbethAddress);
35
- cbeth.approve(spender, amount);
33
+ approve(cbethAddress, spender, amount);
36
34
  return 1;
37
35
  }
38
36
  ```
@@ -21,17 +21,17 @@ import { protocolInfo, deployments, sauceFunctions } from "@eco-incorp/sauce/pro
21
21
 
22
22
  ```typescript
23
23
  // Transfer crvUSD
24
- import { CrvUSDERC20ABI as ICrvUSD } from "./abis";
24
+ import { transfer } from "@sauce/token";
25
25
  function main(crvusdAddress: Address, to: Address, amount: Uint256): Uint256 {
26
- const crvusd = ICrvUSD.at(crvusdAddress);
27
- return crvusd.transfer(to, amount);
26
+ transfer(crvusdAddress, to, amount);
27
+ return 1;
28
28
  }
29
29
 
30
30
  // Approve crvUSD spender
31
- import { CrvUSDERC20ABI as ICrvUSD } from "./abis";
31
+ import { approve } from "@sauce/token";
32
32
  function main(crvusdAddress: Address, spender: Address, amount: Uint256): Uint256 {
33
- const crvusd = ICrvUSD.at(crvusdAddress);
34
- return crvusd.approve(spender, amount);
33
+ approve(crvusdAddress, spender, amount);
34
+ return 1;
35
35
  }
36
36
  ```
37
37
 
@@ -24,26 +24,23 @@ import { protocolInfo, deployments, sauceFunctions } from "@eco-incorp/sauce/pro
24
24
 
25
25
  ```typescript
26
26
  // Transfer tokens
27
- import { ERC20ABI as IERC20 } from "./abis";
27
+ import { transfer } from "@sauce/token";
28
28
  function main(token: Address, to: Address, amount: Uint256): Uint256 {
29
- const t = IERC20.at(token);
30
- t.transfer(to, amount);
29
+ transfer(token, to, amount);
31
30
  return 1;
32
31
  }
33
32
 
34
33
  // Approve spender
35
- import { ERC20ABI as IERC20 } from "./abis";
34
+ import { approve } from "@sauce/token";
36
35
  function main(token: Address, spender: Address, amount: Uint256): Uint256 {
37
- const t = IERC20.at(token);
38
- t.approve(spender, amount);
36
+ approve(token, spender, amount);
39
37
  return 1;
40
38
  }
41
39
 
42
40
  // Transfer from (requires prior approval)
43
- import { ERC20ABI as IERC20 } from "./abis";
41
+ import { transferFrom } from "@sauce/token";
44
42
  function main(token: Address, from: Address, to: Address, amount: Uint256): Uint256 {
45
- const t = IERC20.at(token);
46
- t.transferFrom(from, to, amount);
43
+ transferFrom(token, from, to, amount);
47
44
  return 1;
48
45
  }
49
46
 
@@ -97,5 +94,6 @@ function main(to: Address, amount: Uint256): Uint256 {
97
94
  - approve before transferFrom: spender must be approved by the owner first
98
95
  - Common pattern: approve max (type(uint256).max) for DeFi interactions, or use exact amounts for security
99
96
  - decimals varies: most tokens use 18, USDC/USDT use 6, WBTC uses 8
100
- - Some tokens (USDT) do not return bool from transfer/approve -- use SafeERC20 wrapper for compatibility
97
+ - Some tokens (USDT) do not return bool from transfer/approve. The writes above are `@sauce/token`'s, which follow OpenZeppelin SafeERC20: empty returndata is accepted from a contract, a `false` return reverts, and `approve` resets a non-zero allowance to zero first. They return nothing, since a refused write reverts the program
98
+ - `ERC20ABI.at(token).transfer(...)` is the raw ABI call and is NOT SafeERC20: it reverts on a token that returns nothing and accepts one that returns `false`. Use it only when that is what you mean
101
99
  - The storageTransfer example demonstrates how to implement ERC-20 logic entirely in SauceScript using storage operations
@@ -21,17 +21,17 @@ import { protocolInfo, deployments, sauceFunctions } from "@eco-incorp/sauce/pro
21
21
 
22
22
  ```typescript
23
23
  // Transfer FRAX
24
- import { FraxERC20ABI as IFRAX } from "./abis";
24
+ import { transfer } from "@sauce/token";
25
25
  function main(fraxAddress: Address, to: Address, amount: Uint256): Uint256 {
26
- const frax = IFRAX.at(fraxAddress);
27
- return frax.transfer(to, amount);
26
+ transfer(fraxAddress, to, amount);
27
+ return 1;
28
28
  }
29
29
 
30
30
  // Approve FRAX spender
31
- import { FraxERC20ABI as IFRAX } from "./abis";
31
+ import { approve } from "@sauce/token";
32
32
  function main(fraxAddress: Address, spender: Address, amount: Uint256): Uint256 {
33
- const frax = IFRAX.at(fraxAddress);
34
- return frax.approve(spender, amount);
33
+ approve(fraxAddress, spender, amount);
34
+ return 1;
35
35
  }
36
36
  ```
37
37
 
@@ -21,18 +21,16 @@ import { protocolInfo, deployments, sauceFunctions } from "@eco-incorp/sauce/pro
21
21
 
22
22
  ```typescript
23
23
  // Transfer GHO
24
- import { GhoTokenABI as IGhoToken } from "./abis";
24
+ import { transfer } from "@sauce/token";
25
25
  function main(ghoAddress: Address, to: Address, amount: Uint256): Uint256 {
26
- const gho = IGhoToken.at(ghoAddress);
27
- gho.transfer(to, amount);
26
+ transfer(ghoAddress, to, amount);
28
27
  return 1;
29
28
  }
30
29
 
31
30
  // Approve GHO spender
32
- import { GhoTokenABI as IGhoToken } from "./abis";
31
+ import { approve } from "@sauce/token";
33
32
  function main(ghoAddress: Address, spender: Address, amount: Uint256): Uint256 {
34
- const gho = IGhoToken.at(ghoAddress);
35
- gho.approve(spender, amount);
33
+ approve(ghoAddress, spender, amount);
36
34
  return 1;
37
35
  }
38
36
  ```
@@ -21,18 +21,16 @@ import { protocolInfo, deployments, sauceFunctions } from "@eco-incorp/sauce/pro
21
21
 
22
22
  ```typescript
23
23
  // Transfer BOLD
24
- import { BoldTokenABI as IBoldToken } from "./abis";
24
+ import { transfer } from "@sauce/token";
25
25
  function main(boldAddress: Address, to: Address, amount: Uint256): Uint256 {
26
- const bold = IBoldToken.at(boldAddress);
27
- bold.transfer(to, amount);
26
+ transfer(boldAddress, to, amount);
28
27
  return 1;
29
28
  }
30
29
 
31
30
  // Approve BOLD spender
32
- import { BoldTokenABI as IBoldToken } from "./abis";
31
+ import { approve } from "@sauce/token";
33
32
  function main(boldAddress: Address, spender: Address, amount: Uint256): Uint256 {
34
- const bold = IBoldToken.at(boldAddress);
35
- bold.approve(spender, amount);
33
+ approve(boldAddress, spender, amount);
36
34
  return 1;
37
35
  }
38
36
  ```